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.
binary-parse-stream
Advanced tools
Painless streaming binary protocol parsers using generators.
npm install binary-parse-stream
This module uses the exact same generator interface as binary-parser, which presents a synchronous interface to a generator parser.
var BinaryParseStream = require('binary-parse-stream')
, One = BinaryParseStream.One // -1
BinaryParseStream is a TransformStream that consumes buffers and outputs objects on the other end.
It expects your subclass to implement a _parse
method that is a generator.
When your generator yields a number, it'll be fed a buffer of that length from the input.
If it yields -1, it'll be given the value of the first byte instead of a single-byte buffer.
When your generator returns, the return value will be pushed to the output side.
The following module parses a protocol that consists of a 32-bit unsigned big-endian type parameter, an unsigned 8-bit length parameter, and a buffer of the specified length.
It outputs {type, buf}
objects.
var BinaryParseStream = require('binary-parse-stream')
, inherits = require('util').inherits
module.exports = SillyProtocolParseStream
inherits(SillyProtocolParseStream, BinaryParseStream)
function SillyProtocolParseStream(options) {
BinaryParseStream.call(this, options)
}
SillyProtocolParseStream.prototype._parse = function*() {
var type = (yield 4).readUInt32BE(0, true)
, length = yield -1
, buf = yield length
return { type: type, buf: buf }
}
There is also a shorter syntax for when you don't want to explicitly subclass: BinaryParseStream.extend(function*())
.
FAQs
Painless streaming binary protocol parsers using generators.
The npm package binary-parse-stream receives a total of 21 weekly downloads. As such, binary-parse-stream popularity was classified as not popular.
We found that binary-parse-stream 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.