ci(pegasus): run sonar and supply-chain scans
This commit is contained in:
parent
2ea9550565
commit
9f3abb7441
57
Jenkinsfile
vendored
57
Jenkinsfile
vendored
@ -31,6 +31,13 @@ spec:
|
|||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: workspace-volume
|
- name: workspace-volume
|
||||||
mountPath: /home/jenkins/agent
|
mountPath: /home/jenkins/agent
|
||||||
|
- name: quality-tools
|
||||||
|
image: registry.bstein.dev/bstein/quality-tools:sonar8.0.1-trivy0.70.0-arm64
|
||||||
|
command: ["cat"]
|
||||||
|
tty: true
|
||||||
|
volumeMounts:
|
||||||
|
- name: workspace-volume
|
||||||
|
mountPath: /home/jenkins/agent
|
||||||
volumes:
|
volumes:
|
||||||
- name: workspace-volume
|
- name: workspace-volume
|
||||||
emptyDir: {}
|
emptyDir: {}
|
||||||
@ -69,6 +76,28 @@ spec:
|
|||||||
|
|
||||||
stage('Collect SonarQube evidence') {
|
stage('Collect SonarQube evidence') {
|
||||||
steps {
|
steps {
|
||||||
|
container('quality-tools') {
|
||||||
|
sh '''#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
mkdir -p build
|
||||||
|
args=(
|
||||||
|
"-Dsonar.host.url=${SONARQUBE_HOST_URL}"
|
||||||
|
"-Dsonar.token=${SONARQUBE_TOKEN}"
|
||||||
|
"-Dsonar.projectKey=${SONARQUBE_PROJECT_KEY}"
|
||||||
|
"-Dsonar.projectName=${SONARQUBE_PROJECT_KEY}"
|
||||||
|
"-Dsonar.sources=."
|
||||||
|
"-Dsonar.exclusions=**/.git/**,**/build/**,**/dist/**,**/node_modules/**,**/.venv/**,**/__pycache__/**,**/coverage/**,**/test-results/**,**/playwright-report/**"
|
||||||
|
"-Dsonar.test.inclusions=**/tests/**,**/testing/**,**/*_test.go,**/*.test.ts,**/*.test.tsx,**/*.spec.ts,**/*.spec.tsx"
|
||||||
|
)
|
||||||
|
[ -f build/coverage-backend.out ] && args+=("-Dsonar.go.coverage.reportPaths=build/coverage-backend.out")
|
||||||
|
[ -f build/frontend-coverage/lcov.info ] && args+=("-Dsonar.javascript.lcov.reportPaths=build/frontend-coverage/lcov.info")
|
||||||
|
set +e
|
||||||
|
sonar-scanner "${args[@]}" | tee build/sonar-scanner.log
|
||||||
|
rc=${PIPESTATUS[0]}
|
||||||
|
set -e
|
||||||
|
printf '%s\n' "${rc}" > build/sonarqube-analysis.rc
|
||||||
|
'''
|
||||||
|
}
|
||||||
container('publisher') {
|
container('publisher') {
|
||||||
sh '''
|
sh '''
|
||||||
set -eu
|
set -eu
|
||||||
@ -107,6 +136,34 @@ PY
|
|||||||
|
|
||||||
stage('Collect Supply Chain evidence') {
|
stage('Collect Supply Chain evidence') {
|
||||||
steps {
|
steps {
|
||||||
|
container('quality-tools') {
|
||||||
|
sh '''#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
mkdir -p build
|
||||||
|
set +e
|
||||||
|
trivy fs --no-progress --format json --output build/trivy-fs.json --scanners vuln,secret,misconfig --severity HIGH,CRITICAL .
|
||||||
|
trivy_rc=$?
|
||||||
|
set -e
|
||||||
|
if [ ! -s build/trivy-fs.json ]; then
|
||||||
|
cat > build/ironbank-compliance.json <<EOF
|
||||||
|
{"status":"failed","compliant":false,"scanner":"trivy","scan_type":"filesystem","error":"trivy did not produce JSON output","trivy_rc":${trivy_rc}}
|
||||||
|
EOF
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
critical="$(jq '[.Results[]? | .Vulnerabilities[]? | select(.Severity=="CRITICAL")] | length' build/trivy-fs.json)"
|
||||||
|
high="$(jq '[.Results[]? | .Vulnerabilities[]? | select(.Severity=="HIGH")] | length' build/trivy-fs.json)"
|
||||||
|
secrets="$(jq '[.Results[]? | .Secrets[]?] | length' build/trivy-fs.json)"
|
||||||
|
misconfigs="$(jq '[.Results[]? | .Misconfigurations[]? | select(.Status=="FAIL" and (.Severity=="CRITICAL" or .Severity=="HIGH"))] | length' build/trivy-fs.json)"
|
||||||
|
status=ok
|
||||||
|
compliant=true
|
||||||
|
if [ "${critical}" -gt 0 ] || [ "${secrets}" -gt 0 ] || [ "${misconfigs}" -gt 0 ]; then
|
||||||
|
status=failed
|
||||||
|
compliant=false
|
||||||
|
fi
|
||||||
|
jq -n --arg status "${status}" --argjson compliant "${compliant}" --argjson critical "${critical}" --argjson high "${high}" --argjson secrets "${secrets}" --argjson misconfigs "${misconfigs}" --argjson trivy_rc "${trivy_rc}" \
|
||||||
|
'{status:$status, compliant:$compliant, category:"artifact_security", scan_type:"filesystem", scanner:"trivy", critical_vulnerabilities:$critical, high_vulnerabilities:$high, secrets:$secrets, high_or_critical_misconfigurations:$misconfigs, trivy_rc:$trivy_rc, high_vulnerability_policy:"observe"}' > build/ironbank-compliance.json
|
||||||
|
'''
|
||||||
|
}
|
||||||
container('publisher') {
|
container('publisher') {
|
||||||
sh '''
|
sh '''
|
||||||
set -eu
|
set -eu
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"preview": "vite preview --port 5173",
|
"preview": "vite preview --port 5173",
|
||||||
"test": "jest --runInBand",
|
"test": "jest --runInBand",
|
||||||
"test:ci": "mkdir -p ../build && JEST_JUNIT_OUTPUT_FILE=../build/junit-frontend.xml jest --ci --runInBand --coverage --coverageReporters=text --coverageReporters=json-summary --coverageDirectory=../build/frontend-coverage --reporters=default --reporters=jest-junit"
|
"test:ci": "mkdir -p ../build && JEST_JUNIT_OUTPUT_FILE=../build/junit-frontend.xml jest --ci --runInBand --coverage --coverageReporters=text --coverageReporters=lcov --coverageReporters=json-summary --coverageDirectory=../build/frontend-coverage --reporters=default --reporters=jest-junit"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@picocss/pico": "^2.1.1",
|
"@picocss/pico": "^2.1.1",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user