@code-sentinel-cli/code-sentinel-cli 3.0.9 → 3.0.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-sentinel-cli/code-sentinel-cli",
3
- "version": "3.0.9",
3
+ "version": "3.0.10",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "AI-assisted code review CLI for Angular, Spring Boot, and Flutter projects.",
@@ -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 "::error::code-sentinel quality gate failed: error findings."; exit 1 ;;
74
- 4) echo "::error::code-sentinel quality gate failed: blocker findings."; exit 1 ;;
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 failed: error findings."; exit 1 ;;
48
- 4) echo "code-sentinel quality gate failed: blocker findings."; exit 1 ;;
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