Skip to content

Commit c114632

Browse files
fevra-devclaude
andcommitted
🐛 Render UNKNOWN instead of None for v0.1 finding severity in supply-chain CLI
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3b55907 commit c114632

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

gitexpose/cli_advanced.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -838,9 +838,9 @@ def supply_chain(path: str, output: str, out_file: str):
838838
else:
839839
lines = [f"🔍 {len(findings)} supply-chain finding(s) in {path}:"]
840840
for f in findings:
841-
sev = f.get("severity", "?")
842-
ftype = f.get("type", "?")
843-
src = f.get("source", "")
841+
sev = f.get("severity") or "UNKNOWN"
842+
ftype = f.get("type") or "unknown"
843+
src = f.get("source") or ""
844844
desc = next(iter((f.get("description") or "").splitlines()), "")
845845
lines.append(f" [{sev}] {ftype} ({src})")
846846
if desc:

tests/test_supply_chain_cli.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ def test_supply_chain_handles_synthetic_repo_e2e():
6464
assert "groq_api_key" in result.output
6565

6666

67+
def test_supply_chain_renders_severity_for_v01_findings(tmp_path: Path):
68+
"""Regression: v0.1 secret-dicts have severity=None.
69+
Output must render 'UNKNOWN' (or similar), not the literal '[None]'."""
70+
# generic_api_key is a v0.1 pattern that emits with severity=None
71+
(tmp_path / "config.py").write_text(
72+
'api_key = "abcdefghijklmnopqrstuvwxyz1234567890"\n'
73+
)
74+
runner = CliRunner()
75+
result = runner.invoke(cli, ["supply-chain", str(tmp_path)])
76+
assert "[None]" not in result.output, f"Severity rendered as literal None: {result.output}"
77+
78+
6779
def test_main_cli_accepts_sarif_output_format():
6880
"""`gitexpose --help` lists sarif as an output choice."""
6981
from click.testing import CliRunner

0 commit comments

Comments
 (0)