1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00

feat(sarif): add GUID as part of properties, change ruleID (#3838)

This commit is contained in:
xgoffin 2022-06-17 08:53:44 +02:00 committed by GitHub
parent c11110d791
commit 0457601efd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 4 deletions

View File

@ -193,7 +193,7 @@ func Parse(sys System, data []byte, scanID int) (format.SARIF, error) {
}*/
//General
result.RuleID = "checkmarx-" + cxxml.Query[i].ID
result.RuleID = "checkmarx-" + cxxml.Query[i].Language + "/" + cxxml.Query[i].ID
result.RuleIndex = cweIdsForTaxonomies[cxxml.Query[i].CweID]
result.Level = "none"
msg := new(format.Message)
@ -282,6 +282,7 @@ func Parse(sys System, data []byte, scanID int) (format.SARIF, error) {
}
props.ToolAuditMessage = strings.Join(messageCandidates, " \n ")
}
props.RuleGUID = cxxml.Query[i].ID
props.UnifiedAuditState = ""
result.Properties = props
@ -291,7 +292,7 @@ func Parse(sys System, data []byte, scanID int) (format.SARIF, error) {
//handle the rules array
rule := *new(format.SarifRule)
rule.ID = "checkmarx-" + cxxml.Query[i].ID
rule.ID = "checkmarx-" + cxxml.Query[i].Language + "/" + cxxml.Query[i].ID
words := strings.Split(cxxml.Query[i].Name, "_")
for w := 0; w < len(words); w++ {
words[w] = piperutils.Title(strings.ToLower(words[w]))

View File

@ -87,6 +87,7 @@ type PartialFingerprints struct {
// SarifProperties adding additional information/context to the finding
type SarifProperties struct {
RuleGUID string `json:"ruleGUID,omitempty"`
InstanceID string `json:"instanceID,omitempty"`
InstanceSeverity string `json:"instanceSeverity,omitempty"`
Confidence string `json:"confidence,omitempty"`

View File

@ -578,9 +578,9 @@ func Parse(sys System, project *models.Project, projectVersion *models.ProjectVe
//result.RuleID = fvdl.Vulnerabilities.Vulnerability[i].ClassInfo.ClassID
// Handle ruleID the same way than in Rule
idArray := []string{}
if fvdl.Vulnerabilities.Vulnerability[i].ClassInfo.Kingdom != "" {
/*if fvdl.Vulnerabilities.Vulnerability[i].ClassInfo.Kingdom != "" {
idArray = append(idArray, fvdl.Vulnerabilities.Vulnerability[i].ClassInfo.Kingdom)
}
}*/
if fvdl.Vulnerabilities.Vulnerability[i].ClassInfo.Type != "" {
idArray = append(idArray, fvdl.Vulnerabilities.Vulnerability[i].ClassInfo.Type)
}
@ -791,6 +791,7 @@ func Parse(sys System, project *models.Project, projectVersion *models.ProjectVe
prop.InstanceSeverity = strconv.FormatFloat(fvdl.Vulnerabilities.Vulnerability[i].InstanceInfo.InstanceSeverity, 'f', 1, 64)
prop.Confidence = fvdl.Vulnerabilities.Vulnerability[i].InstanceInfo.Confidence
prop.InstanceID = fvdl.Vulnerabilities.Vulnerability[i].InstanceInfo.InstanceID
prop.RuleGUID = fvdl.Vulnerabilities.Vulnerability[i].ClassInfo.ClassID
//Get the audit data
if err := integrateAuditData(prop, fvdl.Vulnerabilities.Vulnerability[i].InstanceInfo.InstanceID, sys, project, projectVersion, auditData, filterSet, oneRequestPerIssueMode, maxretries); err != nil {
log.Entry().Debug(err)