Assignment 8 secure delivery foundation #17
@@ -0,0 +1,25 @@
|
||||
pipeline {
|
||||
agent { label 'assignment8-trusted' }
|
||||
options { disableConcurrentBuilds(); timeout(time: 20, unit: 'MINUTES'); timestamps(); skipDefaultCheckout() }
|
||||
stages {
|
||||
stage('Checkout') { steps { checkout scm } }
|
||||
stage('Unit tests and dependency audit') {
|
||||
steps { dir('secure-delivery/v1') { sh '''set -eu
|
||||
python3 -m venv .test-venv
|
||||
.test-venv/bin/pip install -r requirements.txt pip-audit==2.10.1
|
||||
.test-venv/bin/python -m unittest -v
|
||||
.test-venv/bin/pip-audit -r requirements.txt
|
||||
''' } }
|
||||
}
|
||||
stage('Secret scan') { steps { sh 'sh secure-delivery/scan-secrets.sh' } }
|
||||
stage('Ansible syntax') { steps { dir('secure-delivery') { sh 'ansible-playbook -i ansible/inventory.ini ansible/deploy.yml --syntax-check' } } }
|
||||
stage('Build test image') { steps { sh 'docker build --build-arg APP_COMMIT=$(git rev-parse HEAD) -t assignment8-pricing:security-check secure-delivery/v1' } }
|
||||
stage('Image vulnerability scan') {
|
||||
steps { sh '''set -eu
|
||||
mkdir -p reports
|
||||
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v /home/codex/myfileagent-gitea/evidence/assignment8/trivy-cache:/root/.cache/ aquasec/trivy@sha256:1c78ed1ef824ab8bb05b04359d186e4c1229d0b3e67005faacb54a7d71974f73 image --quiet --scanners vuln --severity HIGH,CRITICAL --exit-code 1 --format json assignment8-pricing:security-check > reports/image-scan.json
|
||||
''' }
|
||||
}
|
||||
}
|
||||
post { always { archiveArtifacts artifacts: 'reports/*.json', allowEmptyArchive: true } }
|
||||
}
|
||||
@@ -32,3 +32,8 @@
|
||||
- User approved host Docker daemon access for the label-restricted trusted agent; its connection was verified. This access is effectively host administration. Agent-built test image succeeded with placeholder identity, not a release.
|
||||
- Trivy 0.69.1 scan of the Debian slim test image failed the HIGH/CRITICAL gate: 45 Debian and 5 Python findings. A pinned Python Alpine candidate had no OS findings but 5 Python tooling findings. After removing pip and ensurepip bundled wheels from runtime, the candidate scan reported zero HIGH/CRITICAL findings, exit 0, at the time of scan. Reports are in server evidence/assignment8; rescan the actual release image and archive results.
|
||||
- Isolated candidate smoke test initially ran before startup and got connection refused; after allowing startup, health was ok, v1 identity returned development placeholder, and quantity 3 returned 30. No production deployment occurred.
|
||||
|
||||
- Trivy 0.69.1 secret scanner standalone test: an example-format fixture was ignored (exit 0), then a newly generated disposable private-key fixture produced one finding and exit 1. Both fixture files were removed. This proves scanner behavior only; a blocked Jenkins pipeline run remains required.
|
||||
|
||||
## Jenkins synthetic secret gate
|
||||
- Jenkins assignment8-secret-gate-demo #4 detected one generated disposable private key and failed with scanner exit 1; the job removed the fixture. Earlier attempts #1-3 failed due to transfer or job-script errors, not secret detections. Evidence: https://ci.myfileagent.tech/job/assignment8-secret-gate-demo/4/console . Prepared source-controlled security pipeline; it has not yet been run.
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
scanner="a8-secret-${BUILD_NUMBER}"
|
||||
trap 'docker rm -f "$scanner" >/dev/null 2>&1 || true; rm -f secret-report.json' EXIT
|
||||
docker create --name "$scanner" aquasec/trivy@sha256:1c78ed1ef824ab8bb05b04359d186e4c1229d0b3e67005faacb54a7d71974f73 fs --quiet --scanners secret --exit-code 1 --format json /v1 >/dev/null
|
||||
tar -C secure-delivery --exclude=v1/.test-venv --exclude=v1/__pycache__ -cf - v1 | docker cp - "$scanner":/
|
||||
set +e
|
||||
docker start -a "$scanner" > secret-report.json
|
||||
result=$?
|
||||
set -e
|
||||
python3 -c 'import json; p=json.load(open("secret-report.json")); print("Secret findings:",sum(len(r.get("Secrets",[])) for r in p.get("Results",[])))'
|
||||
echo "Secret scanner exit status: $result"
|
||||
exit "$result"
|
||||
Reference in New Issue
Block a user