
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
cli-testing-library
Advanced tools
A testing library that allows you to test input and outputs of your CLI command.
A testing library that allows you to test input and outputs of your CLI command.
Note: This is a work in progress. The API is likely going to change.
Terminal Text Parsing Support Checklist Refer to Full List of Ansi Escape Codes that need to be handled.
With NPM:
npm install --save-dev cli-testing-library
With Yarn:
yarn add --dev cli-testing-library
Test file
// experiment.test.js
const { createCommandInterface } = require('cli-testing-library');
test('should print appropriate greetings', async () => {
const commandInterface = createCommandInterface('node ./experiment.js', {
cwd: __dirname
});
await commandInterface.type('Saurabh\n');
await commandInterface.type('22\n');
const terminal = await commandInterface.getOutput();
expect(terminal.textAfter("What's your name?")).toBe('Hi, Saurabh!');
expect(terminal.textAfter("What's your age?")).toBe('So you are 22!');
});
Code that is being tested A node program that asks user for their name and age, and then prints a greeting.
// experiment.js
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
readline.question(`What's your name?`, (name) => {
console.log(`Hi, ${name}!`);
readline.question(`What's your age?`, (age) => {
console.log(`So you are ${age}!`);
readline.close();
});
});
FAQs
Simple and complete CLI testing utilities that encourage good testing practices.
The npm package cli-testing-library receives a total of 2,665 weekly downloads. As such, cli-testing-library popularity was classified as popular.
We found that cli-testing-library 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
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.