Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use proper finding IDs for sonar and semgrep SARIF #956

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/codemodder/semgrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,18 @@ def from_sarif(
# avoid circular import
from core_codemods.semgrep.api import semgrep_url_from_id

rule_id = cls.extract_rule_id(sarif_result, sarif_run, truncate_rule_id)
finding_id = cls.extract_finding_id(sarif_result) or rule_id
return cls(
rule_id=(
rule_id := cls.extract_rule_id(
sarif_result, sarif_run, truncate_rule_id
)
),
rule_id=rule_id,
locations=cls.extract_locations(sarif_result),
codeflows=cls.extract_code_flows(sarif_result),
related_locations=cls.extract_related_locations(sarif_result),
finding_id=rule_id,
finding_id=finding_id,
finding=Finding(
id=rule_id,
id=cls.extract_finding_id(sarif_result) or rule_id,
rule=Rule(
id=rule_id,
id=finding_id,
name=rule_id,
url=semgrep_url_from_id(rule_id),
),
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/sonar/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def from_result(cls, result: dict) -> Self:
locations=locations,
codeflows=all_flows,
finding=Finding(
id=rule_id,
id=finding_id,
rule=Rule(
id=rule_id,
name=name,
Expand Down
Loading