Skip to content

Commit 0e2b9d2

Browse files
committed
feat: add confidence filtering
1 parent 69fd307 commit 0e2b9d2

4 files changed

Lines changed: 391 additions & 4 deletions

File tree

cli.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
help="Only show findings matching the selected severity",
2525
)
2626

27+
# Limit displayed findings to a selected confidence level.
28+
parser.add_argument(
29+
"--confidence",
30+
choices=["LOW", "MEDIUM", "HIGH"],
31+
help="Only show findings matching the selected confidence level",
32+
)
33+
2734
# Mask detected secret values in text or JSON output.
2835
parser.add_argument(
2936
"--redact",
@@ -38,3 +45,4 @@
3845
use_json = args.json
3946
redact_secrets = args.redact
4047
chosen_severity = args.severity
48+
chosen_confidence = args.confidence

main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Coordinates CLI input, file discovery, scanning, filtering, and output.
55
"""
66

7-
from cli import input_path, chosen_severity, use_json, redact_secrets
7+
from cli import input_path, chosen_severity, use_json, redact_secrets, chosen_confidence
88
from scanner import check_path, scan, list_python_files
99
from output import filter_results, output
1010

@@ -21,7 +21,7 @@
2121
results = scan(files)
2222

2323
# Apply optional severity filtering.
24-
filtered_findings = filter_results(results, chosen_severity)
24+
filtered_findings = filter_results(results, chosen_severity, chosen_confidence)
2525

2626
# Render findings as text or JSON, with optional redaction.
2727
output(filtered_findings, use_json, redact_secrets, files)

output.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def redact_value(value):
1717
return f"{value[:2]}{'*' * (len(value) - 4)}{value[-2:]}"
1818

1919

20-
def filter_results(results, chosen_severity):
20+
def filter_results(results, chosen_severity, chosen_confidence):
2121
"""
2222
Filter findings by severity.
2323
@@ -31,7 +31,7 @@ def filter_results(results, chosen_severity):
3131
filtered_findings = []
3232

3333
for finding in results:
34-
if finding.severity == chosen_severity or chosen_severity is None:
34+
if (finding.severity == chosen_severity or chosen_severity is None) and (finding.confidence == chosen_confidence or chosen_confidence is None):
3535
filtered_findings.append(finding)
3636

3737
return filtered_findings

0 commit comments

Comments
 (0)