Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Timer mechanism to place upper bound on rate of events.
npm install cooldown
This example reads lines of text from stdin. When 'spam' is entered, it will output 'spam' but only at a rate of once per 5 seconds. Entering 'reset' can reset the cooldown and allow 'spam' to succeed immediately after. Entering 'ready?' will display the state of the cooldown timer. The 'ready' event listener will automatically print when the timer is off cooldown.
var Cooldown = require('cooldown');
var readline = require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
// Set limit to 5s
var cd = new Cooldown(5000);
cd.on('ready', console.log.bind('console', 'off cooldown'));
rl.on('line', function (line) {
switch (line) {
case 'spam':
if (cd.fire()) {
console.log('have some spam');
} else {
console.log('not yet');
}
break;
case 'ready?':
console.log(cd.ready ? 'yep' : 'nope');
break;
case 'reset':
// reset the cooldown
cd.reset();
break;
case 'quit':
cd.destroy();
rl.close();
break;
}
});
A cooldown timer with two states:
Return true if the timer was ready (and puts it on-cooldown).
If timer is on-cooldown, reset it back to ready.
Clear any timeouts and set timer to on-cooldown. It will never enter the 'ready' state unless it is reset.
Contains true if the timer is off cooldown and available to fire, else false.
Emitted whenever the timer comes back off cooldown.
Emitted whenever the timer goes on cooldown.
MIT
FAQs
Cooldown timer for rate-limiting events
We found that cooldown demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.