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: [SUP-2164] Change dependency graph root name logic #266

Merged
merged 10 commits into from
Nov 18, 2023

Conversation

dotkas
Copy link
Contributor

@dotkas dotkas commented Nov 15, 2023

What this does

There is a discrepancy between what we call our projects and what we call our root nodes in the dependency graphs. This sounds like it should not matter, but it does.

We have a regression introduced after a bugfix was made last month, where snyk test now does not correctly pick up ignores in the ui after a snyk monitor on certain types of Gradle projects.

Doing this change will fix that.

Problem

(Links to internal projects)

  • This is how we make a project id in monitor.
  • This is how we make a project id in test.

Since the bugfix last month, root package names no longer match the project names in Gradle projects. Doing a --list-deps or looking at the UI will show one name in the project name and another in the root package list.

This is the root cause of the bug why snyk test does not pick up changes, as the project identity that is being tested against is generated from the root package name, not the "defaultProjectName" like snyk monitor.

Breaking change

I'm bumping the major version for this one, unless anybody objects. Not technically a breaking change, as this should not cause orphaned projects. It should merely create a new element in the history i the same project - but out of caution i find it makes sense, just to show that we're changing expected behavior. In case any consumer is relying on this value.

Project identity?

The projectName should not change because of these changes. This change actually more aligns the root package name to what is already done for project names: https://github.com/snyk/snyk-gradle-plugin/blob/a444194f1199afece07232f4568773f36f9bfb9f/lib/index.ts#L306-L316

Snapshot churn?

This should change dependency graphs for CLI monitor projects, and only a part of Gradle customers, so after discussing with some stakeholders in Team Fix, have deemed it should not be dangerous to snapshot churn.

@CLAassistant
Copy link

CLAassistant commented Nov 15, 2023

CLA assistant check
All committers have signed the CLA.

lib/index.ts Outdated
projectName = isValidRootDir
? `${path.basename(root)}/${projectId}`
: `${defaultProject}/${projectId}`;
projectName = `${defaultProject}/${projectId}`;
Copy link
Contributor Author

@dotkas dotkas Nov 15, 2023

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that this is not the actual projectName that is being changed, despite the variable name. It's the root package name only.

Actual projectName stays as it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we accept it we should probably unify it in a function.

Choose a reason for hiding this comment

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

Should the variable be named to something other than projectName to avoid future confusion?

@dotkas dotkas force-pushed the dotkas/SUP-2164/test-monitor-projectname-discrepancy branch 6 times, most recently from 6245cd9 to 6b879dd Compare November 16, 2023 18:49
@dotkas dotkas marked this pull request as ready for review November 16, 2023 18:49
@dotkas dotkas requested a review from a team as a code owner November 16, 2023 18:49
@dotkas dotkas force-pushed the dotkas/SUP-2164/test-monitor-projectname-discrepancy branch 2 times, most recently from 2ef19e0 to 8a7806f Compare November 16, 2023 18:58
BREAKING CHANGE:

This major version bump is mostly cautionary, as existing consumers of this plugin ought not to encounter errors. However, it is a change in how the makeup of the dependency graph works, and therefore could be argued to require this version bump. Thus we err on the side of caution.
@dotkas dotkas force-pushed the dotkas/SUP-2164/test-monitor-projectname-discrepancy branch from 8a7806f to 7aabd6e Compare November 16, 2023 19:06
Comment on lines +8 to +12
targetFile
${'build.gradle'}
${'build.gradle'}
${'build.gradle'}
${path.join(fakeRootDir, 'build.gradle')}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

rootDir was not needed as we're no longer using it for rootPkg name generation.

@dotkas dotkas force-pushed the dotkas/SUP-2164/test-monitor-projectname-discrepancy branch from fed5724 to 80c24c7 Compare November 16, 2023 19:45
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems the pipeline has been failing for a long time, so most likely unrelated to this change.

package.json Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Beyond this points it's all updated fixtures.

@dotkas dotkas requested review from danielroymoore and removed request for klesniewski and danlucian November 18, 2023 09:23
@dotkas dotkas enabled auto-merge November 18, 2023 17:37
@dotkas dotkas merged commit 0305fef into master Nov 18, 2023
@dotkas dotkas deleted the dotkas/SUP-2164/test-monitor-projectname-discrepancy branch November 18, 2023 18:07
@snyksec
Copy link

snyksec commented Nov 18, 2023

🎉 This PR is included in version 4.0.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
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants