@code-sentinel-cli/code-sentinel-cli 4.0.5 → 4.0.7

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.
Files changed (27) hide show
  1. package/dist/bin.js +16865 -10515
  2. package/dist/builtin-rules/static/general/dockerfile-dependency-confusion.rule.js +27 -2
  3. package/dist/builtin-rules/static/general/java-weak-randomness.rule.js +41 -0
  4. package/dist/builtin-rules/static/general/kubernetes-pod-security.rule.js +90 -0
  5. package/dist/builtin-rules/static/general/no-dynamic-code-eval.rule.js +84 -0
  6. package/dist/builtin-rules/static/general/no-hardcoded-secret.rule.js +179 -13
  7. package/dist/builtin-rules/static/general/no-reflective-access-override.rule.js +6 -23
  8. package/dist/builtin-rules/static/general/no-unsafe-html-sink.rule.js +50 -7
  9. package/dist/builtin-rules/static/general/openapi-https-credentials.rule.js +90 -0
  10. package/dist/builtin-rules/static/general/sensitive-exception-response.rule.js +44 -0
  11. package/dist/builtin-rules/static/general/sensitive-output-exposure.rule.js +1 -1
  12. package/dist/builtin-rules/static/spring-boot/explicit-csp-required.rule.js +37 -0
  13. package/dist/builtin-rules/static/spring-boot/no-command-injection.rule.js +7 -1
  14. package/dist/builtin-rules/static/spring-boot/no-devtools-in-production.rule.js +13 -16
  15. package/dist/builtin-rules/static/spring-boot/no-global-permit-all.rule.js +50 -0
  16. package/dist/builtin-rules/static/spring-boot/no-negative-sensitive-input.rule.js +91 -0
  17. package/dist/builtin-rules/static/spring-boot/no-path-traversal.rule.js +7 -1
  18. package/dist/builtin-rules/static/spring-boot/no-servlet-xss.rule.js +7 -1
  19. package/dist/builtin-rules/static/spring-boot/no-spel-injection.rule.js +7 -1
  20. package/dist/builtin-rules/static/spring-boot/no-sql-string-concat.rule.js +7 -1
  21. package/dist/builtin-rules/static/spring-boot/no-ssrf.rule.js +23 -3
  22. package/dist/builtin-rules/static/spring-boot/password-reset-without-proof.rule.js +84 -0
  23. package/dist/builtin-rules/static/spring-boot/stored-content-without-sanitization.rule.js +93 -0
  24. package/dist/index.d.ts +155 -18
  25. package/dist/index.js +16866 -10516
  26. package/node_modules/@code-sentinel/parsers/index.js +330 -198
  27. package/package.json +1 -1
@@ -9,57 +9,178 @@ var isExcludedHost = (hostWithPort) => {
9
9
  );
10
10
  };
11
11
 
