Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
accum - Simple write stream which accumulates or collects the data from a stream. Pipe your stream into this to get all the data as buffer, string, or raw array. (streams2)
Simple write stream which accumulates or collects the data from a stream. Pipe your stream into this to get all the data as buffer, string, or raw array. (streams2)
npm install accum
accum
provides several factory methods for use:
accum([options], listenerFn)
constructs a write stream which checks if the first chunk is a Buffer and if so returns a concatenated Buffer of all the data, otherwise if it is a string then returns a concatenated string, otherwise returns a raw array. The listenerFn
signature is function(alldata)
. The listenerFn
is called after all the data is received just prior to the end
event being emitted. The options
parameter is passed to the underlying writable stream constructor (see Node.js stream docs. The options
parameter can be omitted.var accum = require('accum');
rstream
.pipe(accum(function (alldata) {
// use the accumulated data - alldata will be Buffer, string, or []
}));
For a more deterministic result use one of the following:
accum.buffer([options], listenerFn)
- constructs a write stream which converts everything into a Buffer, concatenates, and calls the listenerFn
with the buffer. The listenerFn
signature is function(buffer)
. The listenerFn
is called after all the data is received just prior to the end
event being emitted. The options
parameter is passed to the underlying writable stream constructor (see Node.js stream docs. The options
parameter can be omitted.var accum = require('accum');
rstream
.pipe(accum.buffer(function (buffer) {
// use the accumulated data - buffer which is a Buffer
}));
accum.string([options], listenerFn)
- constructs a write stream which concatenates everything into a string. Buffer data is converted to string using the optional encoding
which defaults to 'utf8'. Other data is simply converted using .toString()
. The listenerFn
signature is function(string)
. The listenerFn
is called after all the data is received just prior to the end
event being emitted. The options
parameter is passed to the underlying writable stream constructor (see Node.js stream docs. The options
parameter can be omitted.var accum = require('accum');
rstream
.pipe(accum.string({ encoding: 'utf8'}, function (string) {
// use the accumulated data - string which is a utf8 string
}));
accum.array([options], listenerFn)
- constructs a write stream which concatenates everything into an array without any conversion, which the listenerFn
receives the accumulated data on end. The listenerFn
signature is function(arr)
. The listenerFn
is called after all the data is received just prior to the end
event being emitted. The options
parameter is passed to the underlying writable stream constructor (see Node.js stream docs. The options
parameter can be omitted.var accum = require('accum');
rstream
.pipe(accum.array(function (array) {
// use the accumulated data - array which is a raw unconverted array of data chunks
}));
If you are intending to use an object stream, then you will want to set the options
to {objectMode: true}
var accum = require('accum');
rstream
.pipe(accum.array({ objectMode: true }, function (array) {
// use the accumulated data - array of objects
}));
Node.js stream.pipe does not forward errors and neither do many pass-through stream implementations so the recommended way to catch errors is either to attach error handlers at each stream or to use domains.
var d = domain.create();
d.on('error', handleAllErrors);
d.run(function() {
rstream.pipe(accum(function (alldata) {
// use alldata
});
});
Rather than manually accumulating streams, put all the best practices into this one module. There are subtle errors that can occur if utf8 strings happen to be split in the middle of a character, so conversion and concatenation needs to be done properly.
Other projects that also accumululate in slightly different ways:
If you have input or ideas or would like to get involved, you may:
FAQs
accum - Simple write stream which accumulates or collects the data from a stream. Pipe your stream into this to get all the data as buffer, string, or raw array. (streams2)
The npm package accum receives a total of 194 weekly downloads. As such, accum popularity was classified as not popular.
We found that accum 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.