Skip to content

Commit 8d0af71

Browse files
authored
Fix finding IDs for semgrep sarifs (#960)
1 parent b4d64d7 commit 8d0af71

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

src/codemodder/semgrep.py

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
from typing_extensions import Self, override
99

10-
from codemodder.codetf import Finding, Rule
1110
from codemodder.context import CodemodExecutionContext
1211
from codemodder.logging import logger
1312
from codemodder.result import LineInfo, Result, ResultSet, SarifLocation, SarifResult
@@ -48,31 +47,11 @@ class SemgrepResult(SarifResult):
4847
location_type = SemgrepLocation
4948

5049
@classmethod
51-
def from_sarif(
52-
cls, sarif_result, sarif_run, truncate_rule_id: bool = False
53-
) -> Self:
54-
# avoid circular import
50+
def rule_url_from_id(cls, sarif_result, sarif_run, rule_id):
51+
del sarif_result, sarif_run
5552
from core_codemods.semgrep.api import semgrep_url_from_id
5653

57-
return cls(
58-
rule_id=(
59-
rule_id := cls.extract_rule_id(
60-
sarif_result, sarif_run, truncate_rule_id
61-
)
62-
),
63-
locations=cls.extract_locations(sarif_result),
64-
codeflows=cls.extract_code_flows(sarif_result),
65-
related_locations=cls.extract_related_locations(sarif_result),
66-
finding_id=rule_id,
67-
finding=Finding(
68-
id=rule_id,
69-
rule=Rule(
70-
id=rule_id,
71-
name=rule_id,
72-
url=semgrep_url_from_id(rule_id),
73-
),
74-
),
75-
)
54+
return semgrep_url_from_id(rule_id)
7655

7756

7857
class SemgrepResultSet(ResultSet):

0 commit comments

Comments
 (0)