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: policies to be correctly picked up from nested scans #1224

Merged
merged 3 commits into from Jun 23, 2020

Conversation

lili2311
Copy link
Contributor

@lili2311 lili2311 commented Jun 19, 2020

  • Ready for review
  • Follows CONTRIBUTING rules
  • Reviewed by Snyk internal team

What does this PR do?

Show that when triggering a test with --file or --all-project the policy is not discovered as we expect to find it in the root which is where the command is run and it should instead be where the manifest was discovered.

Any background context you want to provide?

While working on yarn workspaces feature test noticed the policy from the workspaces were not being used or sent.

https://github.com/snyk/snyk/issues/1014

@lili2311 lili2311 requested review from a team as code owners June 19, 2020 09:56
@lili2311 lili2311 self-assigned this Jun 19, 2020
@ghost ghost requested review from ekbsnyk and orsagie June 19, 2020 09:56
@lili2311 lili2311 changed the title fix: fix policies to be correctly picked up from nested scans fix: policies to be correctly picked up from nested scans Jun 19, 2020
@lili2311 lili2311 force-pushed the fix/policies-all-projects branch 2 times, most recently from 1bfbb65 to 523bbc5 Compare June 19, 2020 15:06

// Forcing options.path to be a string as pathUtil requires is to be stringified
const targetFileRelativePath = targetFile
? pathUtil.join(pathUtil.resolve(`${options.path || root}`), targetFile)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

there is no options.path when coming via snyk protect flow

@lili2311 lili2311 removed the 🚧 WIP Work In Progress label Jun 19, 2020
@lili2311 lili2311 force-pushed the fix/policies-all-projects branch 6 times, most recently from 8f389af to a498b29 Compare June 21, 2020 16:15
package.json Outdated Show resolved Hide resolved
// TODO: this should return 1 policy when fixed
// uncomment then
// t.match(
// req.body.policy,
Copy link
Member

Choose a reason for hiding this comment

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

What is current missing to make this work? Something that we already discussed about on snyk-gradle-plugin? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes we must fix how targetFile is sent there to not just be build.gradle but relative path from root. currently all the scans look like they are from the same folder and only the projectName indicates otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see the thread in Slack

@github-actions
Copy link
Contributor

github-actions bot commented Jun 23, 2020

Expected release notes (by @lili2311)

fixes:
calculate the policy folder from targetFile (e75db65)

others (will not be included in Semantic-Release notes):
gradle --all-sub-projects policy is not applying (9f50581)
show non root scans ignore policy (7c56e25)

  • I hereby acknowledge these release notes are 🥙 AWESOME 🥙

@lili2311 lili2311 merged commit 14bbc0d into master Jun 23, 2020
@lili2311 lili2311 deleted the fix/policies-all-projects branch June 23, 2020 11:24
@snyksec
Copy link

snyksec commented Jun 23, 2020

🎉 This PR is included in version 1.348.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@erwinw
Copy link

erwinw commented Jun 29, 2020

Eh, this change constitutes in fact a breaking change, which has caused us quite some time loss trying to figure out why Snyk suddenly ignored the .snyk file.

I guess we were unknowingly relying on a bug, but that is no excuse in my opinion. Changing which locations are accepted as a location for config files is a breaking change, so rather than releasing as a bugfix release, v1.138.1 should've been v2.0.0, a major release.

Also, why are the release notes so sparse? It's hardly possible to figure out what has actually changed, and calculate the policy folder from targetFile is not very descriptive unless you're very deep into Snyk.

@lili2311
Copy link
Contributor Author

👋 @erwinpleo Apologies for this inconvenience, you are right the notes could be better I have gone ahead and updated these with more information. I have written up a detailed response here: https://github.com/snyk/snyk/issues/1237#issuecomment-651378812 I hope this helps to clarify the reason for the change and provides some advice. If you have further comments It may be beneficial to keep it on that thread in one place.

@lili2311
Copy link
Contributor Author

@erwinpleo just realised that perhaps you can achieve exactly what you had if you use --policy-path=path/to/.snyk, please let me know if this helps

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