Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
storj-service-middleware
Advanced tools
Common Express middleware for various Storj services.
$ npm install storj-service-middleware --save
var Storage = require('storj-service-storage-models');
var db = new Storage({ /* config */ });
var middleware = require('storj-service-middleware');
var app = require('express')();
app.use(middleware.authenticate(db));
app.use(middleware.errorhandler());
Instantiate the rate limiter with a redis client client
and your express app app
const app = express();
const client = require('redis').createClient();
const limiter = middleware.rateLimiter(client);
Then, you can use limiter
as middleware and pass it an options object.
app.get('/route', limiter({
lookup: function(req) {
return [req.user._id, req.connection.remoteAddress]
},
onRateLimited: function(req, res, next) {
log.info('user rate limited', req.user);
return next(new errors.BadRequestError('Slow down, dude.'));
},
total: 150,
expire: 1000 * 60 // 150 requests a minute allowed
}), function(req, res) {
res.status(200).send('hello');
});
Redis must be running for the tests to work. The easiest way to get an instance running is via Docker.
$ docker run --name redis -p 6379:6379 -d redis
Then, npm test
will kick off the test suite for you.
Credit for much of the rate limiter code goes to https://github.com/juliendangers/express-limiter2 released under the MIT license.
All other code released under AGPLv3.
FAQs
common middleware for various storj services
We found that storj-service-middleware demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.