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.
streamfilter
Advanced tools
streamfilter
is a function based filter for streams inspired per gulp-filter
but no limited to Gulp nor to objectMode streams.
First install streamfilter
in you project:
npm install --save streamfilter
There are 3 scenarios of use :
var FilterStream = require('streamfilter');
var filter = new FilterStream(function(chunk, encoding, cb) {
if(itmustbefiltered) {
cb(true);
} else {
cb(false);
}
});
// Print to stdout a filtered stdin
process.stdin
.pipe(filter)
.pipe(process.stdout);
var FilterStream = require('streamfilter');
var filter = new FilterStream(function(chunk, encoding, cb) {
if(itmustbefiltered) {
cb(true);
} else {
cb(false);
}
}, {
restore: true
});
// Print accepted chunks in stdout
filter.pipe(process.stdout);
// Print filtered one to stderr
filter.restore.pipe(process.stderr);
Let's be hype!
var FilterStream = require('streamfilter');
// Filter values
var filter = new FilterStream(function(chunk, encoding, cb) {
if(itmustbefiltered) {
cb(true);
} else {
cb(false);
}
}, {
restore: true,
passthrough: true
});
// Pipe stdin
process.stdin.pipe(filter)
// Edit kept chunks
.pipe(mySuperTransformStream)
// Restore filtered chunks
.pipe(filter.restore)
// and output!
.pipe(process.stdout)
Note that in this case, this is your responsibility to end the restore stream by piping in another stream or ending him manually.
## API
Filter piped in streams according to the given filterCallback
that takes the
following arguments: chunk
the actual chunk, encoding
the chunk encoding,
filterResultCallback
the function to call as the result of the filtering
process with true
in argument to filter her or false
otherwise.
Options are passed in as is in the various stream instances spawned by this
module. So, to use the objectMode, simply pass in the options.objectMode
value set to true
.
Set to true
, this option create a readable stream allowing you to use the
filtered chunks elsewhere. The restore stream is exposed in the FilterStream
instance as a restore
named property.
Set to true
, this option change the restore stream nature from a readable
stream to a passthrough one, allowing you to reuse the filtered chunks in an
existing pipeline.
Feel free to submit us your improvements. To do so, you must accept to publish your code under the MIT license.
To start contributing, first run the following to setup the development environment:
git clone git@github.com:nfroidure/streamfilter.git
cd streamfilter
npm install
Then, run the tests:
npm test
FAQs
Filtering streams.
The npm package streamfilter receives a total of 240,958 weekly downloads. As such, streamfilter popularity was classified as popular.
We found that streamfilter demonstrated a healthy version release cadence and project activity because the last version was released less than 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.