Skip to content

Commit ded2f70

Browse files
committed
Use proper finding IDs for sonar and semgrep SARIF
1 parent d0be8fb commit ded2f70

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/codemodder/semgrep.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,18 @@ def from_sarif(
5454
# avoid circular import
5555
from core_codemods.semgrep.api import semgrep_url_from_id
5656

57+
rule_id = cls.extract_rule_id(sarif_result, sarif_run, truncate_rule_id)
58+
finding_id = cls.extract_finding_id(sarif_result) or rule_id
5759
return cls(
58-
rule_id=(
59-
rule_id := cls.extract_rule_id(
60-
sarif_result, sarif_run, truncate_rule_id
61-
)
62-
),
60+
rule_id=rule_id,
6361
locations=cls.extract_locations(sarif_result),
6462
codeflows=cls.extract_code_flows(sarif_result),
6563
related_locations=cls.extract_related_locations(sarif_result),
66-
finding_id=rule_id,
64+
finding_id=finding_id,
6765
finding=Finding(
68-
id=rule_id,
66+
id=cls.extract_finding_id(sarif_result) or rule_id,
6967
rule=Rule(
70-
id=rule_id,
68+
id=finding_id,
7169
name=rule_id,
7270
url=semgrep_url_from_id(rule_id),
7371
),

src/core_codemods/sonar/results.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def from_result(cls, result: dict) -> Self:
6969
locations=locations,
7070
codeflows=all_flows,
7171
finding=Finding(
72-
id=rule_id,
72+
id=finding_id,
7373
rule=Rule(
7474
id=rule_id,
7575
name=name,

0 commit comments

Comments
 (0)