12
- // src/security/devtools-scan.ts
13
- var BUILD_FILE_RE = /(?:^|[/\\])(?:pom\.xml|build\.gradle|build\.gradle\.kts)$/i;
14
- var auditPomXmlDevTools = (content, filePath) => {
15
- if (!content.includes("spring-boot-devtools")) {
16
- return null;
17
- }
18
- const depBlockRegex = /<dependency\b[\s\S]*?<\/dependency>/gi;
19
- let match = depBlockRegex.exec(content);
20
- while (match !== null) {
21
- const block = match[0];
22
- if (block.includes("spring-boot-devtools")) {
23
- const hasOptional = /<optional\s*>\s*true\s*<\/optional>/i.test(block);
24
- const isTestScope = /<scope\s*>\s*test\s*<\/scope>/i.test(block);
25
- const before = content.slice(0, match.index);
26
- const line = before.split("\n").length;
27
- if (!hasOptional && !isTestScope) {
28
- return {
29
- file: filePath,
30
- line,
31
- isVulnerable: true,
32
- reason: "Dependency 'spring-boot-devtools' khai b\xE1o thi\u1EBFu '<optional>true</optional>' trong pom.xml \u2014 nguy c\u01A1 b\u1ECB \u0111\xF3ng g\xF3i v\xE0o b\u1EA3n production (CWE-489)."
33
- };
12
+ // src/security/js-comment-mask.ts
13
+ var REGEX_PRECEDING_KEYWORDS = /* @__PURE__ */ new Set([
14
+ "return",
15
+ "typeof",
16
+ "instanceof",
17
+ "in",
18
+ "of",
19
+ "new",
20
+ "delete",
21
+ "void",
22
+ "throw",
23
+ "case",
24
+ "do",
25
+ "else",
26
+ "yield",
27
+ "await"
28
+ ]);
29
+ var isIdentChar = (c) => /[A-Za-z0-9_$]/.test(c);
30
+ var regexAllowedAt = (content, index) => {
31
+ let i = index - 1;
32
+ while (i >= 0 && /\s/.test(content[i] ?? "")) i -= 1;
33
+ if (i < 0) return true;
34
+ const prev = content[i] ?? "";
35
+ if (prev === ")" || prev === "]") return false;
36
+ if (!isIdentChar(prev)) return true;
37
+ let start = i;
38
+ while (start >= 0 && isIdentChar(content[start] ?? "")) start -= 1;
39
+ const word = content.slice(start + 1, i + 1);
40
+ if (/^[0-9]/.test(word)) return false;
41
+ return REGEX_PRECEDING_KEYWORDS.has(word);
42
+ };
43
+ var maskJsComments = (content) => {
44
+ if (!content.includes("//") && !content.includes("/*")) return content;
45
+ const out = content.split("");
46
+ const n = content.length;
47
+ const templateStack = [];
48
+ let braceDepth = 0;
49
+ let inCharClass = false;
50
+ let state = "code";
51
+ let i = 0;
52
+ const blank = (at) => {
53
+ if (content[at] !== "\n") out[at] = " ";
54
+ };
55
+ while (i < n) {
56
+ const c = content[i] ?? "";
57
+ const next = content[i + 1] ?? "";
58
+ if (state === "code") {
59
+ if (c === "/" && next === "/") {
60
+ blank(i);
61
+ blank(i + 1);
62
+ state = "line";
63
+ i += 2;
64
+ } else if (c === "/" && next === "*") {
65
+ blank(i);
66
+ blank(i + 1);
67
+ state = "block";
68
+ i += 2;
69
+ } else if (c === "/" && regexAllowedAt(content, i)) {
70
+ state = "regex";
71
+ inCharClass = false;
72
+ i += 1;
73
+ } else if (c === "'") {
74
+ state = "single";
75
+ i += 1;
76
+ } else if (c === '"') {
77
+ state = "double";
78
+ i += 1;
79
+ } else if (c === "`") {
80
+ state = "template";
81
+ i += 1;
82
+ } else if (c === "{") {
83
+ braceDepth += 1;
84
+ i += 1;
85
+ } else if (c === "}") {
86
+ braceDepth -= 1;
87
+ const top = templateStack[templateStack.length - 1];
88
+ if (top !== void 0 && braceDepth === top) {
89
+ templateStack.pop();
90
+ state = "template";
91
+ }
92
+ i += 1;
93
+ } else {
94
+ i += 1;
95
+ }
96
+ continue;
97
+ }
98
+ if (state === "line") {
99
+ if (c === "\n") state = "code";
100
+ else blank(i);
101
+ i += 1;
102
+ continue;
103
+ }
104
+ if (state === "block") {
105
+ if (c === "*" && next === "/") {
106
+ blank(i);
107
+ blank(i + 1);
108
+ state = "code";
109
+ i += 2;
110
+ } else {
111
+ blank(i);
112
+ i += 1;
34
113
  }
114
+ continue;
35
115
  }
36
- match = depBlockRegex.exec(content);
116
+ if (state === "template") {
117
+ if (c === "\\") {
118
+ i += 2;
119
+ continue;
120
+ }
121
+ if (c === "$" && next === "{") {
122
+ templateStack.push(braceDepth);
123
+ braceDepth += 1;
124
+ state = "code";
125
+ i += 2;
126
+ continue;
127
+ }
128
+ if (c === "`") state = "code";
129
+ i += 1;
130
+ continue;
131
+ }
132
+ if (state === "regex") {
133
+ if (c === "\\") {
134
+ i += 2;
135
+ continue;
136
+ }
137
+ if (c === "[") inCharClass = true;
138
+ else if (c === "]") inCharClass = false;
139
+ else if (c === "/" && !inCharClass) state = "code";
140
+ else if (c === "\n") state = "code";
141
+ i += 1;
142
+ continue;
143
+ }
144
+ if (c === "\\") {
145
+ i += 2;
146
+ continue;
147
+ }
148
+ if (c === "\n") {
149
+ state = "code";
150
+ i += 1;
151
+ continue;
152
+ }
153
+ if (state === "single" && c === "'" || state === "double" && c === '"') state = "code";
154
+ i += 1;
37
155
  }
38
- return null;
156
+ return out.join("");
39
157
  };
40
- var auditGradleDevTools = (content, filePath) => {
41
- if (!content.includes("spring-boot-devtools")) {
42
- return null;
43
- }
44
- const cleaned = content.replace(/\/\/[^\n]*/g, (m) => " ".repeat(m.length)).replace(/\/\*[\s\S]*?\*\//g, (m) => " ".repeat(m.length));
45
- const gradleDepRe = /\b(implementation|compileOnly|api|runtimeOnly|compile|developmentOnly)\s*(?:\(?\s*["'][^"']*spring-boot-devtools[^"']*["']\s*\)?)/gi;
46
- let match = gradleDepRe.exec(cleaned);
47
- while (match !== null) {
48
- const config = match[1] ?? "";
49
- if (!/\bdevelopmentOnly\b/i.test(config)) {
50
- const before = content.slice(0, match.index);
51
- const line = before.split("\n").length;
52
- return {
53
- file: filePath,
54
- line,
55
- isVulnerable: true,
56
- reason: "Dependency 'spring-boot-devtools' \u0111\u01B0\u1EE3c khai b\xE1o b\u1EB1ng c\u1EA5u h\xECnh kh\xF4ng an to\xE0n (thay v\xEC 'developmentOnly') trong Gradle \u2014 nguy c\u01A1 b\u1ECB \u0111\xF3ng g\xF3i v\xE0o b\u1EA3n production (CWE-489)."
57
- };
58
- }
59
- match = gradleDepRe.exec(cleaned);
158
+
159
+ // src/security/devtools-scan.ts
160
+ var BUILD_FILE_RE = /(?:^|[/\\])(?:pom\.xml|build\.gradle|build\.gradle\.kts)$/i;
161
+ var findDevToolsDeclarations = (content, filePath) => {
162
+ const lower = filePath.toLowerCase();
163
+ const maven = lower.endsWith("pom.xml");
164
+ if (!maven && !lower.endsWith("build.gradle") && !lower.endsWith("build.gradle.kts")) return [];
165
+ const cleaned = maven ? content.replace(/<!--[\s\S]*?(?:-->|$)/g, (comment) => comment.replace(/[^\r\n]/g, " ")) : maskJsComments(content);
166
+ const declarations = maven ? /<dependency\b[\s\S]*?<\/dependency>/gi : /\b(implementation|compileOnly|api|runtimeOnly|compile|developmentOnly|testImplementation|testRuntimeOnly)\s*(?:\(?\s*["'][^"']*spring-boot-devtools[^"']*["']\s*\)?)/gi;
167
+ const findings = [];
168
+ for (const match of cleaned.matchAll(declarations)) {
169
+ const artifact = maven ? /<artifactId>\s*spring-boot-devtools\s*<\/artifactId>/i.exec(match[0]) : null;
170
+ if (maven && !artifact) continue;
171
+ const isVulnerable = maven ? !/<optional\s*>\s*true\s*<\/optional>/i.test(match[0]) && !/<scope\s*>\s*test\s*<\/scope>/i.test(match[0]) : !/^(?:developmentOnly|testImplementation|testRuntimeOnly)$/i.test(match[1] ?? "");
172
+ const offset = match.index + (artifact?.index ?? 0);
173
+ findings.push({
174
+ file: filePath,
175
+ line: cleaned.slice(0, offset).split("\n").length,
176
+ isVulnerable,
177
+ reason: isVulnerable ? "Dependency spring-boot-devtools kh\xF4ng \u0111\u01B0\u1EE3c gi\u1EDBi h\u1EA1n b\u1EB1ng optional/test/developmentOnly; review b\u1EA3n build production v\xE0 c\u1EA5u h\xECnh runtime (CWE-489). Ch\u01B0a ch\u1EE9ng minh DevTools \u0111ang ho\u1EA1t \u0111\u1ED9ng." : "C\xF3 khai b\xE1o spring-boot-devtools, k\u1EC3 c\u1EA3 optional/test/developmentOnly; review profile build, JAR/WAR v\xE0 runtime. Ch\u01B0a ch\u1EE9ng minh DevTools b\u1EADt tr\xEAn production. [control=devtools-dependency-review]"
178
+ });
60
179
  }
61
- return null;
180
+ return findings;
62
181
  };
182
+ var auditPomXmlDevTools = (content, filePath) => findDevToolsDeclarations(content, filePath).find((finding) => finding.isVulnerable) ?? null;
183
+ var auditGradleDevTools = (content, filePath) => findDevToolsDeclarations(content, filePath).find((finding) => finding.isVulnerable) ?? null;
63
184
  var auditBuildFile = (content, filePath) => {
64
185
  const lowerPath = filePath.toLowerCase();
65
186
  if (lowerPath.endsWith("pom.xml")) {
@@ -283,151 +404,24 @@ var auditPasswordAutocompleteContent = (content, filePath) => {
283
404
  return findings;
284
405
  };
285
406
 
286
- // src/security/js-comment-mask.ts
287
- var REGEX_PRECEDING_KEYWORDS = /* @__PURE__ */ new Set([
288
- "return",
289
- "typeof",
290
- "instanceof",
291
- "in",
292
- "of",
293
- "new",
294
- "delete",
295
- "void",
296
- "throw",
297
- "case",
298
- "do",
299
- "else",
300
- "yield",
301
- "await"
302
- ]);
303
- var isIdentChar = (c) => /[A-Za-z0-9_$]/.test(c);
304
- var regexAllowedAt = (content, index) => {
305
- let i = index - 1;
306
- while (i >= 0 && /\s/.test(content[i] ?? "")) i -= 1;
307
- if (i < 0) return true;
308
- const prev = content[i] ?? "";
309
- if (prev === ")" || prev === "]") return false;
310
- if (!isIdentChar(prev)) return true;
311
- let start = i;
312
- while (start >= 0 && isIdentChar(content[start] ?? "")) start -= 1;
313
- const word = content.slice(start + 1, i + 1);
314
- if (/^[0-9]/.test(word)) return false;
315
- return REGEX_PRECEDING_KEYWORDS.has(word);
316
- };
317
- var maskJsComments = (content) => {
318
- if (!content.includes("//") && !content.includes("/*")) return content;
319
- const out = content.split("");
320
- const n = content.length;
321
- const templateStack = [];
322
- let braceDepth = 0;
323
- let inCharClass = false;
324
- let state = "code";
325
- let i = 0;
326
- const blank = (at) => {
327
- if (content[at] !== "\n") out[at] = " ";
328
- };
329
- while (i < n) {
330
- const c = content[i] ?? "";
331
- const next = content[i + 1] ?? "";
332
- if (state === "code") {
333
- if (c === "/" && next === "/") {
334
- blank(i);
335
- blank(i + 1);
336
- state = "line";
337
- i += 2;
338
- } else if (c === "/" && next === "*") {
339
- blank(i);
340
- blank(i + 1);
341
- state = "block";
342
- i += 2;
343
- } else if (c === "/" && regexAllowedAt(content, i)) {
344
- state = "regex";
345
- inCharClass = false;
346
- i += 1;
347
- } else if (c === "'") {
348
- state = "single";
349
- i += 1;
350
- } else if (c === '"') {
351
- state = "double";
352
- i += 1;
353
- } else if (c === "`") {
354
- state = "template";
355
- i += 1;
356
- } else if (c === "{") {
357
- braceDepth += 1;
358
- i += 1;
359
- } else if (c === "}") {
360
- braceDepth -= 1;
361
- const top = templateStack[templateStack.length - 1];
362
- if (top !== void 0 && braceDepth === top) {
363
- templateStack.pop();
364
- state = "template";
365
- }
366
- i += 1;
367
- } else {
368
- i += 1;
369
- }
370
- continue;
371
- }
372
- if (state === "line") {
373
- if (c === "\n") state = "code";
374
- else blank(i);
375
- i += 1;
376
- continue;
377
- }
378
- if (state === "block") {
379
- if (c === "*" && next === "/") {
380
- blank(i);
381
- blank(i + 1);
382
- state = "code";
383
- i += 2;
384
- } else {
385
- blank(i);
386
- i += 1;
387
- }
388
- continue;
389
- }
390
- if (state === "template") {
391
- if (c === "\\") {
392
- i += 2;
393
- continue;
394
- }
395
- if (c === "$" && next === "{") {
396
- templateStack.push(braceDepth);
397
- braceDepth += 1;
398
- state = "code";
399
- i += 2;
400
- continue;
401
- }
402
- if (c === "`") state = "code";
403
- i += 1;
404
- continue;
405
- }
406
- if (state === "regex") {
407
- if (c === "\\") {
408
- i += 2;
409
- continue;
410
- }
411
- if (c === "[") inCharClass = true;
412
- else if (c === "]") inCharClass = false;
413
- else if (c === "/" && !inCharClass) state = "code";
414
- else if (c === "\n") state = "code";
415
- i += 1;
416
- continue;
417
- }
418
- if (c === "\\") {
419
- i += 2;
420
- continue;
421
- }
422
- if (c === "\n") {
423
- state = "code";
424
- i += 1;
425
- continue;
426
- }
427
- if (state === "single" && c === "'" || state === "double" && c === '"') state = "code";
428
- i += 1;
407
+ // src/security/third-party-asset.ts
408
+ var FRONTEND_EXT_RE = /\.(?:js|mjs|cjs|jsx|ts|tsx|vue|html?|css)$/i;
409
+ var VENDOR_DIR_RE = /(?:^|[/\\])(?:node_modules|bower_components|vendors?|libs?|deps|third[-_]?party|\.angular)(?:[/\\])/i;
410
+ var GENERATED_NAME_RE = /(?:\.min\.(?:js|css)|\.bundle\.js|(?:^|[/\\])chunk-[\w-]+\.js)$/i;
411
+ var JQUERY_PLUGIN_RE = /(?:^|[/\\])jquery[._-][^/\\]*\.js$/i;
412
+ var KNOWN_LIBRARY_RE = /(?:^|[/\\])(?:chart|mermaid|summernote|ckeditor|tinymce|moment|lodash|underscore|select2|datatables|fullcalendar|sweetalert2?|highcharts|echarts|d3|pdf|pdfmake|jspdf|html2canvas|bootstrap(?:[.-][\w-]+)?|popper|axios|vue|react|angular|alpaca|handlebars|mustache|dropzone|quill|codemirror|ace|froala|toastr|leaflet|openlayers)(?:[.-](?:\d[\w]*|min|bundle|esm|umd|common|full|all|standalone|slim))*\.js$/i;
413
+ var BANNER_RE = /^\s*(?:\/\*![\s\S]{0,560}?(?:\bv?\d+\.\d+|@license|license)|[\s\S]{0,600}?@license\b)/i;
414
+ var MINIFIED_AVG_LINE = 500;
415
+ var isThirdPartyAsset = (path, content) => {
416
+ if (!FRONTEND_EXT_RE.test(path)) return false;
417
+ const normalized = path.replace(/\\/g, "/");
418
+ if (VENDOR_DIR_RE.test(normalized) || GENERATED_NAME_RE.test(normalized) || JQUERY_PLUGIN_RE.test(normalized) || KNOWN_LIBRARY_RE.test(normalized)) {
419
+ return true;
429
420
  }
430
- return out.join("");
421
+ if (content === void 0 || content.length === 0) return false;
422
+ if (BANNER_RE.test(content.slice(0, 600))) return true;
423
+ const newlines = content.split("\n").length;
424
+ return content.length / newlines > MINIFIED_AVG_LINE;
431
425
  };
432
426
 
433
427
  // src/security/sensitive-logging-scan.ts
@@ -442,21 +436,95 @@ var lineOf = (content, index) => {
442
436
  var JAVA_LOG_CALL_RE = /\b(?:log|logger)\s*\.\s*(?:trace|debug|info|warn|error)\s*\(([^;]{0,500}?)\)\s*;/gi;
443
437
  var JAVA_CONSOLE_CALL_RE = /\bSystem\s*\.\s*(?:out|err)\s*\.\s*(?:print|println|printf)\s*\(([^;]{0,500}?)\)\s*;?/g;
444
438
  var JS_CONSOLE_CALL_RE = /\bconsole\s*\.\s*(?:log|info|debug|warn|error)\s*\(([^;]{0,500}?)\)\s*;?/gi;
445
- var stripStringLiterals = (s) => s.replace(/"(?:[^"\\]|\\.)*"/g, "");
446
- var SECRET_RE = /\b\w*(?:password|passwd|pwd|secret|apikey|api_key|credential|privatekey|jwt|otp|pin|token|authorization|accesskey)\w*\b/gi;
439
+ var stripStringLiterals = (s) => s.replace(/"(?:[^"\\]|\\.)*"/g, "").replace(/'(?:[^'\\]|\\.)*'/g, "").replace(
440
+ /`(?:[^`\\]|\\.)*`/g,
441
+ (tpl) => [...tpl.matchAll(/\$\{([^}]*)\}/g)].map((m) => ` ${m[1] ?? ""} `).join(" ")
442
+ );
447
443
  var PII_RE = /\b(?:cvv|cvc|cvv2|ssn|socialsecurity|cccd|socccd|cmnd|socmnd|cmt|creditcard|cardnumber|cardno|sothe|sotaikhoan|stk|taikhoannganhang|passport|passportno|nationalid|sohochieu|geolocation|latitude|longitude|coordinates)\b/gi;
448
- var PROTECTED_TAIL_RE = /(?:hash|hashed|encoded|encrypted|digest|salt|policy|type|name|length|format|masked|redacted|id)$/i;
449
- var findSensitiveToken = (code) => {
450
- for (const m of code.matchAll(SECRET_RE)) {
444
+ var findSensitiveToken = (raw) => {
445
+ const code = stripNonValueExpressions(raw);
446
+ for (const m of code.matchAll(IDENTIFIER_RE)) {
451
447
  const token = m[0];
452
- if (PROTECTED_TAIL_RE.test(token)) continue;
453
- return { token, confidence: 75 };
448
+ if (isSecretIdentifier(token)) return { token, confidence: 75 };
454
449
  }
455
450
  for (const m of code.matchAll(PII_RE)) {
456
451
  return { token: m[0], confidence: 70 };
457
452
  }
458
453
  return null;
459
454
  };
455
+ var IDENTIFIER_RE = /[A-Za-z_$][\w$]*/g;
456
+ var SECRET_SEGMENTS = /* @__PURE__ */ new Set([
457
+ "password",
458
+ "passwd",
459
+ "pwd",
460
+ "passcode",
461
+ "secret",
462
+ "secrets",
463
+ "credential",
464
+ "credentials",
465
+ "apikey",
466
+ "privatekey",
467
+ "accesskey",
468
+ "jwt",
469
+ "otp",
470
+ "pin",
471
+ "token",
472
+ "tokens",
473
+ "authorization"
474
+ ]);
475
+ var SECRET_SEGMENT_PAIRS = /* @__PURE__ */ new Set(["api key", "private key", "access key"]);
476
+ var SECRET_SUBSTRING_RE = /(?:password|passwd|secret|credential|apikey|privatekey|accesskey)/;
477
+ var PROTECTED_SEGMENTS = /* @__PURE__ */ new Set([
478
+ "hash",
479
+ "hashed",
480
+ "encoded",
481
+ "encrypted",
482
+ "digest",
483
+ "salt",
484
+ "policy",
485
+ "type",
486
+ "name",
487
+ "length",
488
+ "format",
489
+ "masked",
490
+ "redacted",
491
+ "id",
492
+ "count",
493
+ "total",
494
+ "size",
495
+ "ttl",
496
+ "expiry",
497
+ "expiration",
498
+ "expires",
499
+ "expired",
500
+ "timeout",
501
+ "valid",
502
+ "present",
503
+ "url",
504
+ "uri",
505
+ "endpoint",
506
+ "path"
507
+ ]);
508
+ var segmentsOf = (identifier) => identifier.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").split(/[_\s$]+/).filter(Boolean).map((s) => s.toLowerCase());
509
+ var isSecretIdentifier = (identifier) => {
510
+ if (/^[A-Z0-9_]+$/.test(identifier) && /[A-Z]/.test(identifier)) return false;
511
+ const segs = segmentsOf(identifier);
512
+ if (segs[0] === "lock") return false;
513
+ for (let i = 0; i < segs.length; i++) {
514
+ const seg = segs[i] ?? "";
515
+ const pair = i + 1 < segs.length ? `${seg} ${segs[i + 1]}` : "";
516
+ const hit = SECRET_SEGMENTS.has(seg) || SECRET_SEGMENT_PAIRS.has(pair) || SECRET_SUBSTRING_RE.test(seg);
517
+ if (!hit) continue;
518
+ const start = SECRET_SEGMENT_PAIRS.has(pair) ? i + 2 : i + 1;
519
+ if (segs.slice(start).some((s) => PROTECTED_SEGMENTS.has(s))) continue;
520
+ return true;
521
+ }
522
+ return false;
523
+ };
524
+ var stripNonValueExpressions = (code) => code.replace(/[\w$.]+\s*[!=]==?\s*null\b|\bnull\s*[!=]==?\s*[\w$.]+/g, " ").replace(/[\w$]+\s*\.\s*(?:isEmpty|isBlank|length|size|hashCode)\s*\(\s*\)/g, " ").replace(
525
+ /\b(?:[A-Z]\w*\s*\.\s*)?(?:isEmpty|isBlank|isNotEmpty|isNotBlank|isNull|isNotNull|nonNull|hasText|hasLength)\s*\(\s*[\w$.]+\s*\)/g,
526
+ " "
527
+ );
460
528
  var collectSensitiveContainers = (content) => {
461
529
  const containers = /* @__PURE__ */ new Map();
462
530
  const writeRe = /\b([A-Za-z_$][\w$]*)\s*\.\s*(?:put|set[A-Za-z_$][\w$]*)\s*\(([^;\n]{0,500})\)\s*;/g;
@@ -475,7 +543,9 @@ var findSensitiveArgument = (args, containers) => {
475
543
  const direct = findSensitiveToken(code);
476
544
  if (direct) return direct;
477
545
  for (const [container, value] of containers) {
478
- if (new RegExp(`\\b${container}\\b`).test(code)) return value;
546
+ if (new RegExp(`(?<![\\w$.])${container.replace(/\$/g, "\\$")}\\b(?!\\s*\\.)`).test(code)) {
547
+ return value;
548
+ }
479
549
  }
480
550
  return null;
481
551
  };
@@ -483,6 +553,8 @@ var findSensitiveOutput = (files) => {
483
553
  const hits = [];
484
554
  for (const original of files) {
485
555
  if (!["java", "typescript", "javascript"].includes(original.language)) continue;
556
+ if (original.language !== "java" && isThirdPartyAsset(original.path, original.content))
557
+ continue;
486
558
  const f = original.language === "java" ? maskJavaFiles([original])[0] ?? original : original;
487
559
  const containers = collectSensitiveContainers(f.content);
488
560
  const patterns = f.language === "java" ? [
@@ -513,6 +585,35 @@ var findSensitiveOutput = (files) => {
513
585
  }).slice(0, MAX_EVIDENCE);
514
586
  };
515
587
 
588
+ // src/security/reflective-access-scan.ts
589
+ var findReflectiveAccess = (content, file) => {
590
+ const active = maskJavaComments(content).replace(
591
+ /"(?:[^"\\]|\\.)*"/g,
592
+ (literal) => literal.replace(/[^\r\n]/g, " ")
593
+ );
594
+ const patterns = [
595
+ {
596
+ re: /\b[A-Za-z_$][\w$]*(?:\s*\.\s*[A-Za-z_$][\w$]*)*\s*\.\s*setAccessible\s*\(\s*true\s*\)/g,
597
+ api: "setAccessible(true)"
598
+ },
599
+ {
600
+ re: /\b[A-Za-z_$][\w$]*(?:\s*\.\s*[A-Za-z_$][\w$]*)*\s*\.\s*trySetAccessible\s*\(\s*\)/g,
601
+ api: "trySetAccessible()"
602
+ },
603
+ {
604
+ re: /\bAccessibleObject\s*\.\s*setAccessible\s*\(\s*[^,;\n]+\s*,\s*true\s*\)/g,
605
+ api: "AccessibleObject.setAccessible(..., true)"
606
+ }
607
+ ];
608
+ return patterns.flatMap(
609
+ ({ re, api }) => [...active.matchAll(re)].map((match) => ({
610
+ file,
611
+ line: active.slice(0, match.index).split("\n").length,
612
+ api
613
+ }))
614
+ ).sort((a, b) => a.line - b.line);
615
+ };
616
+
516
617
  // src/rules-runtime.ts
517
618
  var asTreeSitterTree = (parsed) => {
518
619
  if (parsed.layer !== "syntactic") {
@@ -528,7 +629,38 @@ var asTsMorphSourceFile = (parsed) => {
528
629
  }
529
630
  return parsed.ast;
530
631
  };
632
+ /**
633
+ * Third-party / generated front-end asset detection (Pentest Coverage Layer, [ADR-0030]).
634
+ *
635
+ * A finding in a vendored library is not a finding about the application: the team did not write
636
+ * the sink, cannot fix it in place, and the right action is "upgrade or replace the library" — a
637
+ * dependency question (#6), not an injection-review question. MEASURED on `mcdt_bqp` (2026-09-17):
638
+ * of 102 `general/no-unsafe-html-sink` findings folded into #99, 86 sat in copies of jExcel, Chart.js,
639
+ * bootstrap-editable, summernote, mermaid, jquery-comments/textcomplete and a minified theme bundle,
640
+ * all committed into application source folders (`src/js`, `src/assets/js`, `public`) where no
641
+ * `node_modules` exclude reaches them. The same shape put a commented-out `console.log('token', …)`
642
+ * inside `Chart.bundle.js` into #83.
643
+ *
644
+ * Signals, each measured against that corpus (the application files it kept — `login/src/main.js`,
645
+ * `onegate_21_fe/src/store/index.js`, `mobilink-*.js` — carry none of them):
646
+ * - a license banner (`/*!`, `@license`, `Copyright`, a `vX.Y` version) in the first 600 characters;
647
+ * - a minified or bundled file (average line length above `MINIFIED_AVG_LINE`);
648
+ * - a jQuery-plugin file name (`jquery.x.js`, `jquery-x.js`, `jquery_x.js`) or a known library name;
649
+ * - a vendor directory (`node_modules`, `bower_components`, `vendor(s)`, `lib(s)`, `deps`,
650
+ * `third_party`) or a `.min.js` / `.bundle.js` / `chunk-*.js` file.
651
+ *
652
+ * Scope: JavaScript/TypeScript/CSS/HTML-ish asset paths only — a Java package named `lib` is
653
+ * application code, so Java paths never match. The check is advisory input for callers that choose
654
+ * to skip; it produces no finding itself.
655
+ *
656
+ * [ADR-0030]: ../../../../docs/DECISIONS/0030-pentest-coverage-layer.md
657
+ */
658
+ /**
659
+ * `/*!` is the "preserve this comment through minification" convention libraries use for their
660
+ * banner; `@license` is the other. A plain `Copyright` header is NOT enough — application files at
661
+ * a company often carry one, and skipping them would hide the team's own code.
662
+ */
531
663
 
532
- export { BUILD_FILE_RE as DEVTOOLS_BUILD_FILE_RE, DOCKERFILE_RE, HTML_TEMPLATE_FILE_RE, asTreeSitterTree, asTsMorphSourceFile, auditBuildFile, auditDockerfileContent, auditDockerfileDependencyConfusion, auditPasswordAutocompleteContent, findSensitiveOutput, isExcludedHost, maskJavaFiles, maskJsComments };
664
+ export { BUILD_FILE_RE as DEVTOOLS_BUILD_FILE_RE, DOCKERFILE_RE, HTML_TEMPLATE_FILE_RE, asTreeSitterTree, asTsMorphSourceFile, auditBuildFile, auditDockerfileContent, auditDockerfileDependencyConfusion, auditPasswordAutocompleteContent, findDevToolsDeclarations, findReflectiveAccess, findSensitiveOutput, isExcludedHost, isThirdPartyAsset, maskJavaComments, maskJavaFiles, maskJsComments };
533
665
  //# sourceMappingURL=rules-runtime.js.map
534
666
  //# sourceMappingURL=rules-runtime.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-sentinel-cli/code-sentinel-cli",
3
- "version": "4.0.5",
3
+ "version": "4.0.7",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "AI-assisted code review CLI for Angular, Spring Boot, and Flutter projects.",