npm audit step passes when the audit request fails
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- github-actions, javascript
Research direction
Read npm-vulnerability-scanner.yaml and inspect the “Run NPM Audit & Generate Summary” script, especially how it handles audit errors and missing metadata.vulnerabilities. Reproduce the registry failure with the command and test setup described in the issue. Done when an audit request failure makes the step fail instead of reporting that all packages passed.
Written by the indexing model from the issue text.
Description
The "Run NPM Audit & Generate Summary" step in npm-vulnerability-scanner.yaml runs npm audit --audit-level=high --json 2>/dev/null || true, then reads the critical and high counts with a parser whose catch prints 0. When npm cannot reach the advisory endpoint, npm audit exits 1 with a JSON error that has no metadata. Both counts become 0, and the step passes with "No high or critical vulnerabilities found! All JS packages passed security checks."
To reproduce
Run the step's script from the repo root, with lodash 4.17.15 (rated high) added to package.json and package-lock.json:
npm_config_registry=https://registry.npmjs.org/: the step exits 1, reporting 0 critical and 1 high.npm_config_registry=http://127.0.0.1:9/:npm auditprints{"message": "request to http://127.0.0.1:9/-/npm/v1/security/advisories/bulk failed, ..."}and exits 1. The step exits 0 with the all-clear summary.
So a registry or network outage during a PR's run reports the dependencies as clean.
Possible fix
Fail the step when the audit output has an error or no metadata.vulnerabilities, rather than treating it as zero. Alternatively, take the pass or fail from npm audit --audit-level=high's own exit code and use the JSON only for the summary.
- Dominant language
- Ruby
- Stars
- 16
- Forks
- 48
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 14
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from alphagov/tech-docs-gem
-
documentation
Difficulty 1/5 Under an hour Newbie friendliness 61/100
alphagov/tech-docs-gem#585 ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
alphagov/tech-docs-gem#584 ·
Maintainers usually reply within 1 day
-
Write your contentOpendocumentation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
alphagov/tech-docs-gem#583 ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
alphagov/tech-docs-gem#582 ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
alphagov/tech-docs-gem#581 ·
Maintainers usually reply within 1 day
All issues in alphagov/tech-docs-gem
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
shakacode/react_on_rails#5295 ·
Maintainers usually reply within 1 day
-
account: profile bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
metanorma/metanorma-standoc#1315 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
metanorma/metanorma-iso#1681 ·
Maintainers usually reply within 1 day