Compare commits

...
3 Commits
Author SHA1 Message Date
Codex 28d13ef5b8 Add security validation stages and record blocked gate
myfileagent-python-ci/pipeline/head This commit looks good
2026-11-04 19:58:51 +00:00
Codex 83da3087c9 Use scanned lean pricing image and record baseline evidence 2026-11-04 19:49:32 +00:00
Codex c35558c20b Record validation and define release scan policy 2026-11-04 19:41:49 +00:00
5 changed files with 60 additions and 1 deletions
+25
View File
@@ -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 } }
}
+7
View File
@@ -0,0 +1,7 @@
# Assignment 8 release security policy
The trusted release job must run only reviewed source and must not expose deployment or registry credentials to pull-request builds. Restrict the agent to labeled release jobs and authorized Jenkins users. Docker daemon access confers host-administrator privileges. Record agent identity, access scope, tool versions, scan time, database version, exit status, and archived reports for each release.
Before publication, fail on discovered secrets and on HIGH or CRITICAL vulnerabilities unless a documented time-limited exception is accepted by the instructor. Fail closed if a scanner fails or its database is unavailable. Investigate false positives and unfixed findings; document owner, reason, expiry, and approval for any exception. Never publish a deliberately vulnerable image as the working release.
Run a dependency audit against the exact locked requirements, a repository secret scan, and an image vulnerability scan against the built release image. Demonstrate a blocked gate with a scanner-supported synthetic fixture and remove it before release. The initial pip-audit result in WORK_LOG.md is a baseline, not the final release scan.
+13
View File
@@ -24,3 +24,16 @@
## Validation preparation
- Ansible syntax check passed on assignment8-trusted against the starter playbook on 2026-11-04. The inventory and release records still contain placeholders; syntax success is not deployment. Added a separate draft validation Jenkinsfile for tests and syntax checks; it has not been run in Jenkins.
## Gitea-backed validation
- Published branch assignment8/secure-delivery at 242372e381ecbcab4078e7d8c0916073d600d970. Jenkins assignment8-validation build #1 checked out that commit on assignment8-trusted, passed all 3 v1 unit tests and passed Ansible syntax check. Evidence: https://ci.myfileagent.tech/job/assignment8-validation/1/console . This does not demonstrate deployment, security gates, or image publication.
## Initial image security checks
- 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.
+13
View File
@@ -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"
+2 -1
View File
@@ -1,9 +1,10 @@
FROM python:3.13-slim@sha256:ae14d4ce8771606477a81446e7ef429edd6762305fc50c84507c1041fa8285d1
FROM python:3.13-alpine@sha256:7984cf56ceaddebe4fefeb75d64000b9f45d8b77b11a09b24524da6cdc3af0c8
ARG APP_COMMIT=development
ENV APP_COMMIT=$APP_COMMIT PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN python -m pip uninstall -y pip && rm -rf /usr/local/lib/python3.13/ensurepip/_bundled
COPY app.py .
USER 10001:10001
EXPOSE 8000