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

Cherry-Pick: Fixed bug when using without_vulnerability_details and vulnerability filters #24774

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ee/server/service/software.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func (svc *Service) ListSoftware(ctx context.Context, opts fleet.SoftwareListOpt
// reuse ListSoftware, but include cve scores in premium version
// unless without_vulnerability_details is set to true
// including these details causes a lot of memory bloat
if !opts.WithoutVulnerabilityDetails {
if (opts.MaximumCVSS > 0 || opts.MinimumCVSS > 0 || opts.KnownExploit) || !opts.WithoutVulnerabilityDetails {
opts.IncludeCVEScores = true
}
return svc.Service.ListSoftware(ctx, opts)
Expand Down
2 changes: 1 addition & 1 deletion server/datastore/mysql/software.go
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ func listSoftwareDB(
DetailsLink: fmt.Sprintf("https://nvd.nist.gov/vuln/detail/%s", cveID),
CreatedAt: *result.CreatedAt,
}
if opts.IncludeCVEScores {
if opts.IncludeCVEScores && !opts.WithoutVulnerabilityDetails {
cve.CVSSScore = &result.CVSSScore
cve.EPSSProbability = &result.EPSSProbability
cve.CISAKnownExploit = &result.CISAKnownExploit
Expand Down
19 changes: 19 additions & 0 deletions server/service/integration_enterprise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5223,6 +5223,25 @@ func (s *integrationEnterpriseTestSuite) TestListSoftware() {
require.Nil(t, cve.ResolvedInVersion)
}
}
// without_vulnerability_details with vulnerability filter
s.DoJSON(
"GET", "/api/latest/fleet/software/versions",
listSoftwareRequest{},
http.StatusOK, &respVersions,
"exploit", "true",
"vulnerable", "true",
"without_vulnerability_details", "true",
)
for _, s := range respVersions.Software {
for _, cve := range s.Vulnerabilities {
require.Nil(t, cve.CVSSScore)
require.Nil(t, cve.EPSSProbability)
require.Nil(t, cve.CISAKnownExploit)
require.Nil(t, cve.CVEPublished)
require.Nil(t, cve.Description)
require.Nil(t, cve.ResolvedInVersion)
}
}
s.DoJSON(
"GET", "/api/latest/fleet/software/versions",
listSoftwareRequest{},
Expand Down
6 changes: 5 additions & 1 deletion server/service/software.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ func (svc *Service) ListSoftware(ctx context.Context, opt fleet.SoftwareListOpti
}

// Vulnerability filters are only available in premium (opt.IncludeCVEScores is only true in premium)
if !opt.IncludeCVEScores && (opt.MaximumCVSS > 0 || opt.MinimumCVSS > 0 || opt.KnownExploit) {
lic, err := svc.License(ctx)
if err != nil {
return nil, nil, err
}
if !lic.IsPremium() && (opt.MaximumCVSS > 0 || opt.MinimumCVSS > 0 || opt.KnownExploit) {
return nil, nil, fleet.ErrMissingLicense
}

Expand Down
Loading