feat(projects): pass open vulnerabilities through to the portal #76

Merged
sharang merged 1 commits from feat/project-targets-open-vulnerabilities into main 2026-10-14 18:20:58 +00:00
3 changed files with 9 additions and 3 deletions

No files matched your search

+5 -2
View File
@@ -218,8 +218,11 @@ type projectTarget struct {
TargetType string `json:"target_type"`
LastScanAt *time.Time `json:"last_scan_at,omitempty"`
OpenFindings int `json:"open_findings"`
ProjectIDs []string `json:"project_ids"`
URL string `json:"url,omitempty"`
// OpenVulnerabilities counts the known vulnerabilities in its
// components that still need a decision (Prüfwerk's open CVE alerts).
OpenVulnerabilities int `json:"open_vulnerabilities"`
ProjectIDs []string `json:"project_ids"`
URL string `json:"url,omitempty"`
}
// listProjectTargets is GET /v1/tenants/{id}/projects/{pid}/targets: the
+3 -1
View File
@@ -219,7 +219,7 @@ func TestProjects_targetsFromPruefwerk(t *testing.T) {
w.WriteHeader(500)
return
}
_, _ = io.WriteString(w, `{"items":[{"id":"6aba48d37507608342a05996","name":"STM32 U5","target_type":"firmware_rtos","open_findings":7,"last_scan_at":"2026-09-28T11:07:41Z"},{"id":"x","name":"Y","target_type":"git","project_ids":["`+p.ID+`"]}]}`)
_, _ = io.WriteString(w, `{"items":[{"id":"6aba48d37507608342a05996","name":"STM32 U5","target_type":"firmware_rtos","open_findings":7,"open_vulnerabilities":3,"last_scan_at":"2026-09-28T11:07:41Z"},{"id":"x","name":"Y","target_type":"git","project_ids":["`+p.ID+`"]}]}`)
}))
defer pw.Close()
h.app.Cfg.PruefwerkPlatformURL = pw.URL + "/api/v1/platform/"
@@ -231,11 +231,13 @@ func TestProjects_targetsFromPruefwerk(t *testing.T) {
Items []struct {
ID, Name, URL string
OpenFindings int `json:"open_findings"`
OpenVulns int `json:"open_vulnerabilities"`
ProjectIDs []string `json:"project_ids"`
}
}
_ = json.Unmarshal(raw, &out)
if !out.Available || len(out.Items) != 2 || out.Items[0].OpenFindings != 7 ||
out.Items[0].OpenVulns != 3 || out.Items[1].OpenVulns != 0 ||
out.Items[0].URL != "https://pruefwerk-stage.breakpilot.com/targets/6aba48d37507608342a05996" ||
out.Items[0].ProjectIDs == nil || len(out.Items[1].ProjectIDs) != 1 {
t.Fatalf("targets: %s", raw)
+1
View File
@@ -327,6 +327,7 @@ paths:
target_type: { type: string }
last_scan_at: { type: string, format: date-time }
open_findings: { type: integer }
open_vulnerabilities: { type: integer, description: Known vulnerabilities in its components that are still open (CVE alerts not resolved and not assessed not_affected or fixed). }
project_ids: { type: array, items: { type: string } }
url: { type: string, description: The object in the Prüfwerk dashboard. }
"404": { $ref: "#/components/responses/NotFound" }