Skip to content

Commit 5b32ff1

Browse files
Fix: ruleIDs mapping for PMD
1 parent df55ffa commit 5b32ff1

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

cmd/upload.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,16 @@ func getPatternByID(patterns []domain.PatternConfiguration, patternID string) *d
293293
})
294294
}
295295
for _, p := range sarifPatterns {
296-
if strings.EqualFold(p.ID, patternID) {
296+
//Only for PMD v6 or PMD v7 because the patternID is only part
297+
//of the original ruleset name and the prefix shouldn't be part of it
298+
//because the comparison will be always negative
299+
//So we need to clean that prefix first.
300+
cleanPMDPrefix := strings.TrimPrefix(patternID, "PMD_")
301+
cleanPatternID := strings.TrimPrefix(cleanPMDPrefix, "PMD7_")
302+
303+
lowerID := strings.ToLower(p.ID)
304+
lowerPattern := strings.ToLower(cleanPatternID)
305+
if lowerID == lowerPattern || strings.Contains(lowerID, lowerPattern) {
297306
return &p
298307
}
299308
}

0 commit comments

Comments
 (0)