fleet/ee/server/service/vulnerabilities.go
Victor Lyuboslavsky cd14831e44
Updated /api/v1/fleet/vulnerabilities/{cve} endpoint (#21463)
main task: #19857
subtask: #21392

- For GET /api/v1/fleet/vulnerabilities/{cve} endpoint, added validation
of CVE format, and added a 204 response. The 204 response indicates that
the vulnerability is known to Fleet but not present on any hosts.
- Removed the previous known_vulnerability field implementation

# Checklist for submitter

- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files)
for more information.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2024-08-21 12:52:28 -05:00

27 lines
723 B
Go

package service
import (
"context"
"github.com/fleetdm/fleet/v4/server/fleet"
)
var eeValidVulnSortColumns = []string{
"cve",
"hosts_count",
"created_at",
"cvss_score",
"epss_probability",
"cve_published",
}
func (svc *Service) ListVulnerabilities(ctx context.Context, opt fleet.VulnListOptions) ([]fleet.VulnerabilityWithMetadata, *fleet.PaginationMetadata, error) {
opt.ValidSortColumns = eeValidVulnSortColumns
opt.IsEE = true
return svc.Service.ListVulnerabilities(ctx, opt)
}
func (svc *Service) Vulnerability(ctx context.Context, cve string, teamID *uint, useCVSScores bool) (vuln *fleet.VulnerabilityWithMetadata,
known bool, err error) {
return svc.Service.Vulnerability(ctx, cve, teamID, true)
}