@code-sentinel-cli/code-sentinel-cli 3.0.3 → 3.0.4
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/README.md +1 -1
- package/dist/bin.js +1184 -809
- package/dist/builtin-rules/ai/angular/api-service-contract-risk.prompt.md +71 -0
- package/dist/builtin-rules/ai/angular/api-service-contract-risk.rule.yaml +22 -0
- package/dist/builtin-rules/ai/angular/component-state-flow.prompt.md +79 -0
- package/dist/builtin-rules/ai/angular/component-state-flow.rule.yaml +26 -0
- package/dist/builtin-rules/ai/angular/cross-feature-api-drift.prompt.md +70 -0
- package/dist/builtin-rules/ai/angular/cross-feature-api-drift.rule.yaml +42 -0
- package/dist/builtin-rules/ai/angular/cross-feature-route-permission-drift.prompt.md +73 -0
- package/dist/builtin-rules/ai/angular/cross-feature-route-permission-drift.rule.yaml +50 -0
- package/dist/builtin-rules/ai/angular/reactive-form-flow.prompt.md +82 -0
- package/dist/builtin-rules/ai/angular/reactive-form-flow.rule.yaml +23 -0
- package/dist/builtin-rules/ai/angular/route-permission-flow.prompt.md +80 -0
- package/dist/builtin-rules/ai/angular/route-permission-flow.rule.yaml +23 -0
- package/dist/builtin-rules/ai/angular/rxjs-flow-risk.prompt.md +82 -0
- package/dist/builtin-rules/ai/angular/rxjs-flow-risk.rule.yaml +24 -0
- package/dist/builtin-rules/ai/angular/template-contract-risk.prompt.md +80 -0
- package/dist/builtin-rules/ai/angular/template-contract-risk.rule.yaml +25 -0
- package/dist/builtin-rules/ai/flutter/dynamic-content-risk.prompt.md +55 -0
- package/dist/builtin-rules/ai/flutter/dynamic-content-risk.rule.yaml +18 -0
- package/dist/builtin-rules/ai/flutter/feature-state-flow-risk.prompt.md +58 -0
- package/dist/builtin-rules/ai/flutter/feature-state-flow-risk.rule.yaml +18 -0
- package/dist/builtin-rules/ai/flutter/native-platform-consistency-risk.prompt.md +56 -0
- package/dist/builtin-rules/ai/flutter/native-platform-consistency-risk.rule.yaml +18 -0
- package/dist/builtin-rules/ai/flutter/network-auth-flow-risk.prompt.md +57 -0
- package/dist/builtin-rules/ai/flutter/network-auth-flow-risk.rule.yaml +19 -0
- package/dist/builtin-rules/ai/flutter/ui-responsive-accessibility-risk.prompt.md +60 -0
- package/dist/builtin-rules/ai/flutter/ui-responsive-accessibility-risk.rule.yaml +18 -0
- package/dist/builtin-rules/ai/general/code-clarity.prompt.md +57 -0
- package/dist/builtin-rules/ai/general/code-clarity.rule.yaml +20 -0
- package/dist/builtin-rules/ai/spring-boot/business-invariant-risk.prompt.md +86 -0
- package/dist/builtin-rules/ai/spring-boot/business-invariant-risk.rule.yaml +25 -0
- package/dist/builtin-rules/ai/spring-boot/cache-consistency-risk.prompt.md +80 -0
- package/dist/builtin-rules/ai/spring-boot/cache-consistency-risk.rule.yaml +25 -0
- package/dist/builtin-rules/ai/spring-boot/cross-feature-error-handling-drift.prompt.md +76 -0
- package/dist/builtin-rules/ai/spring-boot/cross-feature-error-handling-drift.rule.yaml +63 -0
- package/dist/builtin-rules/ai/spring-boot/cross-feature-transaction-boundary-drift.prompt.md +85 -0
- package/dist/builtin-rules/ai/spring-boot/cross-feature-transaction-boundary-drift.rule.yaml +68 -0
- package/dist/builtin-rules/ai/spring-boot/error-handling-completeness.prompt.md +121 -0
- package/dist/builtin-rules/ai/spring-boot/error-handling-completeness.rule.yaml +84 -0
- package/dist/builtin-rules/ai/spring-boot/event-publishing-risk.prompt.md +80 -0
- package/dist/builtin-rules/ai/spring-boot/event-publishing-risk.rule.yaml +25 -0
- package/dist/builtin-rules/ai/spring-boot/io-boundary-risk.prompt.md +78 -0
- package/dist/builtin-rules/ai/spring-boot/io-boundary-risk.rule.yaml +25 -0
- package/dist/builtin-rules/ai/spring-boot/ownership-scope-risk.prompt.md +83 -0
- package/dist/builtin-rules/ai/spring-boot/ownership-scope-risk.rule.yaml +25 -0
- package/dist/builtin-rules/ai/spring-boot/pagination-risk.prompt.md +81 -0
- package/dist/builtin-rules/ai/spring-boot/pagination-risk.rule.yaml +25 -0
- package/dist/builtin-rules/ai/spring-boot/security-authorization-risk.prompt.md +75 -0
- package/dist/builtin-rules/ai/spring-boot/security-authorization-risk.rule.yaml +26 -0
- package/dist/builtin-rules/ai/spring-boot/security-mass-assignment-risk.prompt.md +75 -0
- package/dist/builtin-rules/ai/spring-boot/security-mass-assignment-risk.rule.yaml +24 -0
- package/dist/builtin-rules/ai/spring-boot/security-redirect-risk.prompt.md +74 -0
- package/dist/builtin-rules/ai/spring-boot/security-redirect-risk.rule.yaml +24 -0
- package/dist/builtin-rules/ai/spring-boot/security-sensitive-data-risk.prompt.md +75 -0
- package/dist/builtin-rules/ai/spring-boot/security-sensitive-data-risk.rule.yaml +25 -0
- package/dist/builtin-rules/ai/spring-boot/transaction-loop-risk.prompt.md +78 -0
- package/dist/builtin-rules/ai/spring-boot/transaction-loop-risk.rule.yaml +25 -0
- package/dist/builtin-rules/static/angular/component-prefix.rule.js +78 -0
- package/dist/builtin-rules/static/angular/image-control-alt-required.rule.js +105 -0
- package/dist/builtin-rules/static/angular/img-alt-required.rule.js +96 -0
- package/dist/builtin-rules/static/angular/inject-pattern.rule.js +47 -0
- package/dist/builtin-rules/static/angular/lifecycle-method-required.rule.js +59 -0
- package/dist/builtin-rules/static/angular/no-any-type.rule.yaml +55 -0
- package/dist/builtin-rules/static/angular/no-direct-dom-access.rule.js +191 -0
- package/dist/builtin-rules/static/angular/no-dom-xss.rule.js +48 -0
- package/dist/builtin-rules/static/angular/no-leaky-subscription.rule.js +197 -0
- package/dist/builtin-rules/static/angular/no-ngmodule.rule.yaml +44 -0
- package/dist/builtin-rules/static/angular/no-non-null-asserted-optional-chain.rule.js +53 -0
- package/dist/builtin-rules/static/angular/no-uncalled-signal-in-condition.rule.js +112 -0
- package/dist/builtin-rules/static/angular/observable-naming.rule.js +85 -0
- package/dist/builtin-rules/static/angular/onpush-required.rule.js +70 -0
- package/dist/builtin-rules/static/angular/standalone-component-required.rule.js +65 -0
- package/dist/builtin-rules/static/angular/template-dom-xss.rule.js +112 -0
- package/dist/builtin-rules/static/angular/template-syntax-modern.rule.js +154 -0
- package/dist/builtin-rules/static/angular/trackby-required.rule.js +66 -0
- package/dist/builtin-rules/static/flutter/android-exported-component.rule.js +75 -0
- package/dist/builtin-rules/static/flutter/android-manifest-hardening.rule.js +117 -0
- package/dist/builtin-rules/static/flutter/android-sensitive-permissions.rule.js +87 -0
- package/dist/builtin-rules/static/flutter/debug-tooling-release-risk.rule.js +90 -0
- package/dist/builtin-rules/static/flutter/dynamic-archive-risk.rule.js +96 -0
- package/dist/builtin-rules/static/flutter/hive-sensitive-storage.rule.js +77 -0
- package/dist/builtin-rules/static/flutter/ios-privacy-hardening.rule.js +119 -0
- package/dist/builtin-rules/static/flutter/packaged-env-risk.rule.js +95 -0
- package/dist/builtin-rules/static/flutter/sensitive-log-leak.rule.js +94 -0
- package/dist/builtin-rules/static/flutter/webview-bridge-guard.rule.js +102 -0
- package/dist/builtin-rules/static/general/file-too-long.rule.js +41 -0
- package/dist/builtin-rules/static/general/function-too-long.rule.js +72 -0
- package/dist/builtin-rules/static/general/no-circular-import.rule.js +39 -0
- package/dist/builtin-rules/static/general/no-code-injection.rule.js +48 -0
- package/dist/builtin-rules/static/general/no-console-log.rule.js +110 -0
- package/dist/builtin-rules/static/general/no-empty-catch.rule.yaml +56 -0
- package/dist/builtin-rules/static/general/no-hardcoded-secret.rule.js +517 -0
- package/dist/builtin-rules/static/general/no-magic-number.rule.js +78 -0
- package/dist/builtin-rules/static/general/no-open-redirect.rule.js +46 -0
- package/dist/builtin-rules/static/general/no-todo-comment.rule.yaml +30 -0
- package/dist/builtin-rules/static/general/no-unresolved-import-symbol.rule.js +80 -0
- package/dist/builtin-rules/static/general/no-unused-export.rule.js +140 -0
- package/dist/builtin-rules/static/spring-boot/no-autowired-field.rule.js +162 -0
- package/dist/builtin-rules/static/spring-boot/no-business-logic-in-controller.rule.js +94 -0
- package/dist/builtin-rules/static/spring-boot/no-command-injection.rule.js +47 -0
- package/dist/builtin-rules/static/spring-boot/no-entity-in-controller.rule.yaml +52 -0
- package/dist/builtin-rules/static/spring-boot/no-nplus1-query-in-loop.rule.js +106 -0
- package/dist/builtin-rules/static/spring-boot/no-path-traversal.rule.js +47 -0
- package/dist/builtin-rules/static/spring-boot/no-spel-injection.rule.js +41 -0
- package/dist/builtin-rules/static/spring-boot/no-sql-string-concat.rule.js +194 -0
- package/dist/builtin-rules/static/spring-boot/no-ssrf.rule.js +49 -0
- package/dist/builtin-rules/static/spring-boot/no-transactional-self-invocation.rule.js +142 -0
- package/dist/builtin-rules/static/spring-boot/no-unclosed-resource.rule.js +108 -0
- package/dist/builtin-rules/static/spring-boot/no-unsafe-shared-formatter.rule.js +118 -0
- package/dist/builtin-rules/static/spring-boot/repository-naming.rule.yaml +42 -0
- package/dist/builtin-rules/static/spring-boot/restful-naming.rule.yaml +39 -0
- package/dist/builtin-rules/static/spring-boot/transaction-on-service.rule.yaml +58 -0
- package/dist/builtin-rules/static/spring-boot/validate-input.rule.js +123 -0
- package/dist/builtin-rules/vauthz/static/spring-boot/require-authz-check.rule.js +101 -0
- package/dist/index.d.ts +224 -47
- package/dist/index.js +1183 -808
- package/package.json +3 -2
- package/src/migrations/0000_initial.sql +62 -0
- package/src/migrations/0001_add_confidence.sql +7 -0
- package/src/migrations/0002_add_ai_stats.sql +21 -0
- package/src/migrations/0003_add_fix_recipe.sql +29 -0
- package/src/migrations/0004_add_ast_graph.sql +61 -0
- package/src/migrations/0005_add_project_id.sql +1 -0
- package/src/migrations/0006_add_ai_model.sql +5 -0
- package/src/migrations/0006_add_rule_results.sql +1 -0
- package/src/migrations/0007_add_finding_metadata.sql +4 -0
- package/src/migrations/0008_add_coverage.sql +2 -0
- package/src/migrations/0009_run_provenance.sql +5 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
You are a senior Spring Boot security reviewer. Review this unit ONLY for endpoint authorization gaps.
|
|
2
|
+
|
|
3
|
+
## CRITICAL RULES
|
|
4
|
+
|
|
5
|
+
CRITICAL NON-VIOLATIONS:
|
|
6
|
+
|
|
7
|
+
- NEVER report pure IDOR/owner/tenant query scope here. `ownership-scope-risk` owns object-scope bugs after auth exists.
|
|
8
|
+
- NEVER report validation, SQL, filesystem, generic SSRF, transaction, error handling, mass assignment, logging, or open redirect here.
|
|
9
|
+
- NEVER treat the mere presence of `SecurityConfig.java` as protection. It must clearly match the reviewed route and require auth/role.
|
|
10
|
+
|
|
11
|
+
1. Report ONLY evidence visible in the PRIMARY controller or support files.
|
|
12
|
+
2. `line` MUST point to the PRIMARY controller file. If evidence is in SecurityConfig/service, use the controller route line.
|
|
13
|
+
3. Confidence `<50` means DO NOT emit.
|
|
14
|
+
|
|
15
|
+
## Flag only these authorization bugs
|
|
16
|
+
|
|
17
|
+
- Controller method has a route annotation and handles sensitive data/action, but has no method/class `@PreAuthorize`, `@Secured`, `@RolesAllowed`, route-matching SecurityConfig auth/role rule, filter/guard, or service authorization.
|
|
18
|
+
- Sensitive actions include create/update/delete domain object, admin/support/billing/payout/refund/role action, user/account/tenant data by id, or internal operation with privilege impact.
|
|
19
|
+
- SecurityConfig exists but route is explicitly `permitAll()`, bypassed by broad matcher, or not matched by any auth/role rule.
|
|
20
|
+
|
|
21
|
+
## DO NOT flag
|
|
22
|
+
|
|
23
|
+
- Public-safe technical endpoints: health, readiness, static assets, docs, login, callback with visible signature/allowlist check.
|
|
24
|
+
- Read-only search/list endpoint with visible tenant/account scope and no sensitive data/action in cluster.
|
|
25
|
+
- Demo/test/fixture/generated/static-analysis sample controller.
|
|
26
|
+
- Endpoint already protected by method/class security or route-matching SecurityConfig.
|
|
27
|
+
- Owner/tenant/account scope missing after auth; use `ownership-scope-risk`.
|
|
28
|
+
|
|
29
|
+
## Primary file
|
|
30
|
+
|
|
31
|
+
File: `{{file}}`
|
|
32
|
+
Language: `{{language}}`
|
|
33
|
+
|
|
34
|
+
```{{language}}
|
|
35
|
+
{{code}}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Support files in same cluster
|
|
39
|
+
|
|
40
|
+
Use support files only when they relate to the PRIMARY controller.
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
{{cluster_files}}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
{{cluster_summary}}
|
|
47
|
+
|
|
48
|
+
## Output
|
|
49
|
+
|
|
50
|
+
Return ONLY valid JSON, no markdown fence and no extra text:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
{
|
|
54
|
+
"violations": [
|
|
55
|
+
{
|
|
56
|
+
"line": <positive integer, 1-based, in PRIMARY>,
|
|
57
|
+
"endLine": <positive integer | null>,
|
|
58
|
+
"message": "<<=200 chars, Vietnamese, explain missing route authorization>",
|
|
59
|
+
"suggestion": "<fix suggestion | null>",
|
|
60
|
+
"confidence": <integer 0-100>
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
If no clear authorization bug exists: `{"violations": []}`.
|
|
67
|
+
|
|
68
|
+
## REPEAT CRITICAL RULES
|
|
69
|
+
|
|
70
|
+
- `line` must point to PRIMARY controller, not support files.
|
|
71
|
+
- Skip when SecurityConfig clearly protects this exact route.
|
|
72
|
+
- Do not duplicate `ownership-scope-risk`, `security-mass-assignment-risk`, `security-sensitive-data-risk`, `security-redirect-risk`, or static rules.
|
|
73
|
+
- Confidence `<50` means DO NOT emit.
|
|
74
|
+
|
|
75
|
+
Do not explain. JSON only.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
id: spring-boot/security-authorization-risk
|
|
2
|
+
version: 1
|
|
3
|
+
kind: ai
|
|
4
|
+
title: "Spring Boot endpoint authorization gap?"
|
|
5
|
+
description: |
|
|
6
|
+
Per-cluster AI rule for endpoint-level authorization gaps in Spring Boot.
|
|
7
|
+
It flags sensitive controller routes that lack method/class security,
|
|
8
|
+
route-matching SecurityConfig protection, or visible guard/service
|
|
9
|
+
authorization. It does not flag pure owner/tenant scope gaps; those belong
|
|
10
|
+
to `spring-boot/ownership-scope-risk`.
|
|
11
|
+
severity: warning
|
|
12
|
+
category: security
|
|
13
|
+
languages: [java]
|
|
14
|
+
scope: spring-boot
|
|
15
|
+
baseConfidence: 60
|
|
16
|
+
prompt: ./security-authorization-risk.prompt.md
|
|
17
|
+
contextScope: per-cluster
|
|
18
|
+
maxTokens: 1200
|
|
19
|
+
aiConfig:
|
|
20
|
+
tier: regular
|
|
21
|
+
prRouting:
|
|
22
|
+
group: spring-security-risk-group
|
|
23
|
+
targetLayers: [controller, service, config]
|
|
24
|
+
triggers: ["@PreAuthorize", "@PostAuthorize", "SecurityContext", "UserContext", "userId", "tenantId", "role", "permission"]
|
|
25
|
+
riskWeight: 5
|
|
26
|
+
requiresContext: [diff, primaryFile, relatedController, relatedService, securityConfig]
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
You are a senior Spring Boot security reviewer. Review this unit ONLY for mass assignment and security-state input bugs.
|
|
2
|
+
|
|
3
|
+
## CRITICAL RULES
|
|
4
|
+
|
|
5
|
+
CRITICAL NON-VIOLATIONS:
|
|
6
|
+
|
|
7
|
+
- NEVER report missing endpoint authorization, owner/tenant query scope, logging, raw exception response, open redirect, filesystem, generic SSRF, transaction, or validation here.
|
|
8
|
+
- NEVER report DTO/request/form payload usage as mass assignment by itself.
|
|
9
|
+
- NEVER report normal business status/state unless it is security-sensitive; `business-invariant-risk` owns business-only state transitions.
|
|
10
|
+
|
|
11
|
+
1. Report ONLY evidence visible in the PRIMARY controller or support files.
|
|
12
|
+
2. `line` MUST point to the PRIMARY controller file. If entity evidence is in support files, use the controller request-body/write line.
|
|
13
|
+
3. Confidence `<50` means DO NOT emit.
|
|
14
|
+
|
|
15
|
+
## Flag only these bugs
|
|
16
|
+
|
|
17
|
+
- Write endpoint accepts `@RequestBody <EntityClass>` where support files show `<EntityClass>` is a JPA `@Entity`, not a DTO, and exposes server-controlled fields.
|
|
18
|
+
- Server-controlled fields include `id`, `role`, `roles`, `admin`, `isAdmin`, `enabled`, `locked`, `tenantId`, `accountId`, `ownerId`, `createdBy`, `updatedBy`, `approvedBy`, `released`.
|
|
19
|
+
- Request param/header/body directly sets security-sensitive state such as `role`, `admin`, `enabled`, `locked`, `tenantId`, `accountId`, `actingUser`, or `approvedBy` without allowlist, mapper, policy, or principal binding.
|
|
20
|
+
|
|
21
|
+
## DO NOT flag
|
|
22
|
+
|
|
23
|
+
- Type name ends with `Dto`, `DTO`, `Request`, `Form`, `Vm`, `Payload`, or visible mapper copies only allowed fields.
|
|
24
|
+
- Entity fields are protected by `@JsonIgnore`, write-only allowlist, validation group, policy service, or explicit allowlist.
|
|
25
|
+
- Request value is only a search/filter parameter and does not mutate security-sensitive state.
|
|
26
|
+
- Business-only amount/status/state invariant; use `business-invariant-risk`.
|
|
27
|
+
|
|
28
|
+
## Primary file
|
|
29
|
+
|
|
30
|
+
File: `{{file}}`
|
|
31
|
+
Language: `{{language}}`
|
|
32
|
+
|
|
33
|
+
```{{language}}
|
|
34
|
+
{{code}}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Support files in same cluster
|
|
38
|
+
|
|
39
|
+
Use support files only when they relate to the PRIMARY controller.
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
{{cluster_files}}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
{{cluster_summary}}
|
|
46
|
+
|
|
47
|
+
## Output
|
|
48
|
+
|
|
49
|
+
Return ONLY valid JSON, no markdown fence and no extra text:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
{
|
|
53
|
+
"violations": [
|
|
54
|
+
{
|
|
55
|
+
"line": <positive integer, 1-based, in PRIMARY>,
|
|
56
|
+
"endLine": <positive integer | null>,
|
|
57
|
+
"message": "<<=200 chars, Vietnamese, explain mass assignment/security-state input>",
|
|
58
|
+
"suggestion": "<fix suggestion | null>",
|
|
59
|
+
"confidence": <integer 0-100>
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
If no clear mass assignment/security-state input bug exists: `{"violations": []}`.
|
|
66
|
+
|
|
67
|
+
## REPEAT CRITICAL RULES
|
|
68
|
+
|
|
69
|
+
- `line` must point to PRIMARY controller, not support files.
|
|
70
|
+
- Do not flag DTO/request/form payloads.
|
|
71
|
+
- Report only entity binding or request-controlled security-sensitive state with visible evidence.
|
|
72
|
+
- Do not duplicate `security-authorization-risk`, `security-sensitive-data-risk`, `security-redirect-risk`, `ownership-scope-risk`, or `business-invariant-risk`.
|
|
73
|
+
- Confidence `<50` means DO NOT emit.
|
|
74
|
+
|
|
75
|
+
Do not explain. JSON only.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
id: spring-boot/security-mass-assignment-risk
|
|
2
|
+
version: 1
|
|
3
|
+
kind: ai
|
|
4
|
+
title: "Spring Boot mass assignment or security-state input?"
|
|
5
|
+
description: |
|
|
6
|
+
Per-cluster AI rule for mass assignment and client-controlled security
|
|
7
|
+
state in Spring Boot write endpoints. It focuses on `@RequestBody` entity
|
|
8
|
+
binding and request-controlled role/admin/tenant/security flags.
|
|
9
|
+
severity: warning
|
|
10
|
+
category: security
|
|
11
|
+
languages: [java]
|
|
12
|
+
scope: spring-boot
|
|
13
|
+
baseConfidence: 60
|
|
14
|
+
prompt: ./security-mass-assignment-risk.prompt.md
|
|
15
|
+
contextScope: per-cluster
|
|
16
|
+
maxTokens: 1200
|
|
17
|
+
aiConfig:
|
|
18
|
+
tier: regular
|
|
19
|
+
prRouting:
|
|
20
|
+
group: spring-security-risk-group
|
|
21
|
+
targetLayers: [controller, service, dto]
|
|
22
|
+
triggers: ["@RequestBody", "BeanUtils", "ModelMapper", "setRole", "setStatus", "setOwner", "setTenant", "update"]
|
|
23
|
+
riskWeight: 4
|
|
24
|
+
requiresContext: [diff, primaryFile, relatedController, relatedService]
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
You are a senior Spring Boot security reviewer. Review this unit ONLY for open redirect or unsafe forward bugs.
|
|
2
|
+
|
|
3
|
+
## CRITICAL RULES
|
|
4
|
+
|
|
5
|
+
CRITICAL NON-VIOLATIONS:
|
|
6
|
+
|
|
7
|
+
- NEVER report generic outbound HTTP/SSRF, filesystem, auth, owner scope, mass assignment, logging, transaction, or error handling here.
|
|
8
|
+
- NEVER report redirect to a constant internal path.
|
|
9
|
+
- NEVER report when an allowlist or same-origin/relative-path validator is visible before redirect.
|
|
10
|
+
|
|
11
|
+
1. Report ONLY evidence visible in the PRIMARY controller or support files.
|
|
12
|
+
2. `line` MUST point to the PRIMARY controller file. If redirect helper is in service, use the controller line that calls it.
|
|
13
|
+
3. Confidence `<50` means DO NOT emit.
|
|
14
|
+
|
|
15
|
+
## Flag only these redirect bugs
|
|
16
|
+
|
|
17
|
+
- Request param/header/body/path variable controls `new RedirectView(value)`, `response.sendRedirect(value)`, `return "redirect:" + value`, `forward:` value, or equivalent redirect target.
|
|
18
|
+
- Stored redirect destination selected by request id is used without owner check and allowlist.
|
|
19
|
+
- Redirect allowlist exists but is not used on the reviewed path.
|
|
20
|
+
|
|
21
|
+
## DO NOT flag
|
|
22
|
+
|
|
23
|
+
- Redirect target is constant or built from server-side route constants only.
|
|
24
|
+
- Value is validated by allowlist, same-origin check, `startsWith("/")` plus rejection of `//` and scheme, signed return URL, or dedicated redirect policy.
|
|
25
|
+
- Generic webhook/HTTP call; use `io-boundary-risk`.
|
|
26
|
+
- Credential forwarding to webhook; use `security-sensitive-data-risk`.
|
|
27
|
+
|
|
28
|
+
## Primary file
|
|
29
|
+
|
|
30
|
+
File: `{{file}}`
|
|
31
|
+
Language: `{{language}}`
|
|
32
|
+
|
|
33
|
+
```{{language}}
|
|
34
|
+
{{code}}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Support files in same cluster
|
|
38
|
+
|
|
39
|
+
Use support files only when they relate to the PRIMARY controller.
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
{{cluster_files}}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
{{cluster_summary}}
|
|
46
|
+
|
|
47
|
+
## Output
|
|
48
|
+
|
|
49
|
+
Return ONLY valid JSON, no markdown fence and no extra text:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
{
|
|
53
|
+
"violations": [
|
|
54
|
+
{
|
|
55
|
+
"line": <positive integer, 1-based, in PRIMARY>,
|
|
56
|
+
"endLine": <positive integer | null>,
|
|
57
|
+
"message": "<<=200 chars, Vietnamese, explain open redirect/unsafe forward>",
|
|
58
|
+
"suggestion": "<fix suggestion | null>",
|
|
59
|
+
"confidence": <integer 0-100>
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
If no clear redirect/forward bug exists: `{"violations": []}`.
|
|
66
|
+
|
|
67
|
+
## REPEAT CRITICAL RULES
|
|
68
|
+
|
|
69
|
+
- `line` must point to PRIMARY controller, not support files.
|
|
70
|
+
- Report only request-controlled redirect/forward sinks without validation.
|
|
71
|
+
- Do not duplicate `io-boundary-risk`, `security-sensitive-data-risk`, or static rules.
|
|
72
|
+
- Confidence `<50` means DO NOT emit.
|
|
73
|
+
|
|
74
|
+
Do not explain. JSON only.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
id: spring-boot/security-redirect-risk
|
|
2
|
+
version: 1
|
|
3
|
+
kind: ai
|
|
4
|
+
title: "Spring Boot open redirect or unsafe forward?"
|
|
5
|
+
description: |
|
|
6
|
+
Per-cluster AI rule for request-controlled redirect/forward flows in
|
|
7
|
+
Spring Boot controllers. It flags `RedirectView`, `sendRedirect`, and
|
|
8
|
+
`redirect:` return values built from request data without allowlist.
|
|
9
|
+
severity: warning
|
|
10
|
+
category: security
|
|
11
|
+
languages: [java]
|
|
12
|
+
scope: spring-boot
|
|
13
|
+
baseConfidence: 60
|
|
14
|
+
prompt: ./security-redirect-risk.prompt.md
|
|
15
|
+
contextScope: per-cluster
|
|
16
|
+
maxTokens: 1000
|
|
17
|
+
aiConfig:
|
|
18
|
+
tier: regular
|
|
19
|
+
prRouting:
|
|
20
|
+
group: spring-security-risk-group
|
|
21
|
+
targetLayers: [controller, service]
|
|
22
|
+
triggers: ["redirect:", "sendRedirect", "returnUrl", "callback", "next", "url", "uri"]
|
|
23
|
+
riskWeight: 4
|
|
24
|
+
requiresContext: [diff, primaryFile, relatedController]
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
You are a senior Spring Boot security reviewer. Review this unit ONLY for sensitive data exposure.
|
|
2
|
+
|
|
3
|
+
## CRITICAL RULES
|
|
4
|
+
|
|
5
|
+
CRITICAL NON-VIOLATIONS:
|
|
6
|
+
|
|
7
|
+
- NEVER report generic missing auth, owner scope, mass assignment, open redirect, filesystem, generic SSRF, transaction, or validation here.
|
|
8
|
+
- NEVER report a log of public id/username/order number by itself.
|
|
9
|
+
- NEVER report raw exception handling unless the exception detail is returned to the client or serialized.
|
|
10
|
+
|
|
11
|
+
1. Report ONLY evidence visible in the PRIMARY controller or support files.
|
|
12
|
+
2. `line` MUST point to the PRIMARY controller file. If the leak sink is in service, use the controller call line.
|
|
13
|
+
3. Confidence `<50` means DO NOT emit.
|
|
14
|
+
|
|
15
|
+
## Flag only these sensitive data bugs
|
|
16
|
+
|
|
17
|
+
- Log statement prints request or entity fields named like `password`, `passwd`, `pwd`, `token`, `secret`, `apiKey`, `api_key`, `jwt`, `session`, `authorization`, `credential`, or `cookie` without masking.
|
|
18
|
+
- Controller catches exception and returns `e.getMessage()`, `e.toString()`, `ex.getCause()`, raw `Exception`, or serialized exception object in response body.
|
|
19
|
+
- Request credential (`Authorization`, `Cookie`, JWT, session token, API key, password) is forwarded to a URL/webhook selected by request data without destination allowlist.
|
|
20
|
+
|
|
21
|
+
## DO NOT flag
|
|
22
|
+
|
|
23
|
+
- Log data is masked/redacted before logging.
|
|
24
|
+
- Error response is controlled DTO/message such as `new ErrorResponse(code, "Generic error")`.
|
|
25
|
+
- Generic outbound URL/SSRF without credential forwarding; use `io-boundary-risk`.
|
|
26
|
+
- Missing domain exception mapping without data exposure; use `error-handling-completeness`.
|
|
27
|
+
- Style/naming/refactor suggestion.
|
|
28
|
+
|
|
29
|
+
## Primary file
|
|
30
|
+
|
|
31
|
+
File: `{{file}}`
|
|
32
|
+
Language: `{{language}}`
|
|
33
|
+
|
|
34
|
+
```{{language}}
|
|
35
|
+
{{code}}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Support files in same cluster
|
|
39
|
+
|
|
40
|
+
Use support files only when they relate to the PRIMARY controller.
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
{{cluster_files}}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
{{cluster_summary}}
|
|
47
|
+
|
|
48
|
+
## Output
|
|
49
|
+
|
|
50
|
+
Return ONLY valid JSON, no markdown fence and no extra text:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
{
|
|
54
|
+
"violations": [
|
|
55
|
+
{
|
|
56
|
+
"line": <positive integer, 1-based, in PRIMARY>,
|
|
57
|
+
"endLine": <positive integer | null>,
|
|
58
|
+
"message": "<<=200 chars, Vietnamese, explain sensitive data exposure>",
|
|
59
|
+
"suggestion": "<fix suggestion | null>",
|
|
60
|
+
"confidence": <integer 0-100>
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
If no clear sensitive data exposure exists: `{"violations": []}`.
|
|
67
|
+
|
|
68
|
+
## REPEAT CRITICAL RULES
|
|
69
|
+
|
|
70
|
+
- `line` must point to PRIMARY controller, not support files.
|
|
71
|
+
- Report only credential/secret/log/error-response exposure with visible source and sink.
|
|
72
|
+
- Do not duplicate `security-authorization-risk`, `security-mass-assignment-risk`, `security-redirect-risk`, `io-boundary-risk`, or `error-handling-completeness`.
|
|
73
|
+
- Confidence `<50` means DO NOT emit.
|
|
74
|
+
|
|
75
|
+
Do not explain. JSON only.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
id: spring-boot/security-sensitive-data-risk
|
|
2
|
+
version: 1
|
|
3
|
+
kind: ai
|
|
4
|
+
title: "Spring Boot sensitive data exposure?"
|
|
5
|
+
description: |
|
|
6
|
+
Per-cluster AI rule for sensitive data exposure in Spring Boot flows:
|
|
7
|
+
credentials/secrets/tokens written to logs, raw exception details returned
|
|
8
|
+
to clients, and request credentials forwarded to untrusted request-selected
|
|
9
|
+
destinations.
|
|
10
|
+
severity: warning
|
|
11
|
+
category: security
|
|
12
|
+
languages: [java]
|
|
13
|
+
scope: spring-boot
|
|
14
|
+
baseConfidence: 60
|
|
15
|
+
prompt: ./security-sensitive-data-risk.prompt.md
|
|
16
|
+
contextScope: per-cluster
|
|
17
|
+
maxTokens: 1200
|
|
18
|
+
aiConfig:
|
|
19
|
+
tier: regular
|
|
20
|
+
prRouting:
|
|
21
|
+
group: spring-security-risk-group
|
|
22
|
+
targetLayers: [controller, service]
|
|
23
|
+
triggers: ["password", "secret", "token", "credential", "email", "phone", "ssn", "personal", "export"]
|
|
24
|
+
riskWeight: 5
|
|
25
|
+
requiresContext: [diff, primaryFile, relatedController, relatedService]
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
Ban la senior Spring Boot reviewer. Danh gia review unit duoi day ve **transaction consistency va unbounded loop work**.
|
|
2
|
+
|
|
3
|
+
## CRITICAL RULES
|
|
4
|
+
|
|
5
|
+
CRITICAL NON-VIOLATIONS:
|
|
6
|
+
|
|
7
|
+
- NEVER report a simple single-record update plus one audit save unless there is a dependent external side effect or at least three dependent writes.
|
|
8
|
+
- NEVER report `@Transactional` placement as a style issue; static `spring-boot/transaction-on-service` owns simple annotation placement.
|
|
9
|
+
- NEVER report IDOR, SSRF, filesystem, raw exception response, or request-controlled business status here.
|
|
10
|
+
- NEVER report pure list/search/export pagination gaps here; `spring-boot/pagination-risk` owns `findAll()`/unpaged result-window issues when there is no write/external loop.
|
|
11
|
+
|
|
12
|
+
1. **CHI report loi co bang chung cu the** trong PRIMARY hoac support files. Khong doan convention ngoai cluster.
|
|
13
|
+
2. **`line` BAT BUOC tro ve PRIMARY controller file**. Neu bug nam trong service, dung dong controller goi flow do.
|
|
14
|
+
3. **Confidence `<50` -> KHONG emit**.
|
|
15
|
+
|
|
16
|
+
## Chi flag khi co transaction/loop bug cu the
|
|
17
|
+
|
|
18
|
+
- Service method duoc goi tu controller thuc hien nhieu write phu thuoc nhau ma can atomicity, nhung method/class khong co `@Transactional` va khong co compensation/idempotency ro rang.
|
|
19
|
+
- High-signal multi-step flow: it nhat 3 dependent writes, hoac 2 writes + external side effect (HTTP/webhook/queue/payment/email/file).
|
|
20
|
+
- Request-controlled list/ids/events/result set duoc loop, moi item goi repository read/write hoac external/cache call, gay unbounded DB/N+1/DoS risk.
|
|
21
|
+
- Error giua loop/write flow co the de partial writes ma controller van bao success neu evidence nam trong flow.
|
|
22
|
+
|
|
23
|
+
## KHONG flag
|
|
24
|
+
|
|
25
|
+
- Method/class co `@Transactional` dung o service layer, hoac co compensation/idempotency/outbox ro rang.
|
|
26
|
+
- Loop bounded ro bang constant nho, page size, validation size limit, batch repository call (`findAllById`, `saveAll`, bulk update), hoac async job co throttling.
|
|
27
|
+
- Pure list/search/export endpoint goi `findAll()` / scan khong pagination/limit nhung khong loop write/external side effect: de `pagination-risk` xu ly.
|
|
28
|
+
- Endpoint admin/internal migration/test neu cluster ro rang chi dung offline/bounded.
|
|
29
|
+
- Single write flow, read-only simple lookup, hoac transaction preference khong tao bug cu the.
|
|
30
|
+
- Static-only findings: controller `@Transactional`, SQL concat, validation, field injection.
|
|
31
|
+
|
|
32
|
+
## Primary file
|
|
33
|
+
|
|
34
|
+
File: `{{file}}`
|
|
35
|
+
Language: `{{language}}`
|
|
36
|
+
|
|
37
|
+
```{{language}}
|
|
38
|
+
{{code}}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Support files cung cluster
|
|
42
|
+
|
|
43
|
+
Chi dung support files lam bang chung neu lien quan den controller PRIMARY.
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
{{cluster_files}}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
{{cluster_summary}}
|
|
50
|
+
|
|
51
|
+
## Output yeu cau
|
|
52
|
+
|
|
53
|
+
Tra ve **JSON HOP LE DUY NHAT** (khong markdown fence, khong text khac) theo schema:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
{
|
|
57
|
+
"violations": [
|
|
58
|
+
{
|
|
59
|
+
"line": <so nguyen duong, 1-based, trong PRIMARY>,
|
|
60
|
+
"endLine": <so nguyen duong | null>,
|
|
61
|
+
"message": "<<=200 ky tu, tieng Viet, neu flow + atomicity/unbounded-work risk>",
|
|
62
|
+
"suggestion": "<goi y fix | null>",
|
|
63
|
+
"confidence": <so nguyen 0-100>
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Neu khong co transaction/loop bug ro rang: `{"violations": []}`.
|
|
70
|
+
|
|
71
|
+
## REPEAT CRITICAL RULES
|
|
72
|
+
|
|
73
|
+
- `line` phai tro ve PRIMARY controller, khong dung line tu service/repository.
|
|
74
|
+
- Chi report high-signal multi-write/loop bug; khong report style/preference.
|
|
75
|
+
- Khong duplicate static rules hoac `ownership-scope-risk`, `io-boundary-risk`, `pagination-risk`, `cache-consistency-risk`, `event-publishing-risk`, `business-invariant-risk`, `error-handling-completeness`.
|
|
76
|
+
- Confidence `<50` -> KHONG emit.
|
|
77
|
+
|
|
78
|
+
Khong giai thich. JSON thuan.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
id: spring-boot/transaction-loop-risk
|
|
2
|
+
version: 2
|
|
3
|
+
kind: ai
|
|
4
|
+
title: "Spring Boot transaction/loop flow co rui ro khong?"
|
|
5
|
+
description: |
|
|
6
|
+
Per-cluster AI rule for high-signal transaction and unbounded loop bugs:
|
|
7
|
+
multi-write service flows without transaction/compensation/idempotency,
|
|
8
|
+
and repository/external/cache calls inside request-controlled loops. Pure
|
|
9
|
+
list/search/export pagination gaps are handled by `spring-boot/pagination-risk`.
|
|
10
|
+
severity: warning
|
|
11
|
+
category: backend-integrity
|
|
12
|
+
languages: [java]
|
|
13
|
+
scope: spring-boot
|
|
14
|
+
baseConfidence: 60
|
|
15
|
+
prompt: ./transaction-loop-risk.prompt.md
|
|
16
|
+
contextScope: per-cluster
|
|
17
|
+
maxTokens: 1800
|
|
18
|
+
aiConfig:
|
|
19
|
+
tier: regular
|
|
20
|
+
prRouting:
|
|
21
|
+
group: spring-data-consistency-group
|
|
22
|
+
targetLayers: [service, repository]
|
|
23
|
+
triggers: ["@Transactional", ".save(", ".delete(", ".flush(", "for (", ".stream(", "while ("]
|
|
24
|
+
riskWeight: 4
|
|
25
|
+
requiresContext: [diff, primaryFile, relatedService, relatedRepository]
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { asTsMorphSourceFile } from '@code-sentinel/parsers';
|
|
2
|
+
import { SyntaxKind, Node } from 'ts-morph';
|
|
3
|
+
|
|
4
|
+
// builtin-rules/static/angular/component-prefix.rule.ts
|
|
5
|
+
var getComponentDecorator = (cls) => {
|
|
6
|
+
for (const d of cls.getDecorators()) {
|
|
7
|
+
if (d.getName() === "Component") return d;
|
|
8
|
+
}
|
|
9
|
+
return void 0;
|
|
10
|
+
};
|
|
11
|
+
var getStringLiteralValue = (node) => {
|
|
12
|
+
if (!node) return void 0;
|
|
13
|
+
if (Node.isStringLiteral(node) || Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
14
|
+
return node.getLiteralText();
|
|
15
|
+
}
|
|
16
|
+
return void 0;
|
|
17
|
+
};
|
|
18
|
+
var getSelectorValue = (decorator) => {
|
|
19
|
+
const call = decorator.getCallExpression();
|
|
20
|
+
if (!call) return void 0;
|
|
21
|
+
const [arg] = call.getArguments();
|
|
22
|
+
if (!arg || !Node.isObjectLiteralExpression(arg)) return void 0;
|
|
23
|
+
for (const prop of arg.getProperties()) {
|
|
24
|
+
if (!Node.isPropertyAssignment(prop)) continue;
|
|
25
|
+
if (prop.getName() !== "selector") continue;
|
|
26
|
+
const init = prop.getInitializer();
|
|
27
|
+
const value = getStringLiteralValue(init);
|
|
28
|
+
if (value === void 0 || init === void 0) return void 0;
|
|
29
|
+
return { value, node: init };
|
|
30
|
+
}
|
|
31
|
+
return void 0;
|
|
32
|
+
};
|
|
33
|
+
var hasAllowedPrefix = (selector, prefixes) => {
|
|
34
|
+
if (selector.startsWith("[") && selector.endsWith("]")) return true;
|
|
35
|
+
for (const p of prefixes) {
|
|
36
|
+
if (selector.startsWith(`${p}-`)) return true;
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
};
|
|
40
|
+
var rule = {
|
|
41
|
+
id: "angular/component-prefix",
|
|
42
|
+
version: 2,
|
|
43
|
+
kind: "static-ts",
|
|
44
|
+
title: "Component selector ph\u1EA3i c\xF3 prefix d\u1EF1 \xE1n",
|
|
45
|
+
description: '@Component selector n\xEAn b\u1EAFt \u0111\u1EA7u b\u1EB1ng prefix do d\u1EF1 \xE1n quy \u0111\u1ECBnh. Default prefix l\xE0 `app-` (Angular CLI). Tune cho d\u1EF1 \xE1n Viettel qua `options.prefixes: ["vts", "v"]` trong `.codereviewrc.yaml`.',
|
|
46
|
+
severity: "warning",
|
|
47
|
+
category: "angular-best-practice",
|
|
48
|
+
languages: ["typescript"],
|
|
49
|
+
scope: "angular",
|
|
50
|
+
requires: "semantic-ts",
|
|
51
|
+
baseConfidence: 100,
|
|
52
|
+
defaultOptions: { prefixes: ["app"] },
|
|
53
|
+
check(ctx) {
|
|
54
|
+
const prefixes = ctx.options.prefixes;
|
|
55
|
+
const sf = asTsMorphSourceFile(ctx.parsed);
|
|
56
|
+
const findings = [];
|
|
57
|
+
for (const cls of sf.getClasses()) {
|
|
58
|
+
const decorator = getComponentDecorator(cls);
|
|
59
|
+
if (!decorator) continue;
|
|
60
|
+
const selector = getSelectorValue(decorator);
|
|
61
|
+
if (!selector) continue;
|
|
62
|
+
if (hasAllowedPrefix(selector.value, prefixes)) continue;
|
|
63
|
+
const { line, column } = sf.getLineAndColumnAtPos(selector.node.getStart());
|
|
64
|
+
findings.push({
|
|
65
|
+
message: `Component selector "${selector.value}" kh\xF4ng c\xF3 prefix h\u1EE3p l\u1EC7 (${prefixes.map((p) => `${p}-`).join(", ")}).`,
|
|
66
|
+
file: ctx.file.path,
|
|
67
|
+
range: { line, column },
|
|
68
|
+
suggestion: `\u0110\u1ED5i selector th\xE0nh \`${prefixes[0]}-${selector.value.replace(/^[a-z]+-?/, "")}\` ho\u1EB7c th\xEAm prefix d\u1EF1 \xE1n.`
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return findings;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var _internal = { SyntaxKind };
|
|
75
|
+
|
|
76
|
+
export { _internal, rule };
|
|
77
|
+
//# sourceMappingURL=component-prefix.rule.js.map
|
|
78
|
+
//# sourceMappingURL=component-prefix.rule.js.map
|