Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

better-npm-audit

Package Overview
Dependencies
Maintainers
0
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

better-npm-audit

Reshape into a better npm audit for the community and encourage more people to include security audit into their process.

  • 3.11.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
93K
increased by4.42%
Maintainers
0
Weekly downloads
 
Created
Source

Better NPM Audit

The goal of this project is to provide additional features on top of the existing npm audit options. We hope to encourage more people to do security audits for their projects.

NPM

PRs Welcome npm downloads node current node support npm vulnerability GitHub issues npm bundle size Languages

Looking for Collaborators

Hi there! 👋

I’m currently looking for collaborators to help maintain and develop this project. Due to time constraints, I haven’t been able to give it the attention it deserves, but I believe it has great potential to grow with the help of passionate contributors.

Become a Collaborator If you’re interested in contributing on a regular basis, I’d love to have you on board as a collaborator. Whether you’re interested in fixing bugs, adding new features, or improving documentation, your contributions will be highly valued.

As a collaborator, you’ll have push access to the repository and play a key role in shaping the future of the project. If this sounds like something you’d be interested in, please reach out! You can open an issue titled “Interested in Collaborating” or contact me directly via email.

Let’s work together to make this project even better!

NPM version 6 and 7, and 8

NPM has upgraded to version 7 in late 2020 and has breaking changes on the npm audit. The output of npm audit has significantly changed both in the human-readable and --json output styles. Even more unfortunately, when NPM changed the JSON output in npm v7, they removed many of the other useful identifiers (cves, cwe, github_advisory_id) and the only thing left is the URL. We are trying our best to handle each version and provide consistent functionality to all of them. Related docs on v6 and v7 changes:

DocsLink
NPM v6 & v7 changeshttps://github.blog/2020-10-13-presenting-v7-0-0-of-the-npm-cli/
NPM v7 blog posthttps://blog.npmjs.org/post/626173315965468672/npm-v7-series-beta-release-and-semver-major
Official NPM v6 audit docshttps://docs.npmjs.com/cli/v6/commands/npm-audit
Official NPM v7 audit docshttps://docs.npmjs.com/cli/v7/commands/npm-audit
Dealing with new npm audithttps://uko.codes/dealing-with-npm-v7-audit-changes

You may find the sample JSON outputs for each NPM versions in our codebase: v6, v7 & v8.


Installation

$ npm install --save better-npm-audit

or

$ npm install -g better-npm-audit

Usage

Run global

better-npm-audit audit

Run with exceptions

Demo of table displaying the security report

Unhandled or newly reported vulnerabilities will be highlighted:

Demo of table displaying the security report

Unused exceptions will be notified:

Demo of displaying the unused exception

Add into package scripts

{
  "scripts": {
    "prepush": "npm run test && npm run audit",
    "audit": "better-npm-audit audit"
  }
}

Now you can run locally or in your CI pipeline:

npm run audit

Options

FlagShortDescription
--exclude-xExceptions or the vulnerabilities ID(s) to exclude; the ID can be the numeric ID, CVE, CWE or GHSA ID
--module-ignore-mNames of modules to exclude
--level-lThe minimum audit level to validate; Same as the original --audit-level flag
--production-pSkip the devDependencies
--registry-rThe npm registry url to use
--include-columns-iColumns to include in report

Environment Variables

VariableDescription
NO_COLORSupport the no-color standard to allow users use the tool without colored output.
NPM_CONFIG_AUDIT_LEVELUsed in setting the audit level.
Note: this will be disregard if the audit level flag is passed onto the command.

Using .nsprc file to manage exceptions

You may add a file .nsprc to your project root directory to manage the exceptions. For example:

{
  "1337": {
    "active": true,
    "notes": "Ignored since we don't use xxx method",
    "expiry": 1615462134681
  },
  "4501": {
    "active": false,
    "notes": "Ignored since we don't use xxx method"
  },
  "CWE-471": "CWE ID is acceptable",
  "GHSA-ww39-953v-wcq6": "GHSA ID is acceptable",
  "https://npmjs.com/advisories/1213": "Full or partial URL is acceptable too"
}

Fields

AttributeTypeDescriptionDefaultExamples
activeBooleanIf the tool should use it for exceptiontruetrue
expiryString | NumberHuman-readable date, or milliseconds since the UNIX Epoch- '2020-01-31'
- '2020/01/31'
- '01/31/2021, 11:03:58'
- '1 March 2016 15:00'
- '1 March 2016 3:00 pm'
- '2012-01-26T13:51:50.417-07:00'
- 'Sun, 11 Jul 2021 03:03:13 GMT'
- 'Thu Jan 26 2017 11:00:00 GMT+1100 (Australian Eastern Daylight Time)'
- 327611110417
notesStringNotes related to the vulnerability.

When using a .nsprc file, a report will be displayed when it starts running:

Demo of table displaying a list of exceptions

Note: the expiry date will be styled in yellow and red color if it is detected more than one or five years ago.


Changelog

You can find the changelog here.


Contributors

Ian Wright, Edwin Taylor, Maarten Hus, Alex Burkowsky, David M. Lee, Kyle Clark, Guillermo Pincay, Grzegorz Pawłowski, CSLTech, Paul Clarkin, mgdodge, Ricky Sullivan, Sam Gregory, Tristan WAGNER, Zak, Eric Cornelissen, Gaurav Chinavle



If you like this project,

Buy Me A Coffee

Keywords

FAQs

Package last updated on 09 Sep 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc