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

Pass command flags down from resolve-audit to nested npm audit fix #78

Open
jpicton opened this issue Jan 16, 2024 · 2 comments
Open

Pass command flags down from resolve-audit to nested npm audit fix #78

jpicton opened this issue Jan 16, 2024 · 2 comments

Comments

@jpicton
Copy link

jpicton commented Jan 16, 2024

G'day,

When using resolve-audit to resolve vulnerabilities by applying an autofix, my team has been running into an issue where CLI flags aren't passed along to the nested npm audit fix command. As an example, here is the process we use:

CI Build:
Execute check-audit --omit dev --registry CUSTOM_REPO_URL--json > audit-report.json

When the CI build fails at this step, a developer will come along and seek to resolve it by:

  1. Executing resolve-audit --omit dev --registry CUSTOM_REPO_URL
  2. Selecting to "fix" the issue
  3. npm audit fix is then executed (note the flags have been dropped)
  4. This command fails because the registry can't be found
  5. Developer then has to manually run npm audit fix --omit dev --registry CUSTOM_REPO_URL
  6. Developer manually adds entry to audit-resolve.json to state that resolution decision was "fix" (with associated timestamp)

I'm unsure whether this is expected behaviour, but these last two manual steps do become frustrating when you have to repeat them regularly. Is it possible to pass any CLI flags provided to the original resolve-audit call down to the nested npm audit fix?

@naugtur
Copy link
Owner

naugtur commented Jan 16, 2024

Thanks for reporting.
I don't think all flags can be transparently passed on to the fix command, so we'd need a shortlist of those that are, if present.

My intention with the latest major version was to leave the fix command out as it's been proving less capable over time. I encourage you run the fix before resolve-audit and then supplement the fixes manually if needed, after which you run resolve-audit.
Since npm v7 there's no longer a way to fix individual packages, so the ability to mark them as fixed automatically is mostly gone.

Let me know if you think it makes sense to make --registry pass through to the fix command or you'd be better off running audit fix separately.

@jpicton
Copy link
Author

jpicton commented May 15, 2024

Apologies for not following up earlier. Thanks for the explanation. I'll amend our process to run the fix command prior to the reolve-audit command. I think the only caveat here is that you lose your history of "fix" decisions in audit-resolve.json, but perhaps this isn't a huge deal.

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