Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chicken vs egg #92

Open
mandric opened this issue Jun 10, 2019 · 4 comments
Open

chicken vs egg #92

mandric opened this issue Jun 10, 2019 · 4 comments

Comments

@mandric
Copy link

mandric commented Jun 10, 2019

Please tell me if I'm missing something but isn't npm install --save-dev audit-ci also an attack vector since it runs npm install and installs all packages? Isn't the whole point to avoid running npm install until you verify packages are not compromised with npm audit?

So running npm install --save-dev audit-ci is unsafe. The safest path to installing packages is something like (see below)?

npm audit audit-ci  # fails because npm audit does not take a packages as argument
npm install -g audit-ci
audit-ci [your specific args]
npm ci
@quinnturner
Copy link
Member

quinnturner commented Jun 11, 2019

You're definitely right. I will add that to the documentation.

EDIT: I am not sure how to address this problem, it is definitely a chicken-egg problem. One strong consideration would be to reduce the number of dependencies used by audit-ci to mitigate this risk.

@quinnturner
Copy link
Member

quinnturner commented Jun 11, 2019

One approach would be to do a global install as you mentioned but pipe the automatic audit response to something that can process the result; fail if audit-ci has a vulnerability and pass if not.

@quinnturner
Copy link
Member

npm i -g audit-ci | grep "found 0 vulnerabilities"

Minimal testing, but I believe this will return an exit code of 1 if there are any vulnerabilities (regardless of level) in audit-ci

@mandric
Copy link
Author

mandric commented Jun 11, 2019

I guess another little test you can do without installing anything is:

npm audit --json | jq -e '.metadata.vulnerabilities.critical == 0'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants