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

Fix Yarn Audit findings bug and patch-bump version from 2.6.0 -> 2.6.1 #70

Merged
merged 2 commits into from
Aug 5, 2019

Conversation

geraldnash-cb
Copy link
Contributor

type=nonroutine
risk=low
impact=sev5

@geraldnash-cb geraldnash-cb requested a review from xolaz August 3, 2019 00:22
@@ -63,7 +63,7 @@ def run
# For all advisories,
prod = raw_advisories_for_id.any? do |raw_advisory|
# any there there any instances in the prod dependency tree?
raw_advisory.fetch(:findings).any? { |finding| !finding.fetch(:dev) }
raw_advisory.fetch(:findings).any? { |finding| !finding.fetch(:dev, false) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the fix to not run development dependencies?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, previously this scanner expected the advisories fetched by YarnAudit to have a dev key in each object of their findings array. Some advisories don't have the dev key and cause the scanner to error on this line.

The value of the dev key is typically true or false, and this change treats the value as false if the key is not provided.

TLDR: It treats the finding as a non-dev finding by default if not already specified. @xolaz

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Can you write a quick test for this?

Copy link
Contributor

@xolaz xolaz Aug 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test can check that our advisory output is as expected even without the dev key. Aka, advisory output reports regardless of whether the dev key exists.

Copy link
Contributor

@xolaz xolaz Aug 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And what does the dev key mean for NPM/Yarn? That the finding is related to a development package? It looks like this change won't report development dependencies.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xolaz I'm unable to find documentation related to the shape of these advisory objects and the meaning of their keys. Comments in the code claim that the key lets us know whether advisories are in some production dependency tree, but it's unclear how the scanner would know that and what the difference between the production dependency tree and trees in other staging environments would be, if any.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drafting a test case right now.

Copy link
Contributor Author

@geraldnash-cb geraldnash-cb Aug 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I spoke with @nishils and he said that the difference between production and development advisories is that prod advisories are advisories related dependencies and dev advisories are related to devDependencies. So, the dev key lets us know whether the finding is related to a dev dependency. @xolaz

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, in essence if we're unsure whether a finding is related to a dev or non-dev dependency (no dev key provided), we assume the worst by treating it as if it's related to a non-dev dependency. @xolaz

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also quickly test this @geraldnash-cb by running yarn audit --json to see what the output looks like.

@nishils
Copy link
Contributor

nishils commented Aug 5, 2019

This is a good bug fix! Can we also add an option to exclude dev dependencies?

@geraldnash-cb
Copy link
Contributor Author

@nishils @xolaz Please let me know once we've published these updates.

@geraldnash-cb geraldnash-cb merged commit 426a378 into coinbase:master Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants