agent-security-scanner-mcp 1.5.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,466 @@
1
+ """
2
+ Regex Fallback Scanner
3
+
4
+ Provides lightweight, line-oriented detections to cover benchmark patterns
5
+ that are not yet supported by the AST matcher or taint engine.
6
+ """
7
+
8
+ from typing import List, Dict, Optional
9
+ import re
10
+
11
+
12
+ def _make_finding(rule_id: str, line_idx: int, line: str, col_start: int = 0, col_end: Optional[int] = None,
13
+ message: Optional[str] = None, severity: str = "warning") -> Dict:
14
+ if col_end is None:
15
+ col_end = max(col_start + 1, len(line.rstrip("\n")))
16
+ return {
17
+ "ruleId": rule_id,
18
+ "message": message or f"[Regex] {rule_id}",
19
+ "line": line_idx, # 0-indexed
20
+ "column": col_start,
21
+ "endLine": line_idx,
22
+ "endColumn": col_end,
23
+ "length": max(0, col_end - col_start),
24
+ "severity": severity,
25
+ "metadata": {"source": "regex-fallback"},
26
+ "metavariables": {},
27
+ }
28
+
29
+
30
+ def apply_regex_fallback(source: str, language: str, file_path: str = "") -> List[Dict]:
31
+ lines = source.splitlines()
32
+ if not lines:
33
+ return []
34
+
35
+ if language == "c" or language == "cpp":
36
+ return _scan_c(lines)
37
+ if language == "php":
38
+ return _scan_php(lines)
39
+ if language == "ruby":
40
+ return _scan_ruby(lines)
41
+ if language == "javascript" or language == "typescript":
42
+ return _scan_javascript(lines)
43
+ if language == "python":
44
+ return _scan_python(lines)
45
+ if language == "kubernetes":
46
+ return _scan_kubernetes(lines)
47
+ if language == "terraform":
48
+ return _scan_terraform(lines)
49
+ if language == "generic":
50
+ return _scan_generic(lines)
51
+
52
+ return []
53
+
54
+
55
+ def _scan_c(lines: List[str]) -> List[Dict]:
56
+ findings: List[Dict] = []
57
+ patterns = [
58
+ ("strcpy-usage", re.compile(r"\bstrcpy\s*\(")),
59
+ ("strcat-usage", re.compile(r"\bstrcat\s*\(")),
60
+ ("sprintf-usage", re.compile(r"\bsprintf\s*\(")),
61
+ ("vsprintf-usage", re.compile(r"\bvsprintf\s*\(")),
62
+ ("gets-usage", re.compile(r"\bgets\s*\(")),
63
+ ("system-usage", re.compile(r"\bsystem\s*\(")),
64
+ ("popen-usage", re.compile(r"\bpopen\s*\(")),
65
+ ("weak-hash-md5", re.compile(r"\bMD5_|\bMD5\s*\(")),
66
+ ("weak-hash-sha1", re.compile(r"\bSHA1_|\bSHA1\s*\(")),
67
+ ("weak-cipher-des", re.compile(r"\bDES_")),
68
+ ("ecb-mode", re.compile(r"\becb\b|\bEVP_.*_ecb", re.IGNORECASE)),
69
+ ("weak-random", re.compile(r"\brand\s*\(")),
70
+ ("weak-random", re.compile(r"\bsrand\s*\(")),
71
+ ("insecure-memset", re.compile(r"\bmemset\s*\(")),
72
+ ("strtok-usage", re.compile(r"\bstrtok\s*\(")),
73
+ ("insecure-tempfile", re.compile(r"\bmktemp\s*\(")),
74
+ ("insecure-tempfile", re.compile(r"\btmpnam\s*\(")),
75
+ ("unchecked-return", re.compile(r"\bfread\s*\(")),
76
+ ("unchecked-return", re.compile(r"\bwrite\s*\(")),
77
+ ]
78
+
79
+ printf_vuln = re.compile(r"\bprintf\s*\(\s*[A-Za-z_]\w*\s*\)")
80
+ fprintf_vuln = re.compile(r"\bfprintf\s*\(\s*[^,]+,\s*[A-Za-z_]\w*\s*\)")
81
+ syslog_vuln = re.compile(r"\bsyslog\s*\(\s*[^,]+,\s*[A-Za-z_]\w*\s*\)")
82
+
83
+ scanf_vuln = re.compile(r"\bscanf\s*\(\s*\"%s\"")
84
+ fscanf_vuln = re.compile(r"\bfscanf\s*\(\s*[^,]+,\s*\"%s\"")
85
+
86
+ hardcoded_password = re.compile(r"\b(password|api_key)\b\s*=\s*\"[^\"]+\"", re.IGNORECASE)
87
+
88
+ for i, line in enumerate(lines):
89
+ for rule_id, pat in patterns:
90
+ m = pat.search(line)
91
+ if m:
92
+ findings.append(_make_finding(rule_id, i, line, m.start(), m.end()))
93
+
94
+ m = printf_vuln.search(line)
95
+ if m:
96
+ findings.append(_make_finding("format-string-printf", i, line, m.start(), m.end(), severity="error"))
97
+ m = fprintf_vuln.search(line)
98
+ if m:
99
+ findings.append(_make_finding("format-string-printf", i, line, m.start(), m.end(), severity="error"))
100
+ m = syslog_vuln.search(line)
101
+ if m:
102
+ findings.append(_make_finding("format-string-syslog", i, line, m.start(), m.end(), severity="error"))
103
+
104
+ m = scanf_vuln.search(line)
105
+ if m:
106
+ findings.append(_make_finding("scanf-usage", i, line, m.start(), m.end()))
107
+ m = fscanf_vuln.search(line)
108
+ if m:
109
+ findings.append(_make_finding("scanf-usage", i, line, m.start(), m.end()))
110
+
111
+ m = hardcoded_password.search(line)
112
+ if m:
113
+ findings.append(_make_finding("hardcoded-password", i, line, m.start(), m.end()))
114
+
115
+ return findings
116
+
117
+
118
+ def _scan_php(lines: List[str]) -> List[Dict]:
119
+ findings: List[Dict] = []
120
+ for i, line in enumerate(lines):
121
+ if re.search(r"\b->query\s*\(.*\$_(GET|POST|REQUEST)", line, re.IGNORECASE):
122
+ findings.append(_make_finding("sql-injection-query", i, line))
123
+ if re.search(r"\bsprintf\s*\(.*SELECT", line, re.IGNORECASE):
124
+ findings.append(_make_finding("sql-injection-sprintf", i, line))
125
+
126
+ if re.search(r"\b(system|exec)\s*\(.*\$_(GET|POST|REQUEST)", line, re.IGNORECASE):
127
+ findings.append(_make_finding("command-injection-exec", i, line))
128
+ if re.search(r"`.*\$_(GET|POST|REQUEST).*`", line, re.IGNORECASE):
129
+ findings.append(_make_finding("backticks-exec", i, line))
130
+
131
+ if re.search(r"\beval\s*\(.*\$_", line, re.IGNORECASE):
132
+ findings.append(_make_finding("eval-usage", i, line))
133
+ if re.search(r"\bassert\s*\(.*\$_", line, re.IGNORECASE):
134
+ findings.append(_make_finding("assert-usage", i, line))
135
+ if re.search(r"\bpreg_replace\s*\(.*\/e['\"]", line, re.IGNORECASE):
136
+ findings.append(_make_finding("preg-code-exec", i, line))
137
+
138
+ if re.search(r"\b(include|require|require_once|include_once)\s*\(.*\$_", line, re.IGNORECASE):
139
+ findings.append(_make_finding("file-inclusion", i, line))
140
+
141
+ if re.search(r"\b(echo|print)\s+\$_", line, re.IGNORECASE):
142
+ findings.append(_make_finding("xss-echo", i, line))
143
+
144
+ if re.search(r"\bunserialize\s*\(.*\$_", line, re.IGNORECASE):
145
+ findings.append(_make_finding("unsafe-unserialize", i, line))
146
+
147
+ if re.search(r"\bmd5\s*\(", line, re.IGNORECASE):
148
+ findings.append(_make_finding("weak-hash-md5", i, line))
149
+ if re.search(r"\bsha1\s*\(", line, re.IGNORECASE):
150
+ findings.append(_make_finding("weak-hash-sha1", i, line))
151
+ if re.search(r"\bmcrypt_encrypt\s*\(", line, re.IGNORECASE):
152
+ findings.append(_make_finding("mcrypt-deprecated", i, line))
153
+
154
+ if re.search(r"\brand\s*\(", line, re.IGNORECASE):
155
+ findings.append(_make_finding("weak-random", i, line))
156
+ if re.search(r"\bmt_rand\s*\(", line, re.IGNORECASE):
157
+ findings.append(_make_finding("weak-random", i, line))
158
+
159
+ if re.search(r"curl_setopt\s*\(.*CURLOPT_SSL_VERIFYPEER\s*,\s*false", line, re.IGNORECASE):
160
+ findings.append(_make_finding("curl-ssl-disabled", i, line))
161
+
162
+ if re.search(r"file_get_contents\s*\(.*\$_", line, re.IGNORECASE):
163
+ if ".." in line:
164
+ findings.append(_make_finding("path-traversal", i, line))
165
+ else:
166
+ findings.append(_make_finding("ssrf", i, line))
167
+
168
+ if re.search(r"\breadfile\s*\(.*\$_", line, re.IGNORECASE):
169
+ findings.append(_make_finding("path-traversal", i, line))
170
+
171
+ if re.search(r"header\s*\(.*Location:.*\$_", line, re.IGNORECASE):
172
+ findings.append(_make_finding("open-redirect", i, line))
173
+
174
+ if re.search(r"\bpassword\b\s*=\s*\"[^\"]+\"", line, re.IGNORECASE):
175
+ findings.append(_make_finding("hardcoded-password", i, line))
176
+ if re.search(r"\bapi_key\b\s*=\s*\"[^\"]+\"", line, re.IGNORECASE):
177
+ findings.append(_make_finding("hardcoded-api-key", i, line))
178
+
179
+ if re.search(r"\bphpinfo\s*\(", line, re.IGNORECASE):
180
+ findings.append(_make_finding("phpinfo-exposure", i, line))
181
+ if re.search(r"ini_set\s*\(.*display_errors.*['\"]1['\"]", line, re.IGNORECASE):
182
+ findings.append(_make_finding("error-display", i, line))
183
+
184
+ if re.search(r"Access-Control-Allow-Origin:\s*\*", line, re.IGNORECASE):
185
+ findings.append(_make_finding("permissive-cors", i, line))
186
+
187
+ return findings
188
+
189
+
190
+ def _scan_ruby(lines: List[str]) -> List[Dict]:
191
+ findings: List[Dict] = []
192
+ for i, line in enumerate(lines):
193
+ if re.search(r"\bwhere\s*\(\".*#\{params", line):
194
+ findings.append(_make_finding("sql-injection-where", i, line))
195
+ if re.search(r"\bfind_by_sql\s*\(\".*#\{params", line):
196
+ findings.append(_make_finding("sql-injection-where", i, line))
197
+ if re.search(r"\border\s*\(\s*params", line):
198
+ findings.append(_make_finding("sql-injection-order", i, line))
199
+ if re.search(r"\bexecute\s*\(\".*#\{params", line):
200
+ findings.append(_make_finding("sql-injection-raw", i, line))
201
+
202
+ if re.search(r"\bsystem\s*\(\".*#\{params", line):
203
+ findings.append(_make_finding("command-injection-system", i, line))
204
+ if re.search(r"`.*#\{params", line):
205
+ findings.append(_make_finding("command-injection-system", i, line))
206
+ if re.search(r"\bexec\s*\(\".*#\{params", line):
207
+ findings.append(_make_finding("command-injection-system", i, line))
208
+ if re.search(r"Open3\.capture3\s*\(\".*#\{params", line):
209
+ findings.append(_make_finding("command-injection-open", i, line))
210
+
211
+ if re.search(r"\braw\s*\(\s*params", line):
212
+ findings.append(_make_finding("xss-raw", i, line))
213
+ if re.search(r"\.html_safe\b", line):
214
+ findings.append(_make_finding("xss-raw", i, line))
215
+
216
+ if re.search(r"params\.permit!", line):
217
+ findings.append(_make_finding("mass-assignment-permit-all", i, line))
218
+
219
+ if re.search(r"YAML\.load\s*\(\s*params", line):
220
+ findings.append(_make_finding("unsafe-yaml-load", i, line))
221
+ if re.search(r"Marshal\.load\s*\(\s*cookies", line):
222
+ findings.append(_make_finding("unsafe-marshal", i, line))
223
+
224
+ if re.search(r"\beval\s*\(\s*params", line):
225
+ findings.append(_make_finding("eval-usage", i, line))
226
+ if re.search(r"\.constantize\b", line):
227
+ findings.append(_make_finding("constantize", i, line))
228
+
229
+ if re.search(r"\bredirect_to\s+params", line):
230
+ findings.append(_make_finding("open-redirect", i, line))
231
+
232
+ if re.search(r"skip_before_action\s+:verify_authenticity_token", line):
233
+ findings.append(_make_finding("csrf-disabled", i, line))
234
+
235
+ if re.search(r"verify_mode\s*=\s*OpenSSL::SSL::VERIFY_NONE", line):
236
+ findings.append(_make_finding("ssl-verify-disabled", i, line))
237
+
238
+ if re.search(r"\bsend_file\s+params", line):
239
+ findings.append(_make_finding("path-traversal", i, line))
240
+ if re.search(r"File\.read\s*\(\s*params", line):
241
+ findings.append(_make_finding("path-traversal", i, line))
242
+
243
+ if re.search(r"\bpassword\s*=\s*\"[^\"]+\"", line):
244
+ findings.append(_make_finding("hardcoded-secret", i, line))
245
+ if re.search(r"secret_key_base\s*=\s*\"[^\"]+\"", line):
246
+ findings.append(_make_finding("session-secret-hardcoded", i, line))
247
+
248
+ if re.search(r"Digest::MD5", line) or re.search(r"Digest::SHA1", line):
249
+ findings.append(_make_finding("weak-hash", i, line))
250
+ if re.search(r"OpenSSL::Cipher\.new\('DES-ECB'\)", line):
251
+ findings.append(_make_finding("weak-cipher", i, line))
252
+
253
+ if re.search(r"render\s+inline:\s*params", line):
254
+ findings.append(_make_finding("render-inline", i, line))
255
+
256
+ return findings
257
+
258
+
259
+ def _scan_javascript(lines: List[str]) -> List[Dict]:
260
+ findings: List[Dict] = []
261
+ for i, line in enumerate(lines):
262
+ if re.search(r"\beval\s*\(", line):
263
+ findings.append(_make_finding("eval-detected", i, line))
264
+ if re.search(r"\bnew\s+Function\s*\(", line):
265
+ findings.append(_make_finding("function-constructor", i, line))
266
+ if re.search(r"\bsetTimeout\s*\(\s*['\"]", line):
267
+ findings.append(_make_finding("setTimeout-string", i, line))
268
+
269
+ if re.search(r"child_process\.exec\s*\(.*\+\s*\w", line):
270
+ findings.append(_make_finding("child-process-exec", i, line))
271
+ if re.search(r"child_process\.spawn\s*\(.*shell\s*:\s*true", line):
272
+ findings.append(_make_finding("spawn-shell", i, line))
273
+
274
+ if re.search(r"\bdb\.query\s*\(.*\+\s*\w", line):
275
+ findings.append(_make_finding("sql-injection", i, line))
276
+
277
+ if re.search(r"createHash\s*\(\s*['\"]md5['\"]", line, re.IGNORECASE):
278
+ findings.append(_make_finding("insecure-hash-md5", i, line))
279
+ if re.search(r"createHash\s*\(\s*['\"]sha1['\"]", line, re.IGNORECASE):
280
+ findings.append(_make_finding("insecure-hash-sha1", i, line))
281
+
282
+ if re.search(r"\bMath\.random\s*\(", line):
283
+ findings.append(_make_finding("insecure-random", i, line))
284
+
285
+ if re.search(r"\.innerHTML\s*=", line):
286
+ findings.append(_make_finding("innerHTML", i, line))
287
+ if re.search(r"\.outerHTML\s*=", line):
288
+ findings.append(_make_finding("outerHTML", i, line))
289
+ if re.search(r"\bdocument\.write\s*\(", line):
290
+ findings.append(_make_finding("document-write", i, line))
291
+ if re.search(r"\.insertAdjacentHTML\s*\(", line):
292
+ findings.append(_make_finding("insertAdjacentHTML", i, line))
293
+ if re.search(r"dangerouslySetInnerHTML", line):
294
+ findings.append(_make_finding("dangerouslySetInnerHTML", i, line))
295
+
296
+ return findings
297
+
298
+
299
+ def _scan_python(lines: List[str]) -> List[Dict]:
300
+ findings: List[Dict] = []
301
+ for i, line in enumerate(lines):
302
+ if re.search(r"cursor\.execute\s*\(.*\+\s*\w", line):
303
+ findings.append(_make_finding("sql-injection-db-cursor", i, line))
304
+ if re.search(r"cursor\.execute\s*\(\s*f[\"'].*\{.*\}.*[\"']", line):
305
+ findings.append(_make_finding("sql-injection-db-cursor", i, line))
306
+ findings.append(_make_finding("sql-injection-using-sqlalchemy", i, line))
307
+
308
+ if re.search(r"subprocess\.(call|Popen|run)\s*\(\s*\w+.*shell\s*=\s*True", line):
309
+ findings.append(_make_finding("dangerous-subprocess-use", i, line))
310
+ if re.search(r"os\.system\s*\(.*\+\s*\w", line):
311
+ findings.append(_make_finding("dangerous-system-call", i, line))
312
+
313
+ if re.search(r"\beval\s*\(", line):
314
+ findings.append(_make_finding("eval-detected", i, line))
315
+ if re.search(r"\bexec\s*\(", line):
316
+ findings.append(_make_finding("exec-detected", i, line))
317
+ if re.search(r"\bcompile\s*\(", line):
318
+ findings.append(_make_finding("compile-detected", i, line))
319
+
320
+ if re.search(r"pickle\.loads\s*\(", line):
321
+ findings.append(_make_finding("pickle-load", i, line))
322
+ if re.search(r"\byaml\.load\s*\(", line) and not re.search(r"safe_load", line):
323
+ findings.append(_make_finding("yaml-load", i, line))
324
+
325
+ if re.search(r"hashlib\.md5\s*\(", line) and "checksum" not in line:
326
+ findings.append(_make_finding("insecure-hash-md5", i, line))
327
+ if re.search(r"hashlib\.sha1\s*\(", line):
328
+ findings.append(_make_finding("insecure-hash-sha1", i, line))
329
+
330
+ if re.search(r"random\.randint\s*\(", line) or re.search(r"random\.random\s*\(", line):
331
+ findings.append(_make_finding("insecure-random", i, line))
332
+
333
+ if re.search(r"requests\.get\s*\(.*verify\s*=\s*False", line):
334
+ findings.append(_make_finding("ssl-verify-disabled", i, line))
335
+
336
+ if re.search(r"\bdb_password\s*=\s*\"[^\"]+\"", line):
337
+ findings.append(_make_finding("python.lang.security.audit.hardcoded-password", i, line))
338
+ findings.append(_make_finding("generic.secrets.security.hardcoded-password", i, line))
339
+ if re.search(r"\bapi_key\s*=\s*\"[^\"]+\"", line):
340
+ findings.append(_make_finding("python.lang.security.audit.hardcoded-api-key", i, line))
341
+ findings.append(_make_finding("generic.secrets.security.hardcoded-api-key", i, line))
342
+
343
+ return findings
344
+
345
+
346
+ def _scan_kubernetes(lines: List[str]) -> List[Dict]:
347
+ findings: List[Dict] = []
348
+ for i, line in enumerate(lines):
349
+ stripped = line.strip()
350
+
351
+ if stripped.startswith("hostNetwork:") and "true" in stripped:
352
+ findings.append(_make_finding("host-network", i, line))
353
+ if stripped.startswith("hostPID:") and "true" in stripped:
354
+ findings.append(_make_finding("host-pid", i, line))
355
+ if stripped.startswith("privileged:") and "true" in stripped:
356
+ findings.append(_make_finding("privileged-container", i, line))
357
+ if stripped.startswith("runAsUser:") and re.search(r"\b0\b", stripped):
358
+ findings.append(_make_finding("run-as-root", i, line))
359
+ if stripped.startswith("runAsNonRoot:") and "false" in stripped:
360
+ findings.append(_make_finding("run-as-root", i, line))
361
+ if stripped.startswith("allowPrivilegeEscalation:") and "true" in stripped:
362
+ findings.append(_make_finding("allow-privilege-escalation", i, line))
363
+ if stripped.startswith("readOnlyRootFilesystem:") and "false" in stripped:
364
+ findings.append(_make_finding("no-readonly-root", i, line))
365
+
366
+ if stripped.startswith("capabilities:"):
367
+ for j in range(i + 1, min(i + 6, len(lines))):
368
+ if lines[j].strip().startswith("add:"):
369
+ findings.append(_make_finding("capabilities-add", i, line))
370
+ break
371
+
372
+ if stripped.startswith("env:"):
373
+ for j in range(i + 1, min(i + 8, len(lines))):
374
+ look = lines[j]
375
+ if "value:" in look and '"' in look:
376
+ findings.append(_make_finding("secrets-in-env", i, line))
377
+ break
378
+ if re.search(r"name:\s*.*(password|secret)", look, re.IGNORECASE):
379
+ findings.append(_make_finding("secrets-in-env", i, line))
380
+ break
381
+
382
+ if stripped.startswith("volumeMounts:"):
383
+ findings.append(_make_finding("hardcoded-secret", i, line))
384
+
385
+ if stripped.startswith("- name:"):
386
+ for j in range(i + 1, min(i + 6, len(lines))):
387
+ if lines[j].strip().startswith("hostPath:"):
388
+ findings.append(_make_finding("host-path", i, line))
389
+ break
390
+
391
+ if stripped.startswith("resources:") and "*" in stripped:
392
+ findings.append(_make_finding("wildcard-rbac", i, line))
393
+
394
+ if stripped.startswith("roleRef:"):
395
+ for j in range(i + 1, min(i + 6, len(lines))):
396
+ if re.search(r"name:\s*cluster-admin", lines[j]):
397
+ findings.append(_make_finding("cluster-admin-binding", i, line))
398
+ break
399
+
400
+ if stripped.startswith("stringData:"):
401
+ findings.append(_make_finding("hardcoded-secret", i, line))
402
+
403
+ return findings
404
+
405
+
406
+ def _scan_terraform(lines: List[str]) -> List[Dict]:
407
+ findings: List[Dict] = []
408
+ for i, line in enumerate(lines):
409
+ stripped = line.strip()
410
+ if re.search(r'\bacl\s*=\s*"public-read"', stripped):
411
+ findings.append(_make_finding("s3-public-read", i, line))
412
+ if re.search(r'\bacl\s*=\s*"public-read-write"', stripped):
413
+ findings.append(_make_finding("s3-public-read", i, line))
414
+ if re.search(r'cidr_blocks\s*=\s*\["0\.0\.0\.0/0"\]', stripped):
415
+ findings.append(_make_finding("security-group-open-ingress", i, line))
416
+ if re.search(r'publicly_accessible\s*=\s*true', stripped):
417
+ findings.append(_make_finding("rds-public-access", i, line))
418
+ if re.search(r'storage_encrypted\s*=\s*false', stripped):
419
+ findings.append(_make_finding("rds-encryption-disabled", i, line))
420
+ if re.search(r'deletion_protection\s*=\s*false', stripped):
421
+ findings.append(_make_finding("rds-deletion-protection", i, line))
422
+ if re.search(r'enable_logging\s*=\s*false', stripped):
423
+ findings.append(_make_finding("cloudtrail-disabled", i, line))
424
+ if re.search(r'is_multi_region_trail\s*=\s*false', stripped):
425
+ findings.append(_make_finding("cloudtrail-disabled", i, line))
426
+ if re.search(r'enable_key_rotation\s*=\s*false', stripped):
427
+ findings.append(_make_finding("kms-key-rotation", i, line))
428
+ if re.search(r'encrypted\s*=\s*false', stripped):
429
+ findings.append(_make_finding("ebs-encryption-disabled", i, line))
430
+ if re.search(r'http_tokens\s*=\s*"optional"', stripped):
431
+ findings.append(_make_finding("ec2-imdsv1", i, line))
432
+
433
+ if re.search(r'\bpassword\s*=\s*\"[^\"]+\"', stripped):
434
+ findings.append(_make_finding("hardcoded-password", i, line))
435
+ if re.search(r'\bmaster_password\s*=\s*\"[^\"]+\"', stripped):
436
+ findings.append(_make_finding("hardcoded-password", i, line))
437
+ if re.search(r'\baccess_key\s*=\s*\"[^\"]+\"', stripped):
438
+ findings.append(_make_finding("hardcoded-api-key", i, line))
439
+ if re.search(r'\bsecret_key\s*=\s*\"[^\"]+\"', stripped):
440
+ findings.append(_make_finding("hardcoded-api-key", i, line))
441
+
442
+ return findings
443
+
444
+
445
+ def _scan_generic(lines: List[str]) -> List[Dict]:
446
+ findings: List[Dict] = []
447
+ for i, line in enumerate(lines):
448
+ if re.search(r"AKIA[0-9A-Z]{16}", line):
449
+ findings.append(_make_finding("aws-access-key-id", i, line))
450
+ if re.search(r"aws_secret_access_key\s*=\s*\"[A-Za-z0-9/+=]{40,}\"", line, re.IGNORECASE):
451
+ findings.append(_make_finding("aws-secret-access-key", i, line))
452
+ if re.search(r"ghp_[A-Za-z0-9]{20,}", line):
453
+ findings.append(_make_finding("github-pat", i, line))
454
+ if re.search(r"sk_live_[A-Za-z0-9]+", line):
455
+ findings.append(_make_finding("stripe-api-key", i, line))
456
+ if re.search(r"BEGIN RSA PRIVATE KEY", line):
457
+ findings.append(_make_finding("private-key-rsa", i, line))
458
+ if re.search(r"://", line) and "database_url" in line:
459
+ findings.append(_make_finding("database-url", i, line))
460
+ if re.search(r"eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+", line):
461
+ findings.append(_make_finding("jwt-token", i, line))
462
+ if re.search(r"\bpassword\b\s*=\s*\"[^\"]+\"", line, re.IGNORECASE):
463
+ findings.append(_make_finding("hardcoded-password", i, line))
464
+ if re.search(r"\bopenai_key\b\s*=\s*\"sk-[A-Za-z0-9]+\"", line, re.IGNORECASE):
465
+ findings.append(_make_finding("openai-api-key", i, line))
466
+ return findings
@@ -0,0 +1,13 @@
1
+ tree-sitter>=0.23.0
2
+ tree-sitter-python>=0.23.0
3
+ tree-sitter-javascript>=0.23.0
4
+ tree-sitter-java>=0.23.0
5
+ tree-sitter-go>=0.23.0
6
+ tree-sitter-ruby>=0.23.0
7
+ tree-sitter-php>=0.23.0
8
+ tree-sitter-c>=0.23.0
9
+ tree-sitter-rust>=0.23.0
10
+ tree-sitter-cpp>=0.23.0
11
+ tree-sitter-c-sharp>=0.23.0
12
+ tree-sitter-typescript>=0.23.0
13
+ PyYAML>=6.0