@krisbyte/nymc
v0.2.2
Published
A npm/yarn malware scanner
Readme
nymc
A CLI tool that scans your Node.js project for known malware packages. It checks your project's package.json, lock files, node_modules, and the full dependency tree against a configurable list of known malicious packages.
Installation
npm install @krisbyte/nymcUsage
Initialize configuration
nymc --initThis creates a .nymc/config.json file in your project root. Add known malware packages to the packages array using the name@version format:
{
"version": "0.0.1",
"url": "",
"httpsHeader": "",
"packages": [
"[email protected]",
"@scope/[email protected]"
]
}Run the scan
nymcFetch packages from a remote URL
Instead of maintaining a local packages list, you can fetch it from a remote endpoint. Set the url field in .nymc/config.json to point to a JSON API that returns an array of package strings:
{
"url": "https://example.com/malware-list.json",
"httpsHeader": "Authorization: Bearer <token>"
}url– The endpoint that returns a JSON array ofname@versionstrings.httpsHeader– (Optional) A single HTTP header to include with the request, formatted as"Header-Name: value". Useful for authenticated endpoints.
Then run the scan with the --network flag:
nymc --networkWhen --network is used, the remote package list takes precedence over the local packages array.
How it works
For each package in the configuration, nymc runs four checks:
- package.json - Checks if the package is listed in
dependenciesordevDependencies - Lock file - Checks
package-lock.json(npm) oryarn.lock(yarn) for the package - node_modules - Checks if the package is physically installed with the matching version
- Dependency tree - Runs
npm ls --alloryarn list --depth=Infinityto find the package in nested dependencies
If any malware is detected, all checks still run to give a complete report before exiting with code 1.
License
MIT
