-
Notifications
You must be signed in to change notification settings - Fork 13
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
Conversation
MDrakos
commented
Aug 14, 2024
•
edited by github-actions
bot
Loading
edited by github-actions
bot
DX-2966 COMMIT: We get the message with a list of all dependencies and it is also not properly wrapped if too long. |
internal/runners/commit/commit.go
Outdated
@@ -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()) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
@@ -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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Also remove names variable
There was a problem hiding this 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.