From dd5fdb90507a4c00431176dacbca3631db645d51 Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Wed, 5 Jul 2023 10:17:32 -0700 Subject: [PATCH] :sparkles: Add links to rules and issues reports. Signed-off-by: Jeff Ortel --- api/analysis.go | 10 ++++++++++ hack/add/analysis.sh | 18 +++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/api/analysis.go b/api/analysis.go index 6cb5bcc0..5ed47091 100644 --- a/api/analysis.go +++ b/api/analysis.go @@ -768,6 +768,7 @@ func (h AnalysisHandler) RuleReports(ctx *gin.Context) { "i.Category", "i.Effort", "i.Labels", + "i.Links", "COUNT(distinct a.ID) Applications") q = q.Table("Issue i,") q = q.Joins("Analysis a") @@ -816,6 +817,9 @@ func (h AnalysisHandler) RuleReports(ctx *gin.Context) { if m.Labels != nil { _ = json.Unmarshal(m.Labels, &r.Labels) } + if m.Links != nil { + _ = json.Unmarshal(m.Links, &r.Links) + } r.Effort += m.Effort } @@ -888,6 +892,7 @@ func (h AnalysisHandler) AppIssueReports(ctx *gin.Context) { "i.Category", "i.Effort", "i.Labels", + "i.Links", "COUNT(distinct n.File) Files") q = q.Table("Issue i,") q = q.Joins("Incident n") @@ -937,6 +942,9 @@ func (h AnalysisHandler) AppIssueReports(ctx *gin.Context) { if m.Labels != nil { _ = json.Unmarshal(m.Labels, &r.Labels) } + if m.Links != nil { + _ = json.Unmarshal(m.Links, &r.Links) + } r.Effort += m.Effort } @@ -1884,6 +1892,7 @@ type RuleReport struct { Category string `json:"category"` Effort int `json:"effort"` Labels []string `json:"labels"` + Links []Link `json:"links"` Applications int `json:"applications"` } @@ -1898,6 +1907,7 @@ type IssueReport struct { Category string `json:"category"` Effort int `json:"effort"` Labels []string `json:"labels"` + Links []Link `json:"links"` Files int `json:"files"` } diff --git a/hack/add/analysis.sh b/hack/add/analysis.sh index fe9996b6..6212d6b9 100755 --- a/hack/add/analysis.sh +++ b/hack/add/analysis.sh @@ -76,7 +76,18 @@ echo -n "--- ruleset: ruleSet-${r} rule: rule-${i} name: Rule-${r}.${i}-Violated -description: This is a test ${r}/${i} violation. +description: | + This is a test ${r}/${i} violation. + This is a **description** of the issue in markdown*. + Here's how to fix the issue. + + For example: + + This is some bad code. + + Should become: + + This is some good code. category: warning effort: 10 labels: @@ -84,6 +95,11 @@ labels: - RULESET-${r} - ${sources[$((${i}%${#sources[@]}))]} - ${targets[$((${i}%${#targets[@]}))]} +links: +- title: Document A + url: http://ruleset/${r}/rule/${i}/documentA.html +- title: Document B + url: http://ruleset/${r}/rule/${i}/documentB.html incidents: " >> ${file} for n in $(seq 1 ${nIncident})