
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
privatestate
Advanced tools
This module enables files written with the CommonJS module syntax to expose private functions for testing.
In order to use this module, you must have rewire enabled for all required modules. If you are using browserify, you should enable the browserify transform rewireify. If you are using node, you should use rewire-global.
When writing a module, you may have private helper functions:
function helper() {
return 'helper';
}
var Utils = {
run: function() {
return helper();
}
};
module.exports = Utils;
When we write our tests, we can't access helper
when we require our file. privatestate
lets us access it.
Expose your function like this:
var privateState = require('privatestate');
function helper() {
return 'helper';
}
var Utils = {
run: function() {
return helper();
}
};
privateState.exposeForTesting(Utils, ['helper']);
module.exports = Utils;
In our test, we can now access our function:
var utils = require('./utils');
var privateState = require('privatestate');
var sinon = require('sinon');
describe('Utils', function() {
it('should give us a function', function() {
var helper = privateState.getForTesting(utils, 'helper');
assert.isFunction(helper);
});
it('should allow us to modify our function and restore', function() {
privateState.setFunctionForTesting(utils, 'helper', sinon.stub().returns('in test'));
assert.equal('in test', utils.run());
privateState.restore(utils);
});
});
FAQs
Expose your private state in your tests.
The npm package privatestate receives a total of 0 weekly downloads. As such, privatestate popularity was classified as not popular.
We found that privatestate 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.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.