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.
The bin-build npm package is a tool for building binaries using Node.js. It allows you to compile and install binaries from source, making it useful for developers who need to automate the process of building and installing command-line tools or other binary dependencies.
Building a binary from source
This feature allows you to build a binary from a source URL. The code sample demonstrates how to download a source tarball, configure the build, and run the build commands.
const BinBuild = require('bin-build');
const sourceUrl = 'https://example.com/source.tar.gz';
const buildCommands = [
'./configure --disable-shared',
'make',
'make install'
];
const builder = new BinBuild();
builder.src(sourceUrl)
.cmd(buildCommands.join(' && '))
.run((err) => {
if (err) {
console.error('Build failed:', err);
} else {
console.log('Build succeeded');
}
});
Customizing build environment
This feature allows you to customize the build environment by setting environment variables. The code sample shows how to set CFLAGS and LDFLAGS before running the build commands.
const BinBuild = require('bin-build');
const sourceUrl = 'https://example.com/source.tar.gz';
const buildCommands = [
'./configure --disable-shared',
'make',
'make install'
];
const builder = new BinBuild();
builder.src(sourceUrl)
.cmd(buildCommands.join(' && '))
.env({
'CFLAGS': '-O2',
'LDFLAGS': '-L/usr/local/lib'
})
.run((err) => {
if (err) {
console.error('Build failed:', err);
} else {
console.log('Build succeeded');
}
});
Checking for binary existence
This feature allows you to check if a binary exists after the build process. The code sample demonstrates how to run the build commands and then check for the existence of the binary.
const BinBuild = require('bin-build');
const builder = new BinBuild();
builder.src('https://example.com/source.tar.gz')
.cmd('./configure && make && make install')
.run((err) => {
if (err) {
console.error('Build failed:', err);
} else {
console.log('Build succeeded');
builder.exists('path/to/binary', (exists) => {
if (exists) {
console.log('Binary exists');
} else {
console.log('Binary does not exist');
}
});
}
});
node-gyp is a cross-platform command-line tool written in Node.js for compiling native addon modules for Node.js. It is similar to bin-build in that it helps automate the build process, but it is specifically designed for compiling Node.js native addons.
prebuild is a tool for building and publishing prebuilt binaries for Node.js native addons. It is similar to bin-build in that it helps with the build process, but it focuses on creating and distributing prebuilt binaries to avoid the need for users to compile the code themselves.
node-pre-gyp is a Node.js tool that allows you to publish and install Node.js C++ addons from binaries. It is similar to bin-build in that it helps with the build and installation process, but it also includes features for packaging and distributing prebuilt binaries.
Easily build binaries
$ npm install --save bin-build
const binBuild = require('bin-build');
binBuild.url('http://www.lcdf.org/gifsicle/gifsicle-1.80.tar.gz', [
'./configure --disable-gifview --disable-gifdiff',
'make install'
]).then(() => {
console.log('gifsicle built successfully');
});
binBuild.file('gifsicle-1.80.tar.gz', [
'./configure --disable-gifview --disable-gifdiff',
'make install'
]).then(() => {
console.log('gifsicle built successfully');
});
Type: string
Path to a directory containing the source code.
Type: Array
Commands to run when building.
Type: string
Path to a archive file containing the source code.
Type: Array
Commands to run when building.
Type: Object
Type: number
Default: 1
Strip a number of leading paths from file names on extraction.
Type: string
URL to a archive file containing the source code.
Type: Array
Commands to run when building.
Type: Object
Type: number
Default: 1
Strip a number of leading paths from file names on extraction.
MIT © Kevin Mårtensson
FAQs
Easily build binaries
We found that bin-build demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.