
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
check-runtime-env
Advanced tools
Node.js implementation of a checker for some runtime environment properties
Node.js implementation of a checker for some runtime environment properties.
The purpose of this library is to simplify some check in the environment where the code is running (at runtime).
Get a reference to the library:
// Node.js example
const assert = require('assert').strict
// reference the library, not needed if using destructuring assignment, see below
const RuntimeEnvChecker = require('../src/') // from local path
assert(RuntimeEnvChecker !== null)
get some runtime data and version constraints, optional:
const nodeVersion = process.version
assert(nodeVersion !== null)
const npmVersion = RuntimeEnvChecker.getVersionOfNpm()
assert(npmVersion !== null)
const engines = require('../package.json').engines
assert(engines !== null)
const expectedNodeVersion = engines.node
assert(expectedNodeVersion !== null)
const expectedNPMVersion = engines.npm
assert(expectedNPMVersion !== null)
console.log(`Node.js current version: ${nodeVersion}`)
console.log(`Node.js version expected in 'package.json': ${engines.node}`)
console.log(`NPM current version: ${npmVersion}`)
console.log(`NPM version expected in 'package.json': ${engines.npm}`)
call some static method exposed by the class:
console.log(`Doing some tests; note that a check not satisfied will throw Error ...`)
console.log(`Check version of Node, using defaults, success: ${RuntimeEnvChecker.checkVersionOfNode()}`)
console.log(`Check version of Node, using explicit values, success: ${RuntimeEnvChecker.checkVersionOfNode(nodeVersion, expectedNodeVersion)}`)
console.log(`Check version of NPM, using NPM release found, and NPM expected value implicit, success: ${RuntimeEnvChecker.checkVersionOfNpm(npmVersion)}`)
console.log(`Check version of NPM, using explicit values, success: ${RuntimeEnvChecker.checkVersionOfNpm(npmVersion, expectedNPMVersion)}`)
console.log(`Check version (generic), using explicit values, success: ${RuntimeEnvChecker.checkVersion('10.13.0', '>=8.9.0 <12.0.0')}`)
try {
console.log(`Sample failure in check version (generic): expected error`)
console.log(`Check version (generic), using explicit values, success: ${RuntimeEnvChecker.checkVersion('10.13.0', '>=12.0.0')}`)
} catch (e) {
console.log(e)
}
console.log(`Tell the given version '10.13.0', if it's compatible with the constraint '>=12.0.0': ${RuntimeEnvChecker.isVersionCompatible('10.13.0', '>=12.0.0')}, but anyway no error raised here`)
console.log(`Check that the given string is not empty (generic), success: ${RuntimeEnvChecker.checkStringNotEmpty('10.13.0')}`)
console.log(`Node.js environment is: '${process.env.NODE_ENV}'`)
console.log(`Node.js environment from the library is: '${RuntimeEnvChecker.getNodeEnv()}'`)
console.log(`Node.js environment is defined: ${RuntimeEnvChecker.isEnvVarDefined('NODE_ENV')}`)
console.log(`Node.js environment is production: ${RuntimeEnvChecker.isNodeEnvProduction()}`)
// console.log(`Check that Node.js environment is production: ${RuntimeEnvChecker.checkNodeEnvProduction()}`)
console.log('Ensure JavaScript strict mode is enabled (or an Exception will be thrown):')
const checkSafeMode = RuntimeEnvChecker.checkStrictMode()
console.log(`strict mode enabled : ${checkSafeMode}`)
console.log(`No more tests.`)
Look into the example folder for more sample scripts that uses the library (inline but it's the same using it from npm registry).
A sample usage could be to check if current Node.js release satisfies the release wanted, and if not throw an Error (or instead log a Warning).
Node.js 14 LTS (14.15.0) or later; NPM 6.8.0 or later.
Source code is all inside main repo: check-runtime-env.js.
Documentation generated from source code (library API): here.
The library exposes some static methods useful at runtime; for example to check the given version, if it's compatible with an expected version, using the semver syntax for constraints.
Current Node.js version if read from the memory as a default value; NPM version must be retrieved by executing it, so if needed it has to be done by calling related method (could take some time).
The general behavior of check/checker methods here is to throw Error if the check does not pass (if it's false); or return true if successful, or even false
You can find Code Documentation for the API of the library here.
The package name is simplified into 'check-runtime-env', so it will be easier to get it at npm.
See the Semantic Versioning Specification at semver.
More features will be added later to the library.
Licensed under Apache-2.0.
0.4.0 (2022-07-22)
Summary Changelog:
FAQs
Node.js implementation of a checker for some runtime environment properties
The npm package check-runtime-env receives a total of 0 weekly downloads. As such, check-runtime-env popularity was classified as not popular.
We found that check-runtime-env 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
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.