Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add links to rules and issues reports. #434

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions api/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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"`
}

Expand All @@ -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"`
}

Expand Down
18 changes: 17 additions & 1 deletion hack/add/analysis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,30 @@ 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:
- RULE-${i}
- 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})
Expand Down