@code-sentinel-cli/code-sentinel-cli 4.0.10 → 4.0.11
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.
- package/dist/bin.js +958 -182
- package/dist/builtin-rules/static/flutter/android-cleartext-traffic.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/android-debug-certificate-risk.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/android-exported-component.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/android-manifest-hardening.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/android-minsdk-low.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/android-release-debuggable.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/android-sensitive-permissions.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/bad-certificate-callback.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/biometric-without-crypto-object.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/cleartext-http-endpoint.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/debug-tooling-release-risk.rule.js +12 -3
- package/dist/builtin-rules/static/flutter/device-fingerprint-collection.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/dynamic-archive-risk.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/exported-content-provider-leak.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/hardcoded-crypto-key.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/hardcoded-oauth-client-secret.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/hive-sensitive-storage.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/insecure-deep-link.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/ios-ats-exception.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/ios-pasteboard-leak.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/ios-privacy-hardening.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/missing-enforced-update.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/oauth-missing-pkce.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/packaged-env-risk.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/sensitive-log-leak.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/token-insecure-storage.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/tracking-sdk-init.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/weak-mobile-crypto-algorithm.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/weak-prng-mobile.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/webview-bridge-guard.rule.js +1 -0
- package/dist/builtin-rules/static/general/dockerfile-dependency-confusion.rule.js +5 -4
- package/dist/builtin-rules/static/general/dockerfile-no-root-user.rule.js +1 -0
- package/dist/builtin-rules/static/general/no-empty-encryption-key.rule.js +16 -1
- package/dist/builtin-rules/static/general/no-hardcoded-secret.rule.js +15 -8
- package/dist/builtin-rules/static/general/no-insecure-external-link.rule.js +1 -0
- package/dist/builtin-rules/static/general/no-insecure-password-submission.rule.js +34 -2
- package/dist/builtin-rules/static/general/sensitive-exception-response.rule.js +1 -0
- package/dist/builtin-rules/static/general/sensitive-output-exposure.rule.js +1 -0
- package/dist/builtin-rules/static/spring-boot/no-devtools-in-production.rule.js +1 -0
- package/dist/index.js +958 -182
- package/node_modules/@code-sentinel/parsers/index.js +28 -0
- package/package.json +1 -1
|
@@ -44,6 +44,7 @@ var rule = {
|
|
|
44
44
|
description: 'Ph\xE1t hi\u1EC7n `usesCleartextTraffic="true"` \u1EDF manifest ho\u1EB7c network_security_config khai b\xE1o base-config m\xE0 kh\xF4ng ch\u1EB7n cleartext (`cleartextTrafficPermitted="false"`).',
|
|
45
45
|
severity: "warning",
|
|
46
46
|
category: "mobile-security",
|
|
47
|
+
masvsControlIds: ["MASVS-NETWORK-1"],
|
|
47
48
|
languages: ["xml"],
|
|
48
49
|
scope: "flutter",
|
|
49
50
|
requires: "text",
|
|
@@ -47,6 +47,7 @@ var rule = {
|
|
|
47
47
|
description: 'Ph\xE1t hi\u1EC7n `android:debuggable="true"` g\u1EAFn v\u1EDBi `<application>` trong manifest release/main (b\u1ECF qua manifest overlay c\u1EE7a flavor debug).',
|
|
48
48
|
severity: "error",
|
|
49
49
|
category: "mobile-security",
|
|
50
|
+
masvsControlIds: ["MASVS-RESILIENCE-2"],
|
|
50
51
|
languages: ["xml"],
|
|
51
52
|
scope: "flutter",
|
|
52
53
|
requires: "text",
|
|
@@ -23,13 +23,17 @@ var finding = (file, index, message, suggestion, opts = {}) => {
|
|
|
23
23
|
|
|
24
24
|
// builtin-rules/static/flutter/debug-tooling-release-risk.rule.ts
|
|
25
25
|
var RISK_PATTERNS = [
|
|
26
|
-
/RequestsInspector\
|
|
27
|
-
/DevicePreview\
|
|
28
|
-
/InAppDebugConsoleManager\
|
|
26
|
+
/(?:^|[^\w.])RequestsInspector\s*[(<]/,
|
|
27
|
+
/(?:^|[^\w.])DevicePreview\s*[(<]/,
|
|
28
|
+
/(?:^|[^\w.])InAppDebugConsoleManager\s*[(<]/,
|
|
29
29
|
/AndroidWebViewController\.enableDebugging\(\s*true\s*\)/,
|
|
30
30
|
/WebView\.setWebContentsDebuggingEnabled\(\s*true\s*\)/,
|
|
31
31
|
/setWebContentsDebuggingEnabled\(\s*true\s*\)/
|
|
32
32
|
];
|
|
33
|
+
var isCommentOrBlankLine = (line) => {
|
|
34
|
+
const trimmed = line.trim();
|
|
35
|
+
return trimmed === "" || trimmed.startsWith("//") || trimmed.startsWith("/*") || trimmed.startsWith("*");
|
|
36
|
+
};
|
|
33
37
|
var hasCompileTimeDebugGuard = (windowText) => /\bkDebugMode\b|\bBuildConfig\.DEBUG\b|\bDEBUG\b|#if\s+DEBUG|assert\s*\(/.test(windowText);
|
|
34
38
|
var rule = {
|
|
35
39
|
id: "flutter/debug-tooling-release-risk",
|
|
@@ -42,6 +46,7 @@ var rule = {
|
|
|
42
46
|
languages: ["dart", "kotlin", "swift", "java", "objective-c"],
|
|
43
47
|
scope: "flutter",
|
|
44
48
|
requires: "text",
|
|
49
|
+
masvsControlIds: ["MASVS-PLATFORM-3", "MASVS-RESILIENCE-2"],
|
|
45
50
|
baseConfidence: 76,
|
|
46
51
|
defaultOptions: {
|
|
47
52
|
targetProfile: "prod-release"
|
|
@@ -54,6 +59,10 @@ var rule = {
|
|
|
54
59
|
let offset = 0;
|
|
55
60
|
for (let i = 0; i < lines.length; i += 1) {
|
|
56
61
|
const line = lines[i] ?? "";
|
|
62
|
+
if (isCommentOrBlankLine(line)) {
|
|
63
|
+
offset += line.length + 1;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
57
66
|
const matched = RISK_PATTERNS.some((pattern) => pattern.test(line));
|
|
58
67
|
if (!matched) {
|
|
59
68
|
offset += line.length + 1;
|
|
@@ -35,6 +35,7 @@ var rule = {
|
|
|
35
35
|
languages: ["kotlin", "java", "swift", "dart"],
|
|
36
36
|
scope: "flutter",
|
|
37
37
|
requires: "text",
|
|
38
|
+
masvsControlIds: ["MASVS-PRIVACY-1"],
|
|
38
39
|
baseConfidence: 78,
|
|
39
40
|
check(ctx) {
|
|
40
41
|
if (/(?:^|\/)(?:debug|test|__tests__)\//i.test(ctx.file.path)) return [];
|
|
@@ -43,6 +43,7 @@ var rule = {
|
|
|
43
43
|
description: "Ph\xE1t hi\u1EC7n dictionary `NSAppTransportSecurity` b\u1EADt `NSAllowsArbitraryLoads=true` trong Info.plist; gi\u1EA3m confidence khi \u0111i k\xE8m `NSAllowsLocalNetworking`/`NSExceptionDomains` (ph\u1EA1m vi h\u1EB9p h\u01A1n).",
|
|
44
44
|
severity: "warning",
|
|
45
45
|
category: "mobile-security",
|
|
46
|
+
masvsControlIds: ["MASVS-NETWORK-1"],
|
|
46
47
|
languages: ["plist"],
|
|
47
48
|
scope: "flutter",
|
|
48
49
|
requires: "text",
|
|
@@ -45,6 +45,7 @@ var rule = {
|
|
|
45
45
|
description: "Ph\xE1t hi\u1EC7n `UIPasteboard.general` ghi string/objects m\xE0 gi\xE1 tr\u1ECB c\xF3 d\u1EA5u hi\u1EC7u nh\u1EA1y c\u1EA3m (token/password/secret/jwt); b\u1ECF qua intent chia s\u1EBB c\xF4ng khai v\xE0 thao t\xE1c ch\u1EC9 \u0111\u1ECDc.",
|
|
46
46
|
severity: "warning",
|
|
47
47
|
category: "mobile-security",
|
|
48
|
+
masvsControlIds: ["MASVS-STORAGE-2"],
|
|
48
49
|
languages: ["swift", "objective-c"],
|
|
49
50
|
scope: "flutter",
|
|
50
51
|
requires: "text",
|
|
@@ -35,6 +35,7 @@ var rule = {
|
|
|
35
35
|
languages: ["kotlin", "java", "dart", "swift"],
|
|
36
36
|
scope: "flutter",
|
|
37
37
|
requires: "text",
|
|
38
|
+
masvsControlIds: ["MASVS-PRIVACY-1"],
|
|
38
39
|
baseConfidence: 60,
|
|
39
40
|
check(ctx) {
|
|
40
41
|
if (/(?:^|\/)(?:debug|test|__tests__)\//i.test(ctx.file.path)) return [];
|
|
@@ -3,12 +3,13 @@ import { DOCKERFILE_RE, auditDockerfileDependencyConfusion } from '@code-sentine
|
|
|
3
3
|
// builtin-rules/static/general/dockerfile-dependency-confusion.rule.ts
|
|
4
4
|
var rule = {
|
|
5
5
|
id: "general/dockerfile-dependency-confusion",
|
|
6
|
-
version:
|
|
6
|
+
version: 4,
|
|
7
7
|
kind: "static-ts",
|
|
8
8
|
title: "Ng\u0103n ch\u1EB7n Dependency Confusion & Insecure Package Registry trong Dockerfile (CWE-427/CWE-829)",
|
|
9
9
|
description: "Ph\xE1t hi\u1EC7n c\u1EA5u h\xECnh package manager kh\xF4ng an to\xE0n trong Dockerfile (nh\u01B0 `pip install --extra-index-url`, `--trusted-host`, ho\u1EB7c c\u1EA5u h\xECnh registry qua HTTP cleartext) d\u1EABn \u0111\u1EBFn nguy c\u01A1 Dependency Confusion, Package Squatting ho\u1EB7c Man-in-the-Middle.",
|
|
10
10
|
severity: "error",
|
|
11
11
|
category: "security",
|
|
12
|
+
sourceTools: ["fortify"],
|
|
12
13
|
languages: ["text"],
|
|
13
14
|
scope: "general",
|
|
14
15
|
requires: "text",
|
|
@@ -23,9 +24,9 @@ var rule = {
|
|
|
23
24
|
message: h.reason,
|
|
24
25
|
file: file.path,
|
|
25
26
|
range: { line: h.line, column: 1 },
|
|
26
|
-
severity: "error",
|
|
27
|
-
confidence: 90,
|
|
28
|
-
suggestion: h.reason.includes("--extra-index-url") ? "Ch\u1EC9 s\u1EED d\u1EE5ng `--index-url` tr\u1ECF t\u1EDBi kho n\u1ED9i b\u1ED9 (artifact proxy) \u0111\xE3 \u0111\u01B0\u1EE3c b\u1EA3o v\u1EC7, ho\u1EB7c s\u1EED d\u1EE5ng c\u01A1 ch\u1EBF hash-pinning (`--require-hashes`)." : h.reason.includes("--trusted-host") ? "Cung c\u1EA5p ch\u1EE9ng ch\u1EC9 CA n\u1ED9i b\u1ED9 h\u1EE3p l\u1EC7 cho h\u1EC7 \u0111i\u1EC1u h\xE0nh/container thay v\xEC b\u1ECF qua ki\u1EC3m tra an to\xE0n v\u1EDBi `--trusted-host`." : "S\u1EED d\u1EE5ng HTTPS k\xE8m ch\u1EE9ng ch\u1EC9 SSL h\u1EE3p l\u1EC7 cho kho l\u01B0u tr\u1EEF g\xF3i (registry)."
|
|
27
|
+
severity: h.severity ?? "error",
|
|
28
|
+
confidence: h.confidence ?? 90,
|
|
29
|
+
suggestion: h.suggestion ?? (h.reason.includes("--extra-index-url") ? "Ch\u1EC9 s\u1EED d\u1EE5ng `--index-url` tr\u1ECF t\u1EDBi kho n\u1ED9i b\u1ED9 (artifact proxy) \u0111\xE3 \u0111\u01B0\u1EE3c b\u1EA3o v\u1EC7, ho\u1EB7c s\u1EED d\u1EE5ng c\u01A1 ch\u1EBF hash-pinning (`--require-hashes`)." : h.reason.includes("--trusted-host") ? "Cung c\u1EA5p ch\u1EE9ng ch\u1EC9 CA n\u1ED9i b\u1ED9 h\u1EE3p l\u1EC7 cho h\u1EC7 \u0111i\u1EC1u h\xE0nh/container thay v\xEC b\u1ECF qua ki\u1EC3m tra an to\xE0n v\u1EDBi `--trusted-host`." : "S\u1EED d\u1EE5ng HTTPS k\xE8m ch\u1EE9ng ch\u1EC9 SSL h\u1EE3p l\u1EC7 cho kho l\u01B0u tr\u1EEF g\xF3i (registry).")
|
|
29
30
|
}));
|
|
30
31
|
if (ctx.options.requirePinnedPackages) {
|
|
31
32
|
const lines = file.content.split("\n");
|
|
@@ -9,6 +9,7 @@ var rule = {
|
|
|
9
9
|
description: "Ph\xE1t hi\u1EC7n Dockerfile kh\xF4ng khai b\xE1o ch\u1EC9 th\u1ECB USER non-root khi\u1EBFn container ch\u1EA1y v\u1EDBi quy\u1EC1n root (UID 0) m\u1EB7c \u0111\u1ECBnh. Vi ph\u1EA1m nguy\xEAn t\u1EAFc \u0111\u1EB7c quy\u1EC1n t\u1ED1i thi\u1EC3u (CWE-250) v\xE0 t\u0103ng nguy c\u01A1 container escape.",
|
|
10
10
|
severity: "error",
|
|
11
11
|
category: "security",
|
|
12
|
+
sourceTools: ["fortify"],
|
|
12
13
|
languages: ["text"],
|
|
13
14
|
scope: "general",
|
|
14
15
|
requires: "text",
|
|
@@ -3,15 +3,17 @@ var CONFIG_FILE_RE = /\.(?:ya?ml|properties)$/i;
|
|
|
3
3
|
var JAVA_OR_TS_RE = /\.(?:java|ts|js|mjs|cjs)$/i;
|
|
4
4
|
var EMPTY_KEY_VAR_RE = /\b(?:String|byte\[\]|const|let|var)\s+([a-zA-Z0-9_]*(?:secret(?:key)?|encryptionkey|aeskey|deskey|jwtsecret|privatekey|cipherkey)[a-zA-Z0-9_]*)\s*=\s*(?:""|''|`\s*`|new\s+byte\[0\]|new\s+byte\[\]\s*\{\s*\}|\{\s*\})/i;
|
|
5
5
|
var EMPTY_SECRET_KEY_SPEC_RE = /new\s+SecretKeySpec\s*\(\s*(?:""\s*\.getBytes\([^)]*\)|new\s+byte\[0\]|new\s+byte\[\]\s*\{\s*\}|\{\s*\})/i;
|
|
6
|
+
var EMPTY_KEY_PROPERTY_RE = /\b([a-zA-Z0-9_$]*(?:secret(?:key)?|encryptionkey|aeskey|deskey|jwtsecret|privatekey|cipherkey)[a-zA-Z0-9_$]*)\s*:\s*(?:""|''|`\s*`|\[\s*\]|\{\s*\})\s*[,;]?\s*$/i;
|
|
6
7
|
var CONFIG_EMPTY_KEY_RE = /^[^\S\n]*([a-zA-Z0-9_.-]*(?:jwt[._-]secret|secret[._-]key|encryption[._-]key|aes[._-]key|cipher[._-]key|private[._-]key)[a-zA-Z0-9_.-]*)\s*[:=]\s*(?:""|''|\s*)$/i;
|
|
7
8
|
var rule = {
|
|
8
9
|
id: "general/no-empty-encryption-key",
|
|
9
|
-
version:
|
|
10
|
+
version: 2,
|
|
10
11
|
kind: "static-ts",
|
|
11
12
|
title: "Kh\xF4ng s\u1EED d\u1EE5ng kh\xF3a m\xE3 h\xF3a r\u1ED7ng (Empty Encryption Key / Secret)",
|
|
12
13
|
description: 'Ph\xE1t hi\u1EC7n vi\u1EC7c kh\u1EDFi t\u1EA1o SecretKeySpec ho\u1EB7c g\xE1n bi\u1EBFn/c\u1EA5u h\xECnh kh\xF3a m\xE3 h\xF3a (AES, DES, JWT, Cipher) v\u1EDBi gi\xE1 tr\u1ECB r\u1ED7ng ("" ho\u1EB7c new byte[0]). Vi\u1EC7c s\u1EED d\u1EE5ng kh\xF3a r\u1ED7ng khi\u1EBFn thu\u1EADt to\xE1n m\u1EADt m\xE3 m\u1EA5t ho\xE0n to\xE0n t\xEDnh b\u1EA3o m\u1EADt, cho ph\xE9p k\u1EBB t\u1EA5n c\xF4ng d\u1EC5 d\xE0ng gi\u1EA3i m\xE3 d\u1EEF li\u1EC7u ho\u1EB7c gi\u1EA3 m\u1EA1o token (CWE-321/CWE-547).',
|
|
13
14
|
severity: "error",
|
|
14
15
|
category: "security",
|
|
16
|
+
sourceTools: ["fortify"],
|
|
15
17
|
languages: ["java", "typescript", "javascript", "yaml", "text"],
|
|
16
18
|
scope: "general",
|
|
17
19
|
requires: "text",
|
|
@@ -53,6 +55,19 @@ var rule = {
|
|
|
53
55
|
confidence: 90,
|
|
54
56
|
suggestion: "Kh\xF4ng g\xE1n gi\xE1 tr\u1ECB r\u1ED7ng cho bi\u1EBFn kh\xF3a m\u1EADt m\xE3. N\u1EA1p kh\xF3a an to\xE0n t\u1EEB c\u1EA5u h\xECnh b\u1EA3o m\u1EADt ho\u1EB7c KeyManagementService."
|
|
55
57
|
});
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const propMatch = trimmed.match(EMPTY_KEY_PROPERTY_RE);
|
|
61
|
+
if (propMatch) {
|
|
62
|
+
const propName = propMatch[1];
|
|
63
|
+
findings.push({
|
|
64
|
+
message: `Thu\u1ED9c t\xEDnh kh\xF3a m\xE3 h\xF3a \`${propName}\` mang gi\xE1 tr\u1ECB r\u1ED7ng \u2014 n\u1EBFu gi\xE1 tr\u1ECB n\xE0y \u0111\u01B0\u1EE3c d\xF9ng l\xE0m kh\xF3a th\u1EADt th\xEC m\u1ECDi d\u1EEF li\u1EC7u m\xE3 h\xF3a b\u1EB1ng n\xF3 \u0111\u1EC1u b\u1ECB gi\u1EA3i m\xE3 \u0111\u01B0\u1EE3c (CWE-321/CWE-547).`,
|
|
65
|
+
file: file.path,
|
|
66
|
+
range: { line: i + 1, column: 1 },
|
|
67
|
+
severity: "warning",
|
|
68
|
+
confidence: 75,
|
|
69
|
+
suggestion: `\u0110\u1EA3m b\u1EA3o \`${propName}\` lu\xF4n \u0111\u01B0\u1EE3c n\u1EA1p t\u1EEB ngu\u1ED3n b\xED m\u1EADt th\u1EADt (bi\u1EBFn m\xF4i tr\u01B0\u1EDDng/Vault/KeyManagementService) tr\u01B0\u1EDBc khi d\xF9ng; kh\xF4ng \u0111\u1EC3 gi\xE1 tr\u1ECB r\u1ED7ng \u0111i t\u1EDBi Cipher/HashMac.`
|
|
70
|
+
});
|
|
56
71
|
}
|
|
57
72
|
}
|
|
58
73
|
if (isConfig) {
|
|
@@ -325,8 +325,9 @@ var GENERIC_PATTERNS = [
|
|
|
325
325
|
},
|
|
326
326
|
{
|
|
327
327
|
name: "empty-password-assignment",
|
|
328
|
-
regex: /\b(
|
|
328
|
+
regex: /\b([A-Za-z_$][\w$]*(?:password|passwd|pwd))\s*[:=]\s*["']\s*["']/gi,
|
|
329
329
|
confidence: 85,
|
|
330
|
+
keyGroup: 1,
|
|
330
331
|
message: "Empty password assignment detected (CWE-258 / CWE-798). Passwords must not be empty."
|
|
331
332
|
},
|
|
332
333
|
{
|
|
@@ -603,6 +604,7 @@ var EMPTY_PASSWORD_PATTERNS = /* @__PURE__ */ new Set([
|
|
|
603
604
|
"empty-password-method-call"
|
|
604
605
|
]);
|
|
605
606
|
var isClientOnly = (path, language) => path.toLowerCase().endsWith(".vue") || language === "typescript" || language === "javascript";
|
|
607
|
+
var SERVICE_QUALIFIED_CREDENTIAL_RE = /^(?:smtp|smtps|mail|email|ldap|ad|db|database|sql|mysql|mariadb|postgres|mongo|redis|memcached|kafka|rabbit|amqp|proxy|ftp|sftp|ssl|tls|keystore|truststore|admin|root|api|client|server|sso|basic|digest|oauth|vault)\s*(?:password|passwd|pwd)$/i;
|
|
606
608
|
var isI18nKey = (payload) => /^[A-Z][A-Z0-9_]*(?:\.[A-Z0-9_]+)+$/.test(payload);
|
|
607
609
|
var isConstantNameEcho = (matched, payload) => {
|
|
608
610
|
const key = /^\s*([A-Za-z_$][\w$]*)/.exec(matched)?.[1] ?? "";
|
|
@@ -632,6 +634,8 @@ var hasPemBody = (content, headerEnd) => {
|
|
|
632
634
|
};
|
|
633
635
|
var rule = {
|
|
634
636
|
id: "general/no-hardcoded-secret",
|
|
637
|
+
// v15: route constants using the PWD abbreviation (CHANGE_PWD: 'change-password')
|
|
638
|
+
// are semantic key echoes, not stored passwords.
|
|
635
639
|
// v14: a key that NAMES another object (Helm `tlsSecret: my-tls`, `FIELD_PASSWORD = "FieldName"`).
|
|
636
640
|
// v13: a PEM private-key header only fires when key material follows (hasPemBody).
|
|
637
641
|
// v12 (UBCK, 2026-09-25): v11's browser-only skip extends to Angular TS/JS; an empty-password
|
|
@@ -661,7 +665,7 @@ var rule = {
|
|
|
661
665
|
// v2 (1.2.1): added FIELD_NAME_ECHOES filter for enum-value / label-dict
|
|
662
666
|
// FPs (e.g. `PASSWORD = 'password'`). Bumped so the rule cache invalidates
|
|
663
667
|
// stale v1 findings — Phase 9 cache key is (id, version, file.hash).
|
|
664
|
-
version:
|
|
668
|
+
version: 15,
|
|
665
669
|
kind: "static-ts",
|
|
666
670
|
title: "Kh\xF4ng hardcode secrets / API keys / private keys v\xE0o source",
|
|
667
671
|
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.",
|
|
@@ -684,9 +688,7 @@ var rule = {
|
|
|
684
688
|
const extras = compileExtra(ctx.options.extraPatterns, ctx.logger);
|
|
685
689
|
const clientOnly = isClientOnly(ctx.file.path, ctx.file.language);
|
|
686
690
|
const patterns = [
|
|
687
|
-
...BUILTIN_PATTERNS.filter(
|
|
688
|
-
(p) => !disabled.has(p.name) && !(clientOnly && EMPTY_PASSWORD_PATTERNS.has(p.name))
|
|
689
|
-
),
|
|
691
|
+
...BUILTIN_PATTERNS.filter((p) => !disabled.has(p.name)),
|
|
690
692
|
...!disabled.has(HTTP_URL_SECRET_PATTERN.name) ? [HTTP_URL_SECRET_PATTERN] : [],
|
|
691
693
|
...isConfigLanguage(ctx.file.language) ? CONFIG_SECRET_PATTERNS.filter((p) => !disabled.has(p.name)) : [],
|
|
692
694
|
...ctx.file.language === "xml" ? XML_SECRET_PATTERNS.filter((p) => !disabled.has(p.name)) : [],
|
|
@@ -711,12 +713,17 @@ var rule = {
|
|
|
711
713
|
const encrypted = payload !== void 0 && /^(?:ENC\(|\{cipher\})/i.test(payload.trim());
|
|
712
714
|
const keyValue = pattern.keyGroup !== void 0 ? match[pattern.keyGroup] ?? void 0 : void 0;
|
|
713
715
|
const isKeySelfEcho = payload !== void 0 && keyValue !== void 0 && normalizeKeyish(payload) === normalizeKeyish(keyValue);
|
|
716
|
+
const isRouteAliasEcho = payload !== void 0 && keyValue !== void 0 && /^[A-Z][A-Z0-9_]*_PWD$/.test(keyValue) && looksLikeRoutePath(payload) && normalizeKeyish(payload) === normalizeKeyish(keyValue.replace(/_PWD$/, "_PASSWORD"));
|
|
714
717
|
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))) {
|
|
718
|
+
if (payload && (looksLikePlaceholder(payload) || isFieldNameEcho(payload) && pattern.name.startsWith("generic-") || looksLikeRoutePath(payload) && pattern.name.startsWith("generic-") && isCamelCaseKey || isKeySelfEcho && pattern.name.startsWith("generic-") || isRouteAliasEcho && 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
719
|
continue;
|
|
717
720
|
}
|
|
718
|
-
if (EMPTY_PASSWORD_PATTERNS.has(pattern.name)
|
|
719
|
-
continue;
|
|
721
|
+
if (EMPTY_PASSWORD_PATTERNS.has(pattern.name)) {
|
|
722
|
+
if (isBenignEmpty(content, matchStart)) continue;
|
|
723
|
+
if (clientOnly) {
|
|
724
|
+
const key = pattern.keyGroup !== void 0 ? match[pattern.keyGroup] ?? "" : "";
|
|
725
|
+
if (!SERVICE_QUALIFIED_CREDENTIAL_RE.test(key)) continue;
|
|
726
|
+
}
|
|
720
727
|
}
|
|
721
728
|
if (pattern.name.startsWith("private-key") && !hasPemBody(content, matchEnd)) {
|
|
722
729
|
continue;
|
|
@@ -11,6 +11,7 @@ var rule = {
|
|
|
11
11
|
description: "Ph\xE1t hi\u1EC7n li\xEAn k\u1EBFt ho\u1EB7c t\xE0i nguy\xEAn ngo\u1EA1i b\u1ED9 (<a href>, <script src>, <link href>) s\u1EED d\u1EE5ng giao th\u1EE9c cleartext http:// thay v\xEC https://. D\u1EEF li\u1EC7u truy\u1EC1n t\u1EA3i c\xF3 nguy c\u01A1 b\u1ECB nghe l\xE9n, gi\u1EA3 m\u1EA1o ho\u1EB7c t\u1EA5n c\xF4ng Man-In-The-Middle (CWE-319).",
|
|
12
12
|
severity: "warning",
|
|
13
13
|
category: "security",
|
|
14
|
+
sourceTools: ["fortify"],
|
|
14
15
|
languages: ["html"],
|
|
15
16
|
scope: "general",
|
|
16
17
|
requires: "text",
|
|
@@ -2,6 +2,7 @@ import { isExcludedHost } from '@code-sentinel/parsers';
|
|
|
2
2
|
|
|
3
3
|
// builtin-rules/static/general/no-insecure-password-submission.rule.ts
|
|
4
4
|
var HTML_FILE_RE = /\.(?:html|htm|jsp|xhtml|ftl)$/i;
|
|
5
|
+
var SUBMIT_INTERCEPTOR_RE = /\(\s*(?:ngSubmit|ngForm)\s*\)[\s=]|ngNoForm|\[\(ngSubmit\)\]|onsubmit\s*=\s*["'][^"']*preventDefault|\(\s*ngSubmit\s*=/i;
|
|
5
6
|
var lineColumnAt = (content, index) => {
|
|
6
7
|
const safeIndex = Math.max(0, Math.min(index, content.length));
|
|
7
8
|
const before = content.slice(0, safeIndex);
|
|
@@ -10,12 +11,13 @@ var lineColumnAt = (content, index) => {
|
|
|
10
11
|
};
|
|
11
12
|
var rule = {
|
|
12
13
|
id: "general/no-insecure-password-submission",
|
|
13
|
-
version:
|
|
14
|
+
version: 4,
|
|
14
15
|
kind: "static-ts",
|
|
15
16
|
title: "Kh\xF4ng submit m\u1EADt kh\u1EA9u qua HTTP cleartext ho\u1EB7c method GET",
|
|
16
|
-
description: 'Form nh\u1EADp m\u1EADt kh\u1EA9u g\u1EEDi d\u1EEF li\u1EC7u qua HTTP kh\xF4ng m\xE3 h\xF3a (CWE-319, WSTG-ATHN-01)
|
|
17
|
+
description: 'Form nh\u1EADp m\u1EADt kh\u1EA9u g\u1EEDi d\u1EEF li\u1EC7u qua HTTP kh\xF4ng m\xE3 h\xF3a (CWE-319, WSTG-ATHN-01), d\xF9ng method="GET" (CWE-598), khai b\xE1o formaction HTTP cleartext, ho\u1EB7c kh\xF4ng c\xF3 `action` m\xE0 c\u0169ng kh\xF4ng c\xF3 handler ch\u1EB7n submit \u2014 tr\u01B0\u1EDDng h\u1EE3p cu\u1ED1i khi\u1EBFn tr\xECnh duy\u1EC7t GET v\u1EC1 ch\xEDnh URL v\xE0 l\u1ED9 m\u1EADt kh\u1EA9u tr\xEAn query string/log m\xE1y ch\u1EE7.',
|
|
17
18
|
severity: "error",
|
|
18
19
|
category: "security",
|
|
20
|
+
sourceTools: ["fortify"],
|
|
19
21
|
languages: ["html", "text"],
|
|
20
22
|
scope: "general",
|
|
21
23
|
requires: "text",
|
|
@@ -51,6 +53,24 @@ var rule = {
|
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
55
|
}
|
|
56
|
+
const formActionMatch = formBody.match(
|
|
57
|
+
/<button\b[^>]*\bformaction\s*=\s*["'](http:\/\/[^"'\s>]+)["']/i
|
|
58
|
+
);
|
|
59
|
+
if (formActionMatch) {
|
|
60
|
+
const url = formActionMatch[1] ?? "";
|
|
61
|
+
const host = /^http:\/\/([A-Za-z0-9._\-]+(?::\d+)?)/i.exec(url)?.[1] ?? "";
|
|
62
|
+
if (host && !isExcludedHost(host)) {
|
|
63
|
+
const { line, column } = lineColumnAt(content, matchIndex);
|
|
64
|
+
findings.push({
|
|
65
|
+
message: `N\xFAt submit c\u1EE7a form m\u1EADt kh\u1EA9u khai b\xE1o formaction HTTP cleartext: ${url} (CWE-319).`,
|
|
66
|
+
file: file.path,
|
|
67
|
+
range: { line, column },
|
|
68
|
+
severity: "error",
|
|
69
|
+
confidence: 85,
|
|
70
|
+
suggestion: "B\u1ECF `formaction` ho\u1EB7c tr\u1ECF t\u1EDBi endpoint HTTPS c\xF3 ch\u1EE9ng ch\u1EC9 CA h\u1EE3p l\u1EC7."
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
54
74
|
const methodMatch = formAttrs.match(/\bmethod\s*=\s*["']get["']/i);
|
|
55
75
|
if (methodMatch) {
|
|
56
76
|
const { line, column } = lineColumnAt(content, matchIndex);
|
|
@@ -63,6 +83,18 @@ var rule = {
|
|
|
63
83
|
suggestion: 'S\u1EED d\u1EE5ng method="POST" \u0111\u1EC3 truy\u1EC1n th\xF4ng tin x\xE1c th\u1EF1c trong request body.'
|
|
64
84
|
});
|
|
65
85
|
}
|
|
86
|
+
const postsExplicitly = /\bmethod\s*=\s*["']post["']/i.test(formAttrs);
|
|
87
|
+
if (!/\baction\s*=/i.test(formAttrs) && !methodMatch && !postsExplicitly && !SUBMIT_INTERCEPTOR_RE.test(formAttrs) && !SUBMIT_INTERCEPTOR_RE.test(formBody)) {
|
|
88
|
+
const { line, column } = lineColumnAt(content, matchIndex);
|
|
89
|
+
findings.push({
|
|
90
|
+
message: "Form ch\u1EE9a \xF4 m\u1EADt kh\u1EA9u nh\u01B0ng kh\xF4ng c\xF3 `action` v\xE0 kh\xF4ng c\xF3 handler submit \u2192 tr\xECnh duy\u1EC7t g\u1EEDi m\u1EB7c \u0111\u1ECBnh b\u1EB1ng GET t\u1EDBi ch\xEDnh URL hi\u1EC7n t\u1EA1i, l\xE0m l\u1ED9 m\u1EADt kh\u1EA9u tr\xEAn query string v\xE0 log m\xE1y ch\u1EE7 (CWE-598).",
|
|
91
|
+
file: file.path,
|
|
92
|
+
range: { line, column },
|
|
93
|
+
severity: "error",
|
|
94
|
+
confidence: 80,
|
|
95
|
+
suggestion: 'Khai b\xE1o `method="post"` v\xE0 `action` tr\u1ECF t\u1EDBi endpoint HTTPS, ho\u1EB7c ch\u1EAFc ch\u1EAFn framework \u0111\xE3 ch\u1EB7n submit qua `(ngSubmit)`/`preventDefault()`.'
|
|
96
|
+
});
|
|
97
|
+
}
|
|
66
98
|
}
|
|
67
99
|
m = formRe.exec(content);
|
|
68
100
|
}
|
|
@@ -9,6 +9,7 @@ var rule = {
|
|
|
9
9
|
description: "Ph\xE1t hi\u1EC7n password/token/secret/PII b\u1ECB \u0111\u01B0a v\xE0o Java logger, System.out/System.err, ho\u1EB7c browser console. D\xF9ng c\xF9ng b\u1EB1ng ch\u1EE9ng v\u1EDBi `cs assess` checklist #83 (CWE-532).",
|
|
10
10
|
severity: "warning",
|
|
11
11
|
category: "security",
|
|
12
|
+
sourceTools: ["fortify"],
|
|
12
13
|
languages: ["java", "typescript", "javascript"],
|
|
13
14
|
scope: "general",
|
|
14
15
|
requires: "syntactic",
|
|
@@ -9,6 +9,7 @@ var rule = {
|
|
|
9
9
|
description: "Ki\u1EC3m tra dependency spring-boot-devtools. Profile pentest ghi nh\u1EADn c\u1EA3 optional/developmentOnly \u0111\u1EC3 review profile build, JAR/WAR v\xE0 runtime; khai b\xE1o dependency ch\u01B0a ch\u1EE9ng minh DevTools \u0111ang b\u1EADt production.",
|
|
10
10
|
severity: "error",
|
|
11
11
|
category: "security",
|
|
12
|
+
sourceTools: ["fortify"],
|
|
12
13
|
languages: ["xml", "text"],
|
|
13
14
|
scope: "spring-boot",
|
|
14
15
|
requires: "text",
|