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

feat: unify policy handling & plucking #1223

Merged
merged 3 commits into from
Jun 19, 2020
Merged

Conversation

lili2311
Copy link
Contributor

@lili2311 lili2311 commented Jun 18, 2020

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

What does this PR do?

  • Unify how we find & load policies for all the 4 places where we need to do the exact same thing.
  • add some types
  • update pluck policies to always return an string or string array

Any background context you want to provide?

There is a policy handling but with --all-project , gradle sub-projects and --file where we look for policy in the root of where the command is run and not next to the manifest, which can be exposed in a test and fixed in a PR after this initial refactor so that the change is made in one place not 4.

@lili2311 lili2311 requested review from a team as code owners June 18, 2020 17:12
@lili2311 lili2311 self-assigned this Jun 18, 2020
@anthogez anthogez mentioned this pull request Jun 18, 2020
3 tasks
Copy link
Member

@anthogez anthogez left a comment

Choose a reason for hiding this comment

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

We are having an issue on this test

  1. test/acceptance/cli-monitor/cli-monitor.acceptance.test.ts monitor foo:latest --docker doesnt send policy from cwd empty policy is sent:
    Error: empty policy is sent
    at Test.test (test/acceptance/cli-monitor/cli-monitor.acceptance.test.ts:1535:5)

@lili2311 lili2311 force-pushed the feat/unify-policy-loading branch 4 times, most recently from 9fa342b to 72154d2 Compare June 18, 2020 22:38
@@ -466,7 +454,7 @@ async function assembleLocalPayloads(
targetFileRelativePath: `${targetFileRelativePath}`, // Forcing string
projectNameOverride: options.projectName,
originalProjectName,
policy: policy && policy.toString(),
policy: policy ? policy.toString() : undefined,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

make it the same as other instances

@@ -1531,8 +1531,7 @@ test('`monitor foo:latest --docker` doesnt send policy from cwd', async (t) => {
'calls docker plugin with expected arguments',
);

const emptyPolicy = await snykPolicy.create();
t.deepEqual(req.body.policy, emptyPolicy.toString(), 'empty policy is sent');
t.deepEqual(req.body.policy, undefined, 'no policy is sent');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

make monitor & test behave the same way (preferring test)

When plucking policies this only works
if we created a depenency tree with resolve-deps
by traversing node_modules
@github-actions
Copy link
Contributor

github-actions bot commented Jun 18, 2020

Expected release notes (by @lili2311)

features:
unify policy handling & plucking (197f1ec)

fixes:
use relevant resolve dep tree types (9228e50)

others (will not be included in Semantic-Release notes):
update docker monitor test to match test (6652dae)

  • I hereby acknowledge these release notes are 🥙 AWESOME 🥙

@lili2311 lili2311 merged commit 5aa1610 into master Jun 19, 2020
@lili2311 lili2311 deleted the feat/unify-policy-loading branch June 19, 2020 09:36
@snyksec
Copy link

snyksec commented Jun 19, 2020

🎉 This PR is included in version 1.346.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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