diff --git a/internal/server/projects.go b/internal/server/projects.go index 03d0393..d8e9490 100644 --- a/internal/server/projects.go +++ b/internal/server/projects.go @@ -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 diff --git a/internal/server/projects_test.go b/internal/server/projects_test.go index f468492..f47ff37 100644 --- a/internal/server/projects_test.go +++ b/internal/server/projects_test.go @@ -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) diff --git a/openapi.yaml b/openapi.yaml index 4a37629..95ba8d1 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -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" }