Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Circular Queue is an object that can be used whenever you need to connect the head of an iterable to its tail. It can be easily connected to a database in order to persist your queue rotation.
pip install circular-queue
After cloning the repo, you can import the CircularQueue class to your project:
from circular_queue import CircularQueue
You can instantiate the CircularQueue object passing a queue an a pointer as arguments:
mylist = ['Banana', 'Star Fruit', 'Apple', 'Orange', 'Avocado']
pointer = 'Apple'
myqueue = CircularQueue(mylist, pointer)
Now you have two methods at your disposal: get_next_element and get_previous_element:
myqueue.get_next_element()
>>> 'Orange'
myqueue.get_next_element()
>>> 'Avocado'
myqueue.get_next_element()
>>> 'Banana'
myqueue.get_previous_element()
>>> 'Avocado'
If you need to get a batch of elements you can use the get_batch method like so:
mylist = ['Banana', 'Star Fruit', 'Apple', 'Orange', 'Avocado']
pointer = 'Banana'
batch_size = 3
myqueue = CircularQueue(mylist, pointer)
myqueue.get_batch(batch_size)
>>> ['Star Fruit', 'Apple', 'Orange']
You can also get batch elements in queue rotating to the left:
myqueue.get_batch(batch_size, rotation='left')
>>> ['Orange', 'Apple', 'Star Fruit']
FAQs
A pythonic implementation of a circular queue
We found that circular-queue demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.