
Research
/Security News
Intercom’s npm Package Compromised in Ongoing Mini Shai-Hulud Worm Attack
Compromised intercom-client@7.0.4 npm package is tied to the ongoing Mini Shai-Hulud worm attack targeting developer and CI/CD secrets.
Mocks node.js http.ServerResponse (a response). See also mock-req.
Being a readable/writable stream, you can pipe the response body to and from it.
See test.js for further usage.
var MockRes = require('mock-res');
// Basic usage
var res = new MockRes();
// Supply a callback to be called after res.end() is called
var res = new MockRes(function onEnd() {
console.log('Response sent');
});
// Listen for stream events
res.on('error', function (err) {
// If not listened for, the 'error' event will throw,
// as is true for any stream.
});
res.on('finish', function () {
console.log('Finished writing response');
});
// Read status code
res.statusCode; // 200 by default
// Read body as string
res._getString(); // 'I am a chicken';
// Read body as parsed JSON
res._getJSON(); // { chicken: true }
// Pipe body somewhere
res.pipe(fs.createWriteStream('/tmp/yo'));
var assert = require('assert');
var list = require('./list-handler');
var MockRes = require('mock-res');
function test(done) {
/* Arrange */
// Use `mock-req` for a better mock
var req = {
method: 'GET',
url: '/foos'
}
var res = new MockRes(onEnd);
/* Act */
list(req, res);
/* Assert */
function onEnd() {
// NOTE `this` === `res`
assert.equal(this.statusCode, 200);
assert.equal(this._getString(), '[{"id":0},{"id":1}]');
assert.deepEqual(this._getJSON(), [{id: 0 }, {id: 1 }]);
assert.deepEqual(this.getHeader('set-cookie'), ['a=1', 'b=2']);
res.pipe(process.stdout); // `res` is just a readable stream here
done(); // this is an async test
}
}
writeHead(statusCode, [reasonPhrase], [headers]) Sets the response status code, status message, and headers. See also the http.ServerResponse documentation.setHeader(), getHeader(), getHeaders(), removeHeader()_getString() Reads the body as a string, from the internal stream buffer._getJSON() Reads the body as a parsed JSON object, from the internal stream buffer.FAQs
Mocks node.js http.ServerResponse. See also `mock-req`.
The npm package mock-res receives a total of 39,651 weekly downloads. As such, mock-res popularity was classified as popular.
We found that mock-res 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
Compromised intercom-client@7.0.4 npm package is tied to the ongoing Mini Shai-Hulud worm attack targeting developer and CI/CD secrets.

Research
Socket detected a malicious supply chain attack on PyPI package lightning versions 2.6.2 and 2.6.3, which execute credential-stealing malware on import.

Research
A brand-squatted TanStack npm package used postinstall scripts to steal .env files and exfiltrate developer secrets to an attacker-controlled endpoint.