Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .github/scripts/sigilix_sarif_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@ def _sanitize_run_results(run):
}
# OpenGrep runs the same rulesets as Semgrep → reuse the patterns.
_RULE_CLASS_PATTERNS["opengrep"] = _RULE_CLASS_PATTERNS["semgrep"]
# Dedicated secret scanners only ever report hardcoded secrets, so every result
# maps to `hardcoded-secret` (`.+` = any non-empty ruleId). The exactly-one-class
# guard keeps this collision-safe.
_RULE_CLASS_PATTERNS["gitleaks"] = [(re.compile(r".+"), "hardcoded-secret")]
_RULE_CLASS_PATTERNS["trufflehog"] = [(re.compile(r".+"), "hardcoded-secret")]


def stamp_rule_classes(run, tool_id):
Expand Down
6 changes: 6 additions & 0 deletions .github/scripts/sigilix_sarif_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,12 @@ def test_collision_safe_unset_when_two_classes_match(self):
# A contrived ruleId hitting two patterns → exactly-one guard leaves it unset.
self.assertIsNone(self._run("sql-injection-and-ssrf-combo"))

def test_secret_scanners_map_to_hardcoded_secret(self):
for tool in ("gitleaks", "trufflehog"):
run = {"tool": {"driver": {}}, "results": [{"ruleId": "aws-access-token", "properties": {}}]}
stamp_rule_classes(run, tool)
self.assertEqual(run["results"][0]["properties"]["sigilixRuleClass"], "hardcoded-secret")

def test_unknown_tool_id_strips_only(self):
run = {"tool": {"driver": {}}, "results": [{"ruleId": "dangerous-exec", "properties": {"sigilixRuleClass": "x"}}]}
stamp_rule_classes(run, "eslint") # no patterns for eslint → strip only
Expand Down
Loading