Skip to content

Commit a175a56

Browse files
devatsecureclaude
andcommitted
fix: Address 4 Cursor Bugbot findings from PR #34
- hybrid_analyzer.py: Add enable_nuclei_templates and enable_zap_baseline to "at least one tool enabled" validation check - hybrid_analyzer.py + hybrid/report.py: Add Nuclei/ZAP to enabled tools report so active scanners appear in output - nuclei_template_scanner.py: Replace non-deterministic hash() with hashlib.md5 for stable finding IDs across runs (PYTHONHASHSEED) - zap_baseline_scanner.py: Remove order-dependent _finding_counter from ID generation so same finding gets same ID regardless of discovery order Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7feb19e commit a175a56

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

scripts/hybrid/report.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ def get_enabled_tools(flags: dict[str, Any]) -> list[str]:
6262
ai_client = flags.get("ai_client")
6363
provider = getattr(ai_client, "provider", "AI")
6464
tools.append(f"AI-Enrichment ({provider})")
65+
if flags.get("enable_nuclei_templates"):
66+
tools.append("Nuclei-Templates")
67+
if flags.get("enable_zap_baseline"):
68+
tools.append("ZAP-Baseline")
6569
if flags.get("enable_argus"):
6670
tools.append("Argus")
6771
if flags.get("enable_sandbox"):
@@ -103,11 +107,15 @@ def save_results(result: HybridScanResult, output_dir: str, target_path: str) ->
103107

104108
# Print validation summary
105109
if not validation_report.overall_passed:
106-
logger.warning(f"⚠️ QUALITY CHECK FAILED: {validation_report.failed_findings}/{validation_report.total_findings} findings below quality threshold")
110+
logger.warning(
111+
f"⚠️ QUALITY CHECK FAILED: {validation_report.failed_findings}/{validation_report.total_findings} findings below quality threshold"
112+
)
107113
logger.warning(f"⚠️ See {validation_output} for details")
108114
logger.warning("⚠️ DO NOT submit this report to external repositories without fixing quality issues!")
109115
else:
110-
logger.info(f"✅ Quality validation PASSED: All {validation_report.passed_findings} findings meet quality standards")
116+
logger.info(
117+
f"✅ Quality validation PASSED: All {validation_report.passed_findings} findings meet quality standards"
118+
)
111119
except ImportError:
112120
logger.warning("⚠️ report_quality_validator not available - skipping quality check")
113121
except Exception as e:

scripts/hybrid_analyzer.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,13 +575,16 @@ def __init__(
575575
and not self.enable_runtime_security
576576
and not self.enable_regression_testing
577577
and not self.enable_ai_enrichment
578+
and not self.enable_nuclei_templates
579+
and not self.enable_zap_baseline
578580
):
579581
raise ValueError(
580582
"❌ ERROR: At least one tool must be enabled!\n"
581583
" Enable: --enable-semgrep, --enable-trivy, --enable-checkov, "
582584
"--enable-api-security, --enable-dast, --enable-supply-chain, "
583585
"--enable-fuzzing, --enable-threat-intel, --enable-remediation, "
584-
"--enable-runtime-security, --enable-regression-testing, or --enable-ai-enrichment"
586+
"--enable-runtime-security, --enable-regression-testing, "
587+
"--enable-nuclei-templates, --enable-zap-baseline, or --enable-ai-enrichment"
585588
)
586589

587590
def analyze(
@@ -1089,6 +1092,8 @@ def _get_enabled_tools(self) -> list[str]:
10891092
"enable_runtime_security": self.enable_runtime_security,
10901093
"enable_regression_testing": self.enable_regression_testing,
10911094
"enable_ai_enrichment": self.enable_ai_enrichment,
1095+
"enable_nuclei_templates": self.enable_nuclei_templates,
1096+
"enable_zap_baseline": self.enable_zap_baseline,
10921097
"ai_client": self.ai_client,
10931098
"enable_argus": self.enable_argus,
10941099
"enable_sandbox": self.enable_sandbox,

scripts/nuclei_template_scanner.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,8 @@ def _parse_nuclei_output(self, output_lines: list[str]) -> list[dict]:
566566
raw_cwe = classification.get("cwe-id", None)
567567
cwe_id = (raw_cwe[0] if raw_cwe else None) if isinstance(raw_cwe, list) else raw_cwe
568568

569-
finding_id = _make_finding_id(template_id, matched_at, hash(stripped) & 0xFFFFFFFF)
569+
content_hash = int(hashlib.md5(stripped.encode()).hexdigest()[:8], 16)
570+
finding_id = _make_finding_id(template_id, matched_at, content_hash)
570571

571572
finding: dict = {
572573
"finding_id": f"nuclei-live-{finding_id}",

scripts/zap_baseline_scanner.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,8 @@ def _find_zap_binary(self) -> Optional[str]:
532532
# ------------------------------------------------------------------
533533

534534
def _generate_finding_id(self, prefix: str, file_path: str, line: int) -> str:
535-
"""Generate a deterministic finding ID."""
536-
self._finding_counter += 1
537-
hash_input = f"{prefix}:{file_path}:{line}:{self._finding_counter}"
535+
"""Generate a deterministic finding ID from content, not discovery order."""
536+
hash_input = f"{prefix}:{file_path}:{line}"
538537
short_hash = hashlib.sha256(hash_input.encode()).hexdigest()[:8]
539538
return f"ZAP-{prefix}-{short_hash}"
540539

0 commit comments

Comments
 (0)