diff --git a/go.sum b/go.sum index e6ce088..a644d7f 100644 --- a/go.sum +++ b/go.sum @@ -209,6 +209,7 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.7.0 h1:wCi7urQOGBsYcQROHqpUUX4ct84xp40t9R9JX0FuA/U= github.com/prometheus/client_golang v1.7.0/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= +github.com/prometheus/client_golang v1.9.0 h1:Rrch9mh17XcxvEu9D9DEpb4isxjGBtcevQjKvxPRQIU= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= diff --git a/metric_artifacts.go b/metrics_artifacts.go similarity index 94% rename from metric_artifacts.go rename to metrics_artifacts.go index c2f93aa..6b0133b 100644 --- a/metric_artifacts.go +++ b/metrics_artifacts.go @@ -2,6 +2,7 @@ package main import ( "encoding/json" + "net/url" "strconv" "strings" "time" @@ -38,9 +39,10 @@ type scanOverview struct { Summary struct { Fixable int `json:"fixable"` Summary struct { - High int `json:"High"` - Low int `json:"Low"` - Medium int `json:"Medium"` + Critical int `json:"Critical"` + High int `json:"High"` + Medium int `json:"Medium"` + Low int `json:"Low"` } `json:"summary"` Total int `json:"total"` } `json:"summary"` @@ -138,6 +140,7 @@ func (h *HarborExporter) collectArtifactsMetric(ch chan<- prometheus.Metric) boo ch <- prometheus.MustNewConstMetric(vulnMI.Desc, vulnMI.Type, float64(scanInfo.Summary.Summary.Low), projectName, projectID, repoName, repoID, artName, artID, reportID, "low") ch <- prometheus.MustNewConstMetric(vulnMI.Desc, vulnMI.Type, float64(scanInfo.Summary.Summary.Medium), projectName, projectID, repoName, repoID, artName, artID, reportID, "medium") ch <- prometheus.MustNewConstMetric(vulnMI.Desc, vulnMI.Type, float64(scanInfo.Summary.Summary.High), projectName, projectID, repoName, repoID, artName, artID, reportID, "high") + ch <- prometheus.MustNewConstMetric(vulnMI.Desc, vulnMI.Type, float64(scanInfo.Summary.Summary.Critical), projectName, projectID, repoName, repoID, artName, artID, reportID, "critical") // Scan Status. ch <- prometheus.MustNewConstMetric(scansDurMI.Desc, scansDurMI.Type, float64(scanInfo.Duration), projectName, projectID, repoName, repoID, artName, artID, reportID) @@ -249,7 +252,7 @@ func (h *HarborExporter) loadArtifacts(projectName string, repoData repositories var reqURL string if h.isV2 { reqURL = "/projects/" + projectName + - "/repositories" + strings.TrimLeft(repoData[i].Name, projectName) + + "/repositories/" + url.PathEscape(strings.TrimLeft(repoData[i].Name, projectName+"/")) + "/artifacts?with_tag=true&with_scan_overview=true" } else { panic("No v1 API support")