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

Add acknowledged issue list to npm audit #1494

Closed
wants to merge 1 commit into from
Closed

Conversation

nierob
Copy link

@nierob nierob commented Jul 7, 2020

Add acknowledged issue list to npm audit

Currently npm audit is used in many CI systems. Many of them are
blocking, that means that without a positive result from the tool it
is not possible to integrate anything. While having a tool that can
block CI process based on an external event, like a newly discovered
vulnerability, is arguable, it is hard to dismiss lack of options to
filter importance of found issues.

'npm audit' already has two options that allows to "ignore" certain
vulnerabilities, which is crucial in context of CI. It is "audit-level"
and "only". Sadly they do not provide enough granularity. As a result
in many cases the only way to dismiss known errors is to disable
the audit completely.

The change creates an option to add a list of known issues that should
not cause npm audit to return non-zero exit code. Therefore it is
easy to unlock CI and put task of the issue resolution into an adequate,
organization/project dependent workflow.

@nierob nierob requested a review from a team as a code owner July 7, 2020 12:05
Currently `npm audit` is used in many CI systems. Many of them are
blocking, that means that without a positive result from the tool it
is not possible to integrate anything. While having a tool that can
block CI process based on an external event, like a newly discovered
vulnerability, is arguable, it is hard to dismiss lack of options to
filter importance of found issues.

'npm audit' already has two options that allows to "ignore" certain
vulnerabilities, which is crucial in context of CI. It is "audit-level"
and "only". Sadly they do not provide enough granularity. As a result
in many cases the only way to dismiss known errors is to disable
the audit completely.

The change creates an option to add a list of known issues that should
not cause `npm audit` to return non-zero exit code. Therefore it is
easy to unlock CI and put task of the issue resolution into an adequate,
organization/project dependent workflow.
@isaacs
Copy link
Contributor

isaacs commented Jul 7, 2020

Personally, I think this is a good feature, and can certainly see the use for it. I also like that the implementation here is pretty simple, though adding a comma-separated list probably isn't as consistent as an argument that can be specified multiple times, and "acknowledged" is both hard to spell and doesn't quite capture the semantics of what's going on. Ie, maybe instead of --acknowledged-issues=1,2 maybe it should be something like --audit-ignore=1 --audit-ignore=2 ...?

All that said, getting such a change into npm v6 at this point is not a great idea. I'd much rather get it into npm v7, so that it's more future-proof and we don't find ourselves having to maintain a new feature in two different audit implementations.

Would you mind opening an RFC to solicit feedback? That's how we're trying to drive most new features that add or change some conceptual aspect of the CLI. The implementation is straightforward either way, but that'll help us polish the UX and minimize any confusion for users that comes from this. https://github.com/npm/rfcs

If you'd rather just be done with this and let someone else handle it, we can do the RFC, and that's completely fine and understandable. But, it'll probably be done sooner if we can get your input pushing on it while it's top of mind for you.

Thanks!

@nierob
Copy link
Author

nierob commented Jul 8, 2020

Thank you for a quick feedback! It is really appreciated :-)

I’m completely fine with renaming the option to “audit-ignore” and change it from comma separated string. It was developed as such, because I could not find any example of a repeatable parameter, neither in FiggyPudding docs, nor in npm code. A friendly hint/link would be needed to change it :-)

Regarding npm v6 vs npm v7, it is fine for me to have the feature in a newer version, assuming that it will be released rather sooner than later. The whole blocked CI issue is a side track for me, so I would prefer just to close it in some way. Currently it looks like https://www.npmjs.com/package/npm-audit-resolver is a bit more robust solution for me, even then this PR. For the same reason I would prefer to not commit myself to a long standing RFC process. From npm project perspective I can understand that a bit more polished UX than just an “ignore” flag could be desired. One can think about config files, CVEs, ignoring with a timeout and so on… Actually there is one RFC ongoing npm/rfcs#18 that covers it more globally.

My personal opinion is that npm audit should not take part in blocking CI, unless newly introduced dependencies cause errors. It should be executed regularly on a side, preferably trying to commit a patch (npm audit fix) or if it is not possible create a bug report and commit “ignore” flag somewhere.

To summarise, I can do one of:

  • Fixup this PR - change name and type of the parameter and potentially other minor changes
  • Comment on RFC, if that is desired
  • Close the PR

All are fine for me :-) Thank you again!

@naugtur
Copy link

naugtur commented Jul 17, 2020

See this for comparison npm/rfcs#18
And the implementation https://www.npmjs.com/package/npm-audit-resolver

One comment I have is identifying the issues to acknowledge vs new issues with the same advisory or in the same package requires very verbose identifiers. That's why the RFC above uses ${advisory id}|${dependency path} as an identifier to avoid ignoring something that was not in the dependencies at the time of making the decision to ignore.

@nierob I'd appreciate your input on both links above.

@nierob nierob closed this Jul 24, 2020
@nierob
Copy link
Author

nierob commented Jul 24, 2020

I closed the PR as npm-audit-resolver is a more holistic solution to the issue :-)

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

Successfully merging this pull request may close these issues.

3 participants