
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
@npm/spife-ratelimit
Advanced tools
Middleware that adds [Token Bucket]-style ratelimiting to [Spife].
Middleware that adds Token Bucket-style ratelimiting to Spife.
// settings.js:
module.exports.MIDDLEWARE = {
['@npm/spife-ratelimiting', {
redisUrl: 'redis://localhost:6379', // let it connect to redis
redisClient, // (or give it a client)
costHeader: 'npm-cost', // the "cost" header to use
// for determining how many
// tokens a request took
clock: Date.now, // if you would like time to
// move to the beat of a
// different drum
getBucket (spifeRequest) { // given a request, return
// an object describing its
// token bucket
return {
capacity: 100, // how many tokens does
// the bucket hold?
interval: 60, // in minutes, how long
// does the bucket take to
// fill up?
key: String // what should the bucket be
// named?
}
}
}]
}
// views.js:
const reply = require('@npm/spife/reply')
const cost = require('@npm/spife-ratelimiter/decorator')
module.exports = {
// a view can declare how much it costs up-front:
index: cost(index, 5),
other
}
function index (req, context) {
return 'I cost five tokens!'
}
function other (req, context) {
return reply.header(
'I cost a hundred tokens sometimes',
'npm-cost',
Math.random() > 0.5 ? 100 : 0
)
}
This is implemented in redis by keeping two keys per bucket: one that
tracks the current number of tokens, and one that tracks the last update
time. Both keys are expired at interval
, and updated atomically using a
Lua script.
FAQs
Middleware that adds [Token Bucket]-style ratelimiting to [Spife].
The npm package @npm/spife-ratelimit receives a total of 2 weekly downloads. As such, @npm/spife-ratelimit popularity was classified as not popular.
We found that @npm/spife-ratelimit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 30 open source maintainers 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 researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.