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

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 (34) hide show
  1. package/dist/bin.js +17536 -12664
  2. package/dist/builtin-rules/{ai → fortify/ai}/angular/cross-feature-route-permission-drift.rule.yaml +4 -0
  3. package/dist/builtin-rules/{ai → fortify/ai}/angular/route-permission-flow.rule.yaml +4 -0
  4. package/dist/builtin-rules/{ai → fortify/ai}/spring-boot/io-boundary-risk.rule.yaml +4 -0
  5. package/dist/builtin-rules/{ai → fortify/ai}/spring-boot/security-redirect-risk.rule.yaml +4 -0
  6. package/dist/builtin-rules/{ai → fortify/ai}/spring-boot/security-sensitive-data-risk.rule.yaml +4 -0
  7. package/dist/builtin-rules/{static → fortify/static}/angular/sensitive-input-masking.rule.js +5 -1
  8. package/dist/builtin-rules/{static → fortify/static}/general/java-weak-randomness.rule.js +5 -1
  9. package/dist/builtin-rules/{static → fortify/static}/general/no-client-identity-header.rule.js +5 -1
  10. package/dist/builtin-rules/{static → fortify/static}/general/no-guessable-websql-database-name.rule.js +5 -1
  11. package/dist/builtin-rules/{static → fortify/static}/general/no-reflective-access-override.rule.js +5 -1
  12. package/dist/builtin-rules/{static → fortify/static}/general/no-sensitive-string-materialization.rule.js +5 -1
  13. package/dist/builtin-rules/{static → fortify/static}/spring-boot/no-command-injection.rule.js +5 -1
  14. package/dist/builtin-rules/{static → fortify/static}/spring-boot/no-path-traversal.rule.js +5 -1
  15. package/dist/builtin-rules/{static → fortify/static}/spring-boot/no-servlet-xss.rule.js +5 -1
  16. package/dist/builtin-rules/{static → fortify/static}/spring-boot/no-spel-injection.rule.js +5 -1
  17. package/dist/builtin-rules/{static → fortify/static}/spring-boot/no-sql-string-concat.rule.js +5 -1
  18. package/dist/builtin-rules/{static → fortify/static}/spring-boot/no-ssrf.rule.js +5 -1
  19. package/dist/builtin-rules/{static → fortify/static}/spring-boot/no-weak-tls-protocol.rule.js +5 -1
  20. package/dist/builtin-rules/performance/static/spring-boot/http-client-without-timeout.rule.js +83 -0
  21. package/dist/builtin-rules/performance/static/spring-boot/open-in-view-enabled.rule.js +89 -0
  22. package/dist/builtin-rules/performance/static/spring-boot/transaction-holds-remote-call.rule.js +323 -0
  23. package/dist/builtin-rules/performance/static/spring-boot/unbounded-repository-fetch.rule.js +125 -0
  24. package/dist/builtin-rules/performance/static/spring-boot/xssf-workbook-for-export.rule.js +81 -0
  25. package/dist/builtin-rules/static/general/no-circular-import.rule.js +12 -2
  26. package/dist/builtin-rules/static/general/no-open-redirect.rule.js +7 -3
  27. package/dist/index.d.ts +273 -101
  28. package/dist/index.js +17538 -12666
  29. package/package.json +1 -1
  30. /package/dist/builtin-rules/{ai → fortify/ai}/angular/cross-feature-route-permission-drift.prompt.md +0 -0
  31. /package/dist/builtin-rules/{ai → fortify/ai}/angular/route-permission-flow.prompt.md +0 -0
  32. /package/dist/builtin-rules/{ai → fortify/ai}/spring-boot/io-boundary-risk.prompt.md +0 -0
  33. /package/dist/builtin-rules/{ai → fortify/ai}/spring-boot/security-redirect-risk.prompt.md +0 -0
  34. /package/dist/builtin-rules/{ai → fortify/ai}/spring-boot/security-sensitive-data-risk.prompt.md +0 -0
@@ -1,4 +1,8 @@
1
1
  id: angular/cross-feature-route-permission-drift
2
+ # Fortify-family AI detectors: pentest-only by default. `cs review` runs them
3
+ # ONLY when the pack is activated (`rules.packs: ['fortify']` or --packs fortify);
4
+ # `cs assess` always activates the pack for its fold lanes (fold-rules.ts).
5
+ pack: fortify
2
6
  # v2 (Phase 15.5.3): POC gate PASSED on ctdv/periodic-report (GLM-4.7) —
3
7
  # 2/2 findings TP = 100% precision (>= 80% ADR-0016 bar). The finding (route
4
8
  # guard on add/edit/detail vs UI-only `*hasPermission` for delete/export on
