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.
A simple package to make retry loops easier
You can get retimer
from PyPI,
which means it's easily installable with pip
:
python -m pip install retimer
Think of a scenario where you need to keep trying to do something for a range of time, usually you can write this:
from time import perfcounter
timeout = 10
begin = perfcounter()
while percounter() - begin < timeout:
# do something for 10 seconds
if retry_doing_something:
time.sleep(.5)
continue
if something_bad:
break
# all good
break
if perfcounter - begin >= timeout:
print(f"Could not do something after {timeout} seconds")
else:
print("Success!")
Rewriting using this package becomes:
from retimer import Timer
import time
timer = Timer(10)
while timer.not_expired:
# do something for 10 seconds
if retry_doing_something:
time.sleep(.5)
continue
if something_bad:
timer.explode()
# all good
break
if timer.expired:
print(f"Could not do something after {timer.duration} seconds")
else:
print("Success!")
Although both codes accomplish the same result, I personally find the second one more readable and shines when I need two or more chained loops
Refer to the CHANGELOG.md file.
FAQs
Unknown package
We found that retimer 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.