Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@rauschma/stringio
Advanced tools
``` npm install @rauschma/stringio ``` <!-- ########################################################## -->
npm install @rauschma/stringio
See line A and line B:
import * as assert from 'assert';
import { StringStream, readableToString } from '@rauschma/stringio';
test('From string to stream to string', async () => {
const str = 'Hello!\nHow are you?\n';
const stringStream = new StringStream(str); // (A)
const result = await readableToString(stringStream); // (B)
assert.strictEqual(result, str);
});
StringStream
: from string to streamdeclare class StringStream extends Readable {
constructor(str: string);
}
Used in line A.
readableToString
: from stream to stringdeclare function readableToString(readable: Readable, encoding?: string): Promise<string>;
Default encoding is 'utf-8'
.
Used in line B.
async function readStdin() {
const str = await readableToString(process.stdin);
console.log('STR: '+str);
}
string-to-stream
: Convert a string into a stream.get-stream
: Get a stream as a string, buffer, or array.chunksToLinesAsync
: async iterable over chunks to async iterable over linesdeclare function chunksToLinesAsync(chunks: AsyncIterable<string>): AsyncIterable<string>;
Each line includes the line break at the end (if any – the last line may not have one).
Example (starting with Node.js v.10, readable streams are asynchronous iterables):
const fs = require('fs');
const {chunksToLinesAsync} = require('@rauschma/stringio');
async function main() {
const stream = fs.createReadStream(process.argv[2]);
// Works, too: const stream = process.stdin;
for await (const line of chunksToLinesAsync(stream)) {
console.log(chomp(line));
}
}
main();
declare function streamWrite(
stream: Writable,
chunk: string | Buffer | Uint8Array,
encoding = 'utf8')
: Promise<void>;
declare function streamEnd(
stream: Writable)
: Promise<void>;
Usage:
await streamWrite(someStream, 'abc');
await streamWrite(someStream, 'def');
await streamEnd(someStream);
onExit(childProcess)
: wait until a child process is finishedexport declare function onExit(childProcess: ChildProcess): Promise<void>;
Usage:
const childProcess = child_process.spawn(···);
await onExit(childProcess);
Errors emitted by childProcess
or a non-zero exit code reject the Promise returned by onExit()
.
chomp
: remove a line break at the end of a linedeclare function chomp(line: string): string;
The following 2ality blog posts use stringio
:
StringStream
is inspired by: https://github.com/feross/string-to-stream/blob/master/index.jsFAQs
``` npm install @rauschma/stringio ``` <!-- ########################################################## -->
The npm package @rauschma/stringio receives a total of 14,432 weekly downloads. As such, @rauschma/stringio popularity was classified as popular.
We found that @rauschma/stringio 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.