@@ -1,4 +1,8 @@
1
1
  id: angular/route-permission-flow
2
+ # Fortify-family AI detectors: pentest-only by default. `cs review` runs them
3
+ # ONLY when the pack is activated (`rules.packs: ['fortify']` or --packs fortify);
4
+ # `cs assess` always activates the pack for its fold lanes (fold-rules.ts).
5
+ pack: fortify
2
6
  # v5 (ADR-0065 calibration): conf 60→85 (đo 21/21 TP)
3
7
  version: 5
4
8
  kind: ai
@@ -1,4 +1,8 @@
1
1
  id: spring-boot/io-boundary-risk
2
+ # Fortify-family AI detectors: pentest-only by default. `cs review` runs them
3
+ # ONLY when the pack is activated (`rules.packs: ['fortify']` or --packs fortify);
4
+ # `cs assess` always activates the pack for its fold lanes (fold-rules.ts).
5
+ pack: fortify
2
6
  version: 2
3
7
  kind: ai
4
8
  title: "Spring Boot filesystem/HTTP/queue boundary co rui ro khong?"
@@ -1,4 +1,8 @@
1
1
  id: spring-boot/security-redirect-risk
2
+ # Fortify-family AI detectors: pentest-only by default. `cs review` runs them
3
+ # ONLY when the pack is activated (`rules.packs: ['fortify']` or --packs fortify);
4
+ # `cs assess` always activates the pack for its fold lanes (fold-rules.ts).
5
+ pack: fortify
2
6
  version: 2
3
7
  kind: ai
4
8
  title: "Spring Boot open redirect or unsafe forward?"
@@ -1,4 +1,8 @@
1
1
  id: spring-boot/security-sensitive-data-risk
2
+ # Fortify-family AI detectors: pentest-only by default. `cs review` runs them
3
+ # ONLY when the pack is activated (`rules.packs: ['fortify']` or --packs fortify);
4
+ # `cs assess` always activates the pack for its fold lanes (fold-rules.ts).
5
+ pack: fortify
2
6
  version: 3
3
7
  kind: ai
4
8
  title: "Spring Boot sensitive data exposure?"
@@ -1,6 +1,6 @@
1
1
  import { asTreeSitterTree } from '@code-sentinel/parsers';
2
2
 
3
- // builtin-rules/static/angular/sensitive-input-masking.rule.ts
3
+ // builtin-rules/fortify/static/angular/sensitive-input-masking.rule.ts
4
4
  var SENSITIVE_IDENTITY_ATTRS = /* @__PURE__ */ new Set(["name", "id", "formcontrolname"]);
5
5
  var VISIBLE_TEXT_TYPES = /* @__PURE__ */ new Set(["text", "search", "email", "url", "tel"]);
6
6
  var PASSWORD_NAME_RE = /(?:password|passwd|pwd|matkhau)/i;
