@code-sentinel-cli/code-sentinel-cli 3.0.9 → 3.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 +38961 -19863
- package/dist/builtin-rules/ai/angular/api-service-contract-risk.rule.yaml +3 -3
- package/dist/builtin-rules/ai/angular/component-state-flow.rule.yaml +3 -3
- package/dist/builtin-rules/ai/angular/cross-feature-api-drift.prompt.md +0 -1
- package/dist/builtin-rules/ai/angular/cross-feature-api-drift.rule.yaml +3 -6
- package/dist/builtin-rules/ai/angular/cross-feature-route-permission-drift.prompt.md +0 -1
- package/dist/builtin-rules/ai/angular/cross-feature-route-permission-drift.rule.yaml +4 -8
- package/dist/builtin-rules/ai/angular/reactive-form-flow.rule.yaml +3 -3
- package/dist/builtin-rules/ai/angular/route-permission-flow.rule.yaml +3 -3
- package/dist/builtin-rules/ai/angular/rxjs-flow-risk.rule.yaml +3 -3
- package/dist/builtin-rules/ai/angular/template-contract-risk.rule.yaml +3 -3
- package/dist/builtin-rules/ai/flutter/dynamic-content-risk.rule.yaml +1 -2
- package/dist/builtin-rules/ai/flutter/feature-state-flow-risk.rule.yaml +1 -2
- package/dist/builtin-rules/ai/flutter/native-platform-consistency-risk.rule.yaml +1 -2
- package/dist/builtin-rules/ai/flutter/network-auth-flow-risk.rule.yaml +1 -2
- package/dist/builtin-rules/ai/flutter/ui-responsive-accessibility-risk.rule.yaml +0 -2
- package/dist/builtin-rules/ai/general/code-clarity.prompt.md +19 -2
- package/dist/builtin-rules/ai/general/code-clarity.rule.yaml +8 -3
- package/dist/builtin-rules/ai/spring-boot/business-invariant-risk.prompt.md +3 -3
- package/dist/builtin-rules/ai/spring-boot/business-invariant-risk.rule.yaml +1 -2
- package/dist/builtin-rules/ai/spring-boot/cache-consistency-risk.rule.yaml +1 -2
- package/dist/builtin-rules/ai/spring-boot/cross-feature-error-handling-drift.prompt.md +0 -1
- package/dist/builtin-rules/ai/spring-boot/cross-feature-error-handling-drift.rule.yaml +4 -10
- package/dist/builtin-rules/ai/spring-boot/cross-feature-transaction-boundary-drift.prompt.md +9 -8
- package/dist/builtin-rules/ai/spring-boot/cross-feature-transaction-boundary-drift.rule.yaml +12 -14
- package/dist/builtin-rules/ai/spring-boot/error-handling-completeness.prompt.md +4 -4
- package/dist/builtin-rules/ai/spring-boot/error-handling-completeness.rule.yaml +1 -2
- package/dist/builtin-rules/ai/spring-boot/event-publishing-risk.rule.yaml +1 -2
- package/dist/builtin-rules/ai/spring-boot/io-boundary-risk.rule.yaml +1 -2
- package/dist/builtin-rules/ai/spring-boot/ownership-scope-risk.prompt.md +3 -3
- package/dist/builtin-rules/ai/spring-boot/ownership-scope-risk.rule.yaml +1 -2
- package/dist/builtin-rules/ai/spring-boot/pagination-risk.rule.yaml +1 -2
- package/dist/builtin-rules/ai/spring-boot/security-authorization-risk.rule.yaml +3 -3
- package/dist/builtin-rules/ai/spring-boot/security-mass-assignment-risk.rule.yaml +3 -3
- package/dist/builtin-rules/ai/spring-boot/security-redirect-risk.rule.yaml +1 -2
- package/dist/builtin-rules/ai/spring-boot/security-sensitive-data-risk.rule.yaml +1 -2
- package/dist/builtin-rules/ai/spring-boot/transaction-loop-risk.rule.yaml +1 -2
- package/dist/builtin-rules/static/angular/button-accessible-name.rule.js +143 -0
- package/dist/builtin-rules/static/angular/component-prefix.rule.js +6 -2
- package/dist/builtin-rules/static/angular/img-alt-required.rule.js +3 -2
- package/dist/builtin-rules/static/angular/inject-pattern.rule.js +3 -2
- package/dist/builtin-rules/static/angular/lifecycle-method-required.rule.js +3 -2
- package/dist/builtin-rules/static/angular/no-leaky-subscription.rule.js +14 -5
- package/dist/builtin-rules/static/angular/onpush-required.rule.js +3 -2
- package/dist/builtin-rules/static/angular/template-dom-xss.rule.js +28 -4
- package/dist/builtin-rules/static/angular/trackby-required.rule.js +3 -2
- package/dist/builtin-rules/static/flutter/no-undisposed-resource.rule.js +143 -0
- package/dist/builtin-rules/static/general/file-too-long.rule.js +5 -4
- package/dist/builtin-rules/static/general/function-too-long.rule.js +46 -27
- package/dist/builtin-rules/static/general/no-code-injection.rule.js +8 -1
- package/dist/builtin-rules/static/general/no-console-log.rule.js +3 -2
- package/dist/builtin-rules/static/general/no-empty-catch.rule.yaml +14 -8
- package/dist/builtin-rules/static/general/no-hardcoded-vietnamese.rule.js +58 -0
- package/dist/builtin-rules/static/general/no-magic-number.rule.js +151 -8
- package/dist/builtin-rules/static/general/no-todo-comment.rule.js +88 -0
- package/dist/builtin-rules/static/general/no-unused-export.rule.js +53 -6
- package/dist/builtin-rules/static/spring-boot/no-command-injection.rule.js +14 -1
- package/dist/builtin-rules/static/spring-boot/no-path-traversal.rule.js +1 -1
- package/dist/builtin-rules/static/spring-boot/no-servlet-xss.rule.js +41 -0
- package/dist/builtin-rules/static/spring-boot/no-spel-injection.rule.js +8 -1
- package/dist/builtin-rules/static/spring-boot/no-sql-string-concat.rule.js +35 -4
- package/dist/builtin-rules/static/spring-boot/no-ssrf.rule.js +1 -1
- package/dist/builtin-rules/static/spring-boot/no-unzoned-datetime.rule.js +96 -0
- package/dist/builtin-rules/static/spring-boot/repository-naming.rule.yaml +4 -2
- package/dist/index.d.ts +316 -132
- package/dist/index.js +38952 -19854
- package/package.json +1 -1
- package/templates/ci/github-actions.yml +60 -2
- package/templates/ci/gitlab-ci.yml +51 -2
- package/dist/builtin-rules/static/general/no-todo-comment.rule.yaml +0 -30
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
id: angular/api-service-contract-risk
|
|
2
|
-
|
|
2
|
+
# v3 (ADR-0065 calibration): conf 60→85 (đo 26/26 TP)
|
|
3
|
+
version: 3
|
|
3
4
|
kind: ai
|
|
4
5
|
title: "Angular API service/error contract có rủi ro không?"
|
|
5
6
|
description: |
|
|
@@ -14,9 +15,8 @@ severity: warning
|
|
|
14
15
|
category: angular-api
|
|
15
16
|
languages: [typescript]
|
|
16
17
|
scope: angular
|
|
17
|
-
baseConfidence:
|
|
18
|
+
baseConfidence: 85
|
|
18
19
|
prompt: ./api-service-contract-risk.prompt.md
|
|
19
20
|
contextScope: per-cluster
|
|
20
|
-
maxTokens: 1600
|
|
21
21
|
aiConfig:
|
|
22
22
|
tier: regular
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
id: angular/component-state-flow
|
|
2
|
-
|
|
2
|
+
# v4 (ADR-0065 calibration): conf 60→85 (đo 49/49 TP)
|
|
3
|
+
version: 4
|
|
3
4
|
kind: ai
|
|
4
5
|
title: "Angular component state/change detection flow có rủi ro không?"
|
|
5
6
|
description: |
|
|
@@ -18,9 +19,8 @@ severity: warning
|
|
|
18
19
|
category: angular-state
|
|
19
20
|
languages: [typescript]
|
|
20
21
|
scope: angular
|
|
21
|
-
baseConfidence:
|
|
22
|
+
baseConfidence: 85
|
|
22
23
|
prompt: ./component-state-flow.prompt.md
|
|
23
24
|
contextScope: per-cluster
|
|
24
|
-
maxTokens: 1200
|
|
25
25
|
aiConfig:
|
|
26
26
|
tier: regular
|
|
@@ -6,7 +6,6 @@ Bạn là senior Angular architecture reviewer. Đánh giá **một module Angul
|
|
|
6
6
|
2. **MỖI drift pattern = ĐÚNG MỘT finding.** Nếu cùng một pattern (vd. "err.message thay vì err.error.message") xuất hiện ở nhiều file, GỘP thành **một** finding duy nhất — `file`/`line` trỏ vào file ĐẠI DIỆN rõ nhất, và liệt kê TÊN tất cả feature liên quan trong `message`. TUYỆT ĐỐI KHÔNG emit cùng pattern lặp lại một lần cho mỗi file.
|
|
7
7
|
3. **`line` BẮT BUỘC là số nguyên dương** (≥ 1), trỏ vào một dòng cụ thể trong file đã chọn nơi pattern lộ rõ nhất. Nếu không chắc dòng nào → dùng `line: 1`. KHÔNG để trống, KHÔNG dùng `null`, KHÔNG dùng `0`.
|
|
8
8
|
4. **`file` phải là posix path** xuất hiện trong `Module summary` bên dưới — KHÔNG fabricate path mới.
|
|
9
|
-
5. **Confidence `<50` → KHÔNG emit.** Ngưỡng noise thấp (`numMaxFindings: 5`).
|
|
10
9
|
|
|
11
10
|
## Chỉ flag khi có pattern lặp lại ≥ 2 feature
|
|
12
11
|
|
|
@@ -4,7 +4,8 @@ id: angular/cross-feature-api-drift
|
|
|
4
4
|
# — v1 emitted the same drift once per file (5 findings = 2 real patterns); and
|
|
5
5
|
# (b) stronger `line` requirement (v1 returned null/undefined line). Version bump
|
|
6
6
|
# invalidates v1 cached findings.
|
|
7
|
-
|
|
7
|
+
# v3 (ADR-0065 calibration): conf 55→75 (POC gate 5/5 + field 1/1)
|
|
8
|
+
version: 3
|
|
8
9
|
kind: ai
|
|
9
10
|
title: "Angular features trong cùng module gọi /api/* không nhất quán?"
|
|
10
11
|
description: |
|
|
@@ -31,12 +32,8 @@ severity: warning
|
|
|
31
32
|
category: angular-architecture
|
|
32
33
|
languages: [typescript]
|
|
33
34
|
scope: angular
|
|
34
|
-
baseConfidence:
|
|
35
|
+
baseConfidence: 75
|
|
35
36
|
prompt: ./cross-feature-api-drift.prompt.md
|
|
36
37
|
contextScope: per-module
|
|
37
|
-
maxTokens: 1800
|
|
38
38
|
aiConfig:
|
|
39
39
|
tier: regular
|
|
40
|
-
# Cap findings để v1 ngưỡng noise thấp; nâng lên sau khi POC gate đạt
|
|
41
|
-
# ≥ 80% precision theo ADR-0016 §"Implementation phase".
|
|
42
|
-
numMaxFindings: 5
|
|
@@ -7,7 +7,6 @@ Bạn là senior Angular security reviewer. Đánh giá **một module Angular**
|
|
|
7
7
|
- **NHIỀU hành động cùng CHUNG một kiểu drift = MỘT finding.** Vd. nếu cả Delete, Export, Approve... đều "chỉ ẩn UI bằng `*hasPermission` mà thiếu code/route check" trong khi nav actions có guard → đó là **MỘT** pattern duy nhất ("in-component sensitive actions gated UI-only vs guarded nav"). Liệt kê tất cả hành động (Delete, Export, ...) trong `message`, **KHÔNG** tách mỗi hành động thành một finding riêng.
|
|
8
8
|
3. **`line` BẮT BUỘC là số nguyên dương** (≥ 1), trỏ vào một dòng cụ thể trong file đã chọn nơi pattern lộ rõ nhất (vd. dòng khai báo route thiếu guard, dòng gọi action destructive không check). Nếu không chắc dòng nào → dùng `line: 1`. KHÔNG để trống, KHÔNG dùng `null`, KHÔNG dùng `0`.
|
|
9
9
|
4. **`file` phải là posix path** xuất hiện trong `Module summary` bên dưới — KHÔNG fabricate path mới.
|
|
10
|
-
5. **Confidence `<50` → KHÔNG emit.** Ngưỡng noise thấp (`numMaxFindings: 5`).
|
|
11
10
|
|
|
12
11
|
## Chỉ flag khi có pattern lặp lại ≥ 2 feature
|
|
13
12
|
|
|
@@ -7,9 +7,9 @@ id: angular/cross-feature-route-permission-drift
|
|
|
7
7
|
# export) — v2 CRITICAL RULE: multiple actions sharing one drift mechanism =
|
|
8
8
|
# ONE finding (list all actions in the message). Version bump invalidates v1
|
|
9
9
|
# cached findings.
|
|
10
|
-
# Second rule in the per-module family (ADR-0016)
|
|
11
|
-
#
|
|
12
|
-
version:
|
|
10
|
+
# Second rule in the per-module family (ADR-0016).
|
|
11
|
+
# v3 (ADR-0065 calibration): conf 55→75 (POC gate 2/2).
|
|
12
|
+
version: 3
|
|
13
13
|
kind: ai
|
|
14
14
|
title: "Angular features trong cùng module bảo vệ route / permission không nhất quán?"
|
|
15
15
|
description: |
|
|
@@ -39,12 +39,8 @@ severity: warning
|
|
|
39
39
|
category: angular-architecture
|
|
40
40
|
languages: [typescript]
|
|
41
41
|
scope: angular
|
|
42
|
-
baseConfidence:
|
|
42
|
+
baseConfidence: 75
|
|
43
43
|
prompt: ./cross-feature-route-permission-drift.prompt.md
|
|
44
44
|
contextScope: per-module
|
|
45
|
-
maxTokens: 1800
|
|
46
45
|
aiConfig:
|
|
47
46
|
tier: regular
|
|
48
|
-
# Cap findings để v1 ngưỡng noise thấp; nâng lên sau khi POC gate đạt
|
|
49
|
-
# ≥ 80% precision theo ADR-0016 §"Implementation phase".
|
|
50
|
-
numMaxFindings: 5
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
id: angular/reactive-form-flow
|
|
2
|
-
|
|
2
|
+
# v5 (ADR-0065 calibration): conf 60→85 (đo 46/46 TP)
|
|
3
|
+
version: 5
|
|
3
4
|
kind: ai
|
|
4
5
|
title: "Angular reactive form flow có rủi ro submit/validation không?"
|
|
5
6
|
description: |
|
|
@@ -15,9 +16,8 @@ severity: warning
|
|
|
15
16
|
category: angular-form
|
|
16
17
|
languages: [typescript]
|
|
17
18
|
scope: angular
|
|
18
|
-
baseConfidence:
|
|
19
|
+
baseConfidence: 85
|
|
19
20
|
prompt: ./reactive-form-flow.prompt.md
|
|
20
21
|
contextScope: per-cluster
|
|
21
|
-
maxTokens: 1600
|
|
22
22
|
aiConfig:
|
|
23
23
|
tier: regular
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
id: angular/route-permission-flow
|
|
2
|
-
|
|
2
|
+
# v5 (ADR-0065 calibration): conf 60→85 (đo 21/21 TP)
|
|
3
|
+
version: 5
|
|
3
4
|
kind: ai
|
|
4
5
|
title: "Angular route/permission/UI action flow có rủi ro phân quyền không?"
|
|
5
6
|
description: |
|
|
@@ -15,9 +16,8 @@ severity: warning
|
|
|
15
16
|
category: angular-security
|
|
16
17
|
languages: [typescript]
|
|
17
18
|
scope: angular
|
|
18
|
-
baseConfidence:
|
|
19
|
+
baseConfidence: 85
|
|
19
20
|
prompt: ./route-permission-flow.prompt.md
|
|
20
21
|
contextScope: per-cluster
|
|
21
|
-
maxTokens: 1600
|
|
22
22
|
aiConfig:
|
|
23
23
|
tier: regular
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
id: angular/rxjs-flow-risk
|
|
2
|
-
|
|
2
|
+
# v5 (ADR-0065 calibration): conf 60→90 (đo 233/233 TP — rule AI bị định giá thấp nhất catalog)
|
|
3
|
+
version: 5
|
|
3
4
|
kind: ai
|
|
4
5
|
title: "Angular RxJS async flow có rủi ro không?"
|
|
5
6
|
description: |
|
|
@@ -16,9 +17,8 @@ severity: warning
|
|
|
16
17
|
category: async-flow
|
|
17
18
|
languages: [typescript]
|
|
18
19
|
scope: angular
|
|
19
|
-
baseConfidence:
|
|
20
|
+
baseConfidence: 90
|
|
20
21
|
prompt: ./rxjs-flow-risk.prompt.md
|
|
21
22
|
contextScope: per-cluster
|
|
22
|
-
maxTokens: 1200
|
|
23
23
|
aiConfig:
|
|
24
24
|
tier: regular
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
id: angular/template-contract-risk
|
|
2
|
-
|
|
2
|
+
# v5 (ADR-0065 calibration): conf 60→70 (đo 7/7 TP — mẫu nhỏ, nâng dè dặt)
|
|
3
|
+
version: 5
|
|
3
4
|
kind: ai
|
|
4
5
|
title: "Angular template/component contract có rủi ro runtime không?"
|
|
5
6
|
description: |
|
|
@@ -17,9 +18,8 @@ severity: warning
|
|
|
17
18
|
category: angular-template
|
|
18
19
|
languages: [typescript]
|
|
19
20
|
scope: angular
|
|
20
|
-
baseConfidence:
|
|
21
|
+
baseConfidence: 70
|
|
21
22
|
prompt: ./template-contract-risk.prompt.md
|
|
22
23
|
contextScope: per-cluster
|
|
23
|
-
maxTokens: 1200
|
|
24
24
|
aiConfig:
|
|
25
25
|
tier: regular
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
id: flutter/dynamic-content-risk
|
|
2
|
-
version:
|
|
2
|
+
version: 2
|
|
3
3
|
kind: ai
|
|
4
4
|
title: "Flutter dynamic content/file flow có rủi ro không?"
|
|
5
5
|
description: |
|
|
@@ -12,7 +12,6 @@ scope: flutter
|
|
|
12
12
|
baseConfidence: 60
|
|
13
13
|
prompt: ./dynamic-content-risk.prompt.md
|
|
14
14
|
contextScope: per-cluster
|
|
15
|
-
maxTokens: 1400
|
|
16
15
|
aiConfig:
|
|
17
16
|
tier: regular
|
|
18
17
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
id: flutter/feature-state-flow-risk
|
|
2
|
-
version:
|
|
2
|
+
version: 2
|
|
3
3
|
kind: ai
|
|
4
4
|
title: "Flutter feature state/API flow có rủi ro không?"
|
|
5
5
|
description: |
|
|
@@ -12,7 +12,6 @@ scope: flutter
|
|
|
12
12
|
baseConfidence: 60
|
|
13
13
|
prompt: ./feature-state-flow-risk.prompt.md
|
|
14
14
|
contextScope: per-cluster
|
|
15
|
-
maxTokens: 1400
|
|
16
15
|
aiConfig:
|
|
17
16
|
tier: regular
|
|
18
17
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
id: flutter/native-platform-consistency-risk
|
|
2
|
-
version:
|
|
2
|
+
version: 2
|
|
3
3
|
kind: ai
|
|
4
4
|
title: "Flutter Dart/native permission config có lệch nhau không?"
|
|
5
5
|
description: |
|
|
@@ -12,7 +12,6 @@ scope: flutter
|
|
|
12
12
|
baseConfidence: 58
|
|
13
13
|
prompt: ./native-platform-consistency-risk.prompt.md
|
|
14
14
|
contextScope: per-cluster
|
|
15
|
-
maxTokens: 1500
|
|
16
15
|
aiConfig:
|
|
17
16
|
tier: regular
|
|
18
17
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
id: flutter/network-auth-flow-risk
|
|
2
|
-
version:
|
|
2
|
+
version: 2
|
|
3
3
|
kind: ai
|
|
4
4
|
title: "Flutter network/auth flow có rủi ro không?"
|
|
5
5
|
description: |
|
|
@@ -13,7 +13,6 @@ scope: flutter
|
|
|
13
13
|
baseConfidence: 60
|
|
14
14
|
prompt: ./network-auth-flow-risk.prompt.md
|
|
15
15
|
contextScope: per-cluster
|
|
16
|
-
maxTokens: 1400
|
|
17
16
|
aiConfig:
|
|
18
17
|
tier: regular
|
|
19
18
|
|
|
@@ -2,7 +2,7 @@ Bạn là senior code reviewer. Đánh giá đoạn TypeScript/JavaScript dướ
|
|
|
2
2
|
|
|
3
3
|
## Tiêu chí flag (chỉ flag khi RÕ RÀNG có vấn đề)
|
|
4
4
|
|
|
5
|
-
- Tên hàm hoặc biến không nói lên ý nghĩa (1-2 ký
|
|
5
|
+
- Tên hàm hoặc biến không nói lên ý nghĩa (1-2 ký tự, hoặc `tmp` / `data` / `result` không có ngữ cảnh). **Đọc kỹ mục "KHÔNG flag" bên dưới trước khi flag một tên ngắn — phần lớn tên ngắn trong code thật là hợp lệ.**
|
|
6
6
|
- Logic lồng quá sâu (≥4 cấp if/for/try).
|
|
7
7
|
- Comment giải thích cái đã rõ trong code (kiểu `// increment i`), hoặc comment lệch hành vi.
|
|
8
8
|
- String literal bí ẩn làm code khó hiểu khi **không** phải route path, event name, i18n key, enum-like value, test fixture, hoặc message hiển thị.
|
|
@@ -12,7 +12,17 @@ Bạn là senior code reviewer. Đánh giá đoạn TypeScript/JavaScript dướ
|
|
|
12
12
|
- Function nội bộ tầm thường (helper 1-2 dòng).
|
|
13
13
|
- Test/spec files (*.test.ts, *.spec.ts, __tests__).
|
|
14
14
|
- Generated code.
|
|
15
|
-
- Tên ngắn nhưng theo convention rộng rãi (`i` trong loop, `e` trong catch).
|
|
15
|
+
- Tên ngắn nhưng theo convention rộng rãi (`i`/`j`/`k` trong loop, `e` trong catch).
|
|
16
|
+
- **Bí danh (alias) cho một symbol đã import** — `const R = VauthzResource;`,
|
|
17
|
+
`protected readonly R = SomeEnum;`, `const t = this.translate;`. Kể cả tên 1
|
|
18
|
+
ký tự. Giá trị được gán ĐÃ tự nói lên ý nghĩa ngay trên cùng dòng, và alias
|
|
19
|
+
ngắn thường tồn tại để biểu thức trong template đọc được. Đây là nhóm báo sai
|
|
20
|
+
LỚN NHẤT của rule này trên code thật — đừng flag nó.
|
|
21
|
+
- **Tham số 1 ký tự trong callback ngắn** — `.map(b => b.brand)`,
|
|
22
|
+
`.find(o => o.id === id)`, `.filter(v => v !== x)`, `.reduce((a, c) => ...)`.
|
|
23
|
+
Là cú pháp chuẩn của JS/TS khi thân hàm chỉ một biểu thức.
|
|
24
|
+
- **Biến cục bộ 1 ký tự cho một API DOM/thư viện quen thuộc** trong 2-3 dòng
|
|
25
|
+
liền kề — `const a = document.createElement('a'); a.href = url; a.click();`.
|
|
16
26
|
|
|
17
27
|
## Code cần review
|
|
18
28
|
|
|
@@ -52,6 +62,13 @@ Trả về **JSON HỢP LỆ DUY NHẤT** (không markdown fence, không text kh
|
|
|
52
62
|
|
|
53
63
|
KHÔNG inflate confidence. Một finding `confidence: 100` phải là vấn đề mà bất kỳ senior reviewer nào cũng đồng ý cần fix. Nếu có chỗ đáng review nhưng có thể là intentional → confidence 50-70.
|
|
54
64
|
|
|
65
|
+
### Gộp trùng lặp
|
|
66
|
+
|
|
67
|
+
Nếu CÙNG MỘT vấn đề lặp lại nhiều lần trong file (cùng tên biến, cùng kiểu
|
|
68
|
+
comment), trả về **MỘT** violation ở lần xuất hiện đầu tiên và nói rõ trong
|
|
69
|
+
`message` là nó lặp ở bao nhiêu chỗ. Đừng trả N violation cho N dòng của cùng
|
|
70
|
+
một nguyên nhân.
|
|
71
|
+
|
|
55
72
|
Nếu code đã rõ ràng và không có vi phạm: `{"violations": []}`.
|
|
56
73
|
|
|
57
74
|
Đừng giải thích. JSON thuần.
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
id: general/code-clarity
|
|
2
|
-
|
|
2
|
+
# v4 (ADR-0065): ba carve-out theo số đo thực địa. Đo trên hai module Angular
|
|
3
|
+
# sản xuất: 412 finding, 40 bị bác = precision 90,3 % — cao hơn nhiều so với
|
|
4
|
+
# baseConfidence 60 mà v3 khai báo, nên số đó nâng lên 75. 27/40 FP là CÙNG
|
|
5
|
+
# MỘT pattern (`const R = VauthzResource`) lặp ở 27 file; 6 FP là param 1 ký
|
|
6
|
+
# tự trong callback (`.map(b => b.brand)`). Cả hai đều là quy ước hợp lệ,
|
|
7
|
+
# prompt v4 miễn tường minh.
|
|
8
|
+
version: 4
|
|
3
9
|
kind: ai
|
|
4
10
|
title: "Code có rõ ràng và dễ đọc không?"
|
|
5
11
|
description: |
|
|
@@ -14,7 +20,6 @@ severity: warning
|
|
|
14
20
|
category: readability
|
|
15
21
|
languages: [typescript, javascript]
|
|
16
22
|
scope: general
|
|
17
|
-
baseConfidence:
|
|
23
|
+
baseConfidence: 75
|
|
18
24
|
prompt: ./code-clarity.prompt.md
|
|
19
25
|
contextScope: per-file
|
|
20
|
-
maxTokens: 900
|
|
@@ -8,7 +8,7 @@ CRITICAL NON-VIOLATIONS:
|
|
|
8
8
|
- NEVER report mass assignment by itself; `security-mass-assignment-risk` owns request body fields such as `id`, `tenantId`, `accountId`, `role`, `admin`, or entity `status` accepted during create/update.
|
|
9
9
|
- NEVER report transaction/loop/SSRF/filesystem/error-handling issues here.
|
|
10
10
|
- NEVER report DTO validation/style/naming issues; static rules own those.
|
|
11
|
-
- NEVER report
|
|
11
|
+
- NEVER report a file that only plays a supporting/evidence role (a global exception handler, a DTO, a class the cluster shows as the safe path) unless PRIMARY itself shows direct business-state mutation evidence.
|
|
12
12
|
|
|
13
13
|
1. **CHI report loi co bang chung cu the** trong PRIMARY hoac support files. Khong doan convention ngoai cluster.
|
|
14
14
|
2. **`line` BAT BUOC tro ve PRIMARY controller file**. Neu invariant bi bypass trong service, dung dong controller goi flow do.
|
|
@@ -30,7 +30,7 @@ CRITICAL NON-VIOLATIONS:
|
|
|
30
30
|
- Request value chi la filter/search, khong mutate persisted state hoac side effect.
|
|
31
31
|
- Enum/status duoc validate bang allowlist, transition table, domain method (`approve`, `cancel`, `refund`) co guard current state.
|
|
32
32
|
- Fixed server-driven status transition nhu `setStatus("APPROVED")`, `setStatus("PAID")`, `setStatus("CANCELLED")` neu khong co request-controlled target/metadata hoac explicit transition contract visible.
|
|
33
|
-
-
|
|
33
|
+
- Luong DTO an toan, hoac file support-only (global exception handler, mapper, config) neu khong co direct business-state mutation evidence trong PRIMARY.
|
|
34
34
|
- Pure ownership/tenant/auth gap, transaction gap, SSRF/file boundary, raw exception response.
|
|
35
35
|
- Style/naming/refactor suggestion.
|
|
36
36
|
|
|
@@ -79,7 +79,7 @@ Neu khong co business invariant bug ro rang: `{"violations": []}`.
|
|
|
79
79
|
- Chi report khi request-controlled/free-text value hoac blind recalculation co the bypass domain invariant ro rang.
|
|
80
80
|
- Khong report mass assignment/auth/ownership/current-user policy gap trong rule nay.
|
|
81
81
|
- Khong report fixed server-driven status transition chi vi thieu current-state check.
|
|
82
|
-
- Khong flag
|
|
82
|
+
- Khong flag file support-only (global exception handler, DTO, luong an toan) tru khi PRIMARY co direct invariant mutation evidence.
|
|
83
83
|
- Khong duplicate static rules hoac `ownership-scope-risk`, `io-boundary-risk`, `transaction-loop-risk`, `security-authorization-risk`, `security-mass-assignment-risk`, `error-handling-completeness`.
|
|
84
84
|
- Confidence `<50` -> KHONG emit.
|
|
85
85
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
id: spring-boot/business-invariant-risk
|
|
2
|
-
version:
|
|
2
|
+
version: 3
|
|
3
3
|
kind: ai
|
|
4
4
|
title: "Spring Boot business invariant/state transition co rui ro khong?"
|
|
5
5
|
description: |
|
|
@@ -14,7 +14,6 @@ scope: spring-boot
|
|
|
14
14
|
baseConfidence: 60
|
|
15
15
|
prompt: ./business-invariant-risk.prompt.md
|
|
16
16
|
contextScope: per-cluster
|
|
17
|
-
maxTokens: 1800
|
|
18
17
|
aiConfig:
|
|
19
18
|
tier: regular
|
|
20
19
|
prRouting:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
id: spring-boot/cache-consistency-risk
|
|
2
|
-
version:
|
|
2
|
+
version: 2
|
|
3
3
|
kind: ai
|
|
4
4
|
title: "Cache Consistency"
|
|
5
5
|
description: |
|
|
@@ -14,7 +14,6 @@ scope: spring-boot
|
|
|
14
14
|
baseConfidence: 60
|
|
15
15
|
prompt: ./cache-consistency-risk.prompt.md
|
|
16
16
|
contextScope: per-cluster
|
|
17
|
-
maxTokens: 1800
|
|
18
17
|
aiConfig:
|
|
19
18
|
tier: regular
|
|
20
19
|
prRouting:
|
|
@@ -7,7 +7,6 @@ Bạn là senior Spring Boot reviewer. Đánh giá **một module Spring Boot**
|
|
|
7
7
|
- **NHIỀU method / endpoint cùng CHUNG một kiểu drift = MỘT finding.** Vd. nếu nhiều method trong cùng một controller đều "trả `ResponseEntity<String>` raw thay vì error shape chuẩn của module" → đó là **MỘT** pattern duy nhất. Liệt kê các method trong `message`, **KHÔNG** tách mỗi method thành một finding riêng.
|
|
8
8
|
3. **`line` BẮT BUỘC là số nguyên dương** (≥ 1), trỏ vào một dòng cụ thể trong file đã chọn nơi pattern lộ rõ nhất (vd. dòng `catch (Exception e)`, dòng `return ResponseEntity.status(500)...`, dòng method handler lệch chuẩn). Nếu không chắc dòng nào → dùng `line: 1`. KHÔNG để trống, KHÔNG dùng `null`, KHÔNG dùng `0`.
|
|
9
9
|
4. **`file` phải là posix path** xuất hiện trong `Module summary` bên dưới — KHÔNG fabricate path mới.
|
|
10
|
-
5. **Confidence `<50` → KHÔNG emit.** Ngưỡng noise thấp (`numMaxFindings: 5`).
|
|
11
10
|
|
|
12
11
|
## Chỉ flag khi có pattern lặp lại ≥ 2 feature (cùng resource)
|
|
13
12
|
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
id: spring-boot/cross-feature-error-handling-drift
|
|
2
2
|
# v1 (Phase 15.5.3): third rule in the per-module family (ADR-0016), first
|
|
3
3
|
# Spring Boot per-module rule. Mirrors the validated cross-feature-api-drift /
|
|
4
|
-
# cross-feature-route-permission-drift shape
|
|
5
|
-
#
|
|
6
|
-
#
|
|
4
|
+
# cross-feature-route-permission-drift shape: per-module context, sandwich
|
|
5
|
+
# prompt, one-finding-per-pattern, and file-in-members requirements. Detects
|
|
6
|
+
# INCONSISTENT exception-handling /
|
|
7
7
|
# @ExceptionHandler registration across >= 2 controllers (features) of one
|
|
8
|
-
# module serving the same resource.
|
|
9
|
-
# Viettel Spring module) still pending — keep numMaxFindings small until it
|
|
10
|
-
# passes per ADR-0016 §"Implementation phase".
|
|
8
|
+
# module serving the same resource.
|
|
11
9
|
# Expect a likely v1->v2 dedup pass after the gate run (the GLM-4.7
|
|
12
10
|
# over-split quirk recurred on both prior per-module rules even with the
|
|
13
11
|
# one-finding-per-pattern instruction — see DEVELOPMENT.md Phase 15.5.3).
|
|
@@ -55,9 +53,5 @@ scope: spring-boot
|
|
|
55
53
|
baseConfidence: 55
|
|
56
54
|
prompt: ./cross-feature-error-handling-drift.prompt.md
|
|
57
55
|
contextScope: per-module
|
|
58
|
-
maxTokens: 1800
|
|
59
56
|
aiConfig:
|
|
60
57
|
tier: regular
|
|
61
|
-
# Cap findings để v1 ngưỡng noise thấp; nâng lên sau khi POC gate đạt
|
|
62
|
-
# ≥ 80% precision theo ADR-0016 §"Implementation phase".
|
|
63
|
-
numMaxFindings: 5
|
package/dist/builtin-rules/ai/spring-boot/cross-feature-transaction-boundary-drift.prompt.md
CHANGED
|
@@ -7,13 +7,13 @@ Bạn là senior Spring Boot reviewer. Đánh giá **một module Spring Boot**
|
|
|
7
7
|
- **NHIỀU method cùng CHUNG một kiểu drift = MỘT finding.** Vd. nếu nhiều method trong cùng một service đều "gọi nhiều mutation mà không có `@Transactional`" → đó là **MỘT** pattern duy nhất. Liệt kê các method trong `message`, **KHÔNG** tách mỗi method thành một finding riêng.
|
|
8
8
|
3. **`line` BẮT BUỘC là số nguyên dương** (≥ 1), trỏ vào một dòng cụ thể trong file đã chọn nơi pattern lộ rõ nhất (vd. dòng khai báo method mutation thiếu `@Transactional`, dòng `@Transactional(readOnly = true)` lệch chuẩn, dòng controller gọi thẳng repository.save). Nếu không chắc dòng nào → dùng `line: 1`. KHÔNG để trống, KHÔNG dùng `null`, KHÔNG dùng `0`.
|
|
9
9
|
4. **`file` phải là posix path** xuất hiện trong `Module summary` bên dưới — KHÔNG fabricate path mới.
|
|
10
|
-
5. **
|
|
10
|
+
5. **Transaction programmatic cũng là transaction hợp lệ.** `TransactionTemplate.execute(...)`, `executeWithoutResult(...)` và `TransactionOperations.execute(...)` bao phủ method/callback được ghi trong boundary facts; KHÔNG được coi write path đó là thiếu transaction chỉ vì không có annotation.
|
|
11
11
|
|
|
12
12
|
## Chỉ flag khi có pattern lặp lại ≥ 2 feature (cùng resource)
|
|
13
13
|
|
|
14
14
|
Suy ra "cùng resource" từ base path `@RequestMapping("/api/<resource>")`, tên domain trong tên controller/service (vd. `OrderService` + `OrderImportService` → resource `order`), hoặc cùng entity/repository. Chỉ flag khi:
|
|
15
15
|
|
|
16
|
-
- **Coverage drift**: một feature bọc chuỗi mutation nhiều bước (≥ 2 `save`/`delete`/`update` repository hoặc ghi nhiều entity liên quan) trong `@Transactional
|
|
16
|
+
- **Coverage drift**: một feature bọc chuỗi mutation nhiều bước (≥ 2 `save`/`delete`/`update` repository hoặc ghi nhiều entity liên quan) trong transaction declarative (`@Transactional`) hoặc programmatic (`TransactionTemplate`/`TransactionOperations`), feature kia phục vụ cùng resource thực hiện chuỗi mutation tương đương mà KHÔNG có transaction boundary nào → một bên atomic, bên kia partial-write được.
|
|
17
17
|
- **readOnly drift**: cùng một loại thao tác đọc (query/list) trên cùng resource được đánh `@Transactional(readOnly = true)` ở feature này nhưng `@Transactional` thường (write tx) hoặc không có ở feature khác → khoá/tối ưu DB không đồng nhất cho cùng kiểu truy cập.
|
|
18
18
|
- **Boundary-placement drift**: feature A đặt transaction ở tầng service (`@Transactional` trên service method), feature B cùng resource gọi nhiều `repository.save()`/mutation TRỰC TIẾP từ controller hoặc từ một component không `@Transactional` → ranh giới transaction đặt ở chỗ khác nhau cho cùng nghiệp vụ.
|
|
19
19
|
- **Propagation/rollback drift**: cùng một bước nghiệp vụ trên cùng resource dùng `propagation` khác nhau (vd. `REQUIRES_NEW` ở feature này vs mặc định ở feature kia), hoặc một feature khai báo `rollbackFor = Exception.class`/`noRollbackFor` còn feature kia dùng mặc định → hành vi commit/rollback không đồng nhất.
|
|
@@ -22,7 +22,7 @@ Suy ra "cùng resource" từ base path `@RequestMapping("/api/<resource>")`, tê
|
|
|
22
22
|
## KHÔNG flag
|
|
23
23
|
|
|
24
24
|
- Bug chỉ xuất hiện trong 1 feature (đã thuộc per-cluster rule `transaction-loop-risk`).
|
|
25
|
-
- Tất cả feature cùng resource
|
|
25
|
+
- Tất cả feature cùng resource đều có transaction boundary bao phủ write path (`@Transactional` hoặc programmatic), dù cơ chế biểu diễn khác nhau nhưng semantics tương đương → không phải coverage drift.
|
|
26
26
|
- Endpoint/feature chỉ đọc (query, list, get) hợp lý KHÔNG cần `@Transactional`, hoặc thiếu `@Transactional` ở thao tác single-statement (một `save` duy nhất, JPA tự flush) — đó KHÔNG phải drift, đừng so với một feature mutation nhiều bước.
|
|
27
27
|
- Các feature thao tác trên resource KHÁC NHAU — ranh giới transaction khác nhau là hợp lý.
|
|
28
28
|
- `@Transactional(readOnly = true)` chỉ ở read feature và write tx ở write feature là ĐÚNG thiết kế — chỉ flag khi CÙNG loại thao tác mà readOnly/propagation lệch.
|
|
@@ -41,11 +41,11 @@ Suy ra "cùng resource" từ base path `@RequestMapping("/api/<resource>")`, tê
|
|
|
41
41
|
|
|
42
42
|
{{module_findings}}
|
|
43
43
|
|
|
44
|
-
##
|
|
44
|
+
## Transaction boundaries (scan trực tiếp từ source của members — ĐÂY LÀ BẰNG CHỨNG CHÍNH)
|
|
45
45
|
|
|
46
|
-
Mỗi dòng = một
|
|
46
|
+
Mỗi dòng = một transaction boundary tìm thấy trong module. Mechanism có thể là `@Transactional`, `TransactionTemplate.execute`, `TransactionTemplate.executeWithoutResult`, `TransactionOperations.execute` hoặc `TransactionOperations.executeWithoutResult`. Fact kèm vị trí (`file:line`), phạm vi (`class`/`method`) + tên target, helper được callback gọi trực tiếp (`target() -> helper()`), `readOnly`, `rollbackFor`, `propagation`, `isolation`, và `writes≈N`. `readOnly=unknown` nghĩa là template được inject và cấu hình không thể suy ra tĩnh — không dùng giá trị đó để kết luận readOnly drift.
|
|
47
47
|
|
|
48
|
-
**Dùng các fact này để so sánh trực tiếp giữa các feature cùng resource** — đây là nguồn chính xác hơn pass-1 findings cho 4 loại drift bên dưới.
|
|
48
|
+
**Dùng các fact này để so sánh trực tiếp giữa các feature cùng resource** — đây là nguồn chính xác hơn pass-1 findings cho 4 loại drift bên dưới. Programmatic fact trên `split() -> doSplit()` nghĩa là cả callback/helper `doSplit()` chạy trong transaction; mutation nằm trong helper đó KHÔNG phải write ngoài transaction. Chỉ kết luận coverage drift khi một write path không được bất kỳ declarative hoặc programmatic fact nào bao phủ.
|
|
49
49
|
|
|
50
50
|
{{module_transaction_boundaries}}
|
|
51
51
|
|
|
@@ -72,14 +72,15 @@ Nếu không có drift rõ ràng: `{"violations": []}`.
|
|
|
72
72
|
|
|
73
73
|
## REPEAT CRITICAL RULES
|
|
74
74
|
|
|
75
|
-
- Ưu tiên đối chiếu danh sách
|
|
75
|
+
- Ưu tiên đối chiếu danh sách **Transaction boundaries** ở trên để xác định drift — pass-1 findings chỉ là signal phụ.
|
|
76
76
|
- Pattern phải xuất hiện trong ≥ 2 feature của module và CÙNG resource.
|
|
77
77
|
- **MỖI pattern = MỘT finding.** Gộp cùng pattern ngang nhiều file/method thành một finding; liệt kê tên service/controller trong `message`. KHÔNG lặp một pattern theo từng file/method.
|
|
78
78
|
- `file` phải nằm trong `members[]` của module summary trên.
|
|
79
79
|
- `line` phải là số nguyên ≥ 1 trỏ vào file đã chọn — KHÔNG để trống / `null` / `0`.
|
|
80
80
|
- KHÔNG duplicate findings đã có ở pass-1 (chúng đã được report ở leaf rule).
|
|
81
81
|
- Read-only / single-statement feature không có `@Transactional` KHÔNG phải drift — đừng so với feature mutation nhiều bước.
|
|
82
|
-
-
|
|
82
|
+
- Transaction programmatic bao phủ method/helper là transaction hợp lệ; KHÔNG flag thiếu transaction chỉ vì write method không có `@Transactional` trực tiếp.
|
|
83
|
+
- Mọi feature cùng resource đặt transaction nhất quán hoặc có semantics tương đương → KHÔNG phải drift, đừng flag.
|
|
83
84
|
- Confidence `<50` → KHÔNG emit.
|
|
84
85
|
|
|
85
86
|
Đừng giải thích. JSON thuần.
|
package/dist/builtin-rules/ai/spring-boot/cross-feature-transaction-boundary-drift.rule.yaml
CHANGED
|
@@ -2,13 +2,10 @@ id: spring-boot/cross-feature-transaction-boundary-drift
|
|
|
2
2
|
# v1 (Phase 15.5.3): fourth rule in the per-module family (ADR-0016), second
|
|
3
3
|
# Spring Boot per-module rule. Mirrors the validated cross-feature-api-drift /
|
|
4
4
|
# cross-feature-route-permission-drift / cross-feature-error-handling-drift
|
|
5
|
-
# shape
|
|
6
|
-
# one-finding-per-pattern + line >= 1 + file in members[] requirements).
|
|
5
|
+
# shape: one-finding-per-pattern, line >= 1, and file-in-members requirements.
|
|
7
6
|
# Detects INCONSISTENT transaction boundaries (@Transactional placement /
|
|
8
7
|
# readOnly / propagation / rollbackFor) across >= 2 services/controllers
|
|
9
|
-
# (features) of one module mutating the same resource.
|
|
10
|
-
# (>= 80% precision on a small Viettel Spring module) still pending — keep
|
|
11
|
-
# numMaxFindings small until it passes per ADR-0016 §"Implementation phase".
|
|
8
|
+
# (features) of one module mutating the same resource.
|
|
12
9
|
# Unlike rule #3 (error-handling), transaction boundaries live on
|
|
13
10
|
# service-layer methods that DO share import/domain-token edges with the
|
|
14
11
|
# controllers, so the cluster assembler already sees them — no global-advice
|
|
@@ -22,9 +19,13 @@ id: spring-boot/cross-feature-transaction-boundary-drift
|
|
|
22
19
|
# new `{{module_transaction_boundaries}}` prompt var. Prompt now compares
|
|
23
20
|
# those facts directly across features. Version bump cache-busts the v1
|
|
24
21
|
# rows that ran without the boundary evidence.
|
|
25
|
-
|
|
22
|
+
# v3: recognize programmatic Spring transaction boundaries
|
|
23
|
+
# (`TransactionTemplate` / `TransactionOperations`) and their directly
|
|
24
|
+
# delegated helper so annotation absence is no longer treated as proof that a
|
|
25
|
+
# write path is non-transactional. Version bump invalidates cached v2 findings.
|
|
26
|
+
version: 3
|
|
26
27
|
kind: ai
|
|
27
|
-
title: "Các feature trong cùng module quản lý ranh giới
|
|
28
|
+
title: "Các feature trong cùng module quản lý ranh giới transaction không nhất quán?"
|
|
28
29
|
description: |
|
|
29
30
|
Per-module AI rule (Phase 15.5.3, ADR-0016) — phát hiện **drift trong
|
|
30
31
|
ranh giới transaction** giữa nhiều feature (controller + service) CỦA
|
|
@@ -32,9 +33,10 @@ description: |
|
|
|
32
33
|
**synthesis** chỉ lộ ra khi nhìn ngang nhiều feature, không phải vấn đề
|
|
33
34
|
trong 1 cluster:
|
|
34
35
|
- Một feature bọc chuỗi mutation nhiều bước (nhiều `repository.save()` /
|
|
35
|
-
nhiều bảng) trong `@Transactional
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
nhiều bảng) trong transaction declarative (`@Transactional`) hoặc
|
|
37
|
+
programmatic (`TransactionTemplate` / `TransactionOperations`), feature
|
|
38
|
+
khác cùng resource thực hiện thao tác tương đương nhưng KHÔNG có
|
|
39
|
+
transaction → một bên atomic, bên kia có nguy cơ ghi dở (partial write).
|
|
38
40
|
- Cùng một loại thao tác đọc được đánh `@Transactional(readOnly = true)`
|
|
39
41
|
ở feature này nhưng `@Transactional` thường (hoặc không có) ở feature
|
|
40
42
|
khác cùng module → tối ưu / khoá DB không đồng nhất.
|
|
@@ -60,9 +62,5 @@ scope: spring-boot
|
|
|
60
62
|
baseConfidence: 55
|
|
61
63
|
prompt: ./cross-feature-transaction-boundary-drift.prompt.md
|
|
62
64
|
contextScope: per-module
|
|
63
|
-
maxTokens: 1800
|
|
64
65
|
aiConfig:
|
|
65
66
|
tier: regular
|
|
66
|
-
# Cap findings để v1 ngưỡng noise thấp; nâng lên sau khi POC gate đạt
|
|
67
|
-
# ≥ 80% precision theo ADR-0016 §"Implementation phase".
|
|
68
|
-
numMaxFindings: 5
|
|
@@ -12,7 +12,7 @@ Bạn là **senior Spring Boot reviewer**. Đánh giá **error handling flow** c
|
|
|
12
12
|
6. **High-signal only** — rule này KHÔNG phải catch-all cho mọi uncaught service exception. Chỉ emit các pattern trong mục "Tiêu chí flag" bên dưới.
|
|
13
13
|
7. **Không overlap với security/backend-flow** — nếu symptom chính là thiếu authorization, IDOR, unsafe outbound/file flow, transaction multi-write, hoặc invariant nghiệp vụ, để rule tương ứng xử lý. Error-handling chỉ flag cách lỗi bị catch/leak/swallow/map sai.
|
|
14
14
|
8. **Không duplicate raw-error security leak trừ khi có error-handling bug riêng** — `e.getMessage()` / `e.toString()` chỉ là finding rule này khi catch cũng map sai lỗi nghiệp vụ/user-correctable, swallow failure, hoặc làm client hiểu sai kết quả.
|
|
15
|
-
9. **
|
|
15
|
+
9. **File chỉ đóng vai chứng cứ** — KHÔNG report một `@ControllerAdvice` / global exception handler, DTO, hay luồng mà cluster cho thấy là đường an toàn, nếu không có evidence trực tiếp trong PRIMARY. Một global handler chỉ là evidence xử lý lỗi khi annotation/assignable target của nó áp dụng cho PRIMARY.
|
|
16
16
|
10. **Scan đủ cluster trước khi emit** — đọc PRIMARY, service support, repository support, và advice/handler support. Nếu service/advice body cần thiết không có trong cluster thì skip thay vì đoán.
|
|
17
17
|
11. **Global `@ControllerAdvice` / `@RestControllerAdvice` được TIÊM vào MỌI cluster** (kể cả khi nó ở package khác như `exception/`, `web/rest/errors/`). Nếu support files có một advice class với `@ExceptionHandler` cho một exception type (vd. `NotFoundException` → 404, `Exception` → 500), thì exception đó ĐÃ được handle app-wide cho PRIMARY (trừ khi advice khai báo `assignableTypes`/`basePackages` loại trừ PRIMARY). KHÔNG flag "missing handler" cho exception mà advice trong cluster đã cover.
|
|
18
18
|
12. **Confidence `<50` → KHÔNG emit**.
|
|
@@ -42,8 +42,8 @@ Nếu cùng một catch block vừa `catch (Exception)` vừa trả `e.getMessag
|
|
|
42
42
|
## KHÔNG flag
|
|
43
43
|
|
|
44
44
|
- Controller `throws Exception` được handle ở `@ControllerAdvice` HIỆN diện trong cluster (kể cả file `*ExceptionHandler.java` / `*Advice.java`).
|
|
45
|
-
- `
|
|
46
|
-
-
|
|
45
|
+
- Mot `@ControllerAdvice` neu no chi apply cho controller khac (`assignableTypes`, package/path mismatch) va khong phai handler cua PRIMARY; dung no de skip false-positive cho safe flow, khong report chinh file advice do.
|
|
46
|
+
- File support-only (global exception handler, DTO, luong an toan) tru khi PRIMARY co catch/leak/swallow/missing-handler evidence truc tiep.
|
|
47
47
|
- Service throw nhưng controller method gọi nó được wrap trong helper với try/catch xử lý đúng.
|
|
48
48
|
- Test files, generated files, DTO/Entity thuần.
|
|
49
49
|
- Intentional crash / demo / test endpoints (xem CRITICAL RULE 4).
|
|
@@ -101,7 +101,7 @@ Trả về **JSON HỢP LỆ DUY NHẤT** (không markdown fence, không text kh
|
|
|
101
101
|
- **High-signal only** — không flag normal read/not-found flow hoặc Optional `.get()` chỉ vì thiếu handler.
|
|
102
102
|
- **Scan đủ cluster** — trước khi emit missing-handler, xác nhận service method được PRIMARY gọi throw explicit domain/runtime exception và không có applicable `@ExceptionHandler`/`@ControllerAdvice`/`@RestControllerAdvice` trong support files. Global advice giờ được TIÊM vào mọi cluster → nếu thấy advice cover exception đó (kể cả ở package khác), KHÔNG flag missing-handler.
|
|
103
103
|
- Không hard-code theo tên controller/method; quyết định dựa trên flow lỗi thực tế trong cluster và ranh giới rule ở trên.
|
|
104
|
-
- Không report
|
|
104
|
+
- Không report file support-only (global exception handler, DTO, luong an toan) neu khong co direct evidence trong PRIMARY.
|
|
105
105
|
- Raw `e.getMessage()`/`e.toString()` chỉ vào rule này khi có map sai lỗi nghiệp vụ/user-correctable, swallow failure, hoặc wrong success semantics; nếu chỉ là security leak, để security rule.
|
|
106
106
|
- Nếu một catch block vừa generic catch vừa trả raw exception string, gộp thành 1 finding.
|
|
107
107
|
- **Mỗi finding distinct** — không duplicate message cho nhiều dòng.
|
|
@@ -33,7 +33,7 @@ id: spring-boot/error-handling-completeness
|
|
|
33
33
|
# CRITICAL RULE: don't flag missing-handler for an exception a
|
|
34
34
|
# cluster-visible advice already covers. Version bump invalidates the
|
|
35
35
|
# stale findings cached against the pre-injection (smaller) clusters.
|
|
36
|
-
version:
|
|
36
|
+
version: 11
|
|
37
37
|
kind: ai
|
|
38
38
|
title: "Error handling có đầy đủ và đúng pattern không?"
|
|
39
39
|
description: |
|
|
@@ -73,7 +73,6 @@ scope: spring-boot
|
|
|
73
73
|
baseConfidence: 65
|
|
74
74
|
prompt: ./error-handling-completeness.prompt.md
|
|
75
75
|
contextScope: per-cluster
|
|
76
|
-
maxTokens: 1400
|
|
77
76
|
aiConfig:
|
|
78
77
|
tier: regular
|
|
79
78
|
prRouting:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
id: spring-boot/event-publishing-risk
|
|
2
|
-
version:
|
|
2
|
+
version: 2
|
|
3
3
|
kind: ai
|
|
4
4
|
title: "Event Publishing Risk"
|
|
5
5
|
description: |
|
|
@@ -14,7 +14,6 @@ scope: spring-boot
|
|
|
14
14
|
baseConfidence: 60
|
|
15
15
|
prompt: ./event-publishing-risk.prompt.md
|
|
16
16
|
contextScope: per-cluster
|
|
17
|
-
maxTokens: 1800
|
|
18
17
|
aiConfig:
|
|
19
18
|
tier: regular
|
|
20
19
|
prRouting:
|