MCPcopy Create free account
hub / github.com/crashappsec/github-analyzer / parseIssues

Function parseIssues

pkg/output/html/html.go:193–264  ·  view source on GitHub ↗
(
	execStatusPath, issuesPath string,
)

Source from the content-addressed store, hash-verified

191}
192
193func 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

Callers 1

ServeFunction · 0.85

Calls 3

getSeverityFunction · 0.85
normalizeLinksFunction · 0.85
StringMethod · 0.80

Tested by

no test coverage detected