( execStatusPath, issuesPath string, )
| 191 | } |
| 192 | |
| 193 | func parseIssues( |
| 194 | execStatusPath, issuesPath string, |
| 195 | ) ([]WrappedIssue, []string, []string, error) { |
| 196 | var checks map[issue.IssueID]string |
| 197 | jsonFile, err := os.Open(execStatusPath) |
| 198 | if err != nil { |
| 199 | jsonFile.Close() |
| 200 | return nil, nil, nil, err |
| 201 | } |
| 202 | jsonBytes, _ := ioutil.ReadAll(jsonFile) |
| 203 | json.Unmarshal(jsonBytes, &checks) |
| 204 | jsonFile.Close() |
| 205 | |
| 206 | var issues []issue.Issue |
| 207 | |
| 208 | jsonFile, err = os.Open(issuesPath) |
| 209 | if err != nil { |
| 210 | jsonFile.Close() |
| 211 | return nil, nil, nil, err |
| 212 | } |
| 213 | jsonBytes, _ = ioutil.ReadAll(jsonFile) |
| 214 | json.Unmarshal(jsonBytes, &issues) |
| 215 | jsonFile.Close() |
| 216 | |
| 217 | var wrappedIssues []WrappedIssue |
| 218 | |
| 219 | // order by severity in descending order |
| 220 | sort.Slice(issues, func(i, j int) bool { |
| 221 | return issues[i].Severity > issues[j].Severity |
| 222 | }) |
| 223 | for _, i := range issues { |
| 224 | delete(checks, i.ID) |
| 225 | if strings.HasPrefix(string(i.ID), "STATS") { |
| 226 | continue |
| 227 | } |
| 228 | var cweStrings []string |
| 229 | for _, cwe := range i.CWEs { |
| 230 | cweStrings = append( |
| 231 | cweStrings, |
| 232 | fmt.Sprintf( |
| 233 | "<a href=\"https://cwe.mitre.org/data/definitions/%d.html\" target=\"_blank\" rel=\"noopener noreferrer\">%d</a>", |
| 234 | cwe, |
| 235 | cwe, |
| 236 | ), |
| 237 | ) |
| 238 | } |
| 239 | wrappedIssues = append(wrappedIssues, |
| 240 | WrappedIssue{ |
| 241 | Issue: i, |
| 242 | SeverityStr: template.HTML(getSeverity(i.Severity.String())), |
| 243 | Description: template.HTML(normalizeLinks(i.Description)), |
| 244 | Remediation: template.HTML(normalizeLinks(i.Remediation)), |
| 245 | CWEs: template.HTML(strings.Join(cweStrings, ",")), |
| 246 | }) |
| 247 | } |
| 248 | |
| 249 | var passed []string |
| 250 | var failed []string |
no test coverage detected