@code-sentinel-cli/code-sentinel-cli 4.0.9 → 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 +7204 -914
- package/dist/builtin-rules/ai/spring-boot/ownership-scope-risk.rule.yaml +1 -0
- package/dist/builtin-rules/ai/spring-boot/security-authorization-risk.rule.yaml +1 -0
- package/dist/builtin-rules/ai/spring-boot/security-mass-assignment-risk.rule.yaml +1 -0
- package/dist/builtin-rules/ai/spring-boot/state-transition-guard-risk.rule.yaml +1 -0
- package/dist/builtin-rules/fortify/ai/angular/cross-feature-route-permission-drift.rule.yaml +2 -0
- package/dist/builtin-rules/fortify/ai/angular/route-permission-flow.rule.yaml +2 -0
- package/dist/builtin-rules/fortify/ai/spring-boot/io-boundary-risk.rule.yaml +1 -0
- package/dist/builtin-rules/fortify/ai/spring-boot/security-redirect-risk.rule.yaml +2 -0
- package/dist/builtin-rules/fortify/ai/spring-boot/security-sensitive-data-risk.rule.yaml +2 -0
- package/dist/builtin-rules/fortify/static/angular/sensitive-input-masking.rule.js +1 -0
- package/dist/builtin-rules/fortify/static/general/java-weak-randomness.rule.js +2 -0
- package/dist/builtin-rules/fortify/static/general/no-client-identity-header.rule.js +1 -0
- package/dist/builtin-rules/fortify/static/general/no-guessable-websql-database-name.rule.js +1 -0
- package/dist/builtin-rules/fortify/static/general/no-reflective-access-override.rule.js +1 -0
- package/dist/builtin-rules/fortify/static/general/no-sensitive-string-materialization.rule.js +1 -0
- package/dist/builtin-rules/fortify/static/spring-boot/no-command-injection.rule.js +2 -0
- package/dist/builtin-rules/fortify/static/spring-boot/no-path-traversal.rule.js +8 -1
- package/dist/builtin-rules/fortify/static/spring-boot/no-servlet-xss.rule.js +2 -0
- package/dist/builtin-rules/fortify/static/spring-boot/no-spel-injection.rule.js +2 -0
- package/dist/builtin-rules/fortify/static/spring-boot/no-sql-string-concat.rule.js +2 -0
- package/dist/builtin-rules/fortify/static/spring-boot/no-ssrf.rule.js +2 -0
- package/dist/builtin-rules/fortify/static/spring-boot/no-trust-boundary-violation.rule.js +43 -0
- package/dist/builtin-rules/fortify/static/spring-boot/no-weak-tls-protocol.rule.js +2 -0
- package/dist/builtin-rules/static/angular/no-dom-xss.rule.js +1 -0
- package/dist/builtin-rules/static/angular/template-dom-xss.rule.js +1 -0
- package/dist/builtin-rules/static/flutter/INVENTORY.md +44 -0
- package/dist/builtin-rules/static/flutter/NATIVE-INVENTORY.md +34 -0
- package/dist/builtin-rules/static/flutter/android-cleartext-traffic.rule.js +105 -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 +86 -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 +81 -0
- package/dist/builtin-rules/static/flutter/biometric-without-crypto-object.rule.js +87 -0
- package/dist/builtin-rules/static/flutter/cleartext-http-endpoint.rule.js +77 -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 +74 -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 +119 -0
- package/dist/builtin-rules/static/flutter/hardcoded-crypto-key.rule.js +125 -0
- package/dist/builtin-rules/static/flutter/hardcoded-oauth-client-secret.rule.js +108 -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 +154 -0
- package/dist/builtin-rules/static/flutter/ios-ats-exception.rule.js +83 -0
- package/dist/builtin-rules/static/flutter/ios-pasteboard-leak.rule.js +96 -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 +81 -0
- package/dist/builtin-rules/static/flutter/oauth-missing-pkce.rule.js +75 -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 +121 -0
- package/dist/builtin-rules/static/flutter/tracking-sdk-init.rule.js +76 -0
- package/dist/builtin-rules/static/flutter/weak-mobile-crypto-algorithm.rule.js +114 -0
- package/dist/builtin-rules/static/flutter/weak-prng-mobile.rule.js +104 -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/kubernetes-pod-security.rule.js +1 -0
- package/dist/builtin-rules/static/general/no-dynamic-code-eval.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 +72 -9
- 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/no-unsafe-html-sink.rule.js +1 -0
- package/dist/builtin-rules/static/general/no-unused-export.rule.js +1 -0
- package/dist/builtin-rules/static/general/openapi-https-credentials.rule.js +1 -0
- 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/builtin-rules/static/spring-boot/no-unsafe-shared-formatter.rule.js +1 -0
- package/dist/builtin-rules/static/spring-boot/no-unzoned-datetime.rule.js +1 -0
- package/dist/builtin-rules/static/spring-boot/validate-input.rule.js +1 -0
- package/dist/index.d.ts +467 -0
- package/dist/index.js +7203 -913
- package/node_modules/@code-sentinel/parsers/index.js +81 -4
- package/package.json +1 -1
|
@@ -269,6 +269,20 @@ var isLoopback = (host) => {
|
|
|
269
269
|
const h = host.toLowerCase();
|
|
270
270
|
return h === "localhost" || h === "127.0.0.1" || h === "0.0.0.0" || h === "::1";
|
|
271
271
|
};
|
|
272
|
+
var UNREFERENCABLE_BASE_IMAGE = /* @__PURE__ */ new Set(["scratch"]);
|
|
273
|
+
var baseImageReference = (instruction) => instruction.trim().replace(/^FROM\s+/i, "").split(/\s+/).find((w) => w.length > 0 && !w.startsWith("--")) ?? "";
|
|
274
|
+
var FLOATING_TAG_RE = /(?:^|\.)[xX*]$|^\*$/;
|
|
275
|
+
var unpinnedBaseImageReason = (reference) => {
|
|
276
|
+
const image = reference.trim();
|
|
277
|
+
if (!image || UNREFERENCABLE_BASE_IMAGE.has(image.toLowerCase())) return null;
|
|
278
|
+
if (image.includes("@")) return null;
|
|
279
|
+
const lastSlash = image.lastIndexOf("/");
|
|
280
|
+
const lastColon = image.lastIndexOf(":");
|
|
281
|
+
const hasTag = lastColon > lastSlash;
|
|
282
|
+
const tag = hasTag ? image.slice(lastColon + 1) : "";
|
|
283
|
+
if (hasTag && tag && tag !== "latest" && !FLOATING_TAG_RE.test(tag)) return null;
|
|
284
|
+
return hasTag && tag === "latest" ? `Base image \`${image}\` d\xF9ng tag \`latest\` \u2014 kh\xF4ng c\xF3 version r\xE0ng bu\u1ED9c, tag n\xE0y c\xF3 th\u1EC3 b\u1ECB \u0111\u1ED5i n\u1ED9i dung b\u1EA5t k\u1EF3 l\xFAc n\xE0o (CWE-427).` : `Base image \`${image}\` kh\xF4ng c\xF3 tag/digest \u2014 m\u1EB7c \u0111\u1ECBnh l\xE0 \`latest\`, ai \u0111\xF3 c\xF3 quy\u1EC1n \u0111\u1EA9y l\xEAn registry \u0111\u1EC1u thay \u0111\u01B0\u1EE3c image n\xE0y (CWE-427).`;
|
|
285
|
+
};
|
|
272
286
|
var auditDockerfileDependencyConfusion = (content, filePath) => {
|
|
273
287
|
const lines = content.split("\n");
|
|
274
288
|
const hits = [];
|
|
@@ -302,6 +316,20 @@ var auditDockerfileDependencyConfusion = (content, filePath) => {
|
|
|
302
316
|
line: i + 1,
|
|
303
317
|
reason: "Dockerfile c\u1EA5u h\xECnh kho th\u01B0 vi\u1EC7n (registry) qua giao th\u1EE9c HTTP kh\xF4ng m\xE3 h\xF3a (cleartext) \u2014 CWE-319."
|
|
304
318
|
});
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
if (/^FROM\s+\S/i.test(trimmed)) {
|
|
322
|
+
const reason = unpinnedBaseImageReason(baseImageReference(trimmed));
|
|
323
|
+
if (reason) {
|
|
324
|
+
hits.push({
|
|
325
|
+
file: filePath,
|
|
326
|
+
line: i + 1,
|
|
327
|
+
reason,
|
|
328
|
+
severity: "warning",
|
|
329
|
+
confidence: 75,
|
|
330
|
+
suggestion: "Ghim base image b\u1EB1ng digest b\u1EA5t bi\u1EBFn (`image@sha256:\u2026`) ho\u1EB7c \xEDt nh\u1EA5t m\u1ED9t tag c\u1EE5 th\u1EC3 kh\xF4ng ph\u1EA3i `latest`; v\u1EDBi registry n\u1ED9i b\u1ED9, b\u1EADt immutability/tag protection."
|
|
331
|
+
});
|
|
332
|
+
}
|
|
305
333
|
}
|
|
306
334
|
}
|
|
307
335
|
return hits;
|
|
@@ -407,6 +435,7 @@ var auditPasswordAutocompleteContent = (content, filePath) => {
|
|
|
407
435
|
// src/security/third-party-asset.ts
|
|
408
436
|
var FRONTEND_EXT_RE = /\.(?:js|mjs|cjs|jsx|ts|tsx|vue|html?|css)$/i;
|
|
409
437
|
var VENDOR_DIR_RE = /(?:^|[/\\])(?:node_modules|bower_components|vendors?|libs?|deps|third[-_]?party|\.angular)(?:[/\\])/i;
|
|
438
|
+
var ANGULAR_LIBRARY_SRC_RE = /\/src\/libs?\//gi;
|
|
410
439
|
var GENERATED_NAME_RE = /(?:\.min\.(?:js|css)|\.bundle\.js|(?:^|[/\\])chunk-[\w-]+\.js)$/i;
|
|
411
440
|
var JQUERY_PLUGIN_RE = /(?:^|[/\\])jquery[._-][^/\\]*\.js$/i;
|
|
412
441
|
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;
|
|
@@ -415,7 +444,7 @@ var MINIFIED_AVG_LINE = 500;
|
|
|
415
444
|
var isThirdPartyAsset = (path, content) => {
|
|
416
445
|
if (!FRONTEND_EXT_RE.test(path)) return false;
|
|
417
446
|
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)) {
|
|
447
|
+
if (VENDOR_DIR_RE.test(normalized.replace(ANGULAR_LIBRARY_SRC_RE, "/")) || GENERATED_NAME_RE.test(normalized) || JQUERY_PLUGIN_RE.test(normalized) || KNOWN_LIBRARY_RE.test(normalized)) {
|
|
419
448
|
return true;
|
|
420
449
|
}
|
|
421
450
|
if (content === void 0 || content.length === 0) return false;
|
|
@@ -445,7 +474,9 @@ var findSensitiveToken = (raw) => {
|
|
|
445
474
|
const code = stripNonValueExpressions(raw);
|
|
446
475
|
for (const m of code.matchAll(IDENTIFIER_RE)) {
|
|
447
476
|
const token = m[0];
|
|
448
|
-
if (isSecretIdentifier(token))
|
|
477
|
+
if (!isSecretIdentifier(token)) continue;
|
|
478
|
+
if (callsPropertyAccessor(code.slice((m.index ?? 0) + token.length))) continue;
|
|
479
|
+
return { token, confidence: 75 };
|
|
449
480
|
}
|
|
450
481
|
for (const m of code.matchAll(PII_RE)) {
|
|
451
482
|
return { token: m[0], confidence: 70 };
|
|
@@ -453,6 +484,37 @@ var findSensitiveToken = (raw) => {
|
|
|
453
484
|
return null;
|
|
454
485
|
};
|
|
455
486
|
var IDENTIFIER_RE = /[A-Za-z_$][\w$]*/g;
|
|
487
|
+
var VALUE_METHOD_RE = /^(?:toString|value|getValue|getTokenValue|getToken|getAccessToken|getRefreshToken|getIdToken|getPassword|getSecret|getCredentials|getKey|getPrivateKey|getEncoded|getBytes|toCharArray|trim|strip|substring|serialize|compact|toJSON)$/;
|
|
488
|
+
var callsPropertyAccessor = (rest) => {
|
|
489
|
+
const m = /^\s*(?:\(\s*\)\s*)?\.\s*([A-Za-z_$][\w$]*)\s*\(/.exec(rest);
|
|
490
|
+
return m !== null && !VALUE_METHOD_RE.test(m[1] ?? "");
|
|
491
|
+
};
|
|
492
|
+
var TOKEN_COUNT_PREFIXES = /* @__PURE__ */ new Set([
|
|
493
|
+
"input",
|
|
494
|
+
"output",
|
|
495
|
+
"max",
|
|
496
|
+
"min",
|
|
497
|
+
"prompt",
|
|
498
|
+
"completion",
|
|
499
|
+
"cached",
|
|
500
|
+
"used",
|
|
501
|
+
"remaining"
|
|
502
|
+
]);
|
|
503
|
+
var FLAG_PREFIXES = /* @__PURE__ */ new Set([
|
|
504
|
+
"use",
|
|
505
|
+
"has",
|
|
506
|
+
"is",
|
|
507
|
+
"should",
|
|
508
|
+
"require",
|
|
509
|
+
"requires"
|
|
510
|
+
]);
|
|
511
|
+
var MASK_PREFIXES = /* @__PURE__ */ new Set([
|
|
512
|
+
"mask",
|
|
513
|
+
"redact",
|
|
514
|
+
"obfuscate",
|
|
515
|
+
"sanitize",
|
|
516
|
+
"hide"
|
|
517
|
+
]);
|
|
456
518
|
var SECRET_SEGMENTS = /* @__PURE__ */ new Set([
|
|
457
519
|
"password",
|
|
458
520
|
"passwd",
|
|
@@ -503,15 +565,30 @@ var PROTECTED_SEGMENTS = /* @__PURE__ */ new Set([
|
|
|
503
565
|
"url",
|
|
504
566
|
"uri",
|
|
505
567
|
"endpoint",
|
|
506
|
-
"path"
|
|
568
|
+
"path",
|
|
569
|
+
// Describes the secret's state or origin, not its value (dvc-backend 2026-09-25:
|
|
570
|
+
// `secretConfigured`, `secretSource`, `apiKeyRef`, `credentialMissingMessage`, `tokenEx`).
|
|
571
|
+
"ref",
|
|
572
|
+
"reference",
|
|
573
|
+
"source",
|
|
574
|
+
"configured",
|
|
575
|
+
"missing",
|
|
576
|
+
"message",
|
|
577
|
+
"ex",
|
|
578
|
+
"exception",
|
|
579
|
+
"error",
|
|
580
|
+
"err"
|
|
507
581
|
]);
|
|
508
582
|
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
583
|
var isSecretIdentifier = (identifier) => {
|
|
510
584
|
if (/^[A-Z0-9_]+$/.test(identifier) && /[A-Z]/.test(identifier)) return false;
|
|
511
585
|
const segs = segmentsOf(identifier);
|
|
512
586
|
if (segs[0] === "lock") return false;
|
|
587
|
+
if (FLAG_PREFIXES.has(segs[0] ?? "") || MASK_PREFIXES.has(segs[0] ?? "")) return false;
|
|
513
588
|
for (let i = 0; i < segs.length; i++) {
|
|
514
589
|
const seg = segs[i] ?? "";
|
|
590
|
+
if ((seg === "token" || seg === "tokens") && TOKEN_COUNT_PREFIXES.has(segs[i - 1] ?? ""))
|
|
591
|
+
continue;
|
|
515
592
|
const pair = i + 1 < segs.length ? `${seg} ${segs[i + 1]}` : "";
|
|
516
593
|
const hit = SECRET_SEGMENTS.has(seg) || SECRET_SEGMENT_PAIRS.has(pair) || SECRET_SUBSTRING_RE.test(seg);
|
|
517
594
|
if (!hit) continue;
|
|
@@ -521,7 +598,7 @@ var isSecretIdentifier = (identifier) => {
|
|
|
521
598
|
}
|
|
522
599
|
return false;
|
|
523
600
|
};
|
|
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(
|
|
601
|
+
var stripNonValueExpressions = (code) => code.replace(/\b(?:mask|redact|obfuscate|sanitize|hide)\w*\s*\([^()]*\)/gi, " ").replace(/[\w$.]+\s*[!=]==?\s*null\b|\bnull\s*[!=]==?\s*[\w$.]+/g, " ").replace(/[\w$]+\s*\.\s*(?:isEmpty|isBlank|length|size|hashCode)\s*\(\s*\)/g, " ").replace(/[\w$.]+(?:\(\s*\))?\s*\.\s*length\b(?!\s*\()/g, " ").replace(
|
|
525
602
|
/\b(?:[A-Z]\w*\s*\.\s*)?(?:isEmpty|isBlank|isNotEmpty|isNotBlank|isNull|isNotNull|nonNull|hasText|hasLength)\s*\(\s*[\w$.]+\s*\)/g,
|
|
526
603
|
" "
|
|
527
604
|
);
|