MCPcopy Create free account
hub / github.com/XmirrorSecurity/OpenSCA-cli / formatDesc

Function formatDesc

cmd/format/sarif.go:145–173  ·  view source on GitHub ↗
(v *detail.VulnInfo)

Source from the content-addressed store, hash-verified

143}
144
145func formatDesc(v *detail.VulnInfo) string {
146 table := []struct {
147 fmt string
148 val string
149 }{
150 {"| id | %s |", v.Id},
151 {"| --- | --- |", ""},
152 {"| cve | %s |", v.Cve},
153 {"| cnnvd | %s |", v.Cnnvd},
154 {"| cnvd | %s |", v.Cnvd},
155 {"| cwe | %s |", v.Cwe},
156 {"| level | %s |", v.SecurityLevel()},
157 {"| desc | %s |", sanitizeString(v.Description)},
158 {"| suggestion | %s |", sanitizeString(v.Suggestion)},
159 }
160 var lines []string
161 for _, line := range table {
162 if strings.Contains(line.fmt, "%s") && line.val == "" {
163 continue
164 }
165 if line.val == "" {
166 lines = append(lines, line.fmt)
167 } else {
168 lines = append(lines, fmt.Sprintf(line.fmt, line.val))
169 }
170 }
171
172 return strings.Join(lines, "\n")
173}
174
175func sanitizeString(s string) string {
176 re := regexp.MustCompile("<[^>]*>")

Callers 1

SarifFunction · 0.85

Calls 2

sanitizeStringFunction · 0.85
SecurityLevelMethod · 0.80

Tested by

no test coverage detected