Coder Social home page Coder Social logo

eightfinite / better-npm-audit Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 15 KB

๐Ÿ“ฆ Better NPM Audit drop in replacement. Always mirrors the latest version. Patched to behave more consistently in `offline=true` environments and be slightly less verbose. โ€” `npm install better-npm-audit@github:EIGHTFINITE/better-npm-audit#main` โ€” https://github.com/jeemok/better-npm-audit

Home Page: https://github.com/EIGHTFINITE/better-npm-audit/tags

License: MIT License

JavaScript 100.00%
audit cve cve-scanning cwe ghsa github github-security-advisories ignore node nodejs

better-npm-audit's Introduction

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 vulnerability GitHub issues npm bundle size Languages

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:

Docs Link
NPM v6 & v7 changes https://github.blog/2020-10-13-presenting-v7-0-0-of-the-npm-cli/
NPM v7 blog post https://blog.npmjs.org/post/626173315965468672/npm-v7-series-beta-release-and-semver-major
Official NPM v6 audit docs https://docs.npmjs.com/cli/v6/commands/npm-audit
Official NPM v7 audit docs https://docs.npmjs.com/cli/v7/commands/npm-audit
Dealing with new npm audit https://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

Flag Short Description
--exclude -x Exceptions or the vulnerabilities ID(s) to exclude; the ID can be the numeric ID, CVE, CWE or GHSA ID
--module-ignore -m Names of modules to exclude
--level -l The minimum audit level to validate; Same as the original --audit-level flag
--production -p Skip checking the devDependencies
--registry -r The npm registry url to use

Environment Variables

Variable Description
NPM_CONFIG_AUDIT_LEVEL Used 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

Attribute Type Description Default Examples
active Boolean If the tool should use it for exception true true
expiry String | Number Human-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
notes String Notes 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



If you like this project,

Buy Me A Coffee

better-npm-audit's People

Contributors

elght avatar github-actions[bot] avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.