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 dependency names on state commit #3447

Merged
merged 7 commits into from
Aug 16, 2024
Merged

Fix dependency names on state commit #3447

merged 7 commits into from
Aug 16, 2024

Conversation

MDrakos
Copy link
Member

@MDrakos MDrakos commented Aug 14, 2024

BugDX-2966 COMMIT: We get the message with a list of all dependencies and it is also not properly wrapped if too long.

@@ -159,7 +160,19 @@ func (c *Commit) Run() (rerr error) {
dependencies.OutputChangeSummary(out, rtCommit.BuildPlan(), oldCommit.BuildPlan())

// Report CVEs.
if err := cves.NewCveReport(c.prime).Report(rtCommit.BuildPlan(), oldCommit.BuildPlan()); err != nil {
newReqs, err := newRequirements(oldCommit.BuildScript(), rtCommit.BuildScript())
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't feel right, because we're going to need to duplicate this logic in other places that will eventually get CVE reporting. It looks like state import is not passing any names to cves.NewCveReport() either, so presumably it suffers from the same bug.

Can we put all of this logic in the Report() method? Kind of like how the change summary reporter diffs two buildplans? (

changeset := newBuildPlan.DiffArtifacts(oldBuildPlan, false)
). If we need absolutely need buildscripts, then maybe we should be passing commits to the method instead of buildplans.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point about the repeated logic. The changeset gets us back to the original problem where it's including too many requirements as we just want the top level ones and not the dependencies. I've moved this logic inside the Report method and we're now passing it commits.

@MDrakos MDrakos requested a review from mitchell-as August 14, 2024 23:44
@@ -246,7 +246,7 @@ func (r *RequirementOperation) ExecuteRequirementOperation(ts *time.Time, requir

// Report CVEs
names := requirementNames(requirements...)
if err := cves.NewCveReport(r.prime).Report(commit.BuildPlan(), oldCommit.BuildPlan(), names...); err != nil {
if err := cves.NewCveReport(r.prime).Report(commit, oldCommit, names...); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any way we can compute the names here inside Report() and remove these extra arguments? Maybe diffing the buildscripts will be enough?

It's unclear to me when we need to pass names, and when we do not. Currently only requirements passes names, and when other commands start calling this function, are they supposed to pass names or omit them? There's an ambiguity here and I'd either like to remove it, or add a documentation comment to Report() as to when names are required an when they can be omitted.

Copy link
Member Author

Choose a reason for hiding this comment

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

Now that we are using the build plan to get the requested requirements we should be okay to remove the names parameter.

@MDrakos MDrakos requested a review from mitchell-as August 15, 2024 18:40
Copy link
Contributor

@mitchell-as mitchell-as left a comment

Choose a reason for hiding this comment

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

This looks fine to me, but before merging, please run the integration tests for install,import,package. They all use this code path and we want to make sure we didn't break anything.

@MDrakos MDrakos merged commit e93bdae into version/0-46-0-RC1 Aug 16, 2024
6 of 7 checks passed
@MDrakos MDrakos deleted the DX-2966 branch August 16, 2024 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants