@code-sentinel-cli/code-sentinel-cli 4.0.9 → 4.0.10

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 (59) hide show
  1. package/dist/bin.js +6037 -523
  2. package/dist/builtin-rules/ai/spring-boot/ownership-scope-risk.rule.yaml +1 -0
  3. package/dist/builtin-rules/ai/spring-boot/security-authorization-risk.rule.yaml +1 -0
  4. package/dist/builtin-rules/ai/spring-boot/security-mass-assignment-risk.rule.yaml +1 -0
  5. package/dist/builtin-rules/ai/spring-boot/state-transition-guard-risk.rule.yaml +1 -0
  6. package/dist/builtin-rules/fortify/ai/angular/cross-feature-route-permission-drift.rule.yaml +2 -0
  7. package/dist/builtin-rules/fortify/ai/angular/route-permission-flow.rule.yaml +2 -0
  8. package/dist/builtin-rules/fortify/ai/spring-boot/io-boundary-risk.rule.yaml +1 -0
  9. package/dist/builtin-rules/fortify/ai/spring-boot/security-redirect-risk.rule.yaml +2 -0
  10. package/dist/builtin-rules/fortify/ai/spring-boot/security-sensitive-data-risk.rule.yaml +2 -0
  11. package/dist/builtin-rules/fortify/static/angular/sensitive-input-masking.rule.js +1 -0
  12. package/dist/builtin-rules/fortify/static/general/java-weak-randomness.rule.js +2 -0
  13. package/dist/builtin-rules/fortify/static/general/no-client-identity-header.rule.js +1 -0
  14. package/dist/builtin-rules/fortify/static/general/no-guessable-websql-database-name.rule.js +1 -0
  15. package/dist/builtin-rules/fortify/static/general/no-reflective-access-override.rule.js +1 -0
  16. package/dist/builtin-rules/fortify/static/general/no-sensitive-string-materialization.rule.js +1 -0
  17. package/dist/builtin-rules/fortify/static/spring-boot/no-command-injection.rule.js +2 -0
  18. package/dist/builtin-rules/fortify/static/spring-boot/no-path-traversal.rule.js +8 -1
  19. package/dist/builtin-rules/fortify/static/spring-boot/no-servlet-xss.rule.js +2 -0
  20. package/dist/builtin-rules/fortify/static/spring-boot/no-spel-injection.rule.js +2 -0
  21. package/dist/builtin-rules/fortify/static/spring-boot/no-sql-string-concat.rule.js +2 -0
  22. package/dist/builtin-rules/fortify/static/spring-boot/no-ssrf.rule.js +2 -0
  23. package/dist/builtin-rules/fortify/static/spring-boot/no-trust-boundary-violation.rule.js +43 -0
  24. package/dist/builtin-rules/fortify/static/spring-boot/no-weak-tls-protocol.rule.js +2 -0
  25. package/dist/builtin-rules/static/angular/no-dom-xss.rule.js +1 -0
  26. package/dist/builtin-rules/static/angular/template-dom-xss.rule.js +1 -0
  27. package/dist/builtin-rules/static/flutter/INVENTORY.md +44 -0
  28. package/dist/builtin-rules/static/flutter/NATIVE-INVENTORY.md +34 -0
  29. package/dist/builtin-rules/static/flutter/android-cleartext-traffic.rule.js +104 -0
  30. package/dist/builtin-rules/static/flutter/android-release-debuggable.rule.js +85 -0
  31. package/dist/builtin-rules/static/flutter/bad-certificate-callback.rule.js +80 -0
  32. package/dist/builtin-rules/static/flutter/biometric-without-crypto-object.rule.js +86 -0
  33. package/dist/builtin-rules/static/flutter/cleartext-http-endpoint.rule.js +76 -0
  34. package/dist/builtin-rules/static/flutter/device-fingerprint-collection.rule.js +73 -0
  35. package/dist/builtin-rules/static/flutter/exported-content-provider-leak.rule.js +118 -0
  36. package/dist/builtin-rules/static/flutter/hardcoded-crypto-key.rule.js +124 -0
  37. package/dist/builtin-rules/static/flutter/hardcoded-oauth-client-secret.rule.js +107 -0
  38. package/dist/builtin-rules/static/flutter/insecure-deep-link.rule.js +153 -0
  39. package/dist/builtin-rules/static/flutter/ios-ats-exception.rule.js +82 -0
  40. package/dist/builtin-rules/static/flutter/ios-pasteboard-leak.rule.js +95 -0
  41. package/dist/builtin-rules/static/flutter/missing-enforced-update.rule.js +80 -0
  42. package/dist/builtin-rules/static/flutter/oauth-missing-pkce.rule.js +74 -0
  43. package/dist/builtin-rules/static/flutter/token-insecure-storage.rule.js +120 -0
  44. package/dist/builtin-rules/static/flutter/tracking-sdk-init.rule.js +75 -0
  45. package/dist/builtin-rules/static/flutter/weak-mobile-crypto-algorithm.rule.js +113 -0
  46. package/dist/builtin-rules/static/flutter/weak-prng-mobile.rule.js +103 -0
  47. package/dist/builtin-rules/static/general/kubernetes-pod-security.rule.js +1 -0
  48. package/dist/builtin-rules/static/general/no-dynamic-code-eval.rule.js +1 -0
  49. package/dist/builtin-rules/static/general/no-hardcoded-secret.rule.js +61 -5
  50. package/dist/builtin-rules/static/general/no-unsafe-html-sink.rule.js +1 -0
  51. package/dist/builtin-rules/static/general/no-unused-export.rule.js +1 -0
  52. package/dist/builtin-rules/static/general/openapi-https-credentials.rule.js +1 -0
  53. package/dist/builtin-rules/static/spring-boot/no-unsafe-shared-formatter.rule.js +1 -0
  54. package/dist/builtin-rules/static/spring-boot/no-unzoned-datetime.rule.js +1 -0
  55. package/dist/builtin-rules/static/spring-boot/validate-input.rule.js +1 -0
  56. package/dist/index.d.ts +467 -0
  57. package/dist/index.js +6036 -522
  58. package/node_modules/@code-sentinel/parsers/index.js +53 -4
  59. package/package.json +1 -1
@@ -0,0 +1,75 @@
1
+ // builtin-rules/static/flutter/utils.js
2
+ var lineColumnAt = (content, index) => {
3
+ const safeIndex = Math.max(0, Math.min(index, content.length));
4
+ const before = content.slice(0, safeIndex);
5
+ const lines = before.split(/\r?\n/);
6
+ return { line: lines.length, column: lines.at(-1)?.length ?? 0 };
7
+ };
8
+ var finding = (file, index, message, suggestion, opts = {}) => {
9
+ const range = lineColumnAt(file.content, index);
10
+ return {
11
+ message,
12
+ file: file.path,
13
+ range,
14
+ suggestion,
15
+ ...opts.confidence !== void 0 ? { confidence: opts.confidence } : {},
16
+ ...opts.severity !== void 0 ? { severity: opts.severity } : {},
17
+ ...opts.snippet !== void 0 ? { snippet: opts.snippet } : {},
18
+ ...opts.rootCauseKey !== void 0 ? { rootCauseKey: opts.rootCauseKey } : {},
19
+ ...opts.tags !== void 0 ? { tags: opts.tags } : {},
20
+ ...opts.profileApplicability !== void 0 ? { profileApplicability: opts.profileApplicability } : {}
21
+ };
22
+ };
23
+
24
+ // builtin-rules/static/flutter/tracking-sdk-init.rule.ts
25
+ var TRACKING_SDK_INIT_RE = /\b(AppsFlyerLib|AppsFlyerLib\.getInstance\(\)\.init|Adjust\.onCreate|AdjustConfig\(|OneSignal\.initWithContext|OneSignal\.setAppId|FacebookSdk\.sdkInitialize|FacebookSdk\.setApplicationId|FirebaseAnalytics\.getInstance|FirebaseAnalytics\.setAnalyticsCollectionEnabled\(true\))\b/;
26
+ var CONSENT_GATE_RE = /(?:userConsent|analyticsConsent|[Rr]equireConsent|ConsentInformation|ConsentStatus|setAnalyticsCollectionEnabled\(false\)|AppConsent|gdpr|GDPR|ConsentDialog|ConsentDebugGeography)/;
27
+ var rule = {
28
+ id: "flutter/tracking-sdk-init",
29
+ version: 1,
30
+ kind: "static-ts",
31
+ title: "SDK tracking/analytics kh\u1EDFi t\u1EA1o m\xE0 kh\xF4ng c\xF3 c\u1ED5ng \u0111\u1ED3ng thu\u1EADn (consent)",
32
+ description: "AppsFlyer/Adjust/OneSignal/Facebook/Firebase Analytics kh\u1EDFi t\u1EA1o tr\u1EF1c ti\u1EBFp trong Application.onCreate / main / initState m\xE0 kh\xF4ng c\xF3 consent gate (requireConsent / setAnalyticsCollectionEnabled(false) / ConsentInformation). Thu th\u1EADp d\u1EEF li\u1EC7u tr\u01B0\u1EDBc \u0111\u1ED3ng thu\u1EADn vi ph\u1EA1m MASVS-PRIVACY-3.",
33
+ severity: "info",
34
+ category: "mobile-privacy",
35
+ languages: ["kotlin", "java", "dart", "swift"],
36
+ scope: "flutter",
37
+ requires: "text",
38
+ baseConfidence: 60,
39
+ check(ctx) {
40
+ if (/(?:^|\/)(?:debug|test|__tests__)\//i.test(ctx.file.path)) return [];
41
+ const lines = ctx.file.content.split(/\r?\n/);
42
+ const out = [];
43
+ let offset = 0;
44
+ for (let i = 0; i < lines.length; i += 1) {
45
+ const line = lines[i] ?? "";
46
+ if (!TRACKING_SDK_INIT_RE.test(line)) {
47
+ offset += line.length + 1;
48
+ continue;
49
+ }
50
+ if (CONSENT_GATE_RE.test(ctx.file.content)) {
51
+ offset += line.length + 1;
52
+ continue;
53
+ }
54
+ out.push(
55
+ finding(
56
+ ctx.file,
57
+ offset,
58
+ "Kh\u1EDFi t\u1EA1o SDK tracking/analytics kh\xF4ng th\u1EA5y consent gate trong file.",
59
+ "B\u1EADt requireConsent (Adjust/AppsFlyer), await ConsentInformation (Google UMP), ho\u1EB7c setAnalyticsCollectionEnabled(false) cho \u0111\u1EBFn khi ng\u01B0\u1EDDi d\xF9ng \u0111\u1ED3ng \xFD; ch\u1EC9 init collection sau khi c\xF3 consent.",
60
+ {
61
+ snippet: line.trim(),
62
+ rootCauseKey: "tracking-sdk-without-consent-gate",
63
+ tags: ["privacy", "consent", "tracking"]
64
+ }
65
+ )
66
+ );
67
+ offset += line.length + 1;
68
+ }
69
+ return out;
70
+ }
71
+ };
72
+
73
+ export { rule };
74
+ //# sourceMappingURL=tracking-sdk-init.rule.js.map
75
+ //# sourceMappingURL=tracking-sdk-init.rule.js.map
@@ -0,0 +1,113 @@
1
+ // builtin-rules/static/flutter/utils.js
2
+ var lineColumnAt = (content, index) => {
3
+ const safeIndex = Math.max(0, Math.min(index, content.length));
4
+ const before = content.slice(0, safeIndex);
5
+ const lines = before.split(/\r?\n/);
6
+ return { line: lines.length, column: lines.at(-1)?.length ?? 0 };
7
+ };
8
+ var finding = (file, index, message, suggestion, opts = {}) => {
9
+ const range = lineColumnAt(file.content, index);
10
+ return {
11
+ message,
12
+ file: file.path,
13
+ range,
14
+ suggestion,
15
+ ...opts.confidence !== void 0 ? { confidence: opts.confidence } : {},
16
+ ...opts.severity !== void 0 ? { severity: opts.severity } : {},
17
+ ...opts.snippet !== void 0 ? { snippet: opts.snippet } : {},
18
+ ...opts.rootCauseKey !== void 0 ? { rootCauseKey: opts.rootCauseKey } : {},
19
+ ...opts.tags !== void 0 ? { tags: opts.tags } : {},
20
+ ...opts.profileApplicability !== void 0 ? { profileApplicability: opts.profileApplicability } : {}
21
+ };
22
+ };
23
+
24
+ // builtin-rules/static/flutter/weak-mobile-crypto-algorithm.rule.ts
25
+ var WEAK_SPECS = [
26
+ // JCE Cipher.getInstance với ECB/DES/RC4/3DES/Blowfish/PKCS1-no-OAEP
27
+ [
28
+ /\bCipher\.getInstance\s*\(\s*['"][^'"]*\b(?:ECB|DES|DESede|3DES|RC4|ARCFOUR|Blowfish|RSA\/ECB\/PKCS1)/i,
29
+ "Cipher getInstance weak (ECB/DES/RC4/3DES/Blowfish/PKCS1 RSA)"
30
+ ],
31
+ // MessageDigest MD5/SHA-1
32
+ [/\bMessageDigest\.getInstance\s*\(\s*['"](?:MD5|SHA-?1)['"]/i, "MessageDigest MD5/SHA-1"],
33
+ // Mac HmacMD5/HmacSHA1
34
+ [/\bMac\.getInstance\s*\(\s*['"]Hmac(?:MD5|SHA-?1)['"]/i, "HmacMD5/HmacSHA1"],
35
+ // KeyGenerator DES/RC4/3DES (AES được phép)
36
+ [
37
+ /\bKeyGenerator\.getInstance\s*\(\s*['"](?:DES|ARCFOUR|RC4|DESede)['"]/i,
38
+ "KeyGenerator DES/RC4/3DES"
39
+ ],
40
+ // Dart crypto
41
+ [/\bHmac\s*\(\s*sha1\b/i, "Hmac(sha1)"],
42
+ [/\bDigest\s*\(\s*['"](?:SHA-?1|MD5)['"]/i, "Digest(SHA-1|MD5)"]
43
+ ];
44
+ var ECB_LITERAL_RE = /['"][^'"]*\bECB\b[^'"]*['"]/i;
45
+ var IGNORE_COMMENT_RE = /\/\/\s*secure-ignored\b/i;
46
+ var TEST_DEBUG_PATH_RE = /(?:^|\/)(?:test|debug)\//i;
47
+ var rule = {
48
+ id: "flutter/weak-mobile-crypto-algorithm",
49
+ version: 1,
50
+ kind: "static-ts",
51
+ title: "Kh\xF4ng d\xF9ng thu\u1EADt to\xE1n/mode m\xE3 h\xF3a y\u1EBFu (MD5/SHA-1/DES/RC4/ECB)",
52
+ description: "Ph\xE1t hi\u1EC7n thu\u1EADt to\xE1n b\u0103m/m\xE3 h\xF3a y\u1EBFu (MD5, SHA-1, HmacMD5, HmacSHA1), block/stream cipher y\u1EBFu (DES, RC4, 3DES, Blowfish) ho\u1EB7c mode ECB trong code mobile (Dart/Java/Kotlin). C\xE1c ch\u1ECDn l\u1EF1a n\xE0y kh\xF4ng \u0111\u1EA1t khuy\u1EBFn ngh\u1ECB MASVS-CRYPTO-1.",
53
+ severity: "error",
54
+ category: "mobile-security",
55
+ languages: ["dart", "java", "kotlin"],
56
+ scope: "flutter",
57
+ requires: "text",
58
+ baseConfidence: 88,
59
+ check(ctx) {
60
+ if (TEST_DEBUG_PATH_RE.test(ctx.file.path)) return [];
61
+ const lines = ctx.file.content.split(/\r?\n/);
62
+ const out = [];
63
+ let offset = 0;
64
+ for (let i = 0; i < lines.length; i += 1) {
65
+ const line = lines[i] ?? "";
66
+ if (IGNORE_COMMENT_RE.test(line)) {
67
+ offset += line.length + 1;
68
+ continue;
69
+ }
70
+ let emitted = false;
71
+ for (const [re, label] of WEAK_SPECS) {
72
+ if (re.test(line)) {
73
+ out.push(
74
+ finding(
75
+ ctx.file,
76
+ offset,
77
+ `Thu\u1EADt to\xE1n/mode m\xE3 h\xF3a y\u1EBFu (${label}) trong code mobile \u2014 kh\xF4ng \u0111\u1EA1t MASVS-CRYPTO-1 (ATTT #85/#40).`,
78
+ "D\xF9ng thu\u1EADt to\xE1n khuy\u1EBFn ngh\u1ECB: b\u0103m SHA-256 tr\u1EDF l\xEAn (ho\u1EB7c h\u1ECD SHA-3), m\xE3 h\xF3a \u0111\u1ED1i x\u1EE9ng AES v\u1EDBi mode an to\xE0n GCM/CBC+HMAC ho\u1EB7c ChaCha20-Poly1305, HMAC SHA-256+; tuy\u1EC7t \u0111\u1ED1i tr\xE1nh ECB; DES/RC4/3DES/Blowfish kh\xF4ng d\xF9ng cho d\u1EEF li\u1EC7u m\u1EDBi.",
79
+ {
80
+ snippet: line.trim(),
81
+ rootCauseKey: "weak-crypto-algorithm",
82
+ tags: ["crypto", "masvs-crypto"]
83
+ }
84
+ )
85
+ );
86
+ emitted = true;
87
+ break;
88
+ }
89
+ }
90
+ if (!emitted && ECB_LITERAL_RE.test(line) && !/\b(?:CBC|GCM|CTR|CCM|CFB|OFB)\b/i.test(line)) {
91
+ out.push(
92
+ finding(
93
+ ctx.file,
94
+ offset,
95
+ "Mode m\xE3 h\xF3a ECB trong code mobile \u2014 kh\xF4ng \u0111\u1EA1t MASVS-CRYPTO-1 (ATTT #85/#40).",
96
+ "Tr\xE1nh ECB ho\xE0n to\xE0n: n\xF3 r\xF2 r\u1EC9 pattern ciphertext v\xE0 kh\xF4ng \u0111\u1EA1t t\xEDnh ph\xE2n bi\u1EC7t (IND-CPA). D\xF9ng AES-GCM ho\u1EB7c AES-CBC + HMAC-SHA256 v\u1EDBi IV ng\u1EABu nhi\xEAn.",
97
+ {
98
+ snippet: line.trim(),
99
+ rootCauseKey: "weak-crypto-algorithm",
100
+ tags: ["crypto", "masvs-crypto"]
101
+ }
102
+ )
103
+ );
104
+ }
105
+ offset += line.length + 1;
106
+ }
107
+ return out;
108
+ }
109
+ };
110
+
111
+ export { rule };
112
+ //# sourceMappingURL=weak-mobile-crypto-algorithm.rule.js.map
113
+ //# sourceMappingURL=weak-mobile-crypto-algorithm.rule.js.map
@@ -0,0 +1,103 @@
1
+ // builtin-rules/static/flutter/utils.js
2
+ var lineColumnAt = (content, index) => {
3
+ const safeIndex = Math.max(0, Math.min(index, content.length));
4
+ const before = content.slice(0, safeIndex);
5
+ const lines = before.split(/\r?\n/);
6
+ return { line: lines.length, column: lines.at(-1)?.length ?? 0 };
7
+ };
8
+ var finding = (file, index, message, suggestion, opts = {}) => {
9
+ const range = lineColumnAt(file.content, index);
10
+ return {
11
+ message,
12
+ file: file.path,
13
+ range,
14
+ suggestion,
15
+ ...opts.confidence !== void 0 ? { confidence: opts.confidence } : {},
16
+ ...opts.severity !== void 0 ? { severity: opts.severity } : {},
17
+ ...opts.snippet !== void 0 ? { snippet: opts.snippet } : {},
18
+ ...opts.rootCauseKey !== void 0 ? { rootCauseKey: opts.rootCauseKey } : {},
19
+ ...opts.tags !== void 0 ? { tags: opts.tags } : {},
20
+ ...opts.profileApplicability !== void 0 ? { profileApplicability: opts.profileApplicability } : {}
21
+ };
22
+ };
23
+
24
+ // builtin-rules/static/flutter/weak-prng-mobile.rule.ts
25
+ var WEAK_PRNG_RE = /\b(?:new\s+Random\b|Random|ThreadLocalRandom|Math\.random|kotlin\.random\.Random|RandomStringUtils\.random(?:Numeric|Alphabetic|Ascii)?)\b\s*[\t ]*[(.]/;
26
+ var SECURE_PRNG_RE = /SecureRandom|\.secure\s*\(|java\.security\.SecureRandom|HKDF|\/dev\/urandom/i;
27
+ var SECURITY_WORDS = /* @__PURE__ */ new Set([
28
+ "otp",
29
+ "otps",
30
+ "token",
31
+ "tokens",
32
+ "secret",
33
+ "secrets",
34
+ "code",
35
+ "nonce",
36
+ "challenge",
37
+ "csrfstate",
38
+ "verifier",
39
+ "state",
40
+ "pin",
41
+ "pins",
42
+ "captcha"
43
+ ]);
44
+ var splitWords = (identifier) => identifier.replace(/[$_]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[^A-Za-z0-9]+/).filter((word) => word.length > 0);
45
+ var TEST_DEBUG_PATH_RE = /(?:^|\/)(?:test|debug)\//i;
46
+ var hasSecurityContext = (lines, center) => {
47
+ const start = Math.max(0, center - 3);
48
+ const end = Math.min(lines.length, center + 4);
49
+ for (let j = start; j < end; j += 1) {
50
+ const line = lines[j] ?? "";
51
+ const tokens = line.match(/[A-Za-z_$][A-Za-z0-9_$]{1,}/g) ?? [];
52
+ for (const tok of tokens) {
53
+ const words = splitWords(tok).map((w) => w.toLowerCase());
54
+ if (words.some((w) => SECURITY_WORDS.has(w))) return true;
55
+ }
56
+ }
57
+ return false;
58
+ };
59
+ var rule = {
60
+ id: "flutter/weak-prng-mobile",
61
+ version: 1,
62
+ kind: "static-ts",
63
+ title: "Sinh OTP/token/nonce/ph\xEA duy\u1EC7t ph\u1EA3i d\xF9ng PRNG an to\xE0n, kh\xF4ng ph\u1EA3i Random()/Math.random()",
64
+ description: "Ph\xE1t hi\u1EC7n `Random()`, `java.util.Random`, `Math.random()`, `ThreadLocalRandom` ho\u1EB7c `RandomStringUtils` khi trong c\u1EEDa s\u1ED5 \xB13 d\xF2ng c\xF3 identifier li\xEAn quan b\u1EA3o m\u1EADt (otp/token/secret/code/nonce/challenge/csrfState/verifier/state). PRNG y\u1EBFu kh\xF4ng kh\xE1ng \u0111o\xE1n l\u1EA1i attacker cho gi\xE1 tr\u1ECB b\u1EA3o m\u1EADt.",
65
+ severity: "error",
66
+ category: "mobile-security",
67
+ languages: ["dart", "java", "kotlin", "swift"],
68
+ scope: "flutter",
69
+ requires: "text",
70
+ baseConfidence: 85,
71
+ check(ctx) {
72
+ if (TEST_DEBUG_PATH_RE.test(ctx.file.path)) return [];
73
+ const lines = ctx.file.content.split(/\r?\n/);
74
+ const out = [];
75
+ let offset = 0;
76
+ for (let i = 0; i < lines.length; i += 1) {
77
+ const line = lines[i] ?? "";
78
+ if (WEAK_PRNG_RE.test(line) && !SECURE_PRNG_RE.test(line)) {
79
+ if (hasSecurityContext(lines, i)) {
80
+ out.push(
81
+ finding(
82
+ ctx.file,
83
+ offset,
84
+ "D\xF9ng PRNG y\u1EBFu (`Random()`/`Math.random()`/`ThreadLocalRandom`/`RandomStringUtils`) trong ng\u1EEF c\u1EA3nh sinh gi\xE1 tr\u1ECB b\u1EA3o m\u1EADt \u2014 kh\xF4ng kh\xE1ng \u0111o\xE1n l\u1EA1i attacker (ATTT #85; MASVS-CRYPTO-1).",
85
+ "D\xF9ng CSPRNG h\u1ED9i \u0111\u1ED3ng n\u1EC1n t\u1EA3ng: Dart `SecureRandom()` (package:crypto) ho\u1EB7c `Random.secure()`; Java `java.security.SecureRandom`; iOS `SecRandomCopyBytes`. Sinh OTP/nonce/PKCE verifier/state/PIN ch\u1EC9 d\xF9ng CSPRNG; trong Dart \u01B0u ti\xEAn `Random.secure()`.",
86
+ {
87
+ snippet: line.trim(),
88
+ rootCauseKey: "weak-prng-for-security",
89
+ tags: ["crypto", "prng", "masvs-crypto"]
90
+ }
91
+ )
92
+ );
93
+ }
94
+ }
95
+ offset += line.length + 1;
96
+ }
97
+ return out;
98
+ }
99
+ };
100
+
101
+ export { rule };
102
+ //# sourceMappingURL=weak-prng-mobile.rule.js.map
103
+ //# sourceMappingURL=weak-prng-mobile.rule.js.map
@@ -72,6 +72,7 @@ var rule = {
72
72
  title: "Kubernetes khai b\xE1o seccomp v\xE0 gi\u1EDBi h\u1EA1n token ServiceAccount",
73
73
  severity: "warning",
74
74
  category: "security",
75
+ checklistIds: ["7"],
75
76
  languages: ["yaml"],
76
77
  scope: "general",
77
78
  usesParser: false,
@@ -42,6 +42,7 @@ var rule = {
42
42
  description: "Ph\xE1t hi\u1EC7n eval(x) v\xE0 new Function(..., x) khi x kh\xF4ng ph\u1EA3i chu\u1ED7i h\u1EB1ng (CWE-95). N\u1EBFu chu\u1ED7i l\u1EA5y t\u1EEB server, c\u1EA5u h\xECnh ho\u1EB7c ng\u01B0\u1EDDi d\xF9ng, ai ki\u1EC3m so\xE1t \u0111\u01B0\u1EE3c chu\u1ED7i \u0111\xF3 s\u1EBD ch\u1EA1y \u0111\u01B0\u1EE3c JavaScript tr\xEAn tr\xECnh duy\u1EC7t c\u1EE7a m\u1ECDi ng\u01B0\u1EDDi d\xF9ng.",
43
43
  severity: "warning",
44
44
  category: "security",
45
+ checklistIds: ["98"],
45
46
  languages: ["typescript", "javascript"],
46
47
  scope: "general",
47
48
  requires: "syntactic",
@@ -312,10 +312,16 @@ var JWT_PATTERNS = [
312
312
  var GENERIC_PATTERNS = [
313
313
  {
314
314
  name: "generic-password-assignment",
315
- regex: /\b(?:[A-Za-z_$][\w$]*(?:password|passwd|pwd)|password|passwd|pwd)\s*[:=]\s*["']([^"'\s]{8,})["']/gi,
315
+ // Group 1 = assigned key, group 2 = payload (keyGroup/payloadGroup below).
316
+ // MEASURED on ctd_ctct run ptr_muimhnjx_4a064837: the LAST surviving FP was
317
+ // an enum member `CONFIGURATION_PASSWORD = 'Configuration_password'` — the
318
+ // value echoes its own key, which is exactly the v1.2.1 field-name-echo
319
+ // intent generalized from a fixed list to self-echo detection.
320
+ regex: /\b([A-Za-z_$][\w$]*(?:password|passwd|pwd)|password|passwd|pwd)\s*[:=]\s*["']([^"'\s]{8,})["']/gi,
316
321
  confidence: 65,
317
322
  message: "Hard-coded password assignment detected.",
318
- payloadGroup: 1
323
+ payloadGroup: 2,
324
+ keyGroup: 1
319
325
  },
320
326
  {
321
327
  name: "empty-password-assignment",
@@ -411,6 +417,7 @@ var looksLikePlaceholder = (payload) => {
411
417
  if (lower.includes(needle)) return true;
412
418
  }
413
419
  if (payload.length >= 8 && /^(.)\1{7,}$/.test(payload)) return true;
420
+ if (/^<[^<>\s]+>$/.test(payload)) return true;
414
421
  return false;
415
422
  };
416
423
  var FIELD_NAME_ECHOES = [
@@ -434,6 +441,12 @@ var FIELD_NAME_ECHOES = [
434
441
  "client-secret"
435
442
  ];
436
443
  var isFieldNameEcho = (payload) => FIELD_NAME_ECHOES.includes(payload.toLowerCase());
444
+ var looksLikeRoutePath = (payload) => {
445
+ const value = payload.trim();
446
+ if (/^[a-z0-9]+(?:-[a-z0-9]+)+(?:\/[a-z0-9]+(?:-[a-z0-9]+)*)*$/.test(value)) return true;
447
+ return /^\/?[a-z0-9]+(?:-[a-z0-9]+)*(?:\/[a-z0-9]+(?:-[a-z0-9]+)*)+$/.test(value);
448
+ };
449
+ var normalizeKeyish = (value) => value.toLowerCase().replace(/[\s_\-./]+/g, "");
437
450
  var looksExternalized = (payload) => {
438
451
  const trimmed = payload.trim();
439
452
  const lower = trimmed.toLowerCase();
@@ -589,8 +602,41 @@ var EMPTY_PASSWORD_PATTERNS = /* @__PURE__ */ new Set([
589
602
  "empty-password-assignment",
590
603
  "empty-password-method-call"
591
604
  ]);
605
+ var isClientOnly = (path, language) => path.toLowerCase().endsWith(".vue") || language === "typescript" || language === "javascript";
606
+ var isI18nKey = (payload) => /^[A-Z][A-Z0-9_]*(?:\.[A-Z0-9_]+)+$/.test(payload);
607
+ var isConstantNameEcho = (matched, payload) => {
608
+ const key = /^\s*([A-Za-z_$][\w$]*)/.exec(matched)?.[1] ?? "";
609
+ return /^[A-Z][A-Z0-9_]*$/.test(key) && /^[a-z]+(?:[A-Z][a-z0-9]*)+$/.test(payload) && key.replace(/_/g, "").toLowerCase() === payload.toLowerCase();
610
+ };
611
+ var assignedKey = (matched) => (/([A-Za-z_$][\w$-]*)["']?\s*[:=]/.exec(matched)?.[1] ?? "").toLowerCase();
612
+ var namesAnotherObject = (matched, payload) => {
613
+ const key = assignedKey(matched);
614
+ const value = payload.trim().replace(/^["']|["']$/g, "");
615
+ if (/^(?:tls|existing)secret$|secret(?:name|ref)$/.test(key) && /^[a-z0-9](?:[-a-z0-9]*[a-z0-9])?$/.test(value) && value.includes("-")) {
616
+ return true;
617
+ }
618
+ return /^(?:field|column|col|param|key|label|attr|prop|header)_/.test(key) && /^[A-Za-z_]+$/.test(value);
619
+ };
620
+ var isBenignEmpty = (content, start) => {
621
+ const lineStart = content.lastIndexOf("\n", start - 1) + 1;
622
+ const before = content.slice(lineStart, start);
623
+ if (/\?\s*[\w$.]*\s*$/.test(before) && /\?/.test(before)) return true;
624
+ return /^\s*(?:private|protected|public)\s+(?!static\b)(?:final\s+)?String\s+$/.test(before);
625
+ };
626
+ var hasPemBody = (content, headerEnd) => {
627
+ const window = content.slice(headerEnd, headerEnd + 200);
628
+ const end = window.indexOf("-----END");
629
+ const body = (end >= 0 ? window.slice(0, end) : window).replace(/\\n|\s/g, "");
630
+ if (/[A-Za-z0-9+/=]{40,}/.test(body)) return true;
631
+ return !(end >= 0 || /^(?:\.{3}|…)/.test(body));
632
+ };
592
633
  var rule = {
593
634
  id: "general/no-hardcoded-secret",
635
+ // v14: a key that NAMES another object (Helm `tlsSecret: my-tls`, `FIELD_PASSWORD = "FieldName"`).
636
+ // v13: a PEM private-key header only fires when key material follows (hasPemBody).
637
+ // v12 (UBCK, 2026-09-25): v11's browser-only skip extends to Angular TS/JS; an empty-password
638
+ // match on a ternary else-branch or a non-static Java field default is skipped; generic patterns
639
+ // skip dotted UPPER_SNAKE i18n keys and `CONST_NAME: 'constName'` echoes.
594
640
  // v11: skip the EMPTY-password patterns in a Vue SFC ([ADR-0093]). A `.vue` component only ever
595
641
  // runs in the browser, so `passWord: ''` in its `data()` is a form field being reset, never a
596
642
  // credential a server authenticates with. Measured on mcdt_bqp: 54 of 54 hits were exactly that
@@ -615,12 +661,13 @@ var rule = {
615
661
  // v2 (1.2.1): added FIELD_NAME_ECHOES filter for enum-value / label-dict
616
662
  // FPs (e.g. `PASSWORD = 'password'`). Bumped so the rule cache invalidates
617
663
  // stale v1 findings — Phase 9 cache key is (id, version, file.hash).
618
- version: 11,
664
+ version: 14,
619
665
  kind: "static-ts",
620
666
  title: "Kh\xF4ng hardcode secrets / API keys / private keys v\xE0o source",
621
667
  description: "Qu\xE9t credentials, API keys, tokens, private keys committed v\xE0o code. H\u1ED7 tr\u1EE3 AWS / GitHub / GitLab / Slack / Stripe / Google / Azure / Twilio / SendGrid / Mailgun / NPM / PyPI / Discord / Telegram / DataDog / New Relic / Cloudflare / DigitalOcean / Docker Hub + PEM private keys + connection strings c\xF3 inline credentials + JWT + generic password/secret/apiKey assignments. Severity = error (CI gate). Confidence t\u1EEB 65 (generic, c\xF3 false positive) t\u1EDBi 95 (provider-prefixed, near-zero false positive). Tune qua options.disabledPatterns + options.extraPatterns.",
622
668
  severity: "error",
623
669
  category: "security",
670
+ checklistIds: ["23"],
624
671
  // Pure content scan: can run on YAML and text-classified config files.
625
672
  languages: ["typescript", "javascript", "java", "xml", "yaml", "text", "shell"],
626
673
  scope: "general",
@@ -635,7 +682,7 @@ var rule = {
635
682
  if (isOwnTestFile(ctx.file.path)) return [];
636
683
  const disabled = new Set(ctx.options.disabledPatterns);
637
684
  const extras = compileExtra(ctx.options.extraPatterns, ctx.logger);
638
- const clientOnly = ctx.file.path.toLowerCase().endsWith(".vue");
685
+ const clientOnly = isClientOnly(ctx.file.path, ctx.file.language);
639
686
  const patterns = [
640
687
  ...BUILTIN_PATTERNS.filter(
641
688
  (p) => !disabled.has(p.name) && !(clientOnly && EMPTY_PASSWORD_PATTERNS.has(p.name))
@@ -662,7 +709,16 @@ var rule = {
662
709
  if (overlapsReported(matchStart, matchEnd)) continue;
663
710
  const payload = pattern.payloadGroup !== void 0 ? match[pattern.payloadGroup] : match[0];
664
711
  const encrypted = payload !== void 0 && /^(?:ENC\(|\{cipher\})/i.test(payload.trim());
665
- if (payload && (looksLikePlaceholder(payload) || isFieldNameEcho(payload) && pattern.name.startsWith("generic-") || looksExternalized(payload) && !(encrypted && ctx.options.inspectEncryptedValues) || pattern.name === "config-secret-assignment" && /^(?:true|false|null|~)?$/i.test(payload.trim()))) {
712
+ const keyValue = pattern.keyGroup !== void 0 ? match[pattern.keyGroup] ?? void 0 : void 0;
713
+ const isKeySelfEcho = payload !== void 0 && keyValue !== void 0 && normalizeKeyish(payload) === normalizeKeyish(keyValue);
714
+ const isCamelCaseKey = keyValue !== void 0 && /[a-z][A-Z]/.test(keyValue);
715
+ if (payload && (looksLikePlaceholder(payload) || isFieldNameEcho(payload) && pattern.name.startsWith("generic-") || looksLikeRoutePath(payload) && pattern.name.startsWith("generic-") && isCamelCaseKey || isKeySelfEcho && pattern.name.startsWith("generic-") || looksExternalized(payload) && !(encrypted && ctx.options.inspectEncryptedValues) || pattern.name === "config-secret-assignment" && /^(?:true|false|null|~)?$/i.test(payload.trim()) || pattern.name.startsWith("generic-") && (isI18nKey(payload) || isConstantNameEcho(match[0], payload)) || (pattern.name.startsWith("generic-") || pattern.name === "config-secret-assignment") && namesAnotherObject(match[0], payload))) {
716
+ continue;
717
+ }
718
+ if (EMPTY_PASSWORD_PATTERNS.has(pattern.name) && isBenignEmpty(content, matchStart)) {
719
+ continue;
720
+ }
721
+ if (pattern.name.startsWith("private-key") && !hasPemBody(content, matchEnd)) {
666
722
  continue;
667
723
  }
668
724
  const { line, column } = lineColAt(content, matchStart);
@@ -78,6 +78,7 @@ var rule = {
78
78
  description: "Ph\xE1t hi\u1EC7n jQuery.html(), innerHTML/outerHTML, insertAdjacentHTML(), document.write() v\xE0 v-html c\u1EE7a Vue nh\u1EADn gi\xE1 tr\u1ECB \u0111\u1ED9ng. \u0110\xE2y l\xE0 HTML Injection; n\u1EBFu gi\xE1 tr\u1ECB \u0111\u01B0\u1EE3c l\u01B0u v\xE0 hi\u1EC3n th\u1ECB l\u1EA1i th\xEC c\xF3 th\u1EC3 l\xE0 Stored XSS.",
79
79
  severity: "warning",
80
80
  category: "security",
81
+ checklistIds: ["99"],
81
82
  languages: ["typescript", "javascript", "html"],
82
83
  scope: "general",
83
84
  requires: "syntactic",
@@ -165,6 +165,7 @@ var rule = {
165
165
  description: "Symbol \u0111\u01B0\u1EE3c export nh\u01B0ng kh\xF4ng c\xF3 file n\xE0o trong project import l\u1EA1i. Conservative: b\u1ECF qua export ki\u1EC3u (interface/type/enum \u2014 m\u1EB7c \u0111\u1ECBnh, v\xEC \u0111\xF3 l\xE0 h\u1EE3p \u0111\u1ED3ng d\xF9ng chung), wildcard re-export targets, default exports, orphan files, v\xE0 c\xE1c file public-API/entry-point/h\u1EE3p \u0111\u1ED3ng (index.ts, public-api.ts, *.module.ts, *.routes.ts, *.types.ts, *.interface.ts, *.const.ts, *.model.ts, *.d.ts, ...). \u26A0 CH\u1EC8 \u0111\xE1ng tin khi qu\xE9t TO\xC0N d\u1EF1 \xE1n: \u0111\u1ED3 th\u1ECB ch\u1EC9 ch\u1EE9a file \u0111\u01B0\u1EE3c qu\xE9t, n\xEAn qu\xE9t m\u1ED9t th\u01B0 m\u1EE5c con s\u1EBD l\xE0m m\u1ECDi export \u1EDF bi\xEAn module tr\xF4ng nh\u01B0 kh\xF4ng ai d\xF9ng.",
166
166
  severity: "info",
167
167
  category: "maintainability",
168
+ checklistIds: ["6"],
168
169
  languages: ["typescript", "javascript"],
169
170
  scope: "general",
170
171
  requires: "semantic-ts",
@@ -72,6 +72,7 @@ var rule = {
72
72
  title: "OpenAPI trao \u0111\u1ED5i credential qua HTTPS",
73
73
  severity: "warning",
74
74
  category: "security",
75
+ checklistIds: ["22"],
75
76
  languages: ["yaml"],
76
77
  scope: "general",
77
78
  usesParser: false,
@@ -72,6 +72,7 @@ var rule = {
72
72
  description: "`SimpleDateFormat`/`DateFormat`/`NumberFormat`/`DecimalFormat`/`Calendar` KH\xD4NG thread-safe (`format`/`parse` mutate state n\u1ED9i b\u1ED9). \u0110\u1EB7t ch\xFAng l\xE0m field `static` (d\xF9ng chung to\xE0n process) ho\u1EB7c field instance c\u1EE7a m\u1ED9t Spring bean singleton (`@Service`/`@Component`/\u2026 ph\u1EE5c v\u1EE5 m\u1ECDi request \u0111\u1ED3ng th\u1EDDi) \u2192 hai lu\u1ED3ng d\xF9ng chung m\u1ED9t instance s\u1EBD ph\xE1 k\u1EBFt qu\u1EA3 c\u1EE7a nhau (ng\xE0y sai, `NumberFormatException`, l\u1ED7i ng\u1EABu nhi\xEAn ch\u1EC9 xu\u1EA5t hi\u1EC7n d\u01B0\u1EDBi t\u1EA3i). Kh\u1EAFc ph\u1EE5c: d\xF9ng `DateTimeFormatter` (java.time, immutable + thread-safe), `ThreadLocal<SimpleDateFormat>`, ho\u1EB7c t\u1EA1o instance c\u1EE5c b\u1ED9 m\u1ED7i l\u1EA7n d\xF9ng. T\u01B0\u01A1ng \u0111\u01B0\u01A1ng SonarQube S2885 / SpotBugs STCAL.",
73
73
  severity: "warning",
74
74
  category: "thread-safety",
75
+ sourceTools: ["sonarqube"],
75
76
  languages: ["java"],
76
77
  scope: "spring-boot",
77
78
  requires: "syntactic",
@@ -31,6 +31,7 @@ var rule = {
31
31
  description: "G\u1ECDi `LocalDateTime.now()`, `new Date()`, `Calendar.getInstance()` kh\xF4ng truy\u1EC1n `Clock` ho\u1EB7c `ZoneId` ng\u1EA7m s\u1EED d\u1EE5ng m\xFAi gi\u1EDD c\u1EE7a m\xE1y ch\u1EE7. Khi ch\u1EA1y tr\xEAn m\xF4i tr\u01B0\u1EDDng Cloud/K8s c\xF3 m\xFAi gi\u1EDD UTC, \u0111i\u1EC1u n\xE0y d\u1EABn \u0111\u1EBFn sai l\u1EC7ch d\u1EEF li\u1EC7u ng\xE0y gi\u1EDD v\xE0 kh\xF4ng th\u1EC3 mock khi vi\u1EBFt test.",
32
32
  severity: "warning",
33
33
  category: "correctness",
34
+ sourceTools: ["sonarqube"],
34
35
  languages: ["java"],
35
36
  scope: "spring-boot",
36
37
  requires: "syntactic",
@@ -83,6 +83,7 @@ var rule = {
83
83
  description: "Kh\xF4ng c\xF3 @Valid \u2192 Spring skip JSR-303 validation; input kh\xF4ng h\u1EE3p l\u1EC7 (null fields, out-of-range, missing email) s\u1EBD chui v\xE0o service layer. Security + data integrity risk.",
84
84
  severity: "error",
85
85
  category: "security",
86
+ checklistIds: ["78", "79"],
86
87
  languages: ["java"],
87
88
  scope: "spring-boot",
88
89
  requires: "syntactic",