@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
package/package.json
CHANGED
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
# To require central ingest, provide the scoped non-human project credential as
|
|
6
6
|
# repository secrets/environment and set CODE_SENTINEL_CI_PUSH=always. Never
|
|
7
7
|
# echo CODE_SENTINEL_DASHBOARD_TOKEN.
|
|
8
|
+
#
|
|
9
|
+
# Review gate (CS-05): findings (exit 3/4) are NON-BLOCKING by default so a
|
|
10
|
+
# merge is never stalled by thresholds the team has not agreed on. To enable
|
|
11
|
+
# blocking, change the two "quality gate" branches below from `echo` to
|
|
12
|
+
# `echo ...; exit 1` once your team has picked severity/confidence thresholds.
|
|
8
13
|
name: code-sentinel
|
|
9
14
|
|
|
10
15
|
on:
|
|
@@ -63,6 +68,59 @@ jobs:
|
|
|
63
68
|
path: code-sentinel.sarif
|
|
64
69
|
retention-days: 30
|
|
65
70
|
|
|
71
|
+
- name: Run pentest coverage assessment
|
|
72
|
+
if: always()
|
|
73
|
+
run: |
|
|
74
|
+
set +e
|
|
75
|
+
cs assess . --scope auto --json assessment.json --silent
|
|
76
|
+
ASSESS_EXIT=$?
|
|
77
|
+
set -e
|
|
78
|
+
echo "CS_ASSESS_EXIT=$ASSESS_EXIT" >> "$GITHUB_ENV"
|
|
79
|
+
|
|
80
|
+
- name: Publish assessment to Code Sentinel
|
|
81
|
+
if: always()
|
|
82
|
+
env:
|
|
83
|
+
ASSESSMENT_INGEST_URL: ${{ secrets.CODE_SENTINEL_ASSESSMENT_INGEST_URL }}
|
|
84
|
+
DASHBOARD_TOKEN: ${{ secrets.CODE_SENTINEL_DASHBOARD_TOKEN }}
|
|
85
|
+
run: |
|
|
86
|
+
if [ -z "${ASSESSMENT_INGEST_URL:-}" ] && [ -z "${DASHBOARD_TOKEN:-}" ]; then
|
|
87
|
+
echo "Central assessment ingest is not configured; keeping the local artifact only."
|
|
88
|
+
exit 0
|
|
89
|
+
fi
|
|
90
|
+
if [ -z "${ASSESSMENT_INGEST_URL:-}" ] || [ -z "${DASHBOARD_TOKEN:-}" ]; then
|
|
91
|
+
echo "::error::Assessment ingest requires both URL and dashboard token."
|
|
92
|
+
exit 2
|
|
93
|
+
fi
|
|
94
|
+
test -f assessment.json
|
|
95
|
+
curl --fail-with-body \
|
|
96
|
+
-X POST "$ASSESSMENT_INGEST_URL" \
|
|
97
|
+
-H "Authorization: Bearer $DASHBOARD_TOKEN" \
|
|
98
|
+
-H "Content-Type: application/json" \
|
|
99
|
+
-H "Idempotency-Key: assessment-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" \
|
|
100
|
+
--data-binary @assessment.json
|
|
101
|
+
|
|
102
|
+
- name: Upload assessment artifact
|
|
103
|
+
if: always()
|
|
104
|
+
uses: actions/upload-artifact@v4
|
|
105
|
+
with:
|
|
106
|
+
name: code-sentinel-assessment
|
|
107
|
+
path: |
|
|
108
|
+
assessment.json
|
|
109
|
+
code-sentinel-assessment.md
|
|
110
|
+
if-no-files-found: ignore
|
|
111
|
+
retention-days: 30
|
|
112
|
+
|
|
113
|
+
- name: Classify assessment exit
|
|
114
|
+
if: always()
|
|
115
|
+
run: |
|
|
116
|
+
case "${CS_ASSESS_EXIT:-1}" in
|
|
117
|
+
0) echo "code-sentinel assessment completed" ;;
|
|
118
|
+
1) echo "::error::code-sentinel assessment command failure. Check logs."; exit 1 ;;
|
|
119
|
+
2) echo "::error::code-sentinel assessment IO failure. Check artifact paths."; exit 1 ;;
|
|
120
|
+
3) echo "::error::code-sentinel pentest gate failed: confirmed vulnerability."; exit 1 ;;
|
|
121
|
+
*) echo "::error::code-sentinel assessment returned an unexpected exit ${CS_ASSESS_EXIT}."; exit 1 ;;
|
|
122
|
+
esac
|
|
123
|
+
|
|
66
124
|
- name: Classify review exit
|
|
67
125
|
if: always()
|
|
68
126
|
run: |
|
|
@@ -70,7 +128,7 @@ jobs:
|
|
|
70
128
|
0) echo "code-sentinel review completed" ;;
|
|
71
129
|
1) echo "::error::code-sentinel configuration or command failure. Check review logs."; exit 1 ;;
|
|
72
130
|
2) echo "::error::code-sentinel runtime, authentication, network, or required push failure. Retry only when safe."; exit 1 ;;
|
|
73
|
-
3) echo "::
|
|
74
|
-
4) echo "::
|
|
131
|
+
3) echo "::warning::code-sentinel quality gate: error findings. Non-blocking by default (CS-05); map this branch to 'exit 1' to block after your team agrees thresholds." ;;
|
|
132
|
+
4) echo "::warning::code-sentinel quality gate: blocker findings. Non-blocking by default (CS-05); map this branch to 'exit 1' to block after your team agrees thresholds." ;;
|
|
75
133
|
*) echo "::error::code-sentinel returned an unexpected exit ${CS_EXIT}."; exit 1 ;;
|
|
76
134
|
esac
|
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
# Markdown/JSON artifacts remain independent from any central ingestion.
|
|
6
6
|
# Set CODE_SENTINEL_CI_PUSH=always only with a masked, scoped
|
|
7
7
|
# CODE_SENTINEL_DASHBOARD_TOKEN and the corresponding server/project variables.
|
|
8
|
+
#
|
|
9
|
+
# Review gate (CS-05): findings (exit 3/4) are NON-BLOCKING by default so a
|
|
10
|
+
# merge request is never failed by thresholds the team has not agreed on. To
|
|
11
|
+
# enable blocking, change the two "quality gate" branches below from `echo` to
|
|
12
|
+
# `echo ...; exit 1` once your team has picked severity/confidence thresholds.
|
|
8
13
|
stages:
|
|
9
14
|
- review
|
|
10
15
|
|
|
@@ -44,8 +49,8 @@ code-sentinel:
|
|
|
44
49
|
0) echo "code-sentinel review completed" ;;
|
|
45
50
|
1) echo "code-sentinel configuration or command failure. Check review logs."; exit 1 ;;
|
|
46
51
|
2) echo "code-sentinel runtime, authentication, network, or required push failure. Retry only when safe."; exit 2 ;;
|
|
47
|
-
3) echo "code-sentinel quality gate
|
|
48
|
-
4) echo "code-sentinel quality gate
|
|
52
|
+
3) echo "code-sentinel quality gate: error findings. Non-blocking by default (CS-05); map this branch to 'exit 1' to block after your team agrees thresholds." ;;
|
|
53
|
+
4) echo "code-sentinel quality gate: blocker findings. Non-blocking by default (CS-05); map this branch to 'exit 1' to block after your team agrees thresholds." ;;
|
|
49
54
|
*) echo "code-sentinel returned an unexpected exit $EXIT."; exit 1 ;;
|
|
50
55
|
esac
|
|
51
56
|
artifacts:
|
|
@@ -55,3 +60,47 @@ code-sentinel:
|
|
|
55
60
|
paths:
|
|
56
61
|
- code-sentinel.md
|
|
57
62
|
- code-sentinel.json
|
|
63
|
+
|
|
64
|
+
code-sentinel-assessment:
|
|
65
|
+
stage: review
|
|
66
|
+
image:
|
|
67
|
+
name: registry.example.vn/code-sentinel/cli:3.0.0
|
|
68
|
+
entrypoint: [""]
|
|
69
|
+
rules:
|
|
70
|
+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
71
|
+
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
72
|
+
script:
|
|
73
|
+
- |
|
|
74
|
+
set +e
|
|
75
|
+
cs assess . --scope auto --json assessment.json --silent
|
|
76
|
+
ASSESS_EXIT=$?
|
|
77
|
+
set -e
|
|
78
|
+
|
|
79
|
+
if [ -n "${CODE_SENTINEL_ASSESSMENT_INGEST_URL:-}" ] || [ -n "${CODE_SENTINEL_DASHBOARD_TOKEN:-}" ]; then
|
|
80
|
+
if [ -z "${CODE_SENTINEL_ASSESSMENT_INGEST_URL:-}" ] || [ -z "${CODE_SENTINEL_DASHBOARD_TOKEN:-}" ]; then
|
|
81
|
+
echo "Assessment ingest requires both CODE_SENTINEL_ASSESSMENT_INGEST_URL and CODE_SENTINEL_DASHBOARD_TOKEN."
|
|
82
|
+
exit 2
|
|
83
|
+
fi
|
|
84
|
+
test -f assessment.json
|
|
85
|
+
curl --fail-with-body \
|
|
86
|
+
-X POST "$CODE_SENTINEL_ASSESSMENT_INGEST_URL" \
|
|
87
|
+
-H "Authorization: Bearer $CODE_SENTINEL_DASHBOARD_TOKEN" \
|
|
88
|
+
-H "Content-Type: application/json" \
|
|
89
|
+
-H "Idempotency-Key: assessment-$CI_PIPELINE_ID-$CI_JOB_ID" \
|
|
90
|
+
--data-binary @assessment.json
|
|
91
|
+
fi
|
|
92
|
+
|
|
93
|
+
case "$ASSESS_EXIT" in
|
|
94
|
+
0) echo "code-sentinel assessment completed" ;;
|
|
95
|
+
1) echo "code-sentinel assessment command failure. Check logs."; exit 1 ;;
|
|
96
|
+
2) echo "code-sentinel assessment IO failure. Check artifact paths."; exit 2 ;;
|
|
97
|
+
3) echo "code-sentinel pentest gate failed: confirmed vulnerability."; exit 1 ;;
|
|
98
|
+
*) echo "code-sentinel assessment returned an unexpected exit $ASSESS_EXIT."; exit 1 ;;
|
|
99
|
+
esac
|
|
100
|
+
artifacts:
|
|
101
|
+
name: 'code-sentinel-assessment-${CI_COMMIT_SHORT_SHA}'
|
|
102
|
+
when: always
|
|
103
|
+
expire_in: 30 days
|
|
104
|
+
paths:
|
|
105
|
+
- assessment.json
|
|
106
|
+
- code-sentinel-assessment.md
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
id: general/no-todo-comment
|
|
2
|
-
version: 1
|
|
3
|
-
kind: static-yaml
|
|
4
|
-
title: "Không để TODO/FIXME/HACK/XXX trong code đã commit"
|
|
5
|
-
description: |
|
|
6
|
-
TODO comments không phải là cách tracking công việc — chúng tích tụ và bị quên.
|
|
7
|
-
Hãy tạo issue trong tracker (Jira/Linear), commit code đã hoàn thành, và để comment
|
|
8
|
-
giải thích "tại sao" thay vì "còn thiếu gì". Rule này flag mọi comment chứa
|
|
9
|
-
TODO, FIXME, HACK, XXX (không phân biệt hoa thường).
|
|
10
|
-
severity: info
|
|
11
|
-
category: maintainability
|
|
12
|
-
languages: [typescript, javascript]
|
|
13
|
-
scope: general
|
|
14
|
-
baseConfidence: 100
|
|
15
|
-
detection:
|
|
16
|
-
type: tree-sitter
|
|
17
|
-
captureName: violation
|
|
18
|
-
query: |
|
|
19
|
-
(comment) @violation
|
|
20
|
-
(#match? @violation "\\b([Tt][Oo][Dd][Oo]|[Ff][Ii][Xx][Mm][Ee]|[Hh][Aa][Cc][Kk]|XXX|xxx)\\b")
|
|
21
|
-
message: "Comment chứa TODO/FIXME/HACK/XXX — tạo issue trong tracker thay vì để trong code."
|
|
22
|
-
suggestion: "Tạo ticket trong Jira/Linear với context cụ thể, xoá comment khi đã có ticket."
|
|
23
|
-
examples:
|
|
24
|
-
good: |
|
|
25
|
-
// Cache layer luôn invalidate khi project changes — xem ADR-0007 để hiểu vì sao.
|
|
26
|
-
const cache = createCache();
|
|
27
|
-
bad: |
|
|
28
|
-
// TODO: handle errors here
|
|
29
|
-
// FIXME: this breaks when user is null
|
|
30
|
-
function process() {}
|