Security News
Internet Archive Hacked, 31 Million Record Compromised
The Internet Archive's "Wayback Machine" has been hacked and defaced, with 31 millions records compromised.
audit-ci is an npm package that helps you run security audits on your project's dependencies. It integrates with CI/CD pipelines to ensure that vulnerabilities are caught and addressed before they make it to production.
Run Security Audits
This command runs a security audit on your project's dependencies and reports any vulnerabilities found.
npx audit-ci
Set Severity Levels
This command runs a security audit and only fails if vulnerabilities of 'low' severity or higher are found.
npx audit-ci --low
Whitelist Vulnerabilities
This command runs a security audit but ignores the specified vulnerability ID (12345 in this case).
npx audit-ci --allowlist 12345
JSON Output
This command runs a security audit and outputs the results in JSON format, which can be useful for further processing or logging.
npx audit-ci --json
npm-audit is a built-in npm command that performs a security audit of your project's dependencies. It provides similar functionality to audit-ci but lacks some of the CI/CD integration features.
Snyk is a comprehensive security tool that not only audits your dependencies but also provides fixes and continuous monitoring. It offers more features compared to audit-ci but may require a subscription for advanced functionalities.
This module is intended to be consumed by your favourite continuous integration tool to
halt execution if npm audit
finds vulnerabilities at or above the specified threshold.
npm install --save-dev audit-ci
Assuming medium, high, and critical severity vulnerabilities prevent build continuation:
For Travis-CI
(only on PR builds is recommended):
scripts:
# This script should be the first that runs to reduce the risk of
# executing a script from a compromised NPM package.
- if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then audit-ci --moderate; fi
For Travis-CI
not using PR builds:
scripts:
# This script should be the first that runs to reduce the risk of
# executing a script from a compromised NPM package.
- audit-ci --moderate
For CircleCI
:
# ... excludes set up for job
steps:
- checkout
- run:
name: update-npm
command: 'sudo npm install -g npm'
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: install-npm
command: 'npm install --no-audit'
# This should run immediately after installation to reduce
# the risk of executing a script from a compromised NPM package.
- run:
name: run-audit-ci
command: 'audit-ci --moderate'
An alternative to installing as a devDependency is to install globally within the CI environment at run-time.
before_install:
- if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then npm i -g audit-ci && audit-ci -m; fi
Args | Alias | Description |
---|---|---|
-l | --low | Prevents integration with low or higher vulnerabilities (default false ) |
-m | --moderate | Prevents integration with moderate or higher vulnerabilities (default false ) |
-h | --high | Prevents integration with high or critical vulnerabilities (default false ) |
-c | --critical | Prevents integration only with critical vulnerabilities (default false ) |
-r | --report | Shows the npm audit --json report (default true ) |
-w | --whitelist | Vulnerable modules to whitelist from preventing integration (default none ) |
audit-ci -m
audit-ci -l -w lodash base64url
audit-ci --critical --report false
audit-ci
audit-ci
on PR builds for Travis-CI
and not the push builds?If audit-ci
is run on the PR build and not on the push build, you can continue to push new code and create PRs parallel to the actual vulnerability fix. However, they can't be merged until the fix is implemented. Since audit-ci
performs the audit on the PR build, it will always have the most up-to-date dependencies vs. the push build, which would require a manual merge with master
before passing the audit.
FAQs
Audits NPM, Yarn, and PNPM projects in CI environments
The npm package audit-ci receives a total of 136,509 weekly downloads. As such, audit-ci popularity was classified as popular.
We found that audit-ci demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
The Internet Archive's "Wayback Machine" has been hacked and defaced, with 31 millions records compromised.
Security News
TC39 is meeting in Tokyo this week and they have approved nearly a dozen proposals to advance to the next stages.
Security News
Our threat research team breaks down two malicious npm packages designed to exploit developer trust, steal your data, and destroy data on your machine.