Rootsystem2101 Claude Sonnet 4.6 commited on
Commit
a0ae748
Β·
1 Parent(s): 1c239b7

Fix 4 false positive sources + restore AI engine connectivity

Browse files

- HF API URL: api-inference β†’ router.huggingface.co (HTTP 410 fix)
- _UNIT_TEST_FILE_RE: now catches *.test.api.ts multi-extension patterns
- PHP SQL rule: exclude JS template literals ${} (was flagging TS log messages)
- Debug Enabled rule: remove bare 'key' keyword (was matching 'foreign key')

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -83,7 +83,7 @@ RULES = [
83
  "HIGH"),
84
 
85
  ("SQL Injection","CRITICAL",
86
- r'(?i)["\'].*(SELECT|INSERT|UPDATE|DELETE|WHERE|FROM)\s+.*["\']\s*\.\s*\$(?!_SESSION)',
87
  "PHP SQL query with direct variable concat (not session)",
88
  "Replace with PDO prepared statements: $stmt = $pdo->prepare('SELECT * FROM users WHERE id = ?'); $stmt->execute([$id]);",
89
  "HIGH"),
@@ -536,7 +536,7 @@ RULES = [
536
  "HIGH"),
537
 
538
  ("Debug Enabled","MEDIUM",
539
- r'(?i)(console\.log|print|var_dump|debug)\s*\([^)]*\b(password|token|secret|key|api_key)\b',
540
  "Sensitive value logged to console/output",
541
  "Remove sensitive data from logs. Use structured logging with field filtering.",
542
  "HIGH"),
@@ -1600,7 +1600,7 @@ def scan_file_content(content, filename):
1600
  # ══════════════════════════════════════════════════════════
1601
  # ZEROCYBER-SLM AI ENGINE (Mistral-7B Β· HF Inference API)
1602
  # ══════════════════════════════════════════════════════════
1603
- HF_MODEL_URL = "https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.3"
1604
 
1605
  def zerocyber_ai_analyze(findings, repo_name, hf_token):
1606
  """AI-powered deep analysis of top findings using ZeroCyber-SLM AI Engine."""
@@ -1800,7 +1800,12 @@ def parse_repo_url(url):
1800
  return None, None, "Invalid URL. Use: owner/repo or https://github.com/owner/repo"
1801
 
1802
 
1803
- _UNIT_TEST_FILE_RE = re.compile(r'(spec|test)\.[a-z]+$', re.IGNORECASE)
 
 
 
 
 
1804
 
1805
  def _should_skip(path):
1806
  p = path.lower()
 
83
  "HIGH"),
84
 
85
  ("SQL Injection","CRITICAL",
86
+ r'(?i)["\'].*(SELECT|INSERT|UPDATE|DELETE|WHERE|FROM)\s+.*["\']\s*\.\s*\$(?!_SESSION)(?!\{)',
87
  "PHP SQL query with direct variable concat (not session)",
88
  "Replace with PDO prepared statements: $stmt = $pdo->prepare('SELECT * FROM users WHERE id = ?'); $stmt->execute([$id]);",
89
  "HIGH"),
 
536
  "HIGH"),
537
 
538
  ("Debug Enabled","MEDIUM",
539
+ r'(?i)(console\.log|print|var_dump|debug)\s*\([^)]*\b(password|token|secret|api_key|apikey|auth_key|private_key|secretkey)\b',
540
  "Sensitive value logged to console/output",
541
  "Remove sensitive data from logs. Use structured logging with field filtering.",
542
  "HIGH"),
 
1600
  # ══════════════════════════════════════════════════════════
1601
  # ZEROCYBER-SLM AI ENGINE (Mistral-7B Β· HF Inference API)
1602
  # ══════════════════════════════════════════════════════════
1603
+ HF_MODEL_URL = "https://router.huggingface.co/hf-inference/models/mistralai/Mistral-7B-Instruct-v0.3"
1604
 
1605
  def zerocyber_ai_analyze(findings, repo_name, hf_token):
1606
  """AI-powered deep analysis of top findings using ZeroCyber-SLM AI Engine."""
 
1800
  return None, None, "Invalid URL. Use: owner/repo or https://github.com/owner/repo"
1801
 
1802
 
1803
+ # Matches: 2faSpec.ts *.spec.ts *.test.js *.test.api.ts (any multi-extension pattern)
1804
+ _UNIT_TEST_FILE_RE = re.compile(
1805
+ r'(spec|test)\.[a-z]' # *Spec.ts *Test.js *spec.ts
1806
+ r'|\.(spec|test)\.', # *.spec.ts *.test.api.ts (embedded between dots)
1807
+ re.IGNORECASE
1808
+ )
1809
 
1810
  def _should_skip(path):
1811
  p = path.lower()