@@ -61,6 +61,10 @@ var inputAttributes = (tag) => {
61
61
  var isInputTag = (tag) => childOfType(tag, "tag_name")?.text.toLowerCase() === "input";
62
62
  var rule = {
63
63
  id: "angular/sensitive-input-masking",
64
+ // Fortify-family flaw detectors: pentest-only by default. `cs review` runs them
65
+ // ONLY when the pack is activated (`rules.packs: ['fortify']` or --packs fortify);
66
+ // `cs assess` always activates the pack for its fold lanes (fold-rules.ts).
67
+ pack: "fortify",
64
68
  version: 1,
65
69
  kind: "static-ts",
66
70
  title: '\xD4 nh\u1EADp m\u1EADt kh\u1EA9u ph\u1EA3i d\xF9ng type="password"',
@@ -1,8 +1,12 @@
1
1
  import { maskJavaFiles } from '@code-sentinel/parsers';
2
2
 
3
- // builtin-rules/static/general/java-weak-randomness.rule.ts
3
+ // builtin-rules/fortify/static/general/java-weak-randomness.rule.ts
4
4
  var rule = {
5
5
  id: "general/java-weak-randomness",
6
+ // Fortify-family flaw detectors: pentest-only by default. `cs review` runs them
7
+ // ONLY when the pack is activated (`rules.packs: ['fortify']` or --packs fortify);
8
+ // `cs assess` always activates the pack for its fold lanes (fold-rules.ts).
9
+ pack: "fortify",
6
10
  version: 1,
7
11
  kind: "static-ts",
8
12
  title: "Java PRNG kh\xF4ng d\xF9ng cho gi\xE1 tr\u1ECB c\u1EA7n kh\xF3 \u0111o\xE1n",
@@ -1,12 +1,16 @@
1
1
  import { maskJsComments } from '@code-sentinel/parsers';
2
2
 
3
- // builtin-rules/static/general/no-client-identity-header.rule.ts
3
+ // builtin-rules/fortify/static/general/no-client-identity-header.rule.ts
4
4
  var IDENTITY_HEADER_RE = /^(?:x-)?(?:[a-z0-9-]*)(?:user[-_]?id|userid|tenant[-_]?id|tenantid|account[-_]?id|accountid|role)$/i;
5
5
  var SET_HEADER_RE = /\.\s*setHeader\s*\(\s*(['"])([^'"\r\n]+)\1\s*,/g;
6
6
  var NAMED_HEADERS_RE = /\b(?:this\s*\.\s*)?(?:headers|httpHeaders|requestHeaders)\s*\.\s*(?:set|append)\s*\(\s*(['"])([^'"\r\n]+)\1\s*,/g;
7
7
  var lineOf = (content, index) => content.slice(0, index).split("\n").length;
8
8
  var rule = {
9
9
  id: "general/no-client-identity-header",
10
+ // Fortify-family flaw detectors: pentest-only by default. `cs review` runs them
11
+ // ONLY when the pack is activated (`rules.packs: ['fortify']` or --packs fortify);
12
+ // `cs assess` always activates the pack for its fold lanes (fold-rules.ts).
13
+ pack: "fortify",
10
14
  version: 1,
11
15
  kind: "static-ts",
12
16
  title: "Kh\xF4ng g\u1EAFn \u0111\u1ECBnh danh ho\u1EB7c quy\u1EC1n t\u1EEB HTTP header ph\xEDa client",
@@ -1,10 +1,14 @@
1
1
  import { maskJsComments } from '@code-sentinel/parsers';
2
2
 
3
- // builtin-rules/static/general/no-guessable-websql-database-name.rule.ts
3
+ // builtin-rules/fortify/static/general/no-guessable-websql-database-name.rule.ts
4
4
  var OPEN_DATABASE_LITERAL_RE = /\b(?:(?:[A-Za-z_$][\w$]*\s*\.\s*)*)openDatabase\s*\(\s*(['"])([^'"\r\n]+)\1/g;
5
5
  var lineOf = (content, index) => content.slice(0, index).split("\n").length;
6
6
  var rule = {
7
7
  id: "general/no-guessable-websql-database-name",
8
+ // Fortify-family flaw detectors: pentest-only by default. `cs review` runs them
9
+ // ONLY when the pack is activated (`rules.packs: ['fortify']` or --packs fortify);
10
+ // `cs assess` always activates the pack for its fold lanes (fold-rules.ts).
11
+ pack: "fortify",
8
12
  version: 2,
9
13
  kind: "static-ts",
10
14
  title: "Kh\xF4ng d\xF9ng t\xEAn Web SQL c\xF3 th\u1EC3 \u0111o\xE1n t\u1EEB bundle",
@@ -1,6 +1,6 @@
1
1
  import { findReflectiveAccess } from '@code-sentinel/parsers';
2
2
 
3
- // builtin-rules/static/general/no-reflective-access-override.rule.ts
3
+ // builtin-rules/fortify/static/general/no-reflective-access-override.rule.ts
4
4
  var finding = (file, line, api) => ({
5
5
  file,
6
6
  range: { line, column: 1 },
@@ -10,6 +10,10 @@ var finding = (file, line, api) => ({
10
10
  });
11
11
  var rule = {
12
12
  id: "general/no-reflective-access-override",
13
+ // Fortify-family flaw detectors: pentest-only by default. `cs review` runs them
14
+ // ONLY when the pack is activated (`rules.packs: ['fortify']` or --packs fortify);
15
+ // `cs assess` always activates the pack for its fold lanes (fold-rules.ts).
16
+ pack: "fortify",
13
17
  version: 2,
14
18
  kind: "static-ts",
15
19
  title: "Kh\xF4ng v\u01B0\u1EE3t access modifier b\u1EB1ng Java reflection",
@@ -1,6 +1,6 @@
1
1
  import { maskJavaFiles, asTreeSitterTree } from '@code-sentinel/parsers';
2
2
 
3
- // builtin-rules/static/general/no-sensitive-string-materialization.rule.ts
3
+ // builtin-rules/fortify/static/general/no-sensitive-string-materialization.rule.ts
4
4
  var STRING_CONSTRUCTOR_RE = /\bnew\s+String\s*\(\s*([^;\n]{0,300}?)(?:\)|$)/g;
5
5
  var SENSITIVE_PRODUCER_RE = /\bdecrypt\w*\s*\(|\bget(?:Password|Passwd|Pwd|Secret|Token|Key)\s*\(/i;
6
6
  var SENSITIVE_IDENTIFIER_RE = /\b\w*(?:password|passwd|pwd|secret|token|privatekey|apikey|credential|accesskey|signingkey|encryptionkey)\w*\b/i;
@@ -69,6 +69,10 @@ var firstConstructorArgument = (node) => {
69
69
  var isStringConstructor = (node) => node.type === "object_creation_expression" && node.childForFieldName("type")?.text === "String";
70
70
  var rule = {
71
71
  id: "general/no-sensitive-string-materialization",
72
+ // Fortify-family flaw detectors: pentest-only by default. `cs review` runs them
73
+ // ONLY when the pack is activated (`rules.packs: ['fortify']` or --packs fortify);
74
+ // `cs assess` always activates the pack for its fold lanes (fold-rules.ts).
75
+ pack: "fortify",
72
76
  version: 2,
73
77
  kind: "static-ts",
74
78
  title: "Kh\xF4ng chuy\u1EC3n d\u1EEF li\u1EC7u nh\u1EA1y c\u1EA3m sang Java String",
@@ -1,4 +1,4 @@
1
- // builtin-rules/static/spring-boot/no-command-injection.rule.ts
1
+ // builtin-rules/fortify/static/spring-boot/no-command-injection.rule.ts
2
2
  var COMMAND_INJECTION_SINK_IDS = /* @__PURE__ */ new Set([
3
3
  "spring/runtime-exec",
4
4
  "spring/process-builder-command",
@@ -11,6 +11,10 @@ var SINK_LABEL = {
11
11
  };
12
12
  var rule = {
13
13
  id: "spring-boot/no-command-injection",
14
+ // Fortify-family flaw detectors: pentest-only by default. `cs review` runs them
15
+ // ONLY when the pack is activated (`rules.packs: ['fortify']` or --packs fortify);
16
+ // `cs assess` always activates the pack for its fold lanes (fold-rules.ts).
17
+ pack: "fortify",
14
18
  // v4 (Pentest Coverage Layer P3 #4): the Java analyzer now folds a tainted
15
19
  // collection element (`argList.add("echo " + param)`) into the collection so
16
20
  // the whole list reaching `pb.command(argList)` / `new ProcessBuilder(argList)`
@@ -1,4 +1,4 @@
1
- // builtin-rules/static/spring-boot/no-path-traversal.rule.ts
1
+ // builtin-rules/fortify/static/spring-boot/no-path-traversal.rule.ts
2
2
  var PATH_TRAVERSAL_SINK_IDS = /* @__PURE__ */ new Set([
3
3
  "spring/path-file",
4
4
  "spring/path-resource",
@@ -11,6 +11,10 @@ var SINK_LABEL = {
11
11
  };
12
12
  var rule = {
13
13
  id: "spring-boot/no-path-traversal",
14
+ // Fortify-family flaw detectors: pentest-only by default. `cs review` runs them
15
+ // ONLY when the pack is activated (`rules.packs: ['fortify']` or --packs fortify);
16
+ // `cs assess` always activates the pack for its fold lanes (fold-rules.ts).
17
+ pack: "fortify",
14
18
  // v4 (D1 — JAX-RS taint sources): no rule-logic change. The Java analyzer
15
19
  // gained 8 `jaxrs/*` parameter sources (`@QueryParam`/`@FormParam`/…, javax +
16
20
  // jakarta) and seeds a bare impl param from the annotation on the interface
@@ -1,10 +1,14 @@
1
- // builtin-rules/static/spring-boot/no-servlet-xss.rule.ts
1
+ // builtin-rules/fortify/static/spring-boot/no-servlet-xss.rule.ts
2
2
  var SERVLET_XSS_SINK_IDS = /* @__PURE__ */ new Set(["spring/servlet-writer"]);
3
3
  var SINK_LABEL = {
4
4
  "spring/servlet-writer": "response.getWriter().write/print(...)"
5
5
  };
6
6
  var rule = {
7
7
  id: "spring-boot/no-servlet-xss",
8
+ // Fortify-family flaw detectors: pentest-only by default. `cs review` runs them
9
+ // ONLY when the pack is activated (`rules.packs: ['fortify']` or --packs fortify);
10
+ // `cs assess` always activates the pack for its fold lanes (fold-rules.ts).
11
+ pack: "fortify",
8
12
  // v2 (D1 — JAX-RS taint sources): no rule-logic change. The Java analyzer
9
13
  // gained 8 `jaxrs/*` parameter sources (`@QueryParam`/`@FormParam`/…, javax +
10
14
  // jakarta) and seeds a bare impl param from the annotation on the interface
@@ -1,10 +1,14 @@
1
- // builtin-rules/static/spring-boot/no-spel-injection.rule.ts
1
+ // builtin-rules/fortify/static/spring-boot/no-spel-injection.rule.ts
2
2
  var SPEL_SINK_IDS = /* @__PURE__ */ new Set(["spring/spel-parse"]);
3
3
  var SINK_LABEL = {
4
4
  "spring/spel-parse": "ExpressionParser.parseExpression(...)"
5
5
  };
6
6
  var rule = {
7
7
  id: "spring-boot/no-spel-injection",
8
+ // Fortify-family flaw detectors: pentest-only by default. `cs review` runs them
9
+ // ONLY when the pack is activated (`rules.packs: ['fortify']` or --packs fortify);
10
+ // `cs assess` always activates the pack for its fold lanes (fold-rules.ts).
11
+ pack: "fortify",
8
12
  // v3 (ADR-0065 calibration): luồng taint trực tiếp → severity blocker
9
13
  // v4 (D1 — JAX-RS taint sources): no rule-logic change. The Java analyzer
10
14
  // gained 8 `jaxrs/*` parameter sources (`@QueryParam`/`@FormParam`/…, javax +
@@ -1,6 +1,6 @@
1
1
  import { asTreeSitterTree } from '@code-sentinel/parsers';
2
2
 
3
- // builtin-rules/static/spring-boot/no-sql-string-concat.rule.ts
3
+ // builtin-rules/fortify/static/spring-boot/no-sql-string-concat.rule.ts
4
4
  var SQL_KEYWORD = /\b(SELECT|INSERT|UPDATE|DELETE|FROM|WHERE)\b/;
5
5
  var SQL_SINK_CALLEES = /* @__PURE__ */ new Set([
6
6
  "createQuery",
@@ -152,6 +152,10 @@ var isConcatRoot = (node) => {
152
152
  };
153
153
  var rule = {
154
154
  id: "spring-boot/no-sql-string-concat",
155
+ // Fortify-family flaw detectors: pentest-only by default. `cs review` runs them
156
+ // ONLY when the pack is activated (`rules.packs: ['fortify']` or --packs fortify);
157
+ // `cs assess` always activates the pack for its fold lanes (fold-rules.ts).
158
+ pack: "fortify",
155
159
  // v7 (ADR-0065 calibration): band CONFIRMED → severity blocker
156
160
  // v8 (D1 — JAX-RS taint sources): no rule-logic change. The Java analyzer
157
161
  // gained 8 `jaxrs/*` parameter sources (`@QueryParam`/`@FormParam`/…, javax +
@@ -1,4 +1,4 @@
1
- // builtin-rules/static/spring-boot/no-ssrf.rule.ts
1
+ // builtin-rules/fortify/static/spring-boot/no-ssrf.rule.ts
2
2
  var SSRF_SINK_IDS = /* @__PURE__ */ new Set([
3
3
  "spring/rest-template-ssrf",
4
4
  "spring/web-client-ssrf",
@@ -17,6 +17,10 @@ var SINK_LABEL = {
17
17
  };
18
18
  var rule = {
19
19
  id: "spring-boot/no-ssrf",
20
+ // Fortify-family flaw detectors: pentest-only by default. `cs review` runs them
21
+ // ONLY when the pack is activated (`rules.packs: ['fortify']` or --packs fortify);
22
+ // `cs assess` always activates the pack for its fold lanes (fold-rules.ts).
23
+ pack: "fortify",
20
24
  // v5 (D1 — JAX-RS taint sources): no rule-logic change. The Java analyzer
21
25
  // gained 8 `jaxrs/*` parameter sources (`@QueryParam`/`@FormParam`/…, javax +
22
26
  // jakarta) and seeds a bare impl param from the annotation on the interface
@@ -1,4 +1,4 @@
1
- // builtin-rules/static/spring-boot/no-weak-tls-protocol.rule.ts
1
+ // builtin-rules/fortify/static/spring-boot/no-weak-tls-protocol.rule.ts
2
2
  var WEAK_TLS_PATTERNS = [
3
3
  {
4
4
  regex: /\bSSLContext\.getInstance\s*\(\s*["'](?:SSL|SSLv2|SSLv3|TLSv1|TLSv1\.0|TLSv1\.1)["']/g,
@@ -17,6 +17,10 @@ var lineColumnAt = (content, index) => {
17
17
  };
18
18
  var rule = {
19
19
  id: "spring-boot/no-weak-tls-protocol",
20
+ // Fortify-family flaw detectors: pentest-only by default. `cs review` runs them
21
+ // ONLY when the pack is activated (`rules.packs: ['fortify']` or --packs fortify);
22
+ // `cs assess` always activates the pack for its fold lanes (fold-rules.ts).
23
+ pack: "fortify",
20
24
  version: 1,
21
25
  kind: "static-ts",
22
26
  title: "Kh\xF4ng s\u1EED d\u1EE5ng giao th\u1EE9c SSL/TLS l\u1ED7i th\u1EDDi (SSLv3, TLSv1, TLSv1.1)",
@@ -0,0 +1,83 @@
1
+ import { asTreeSitterTree } from '@code-sentinel/parsers';
2
+
3
+ // builtin-rules/performance/static/spring-boot/http-client-without-timeout.rule.ts
4
+ function* walk(node, type) {
5
+ const stack = [node];
6
+ while (stack.length > 0) {
7
+ const cur = stack.pop();
8
+ if (!cur) continue;
9
+ if (cur.type === type) yield cur;
10
+ for (let i = cur.namedChildCount - 1; i >= 0; i--) {
11
+ const child = cur.namedChild(i);
12
+ if (child) stack.push(child);
13
+ }
14
+ }
15
+ }
16
+ var rule = {
17
+ id: "spring-boot/http-client-without-timeout",
18
+ version: 1,
19
+ kind: "static-ts",
20
+ pack: "performance",
21
+ title: "RestTemplate kh\xF4ng \u0111\u1EB7t timeout \u2014 treo v\xF4 h\u1EA1n khi upstream \u0111\u1EE9ng",
22
+ description: "`new RestTemplate()` tr\u1EA7n d\xF9ng `SimpleClientHttpRequestFactory` c\u1EE7a JDK v\u1EDBi connect/read timeout M\u1EB6C \u0110\u1ECANH KH\xD4NG \u0110\u1EB6T (v\xF4 h\u1EA1n). M\u1ED9t l\u1EDDi g\u1ECDi t\u1EDBi d\u1ECBch v\u1EE5 b\u1ECB \u0111\u1EE9ng s\u1EBD gi\u1EEF thread (v\xE0 k\u1EBFt n\u1ED1i DB n\u1EBFu \u0111ang trong transaction) ch\u1EDD v\xF4 th\u1EDDi h\u1EA1n. \u0110\u1EB7t timeout qua `SimpleClientHttpRequestFactory.setConnectTimeout/setReadTimeout` r\u1ED3i truy\u1EC1n v\xE0o constructor, ho\u1EB7c d\xF9ng `RestTemplateBuilder.setConnectTimeout/\u2026setReadTimeout`.",
23
+ severity: "warning",
24
+ category: "performance",
25
+ languages: ["java"],
26
+ scope: "spring-boot",
27
+ requires: "syntactic",
28
+ baseConfidence: 75,
29
+ examples: {
30
+ good: [
31
+ {
32
+ code: [
33
+ "@Bean",
34
+ "public RestTemplate restTemplate() {",
35
+ " SimpleClientHttpRequestFactory f = new SimpleClientHttpRequestFactory();",
36
+ " f.setConnectTimeout(5_000);",
37
+ " f.setReadTimeout(30_000);",
38
+ " return new RestTemplate(f);",
39
+ "}"
40
+ ].join("\n"),
41
+ explanation: "Factory c\xF3 timeout \u2014 l\u1EDDi g\u1ECDi \u0111\u1EE9ng s\u1EBD th\u1EA5t b\u1EA1i sau th\u1EDDi h\u1EA1n thay v\xEC treo v\xF4 h\u1EA1n."
42
+ }
43
+ ],
44
+ bad: [
45
+ {
46
+ code: [
47
+ "@Bean",
48
+ "public RestTemplate restTemplate() {",
49
+ " return new RestTemplate(); // timeout v\xF4 h\u1EA1n (m\u1EB7c \u0111\u1ECBnh JDK factory)",
50
+ "}"
51
+ ].join("\n"),
52
+ explanation: "Constructor tr\u1EA7n \u2014 kh\xF4ng c\xF3 timeout n\xE0o; upstream \u0111\u1EE9ng \u21D2 thread ch\u1EDD v\xF4 h\u1EA1n."
53
+ }
54
+ ]
55
+ },
56
+ check(ctx) {
57
+ const tree = asTreeSitterTree(ctx.parsed);
58
+ const findings = [];
59
+ for (const creation of walk(tree.rootNode, "object_creation_expression")) {
60
+ const typeNode = creation.childForFieldName("type");
61
+ if (!typeNode || typeNode.text !== "RestTemplate") continue;
62
+ const args = creation.childForFieldName("arguments");
63
+ const argCount = args ? args.namedChildCount : 0;
64
+ if (argCount > 0) continue;
65
+ findings.push({
66
+ message: "`new RestTemplate()` kh\xF4ng \u0111\u1EB7t timeout \u2014 factory JDK m\u1EB7c \u0111\u1ECBnh c\xF3 connect/read timeout v\xF4 h\u1EA1n: m\u1ED9t l\u1EDDi g\u1ECDi t\u1EDBi d\u1ECBch v\u1EE5 \u0111\u1EE9ng s\u1EBD gi\u1EEF thread (v\xE0 k\u1EBFt n\u1ED1i DB n\u1EBFu trong transaction) ch\u1EDD v\xF4 th\u1EDDi h\u1EA1n. M\u1EE9c \u1EA3nh h\u01B0\u1EDFng ph\u1EE5 thu\u1ED9c kh\u1EA3 n\u0103ng d\u1ECBch v\u1EE5 \u0111\xEDch b\u1ECB \u0111\u1EE9ng.",
67
+ file: ctx.file.path,
68
+ range: {
69
+ line: creation.startPosition.row + 1,
70
+ column: creation.startPosition.column + 1
71
+ },
72
+ snippet: creation.text,
73
+ suggestion: "\u0110\u1EB7t `SimpleClientHttpRequestFactory` v\u1EDBi `setConnectTimeout`/`setReadTimeout` r\u1ED3i truy\u1EC1n v\xE0o constructor, ho\u1EB7c d\xF9ng `RestTemplateBuilder` v\u1EDBi `setConnectTimeout(\u2026).setReadTimeout(\u2026)`.",
74
+ confidence: 75
75
+ });
76
+ }
77
+ return findings;
78
+ }
79
+ };
80
+
81
+ export { rule };
82
+ //# sourceMappingURL=http-client-without-timeout.rule.js.map
83
+ //# sourceMappingURL=http-client-without-timeout.rule.js.map
@@ -0,0 +1,89 @@
1
+ // builtin-rules/performance/static/spring-boot/open-in-view-enabled.rule.ts
2
+ var BASE_CONFIG_RE = /^(?:.*\/)?services\/[^/]+\/src\/main\/resources\/(?:config\/)?application\.yml$/;
3
+ function readKeys(content) {
4
+ const keys = /* @__PURE__ */ new Map();
5
+ const stack = [];
6
+ const lines = content.split("\n");
7
+ for (let i = 0; i < lines.length; i++) {
8
+ const raw = lines[i] ?? "";
9
+ const trimmed = raw.trim();
10
+ if (!trimmed || trimmed.startsWith("#") || trimmed.startsWith("-")) continue;
11
+ const indent = (raw.match(/^(\s*)/)?.[1] ?? "").length;
12
+ while (stack.length > 0 && (stack[stack.length - 1]?.indent ?? 0) >= indent) {
13
+ stack.pop();
14
+ }
15
+ const sep = trimmed.match(/^([^:=#]+)[:=]\s*(.*)$/);
16
+ if (!sep) continue;
17
+ const key = sep[1]?.trim() ?? "";
18
+ const value = (sep[2] ?? "").replace(/\s*#.*$/, "").trim();
19
+ if (!value) {
20
+ stack.push({ indent, key });
21
+ continue;
22
+ }
23
+ const fullKey = [...stack.map((s) => s.key), key].join(".");
24
+ keys.set(fullKey, { value, line: i + 1 });
25
+ }
26
+ return keys;
27
+ }
28
+ var rule = {
29
+ id: "spring-boot/open-in-view-enabled",
30
+ version: 1,
31
+ kind: "static-ts",
32
+ pack: "performance",
33
+ title: "OSIV kh\xF4ng t\u1EAFt t\u01B0\u1EDDng minh \u2014 k\u1EBFt n\u1ED1i DB gi\u1EEF su\u1ED1t request (Spring Boot m\u1EB7c \u0111\u1ECBnh b\u1EADt)",
34
+ description: "Config ch\xEDnh c\u1EE7a service kh\xF4ng khai b\xE1o `spring.jpa.open-in-view: false` (ho\u1EB7c khai b\xE1o b\u1EADt) \u21D2 Spring Boot m\u1EB7c \u0111\u1ECBnh B\u1EACT Open-In-View: EntityManager v\xE0 k\u1EBFt n\u1ED1i DB b\u1ECB bu\u1ED9c v\xE0o thread request t\u1EDBi khi response render xong sau l\u1EA7n truy v\u1EA5n \u0111\u1EA7u ti\xEAn (\u0111o b\u1EB1ng fixture, ADR-0087 V2 case g). M\u1ECDi I/O sau \u0111\xF3 (g\u1ECDi HTTP, render file) \u0111\u1EC1u gi\u1EEF k\u1EBFt n\u1ED1i pool.",
35
+ severity: "warning",
36
+ category: "performance",
37
+ languages: ["yaml", "text"],
38
+ scope: "spring-boot",
39
+ requires: "text",
40
+ usesParser: false,
41
+ baseConfidence: 80,
42
+ examples: {
43
+ good: [
44
+ {
45
+ code: "spring:\n jpa:\n open-in-view: false\n",
46
+ explanation: "T\u1EAFt t\u01B0\u1EDDng minh \u2014 EntityManager ch\u1EC9 m\u1EDF trong transaction, k\u1EBFt n\u1ED1i tr\u1EA3 v\u1EC1 pool ngay sau commit."
47
+ }
48
+ ],
49
+ bad: [
50
+ {
51
+ code: "# spring.jpa.open-in-view kh\xF4ng khai b\xE1o \u2014 Spring Boot m\u1EB7c \u0111\u1ECBnh true\nspring:\n jpa:\n hibernate:\n ddl-auto: none\n",
52
+ explanation: "Thi\u1EBFu khai b\xE1o = m\u1EB7c \u0111\u1ECBnh b\u1EADt; controller g\u1ECDi HTTP/render sau khi \u0111\xE3 query s\u1EBD gi\u1EEF k\u1EBFt n\u1ED1i DB su\u1ED1t request."
53
+ }
54
+ ]
55
+ },
56
+ check(ctx) {
57
+ const file = ctx.file;
58
+ if (!BASE_CONFIG_RE.test(file.path)) return [];
59
+ const keys = readKeys(file.content);
60
+ const osiv = keys.get("spring.jpa.open-in-view");
61
+ const hasJpaBlock = [...keys.keys()].some((k) => k.startsWith("spring.jpa."));
62
+ if (!hasJpaBlock) return [];
63
+ if (osiv?.value === "false") return [];
64
+ if (osiv) {
65
+ return [
66
+ {
67
+ message: `\`${file.path.split("/").pop()}\` khai b\xE1o \`spring.jpa.open-in-view: ${osiv.value}\` \u2014 OSIV b\u1EADt: EntityManager v\xE0 k\u1EBFt n\u1ED1i DB b\u1ECB gi\u1EEF t\u1EDBi khi response render xong sau l\u1EA7n truy v\u1EA5n \u0111\u1EA7u ti\xEAn (ADR-0087 V2 case g). Gi\xE1 tr\u1ECB hi\u1EC7u l\u1EF1c ph\u1EE5 thu\u1ED9c profile tri\u1EC3n khai.`,
68
+ file: file.path,
69
+ range: { line: osiv.line, column: 1 },
70
+ confidence: 85,
71
+ suggestion: "Khai b\xE1o t\u01B0\u1EDDng minh `spring.jpa.open-in-view: false` trong config ch\xEDnh c\u1EE7a service."
72
+ }
73
+ ];
74
+ }
75
+ return [
76
+ {
77
+ message: "Config ch\xEDnh c\u1EE7a service KH\xD4NG khai b\xE1o `spring.jpa.open-in-view: false` \u2014 Spring Boot m\u1EB7c \u0111\u1ECBnh B\u1EACT OSIV: k\u1EBFt n\u1ED1i DB b\u1ECB gi\u1EEF t\u1EDBi khi response render xong sau l\u1EA7n truy v\u1EA5n \u0111\u1EA7u ti\xEAn (ADR-0087 V2 case g). Gi\xE1 tr\u1ECB hi\u1EC7u l\u1EF1c ph\u1EE5 thu\u1ED9c profile tri\u1EC3n khai.",
78
+ file: file.path,
79
+ range: { line: 1, column: 1 },
80
+ confidence: 80,
81
+ suggestion: "Th\xEAm `spring.jpa.open-in-view: false` v\xE0o kh\u1ED1i `spring.jpa` trong `application.yml`. N\u1EBFu ch\u1EE7 \xFD gi\u1EEF b\u1EADt, khai b\xE1o `true` t\u01B0\u1EDDng minh k\xE8m l\xFD do \u0111\u1EC3 m\u1EB7c \u0111\u1ECBnh kh\xF4ng b\u1ECB \u0111\u1ECDc l\xE0 c\u1ED1 \xFD."
82
+ }
83
+ ];
84
+ }
85
+ };
86
+
87
+ export { rule };
88
+ //# sourceMappingURL=open-in-view-enabled.rule.js.map
89
+ //# sourceMappingURL=open-in-view-enabled.rule.js.map