Skip to content

Support RHEL content sets in a call to GetNodeVulnerabilities - #1059

Merged
vikin91 merged 6 commits into
masterfrom
piotr/cpes-vs-content-sets
Jan 23, 2023
Merged

Support RHEL content sets in a call to GetNodeVulnerabilities#1059
vikin91 merged 6 commits into
masterfrom
piotr/cpes-vs-content-sets

Conversation

@vikin91

@vikin91 vikin91 commented Jan 18, 2023

Copy link
Copy Markdown
Contributor

As a result of #1053 we decided that Analyze will not provide CPEs but instead would include RHEL content sets. This PR adapts the GetNodeVulnerabilities to that change, so that content sets are translated to CPEs in Scanner.

How tested

Screenshot 2023-01-18 at 18 05 45

@vikin91
vikin91 requested a review from jschnath January 18, 2023 16:07
@ghost

ghost commented Jan 18, 2023

Copy link
Copy Markdown

Images are ready for the commit at becf56c.

To use the images, use the tag 2.27.x-36-gbecf56cb28.

@jvdm jvdm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have one question that might require a change, so still pending. I also have a Nit that is not a blocker.

Comment thread api/v1/nodescan/service.go Outdated
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
log.Debugf("Scanned %d components from NodeInventory and returning %d features", len(components.GetRhelComponents()), len(layer.Features))

@jvdm jvdm Jan 19, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: I would adjust the terminology. We usually consider "Vulnerability Scanning" as a two parts process: Analysis (detection and inventory creation) and Vulnerability Matching. What you are doing here is the latter.

Maybe "Matched vulnerabilities on %d RHEL components in node inventory." instead?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, making this an INFO rather than a DEBUG would cause too much impact in the logs? Having this sort of info in the bundles would be valuable, but I am not sure of the impact. Just push me back if that is not feasible.

Comment thread api/v1/nodescan/service.go Outdated
cpes := s.repoToCPE.Get(components.GetRhelContentSets())
log.Debugf("Converted content sets '%v' to CPEs '%v'", components.GetRhelContentSets(), cpes)
for _, comp := range components.GetRhelComponents() {
comp.Cpes = append(comp.Cpes, cpes...)

@jvdm jvdm Jan 19, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe ensure comp.Cpes is empty since it came from the API call. Or were you purposefully appending not to overwrite?

We will revisit this piece of code as part of ROX-14414. By then, we will have to decide how to support input that has CPEs set and inputs that don't. But until then, overwriting to sanitize input seems the right course of action.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay, I was appending not to overwrite - having more CPEs seems not bad to me. But if we have a followup to tackle this, then I will follow your suggestion too overwrite and leave a comment about the follow-up ticket.

@jvdm jvdm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM.

@vikin91
vikin91 merged commit a299911 into master Jan 23, 2023
@vikin91
vikin91 deleted the piotr/cpes-vs-content-sets branch January 23, 2023 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants