Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f14abad27b | |||
| c46f127e8c | |||
| 05d3c58c3a | |||
| 3fcd04010a | |||
| ad37d148ed | |||
| c864ddd0d2 | |||
| 8979d92c00 | |||
| 17750b844b | |||
| fb2bac752a | |||
| 3b79b7e07a | |||
| 60019db7da | |||
| 2a35f97071 | |||
| d8a5d2717b | |||
| 5e17a009dc | |||
| 7e76950690 | |||
| 27f8f20275 | |||
| 98f86092a2 | |||
| 459838dfcd | |||
| 6553b4400c |
@@ -1 +1,2 @@
|
|||||||
__pycache__/
|
__pycache__/
|
||||||
|
security-reports/
|
||||||
@@ -67,17 +67,11 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6.4.5 (kholmes): dependency + secret checks on the source.
|
// 6.4.5: dependency and secret checks on the source. Fails closed:
|
||||||
|
// a missing script, a scanner error, or a finding stops the run.
|
||||||
stage('Security scan: source') {
|
stage('Security scan: source') {
|
||||||
steps {
|
steps { sh 'bash security/scan.sh source' }
|
||||||
sh '''
|
post { always { archiveArtifacts artifacts: 'security-reports/**', allowEmptyArchive: true } }
|
||||||
if [ -x security/scan.sh ]; then
|
|
||||||
security/scan.sh source
|
|
||||||
else
|
|
||||||
echo "security/scan.sh not added yet (6.4.5)"
|
|
||||||
fi
|
|
||||||
'''
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Build image') {
|
stage('Build image') {
|
||||||
@@ -88,17 +82,10 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6.4.5 (kholmes): image vulnerability scan before publishing.
|
// 6.4.5: image vulnerability scan before publishing. Fails closed.
|
||||||
stage('Security scan: image') {
|
stage('Security scan: image') {
|
||||||
steps {
|
steps { sh 'bash security/scan.sh image "$IMAGE_TAG"' }
|
||||||
sh '''
|
post { always { archiveArtifacts artifacts: 'security-reports/**', allowEmptyArchive: true } }
|
||||||
if [ -x security/scan.sh ]; then
|
|
||||||
security/scan.sh image "$IMAGE_TAG"
|
|
||||||
else
|
|
||||||
echo "security/scan.sh not added yet (6.4.5)"
|
|
||||||
fi
|
|
||||||
'''
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Publish') {
|
stage('Publish') {
|
||||||
@@ -185,4 +172,4 @@ proxy_network: gitea-net
|
|||||||
success { echo 'All stages passed.' }
|
success { echo 'All stages passed.' }
|
||||||
failure { echo 'A stage failed: see the stage view for which one.' }
|
failure { echo 'A stage failed: see the stage view for which one.' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
# Secrets and host-specific values stay on the Droplet
|
||||||
|
jenkins-agent.secret
|
||||||
|
agent.secrets.env
|
||||||
|
.env
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# Trusted Jenkins delivery agent for Chapter 6.
|
||||||
|
# Build context is the repository root (see agent/compose.yaml).
|
||||||
|
FROM jenkins/inbound-agent:latest-jdk21
|
||||||
|
|
||||||
|
USER root
|
||||||
|
|
||||||
|
# Python 3 + venv for tests, pip-audit and Ansible; curl for checks
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends python3 python3-venv python3-pip ca-certificates curl \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Docker CLI + buildx plugin (client only; the daemon is the host's, via the mounted socket)
|
||||||
|
COPY --from=docker:cli /usr/local/bin/docker /usr/local/bin/docker
|
||||||
|
COPY --from=docker/buildx-bin /buildx /usr/libexec/docker/cli-plugins/docker-buildx
|
||||||
|
|
||||||
|
# Trivy scanner (image vulnerabilities + secret scanning)
|
||||||
|
COPY --from=aquasec/trivy:latest /usr/local/bin/trivy /usr/local/bin/trivy
|
||||||
|
|
||||||
|
# Ansible in its own virtual environment, plus the community.docker collection
|
||||||
|
ENV ANSIBLE_COLLECTIONS_PATH=/opt/ansible-collections
|
||||||
|
COPY ansible/requirements.yml /tmp/ansible-requirements.yml
|
||||||
|
RUN python3 -m venv /opt/ansible-venv \
|
||||||
|
&& /opt/ansible-venv/bin/pip install --no-cache-dir ansible-core \
|
||||||
|
&& /opt/ansible-venv/bin/ansible-galaxy collection install -r /tmp/ansible-requirements.yml -p /opt/ansible-collections \
|
||||||
|
&& rm /tmp/ansible-requirements.yml
|
||||||
|
|
||||||
|
# pip-audit in a separate tools venv
|
||||||
|
RUN python3 -m venv /opt/tools-venv \
|
||||||
|
&& /opt/tools-venv/bin/pip install --no-cache-dir pip-audit
|
||||||
|
|
||||||
|
USER jenkins
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
# Trusted delivery agent. Connects to the existing Jenkins controller over the
|
||||||
|
# internal gitea-net network (WebSocket), so no new port is published.
|
||||||
|
services:
|
||||||
|
jenkins-agent:
|
||||||
|
build:
|
||||||
|
context: ..
|
||||||
|
dockerfile: agent/Dockerfile
|
||||||
|
image: ssw590/jenkins-delivery-agent:1
|
||||||
|
container_name: jenkins-agent
|
||||||
|
restart: unless-stopped
|
||||||
|
# Start agent.jar directly. The secret is read from a file (-secret @file),
|
||||||
|
# so it never appears in the process list, docker inspect, or Git.
|
||||||
|
entrypoint:
|
||||||
|
- java
|
||||||
|
- -jar
|
||||||
|
- /usr/share/jenkins/agent.jar
|
||||||
|
- -url
|
||||||
|
- http://jenkins:8080/
|
||||||
|
- -webSocket
|
||||||
|
- -name
|
||||||
|
- delivery-agent
|
||||||
|
- -workDir
|
||||||
|
- /home/jenkins/agent
|
||||||
|
- -secret
|
||||||
|
- "@/run/secrets/jenkins-agent-secret"
|
||||||
|
# Host Docker socket: needed to build/push images. This is effectively root
|
||||||
|
# on the Droplet, so only reviewed main-branch delivery jobs may use this agent.
|
||||||
|
group_add: ["${DOCKER_GID:?set DOCKER_GID in .env}"]
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
- ./jenkins-agent.secret:/run/secrets/jenkins-agent-secret:ro
|
||||||
|
- agent_home:/home/jenkins # workspace, known_hosts, registry login
|
||||||
|
networks: [gitea-net]
|
||||||
|
|
||||||
|
networks:
|
||||||
|
gitea-net:
|
||||||
|
external: true
|
||||||
|
name: gitea-net
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
agent_home:
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Print tool versions inside the agent. From the repo root on the Droplet:
|
||||||
|
# docker exec -i jenkins-agent sh -s < agent/versions.sh
|
||||||
|
echo "== java"; java -version 2>&1 | head -1
|
||||||
|
echo "== python"; python3 --version
|
||||||
|
echo "== docker"; docker version --format 'client {{.Client.Version}} / server {{.Server.Version}}'
|
||||||
|
echo "== buildx"; docker buildx version
|
||||||
|
echo "== trivy"; trivy --version | head -1
|
||||||
|
echo "== pip-audit"; /opt/tools-venv/bin/pip-audit --version
|
||||||
|
echo "== ansible"; /opt/ansible-venv/bin/ansible --version | head -3
|
||||||
|
echo "== collections"; /opt/ansible-venv/bin/ansible-galaxy collection list community.docker 2>/dev/null | tail -2
|
||||||
|
echo "== os"; . /etc/os-release; echo "$PRETTY_NAME $(uname -m)"
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
- name: Deploy a selected immutable pricing release
|
||||||
|
hosts: delivery
|
||||||
|
become: true
|
||||||
|
vars:
|
||||||
|
project_dir: "/opt/startup/pricing-{{ target_env }}"
|
||||||
|
tasks:
|
||||||
|
- name: Validate release selection
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- target_env in ['staging', 'production']
|
||||||
|
- "'@sha256:' in release_image"
|
||||||
|
- expected_version in ['v1', 'v2']
|
||||||
|
- expected_total | int > 0
|
||||||
|
- public_url.startswith('https://')
|
||||||
|
- proxy_network | length > 0
|
||||||
|
- name: Create deployment directory
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ project_dir }}"
|
||||||
|
state: directory
|
||||||
|
mode: '0750'
|
||||||
|
- name: Render selected Compose configuration
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: compose.yaml.j2
|
||||||
|
dest: "{{ project_dir }}/compose.yaml"
|
||||||
|
mode: '0640'
|
||||||
|
- name: Converge application without rebuilding
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: "{{ project_dir }}"
|
||||||
|
project_name: "pricing-{{ target_env }}"
|
||||||
|
state: present
|
||||||
|
build: never
|
||||||
|
pull: missing
|
||||||
|
wait: true
|
||||||
|
wait_timeout: 90
|
||||||
|
- name: Verify health through public TLS endpoint
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "{{ public_url }}/health"
|
||||||
|
return_content: true
|
||||||
|
validate_certs: true
|
||||||
|
register: health
|
||||||
|
until: health.status == 200 and health.json.status == 'ok'
|
||||||
|
retries: 12
|
||||||
|
delay: 5
|
||||||
|
changed_when: false
|
||||||
|
- name: Read release identity
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "{{ public_url }}/"
|
||||||
|
return_content: true
|
||||||
|
register: identity
|
||||||
|
changed_when: false
|
||||||
|
- name: Exercise business behavior
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "{{ public_url }}/price?quantity=3"
|
||||||
|
return_content: true
|
||||||
|
register: price
|
||||||
|
changed_when: false
|
||||||
|
- name: Check release identity and calculation
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- identity.json.version == expected_version
|
||||||
|
- identity.json.commit == expected_commit
|
||||||
|
- price.json.total | int == expected_total | int
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
[delivery]
|
||||||
|
# Target: the existing Droplet, reached over SSH as the dedicated deploy account.
|
||||||
|
# Host key must be verified and pinned in the agent's known_hosts before first use.
|
||||||
|
startup ansible_host=147.182.179.191 ansible_user=deploy
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
collections:
|
||||||
|
- name: community.docker
|
||||||
|
version: ">=4.8.0,<6.0.0"
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
services:
|
||||||
|
app:
|
||||||
|
image: "{{ release_image }}"
|
||||||
|
restart: unless-stopped
|
||||||
|
read_only: true
|
||||||
|
tmpfs:
|
||||||
|
- /tmp
|
||||||
|
cap_drop:
|
||||||
|
- ALL
|
||||||
|
security_opt:
|
||||||
|
- no-new-privileges:true
|
||||||
|
networks:
|
||||||
|
edge:
|
||||||
|
aliases:
|
||||||
|
- "pricing-{{ target_env }}"
|
||||||
|
networks:
|
||||||
|
edge:
|
||||||
|
external: true
|
||||||
|
name: "{{ proxy_network }}"
|
||||||
|
After Width: | Height: | Size: 120 KiB |
|
After Width: | Height: | Size: 181 KiB |
|
After Width: | Height: | Size: 216 KiB |
|
After Width: | Height: | Size: 79 KiB |
|
After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 446 KiB |
|
After Width: | Height: | Size: 93 KiB |
|
After Width: | Height: | Size: 155 KiB |
|
After Width: | Height: | Size: 192 KiB |
|
After Width: | Height: | Size: 192 KiB |
|
After Width: | Height: | Size: 189 KiB |
|
After Width: | Height: | Size: 220 KiB |
|
After Width: | Height: | Size: 309 KiB |
|
After Width: | Height: | Size: 171 KiB |
|
After Width: | Height: | Size: 92 KiB |
|
After Width: | Height: | Size: 113 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 234 KiB |
|
After Width: | Height: | Size: 53 KiB |
@@ -41,10 +41,10 @@
|
|||||||
\newcommand{\CourseName}{DevOps}
|
\newcommand{\CourseName}{DevOps}
|
||||||
\newcommand{\Instructor}{Samah Keshiro and Kayla Holmes}
|
\newcommand{\Instructor}{Samah Keshiro and Kayla Holmes}
|
||||||
\newcommand{\Organization}{Stevens Institute of Technology}
|
\newcommand{\Organization}{Stevens Institute of Technology}
|
||||||
\newcommand{\DocumentDate}{October 29, 2026}
|
\newcommand{\DocumentDate}{November 13, 2026}
|
||||||
\newcommand{\DueDate}{[Due Date and Time]}
|
\newcommand{\DueDate}{[Due Date and Time]}
|
||||||
\newcommand{\VERSION}{Version 1.6}
|
\newcommand{\VERSION}{Version 1.7 (draft)}
|
||||||
\newcommand{\AssignmentNumber}{6}
|
\newcommand{\AssignmentNumber}{7}
|
||||||
|
|
||||||
\newcolumntype{Y}{>{\raggedright\arraybackslash}X}
|
\newcolumntype{Y}{>{\raggedright\arraybackslash}X}
|
||||||
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
|
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
|
||||||
@@ -137,6 +137,7 @@
|
|||||||
\include{devopsAutomatedManualBuild}
|
\include{devopsAutomatedManualBuild}
|
||||||
\include{devopsCI}
|
\include{devopsCI}
|
||||||
\include{devopsSRE}
|
\include{devopsSRE}
|
||||||
|
\include{devopsSecureDelivery}
|
||||||
|
|
||||||
\printglossaries
|
\printglossaries
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
\toprule \textbf{Date / Version} & \textbf{Authors} & \textbf{Change} & \textbf{Changed At}\\ \midrule
|
\toprule \textbf{Date / Version} & \textbf{Authors} & \textbf{Change} & \textbf{Changed At}\\ \midrule
|
||||||
\endhead
|
\endhead
|
||||||
|
|
||||||
|
November 13, 2026 / 1.7 (draft) & SK, KH & In progress: Secure Delivery and Rollback assignment. Added the trusted Jenkins delivery agent, locked dependencies and pinned base image, the Gitea container registry, staging and production proxy routes, image build and publish by digest, and Ansible deployment to staging with an idempotence check. Security gates, approval and promotion, v2 and recovery, and monitoring sections still to be completed. Updated the Hosts and Passwords tables and the Glossary. & \ChapterRef{SecureDelivery}, \ChapterRef{PWDHST} \\
|
||||||
|
|
||||||
October 29, 2026 / 1.6 & SK, KH & Completed the Introduction to SRE assignment: deployed Prometheus, Grafana OSS, Node Exporter, and Blackbox Exporter as four pinned, persistent containers on the existing Droplet; published authenticated Grafana at \texttt{metrics.ssw590-08.me}; built a six-panel dashboard; defined an availability SLI and SLO; configured and tested Grafana-managed alerts with a Discord contact point; and ran a controlled Jenkins outage with a blameless review. Updated the Hosts and Passwords tables and the Glossary. & \ChapterRef{SRE}, \ChapterRef{PWDHST} \\
|
October 29, 2026 / 1.6 & SK, KH & Completed the Introduction to SRE assignment: deployed Prometheus, Grafana OSS, Node Exporter, and Blackbox Exporter as four pinned, persistent containers on the existing Droplet; published authenticated Grafana at \texttt{metrics.ssw590-08.me}; built a six-panel dashboard; defined an availability SLI and SLO; configured and tested Grafana-managed alerts with a Discord contact point; and ran a controlled Jenkins outage with a blameless review. Updated the Hosts and Passwords tables and the Glossary. & \ChapterRef{SRE}, \ChapterRef{PWDHST} \\
|
||||||
|
|
||||||
October 23, 2026 / 1.5 & SK, KH & Completed the Continuous Integration with Jenkins assignment: deployed a persistent Jenkins LTS container behind HTTPS at \texttt{ci.ssw590-08.me} with firewall-restricted access; integrated Jenkins with the Scrap-Web Gitea repository through a dedicated integration account; added a pricing module, unit tests, and a versioned \texttt{Jenkinsfile}; protected \texttt{main} with a required Jenkins status check and one required approval; and demonstrated a failed, repaired, reviewed, and merged pull request. Updated the Hosts table (Jenkins host and ports) and the Passwords table (Jenkins administrator accounts and the Gitea integration token, hints only). & \ChapterRef{ContinuousIntegration}, \ChapterRef{PWDHST} \\
|
October 23, 2026 / 1.5 & SK, KH & Completed the Continuous Integration with Jenkins assignment: deployed a persistent Jenkins LTS container behind HTTPS at \texttt{ci.ssw590-08.me} with firewall-restricted access; integrated Jenkins with the Scrap-Web Gitea repository through a dedicated integration account; added a pricing module, unit tests, and a versioned \texttt{Jenkinsfile}; protected \texttt{main} with a required Jenkins status check and one required approval; and demonstrated a failed, repaired, reviewed, and merged pull request. Updated the Hosts table (Jenkins host and ports) and the Passwords table (Jenkins administrator accounts and the Gitea integration token, hints only). & \ChapterRef{ContinuousIntegration}, \ChapterRef{PWDHST} \\
|
||||||
|
|||||||
@@ -22,3 +22,7 @@
|
|||||||
\newglossaryentry{errorbudget}{name={error budget},description={The amount of failure an SLO allows over its window; for a 99\% target, 1\% of scheduled measurements}}
|
\newglossaryentry{errorbudget}{name={error budget},description={The amount of failure an SLO allows over its window; for a 99\% target, 1\% of scheduled measurements}}
|
||||||
\newglossaryentry{probe}{name={probe},description={A synthetic request, here an HTTPS GET from Blackbox Exporter, that tests whether a service responds as expected}}
|
\newglossaryentry{probe}{name={probe},description={A synthetic request, here an HTTPS GET from Blackbox Exporter, that tests whether a service responds as expected}}
|
||||||
\newglossaryentry{contactpoint}{name={contact point},description={The Grafana destination, such as a Discord webhook or email address, that receives alert notifications}}
|
\newglossaryentry{contactpoint}{name={contact point},description={The Grafana destination, such as a Discord webhook or email address, that receives alert notifications}}
|
||||||
|
\newglossaryentry{idempotence}{name={idempotence},description={The property that running the same deployment again on an already-correct system changes nothing}}
|
||||||
|
\newglossaryentry{imagedigest}{name={image digest},description={The SHA-256 content hash that identifies one exact container image in a registry; unlike a tag, it cannot be moved to another image}}
|
||||||
|
\newglossaryentry{releaserecord}{name={release record},description={A file that ties one deployment to its image digest, source commit, expected behavior, environment, and build}}
|
||||||
|
\newglossaryentry{trustedagent}{name={trusted agent},description={A Jenkins build node that holds deployment credentials and therefore runs only reviewed code}}
|
||||||
|
|||||||
@@ -66,6 +66,17 @@ Discord webhook (Grafana contact point \texttt{team-alerts})
|
|||||||
& Webhook URL stored only in Grafana's database; re-created from the Discord channel's Integrations $\rightarrow$ Webhooks settings\\
|
& Webhook URL stored only in Grafana's database; re-created from the Discord channel's Integrations $\rightarrow$ Webhooks settings\\
|
||||||
\hline
|
\hline
|
||||||
|
|
||||||
|
Deployment account (Ansible)
|
||||||
|
& deploy
|
||||||
|
& No password; SSH key stored only in Jenkins credential \texttt{deploy-ssh}\\
|
||||||
|
\hline
|
||||||
|
Gitea container registry
|
||||||
|
& Push: Jenkins credential \texttt{gitea-registry-push}; pull: root on the Droplet
|
||||||
|
& Package-write and package-read tokens; never stored in Git, logs, or screenshots\\
|
||||||
|
\hline
|
||||||
|
Jenkins delivery agent
|
||||||
|
& delivery-agent
|
||||||
|
& Agent secret in a file on the Droplet beside \texttt{agent/compose.yaml}; not in Git\\
|
||||||
\end{longtable}
|
\end{longtable}
|
||||||
|
|
||||||
|
|
||||||
@@ -100,7 +111,7 @@ Jenkins Web Interface & ci.ssw590-08.me & 443 & HTTPS access to Jenkins through
|
|||||||
\hline
|
\hline
|
||||||
Jenkins Container & jenkins & 8080 & Internal Docker network web service; not published on the host \\
|
Jenkins Container & jenkins & 8080 & Internal Docker network web service; not published on the host \\
|
||||||
\hline
|
\hline
|
||||||
Jenkins Agent Port & jenkins & 50000 & Not published on the host; no separate build agent is used \\
|
Jenkins Agent Port & jenkins & 50000 & Not published on the host and not used; the delivery agent connects over WebSocket through port 8080 on \texttt{gitea-net} \\
|
||||||
\hline
|
\hline
|
||||||
Grafana Web Interface & metrics.ssw590-08.me & 443 & HTTPS access to Grafana through Caddy \\
|
Grafana Web Interface & metrics.ssw590-08.me & 443 & HTTPS access to Grafana through Caddy \\
|
||||||
\hline
|
\hline
|
||||||
@@ -112,4 +123,12 @@ Node Exporter Container & node-exporter & 9100 & Private, \texttt{monitoring} ne
|
|||||||
\hline
|
\hline
|
||||||
Blackbox Exporter Container & blackbox-exporter & 9115 & Private, \texttt{monitoring} network only; HTTPS probes of Gitea and Jenkins \\
|
Blackbox Exporter Container & blackbox-exporter & 9115 & Private, \texttt{monitoring} network only; HTTPS probes of Gitea and Jenkins \\
|
||||||
\hline
|
\hline
|
||||||
|
Staging Application & staging.ssw590-08.me & 443 & HTTPS access to the staging pricing service through Caddy \\
|
||||||
|
\hline
|
||||||
|
Production Application & app.ssw590-08.me & 443 & HTTPS access to the production-like pricing service through Caddy \\
|
||||||
|
\hline
|
||||||
|
Pricing Containers & pricing-staging, pricing-production & 8000 & Private, \texttt{gitea-net} only; Gunicorn; not published on the host; Compose projects under \texttt{/opt/startup/pricing-\{staging,production\}}; no data volume \\
|
||||||
|
\hline
|
||||||
|
Jenkins Delivery Agent & jenkins-agent & None & Container on \texttt{gitea-net}; runs Docker builds and Ansible; mounts the host Docker socket; state in volume \texttt{agent\_home} \\
|
||||||
|
\hline
|
||||||
\end{longtable}
|
\end{longtable}
|
||||||
@@ -95,3 +95,66 @@
|
|||||||
url = {https://docs.digitalocean.com/support/why-is-smtp-blocked/},
|
url = {https://docs.digitalocean.com/support/why-is-smtp-blocked/},
|
||||||
note = {Accessed: Oct. 28, 2026}
|
note = {Accessed: Oct. 28, 2026}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@misc{AnsibleCompose,
|
||||||
|
author = {{Ansible Project}},
|
||||||
|
title = {{community.docker.docker\_compose\_v2 module}},
|
||||||
|
howpublished = {Ansible Documentation},
|
||||||
|
year = {2026},
|
||||||
|
url = {https://docs.ansible.com/ansible/latest/collections/community/docker/docker_compose_v2_module.html},
|
||||||
|
note = {Accessed: Nov. 13, 2026}
|
||||||
|
}
|
||||||
|
|
||||||
|
@misc{AnsibleInstall,
|
||||||
|
author = {{Ansible Project}},
|
||||||
|
title = {{Installing Ansible}},
|
||||||
|
howpublished = {Ansible Documentation},
|
||||||
|
year = {2026},
|
||||||
|
url = {https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html},
|
||||||
|
note = {Accessed: Nov. 13, 2026}
|
||||||
|
}
|
||||||
|
|
||||||
|
@misc{GiteaContainerRegistry,
|
||||||
|
author = {{Gitea}},
|
||||||
|
title = {{Container Registry}},
|
||||||
|
howpublished = {Gitea Documentation},
|
||||||
|
year = {2026},
|
||||||
|
url = {https://docs.gitea.com/usage/packages/container},
|
||||||
|
note = {Accessed: Nov. 13, 2026}
|
||||||
|
}
|
||||||
|
|
||||||
|
@misc{DockerPullDigest,
|
||||||
|
author = {{Docker Inc.}},
|
||||||
|
title = {{docker image pull: Pull an image by digest}},
|
||||||
|
howpublished = {Docker Documentation},
|
||||||
|
year = {2026},
|
||||||
|
url = {https://docs.docker.com/reference/cli/docker/image/pull/},
|
||||||
|
note = {Accessed: Nov. 13, 2026}
|
||||||
|
}
|
||||||
|
|
||||||
|
@misc{JenkinsAgents,
|
||||||
|
author = {{Jenkins Project}},
|
||||||
|
title = {{Using Jenkins agents}},
|
||||||
|
howpublished = {Jenkins User Documentation},
|
||||||
|
year = {2026},
|
||||||
|
url = {https://www.jenkins.io/doc/book/using/using-agents/},
|
||||||
|
note = {Accessed: Nov. 13, 2026}
|
||||||
|
}
|
||||||
|
|
||||||
|
@misc{TrivyDocs,
|
||||||
|
author = {{Aqua Security}},
|
||||||
|
title = {{Trivy Documentation}},
|
||||||
|
howpublished = {Trivy project documentation},
|
||||||
|
year = {2026},
|
||||||
|
url = {https://trivy.dev/docs/latest/},
|
||||||
|
note = {Accessed: Nov. 13, 2026}
|
||||||
|
}
|
||||||
|
|
||||||
|
@misc{PipAudit,
|
||||||
|
author = {{Python Packaging Authority}},
|
||||||
|
title = {{pip-audit: Audit Python environments and requirements for known vulnerabilities}},
|
||||||
|
howpublished = {Project repository},
|
||||||
|
year = {2026},
|
||||||
|
url = {https://github.com/pypa/pip-audit},
|
||||||
|
note = {Accessed: Nov. 13, 2026}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,751 @@
|
|||||||
|
\chapter{Secure Delivery and Rollback}
|
||||||
|
\ChapterLabel{SecureDelivery}
|
||||||
|
\index{continuous delivery}
|
||||||
|
\index{Ansible}
|
||||||
|
\index{rollback}
|
||||||
|
\sloppy
|
||||||
|
|
||||||
|
% Red marker for values still to be filled in from the team's own outputs.
|
||||||
|
% Search this file for \FillIn before submitting; none should remain.
|
||||||
|
\providecommand{\FillIn}[1]{\textcolor{devopsRed}{\textbf{[TO FILL: #1]}}}
|
||||||
|
|
||||||
|
% Figure helper: shows a labelled box until the screenshot file exists.
|
||||||
|
\providecommand{\delfig}[4]{%
|
||||||
|
\begin{figure}[H]\centering
|
||||||
|
\IfFileExists{HW8 images/#1}{\includegraphics[width=#2\linewidth]{HW8 images/#1}}%
|
||||||
|
{\fbox{\parbox{0.8\linewidth}{\centering\vspace{1em}\textit{[Screenshot needed: HW8 images/#1]}\vspace{1em}}}}
|
||||||
|
\caption{#3}\label{#4}\end{figure}}
|
||||||
|
|
||||||
|
This chapter closes the delivery loop for the team's startup. The Startup
|
||||||
|
Pricing Service, a small stateless Flask application served by Gunicorn, is
|
||||||
|
built once into a container image, published to the Gitea container registry,
|
||||||
|
and deployed by Ansible to a staging environment on the existing Droplet behind
|
||||||
|
the existing Caddy proxy. The same image digest is then approved and promoted
|
||||||
|
to a production-like environment, a second release (v2) is delivered, and two
|
||||||
|
recovery cases are exercised.
|
||||||
|
|
||||||
|
The existing Gitea, Jenkins, Caddy, and monitoring containers from earlier
|
||||||
|
chapters are reused unchanged. Nothing was reinstalled, and no Kubernetes,
|
||||||
|
Argo CD, cAdvisor, or database was added. Staging and production share one
|
||||||
|
Droplet, so they share a failure domain and its CPU, memory, and disk: separate
|
||||||
|
Compose projects give configuration separation, not high availability.
|
||||||
|
|
||||||
|
\textbf{Division of work.} Sections~\ref{sec:del-baseline}--\ref{sec:del-build}
|
||||||
|
and Section~\ref{sec:del-ansible} were carried out by \texttt{samahk13}, who
|
||||||
|
holds the Gitea administrator, Jenkins, DNS, and Droplet SSH access.
|
||||||
|
Sections~\ref{sec:del-security} and~\ref{sec:del-promote}--\ref{sec:del-ops}
|
||||||
|
were carried out by \texttt{kholmes}.
|
||||||
|
|
||||||
|
\section{Deployment Architecture}
|
||||||
|
\label{sec:del-architecture}
|
||||||
|
|
||||||
|
\begin{itemize}
|
||||||
|
\item \textbf{Source and images:} the existing Gitea server
|
||||||
|
(\texttt{git.ssw590-08.me}) holds the repository and, with its package
|
||||||
|
registry enabled~\cite{GiteaContainerRegistry}, the application images under
|
||||||
|
\texttt{git.ssw590-08.me/ssw-590-08/pricing}.
|
||||||
|
\item \textbf{Orchestration:} the existing Jenkins controller schedules the
|
||||||
|
pipeline. Delivery stages run on a new \gls{trustedagent} container~\cite{JenkinsAgents},
|
||||||
|
\texttt{jenkins-agent} (node \texttt{delivery-agent}, label
|
||||||
|
\texttt{delivery}), on the same Droplet. Ansible runs inside this agent, not
|
||||||
|
on the controller and not in the application container.
|
||||||
|
\item \textbf{Target:} Ansible connects over SSH to the Droplet host as the
|
||||||
|
dedicated \texttt{deploy} account and applies a separate Compose project
|
||||||
|
for each environment under \texttt{/opt/startup/pricing-staging} and
|
||||||
|
\texttt{/opt/startup/pricing-production}.
|
||||||
|
\item \textbf{Traffic:} browser $\rightarrow$ Caddy (HTTPS 443)
|
||||||
|
$\rightarrow$ \texttt{pricing-staging:8000} or
|
||||||
|
\texttt{pricing-production:8000} over the private \texttt{gitea-net}
|
||||||
|
network. No application port is published on the host.
|
||||||
|
\item \textbf{Monitoring:} the Chapter~\ref{Chapter:SRE} stack (Prometheus,
|
||||||
|
Grafana, Blackbox Exporter, Node Exporter) is reused; see
|
||||||
|
Section~\ref{sec:del-ops}.
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
\FillIn{team deployment diagram (HW8 images/delivery-architecture.png) showing
|
||||||
|
actual hosts, container boundaries, volumes and bind mounts, Ansible SSH, both
|
||||||
|
environments, proxy, and monitoring}
|
||||||
|
|
||||||
|
\section{Prepare the Repository and Establish a Baseline}
|
||||||
|
\label{sec:del-baseline}
|
||||||
|
|
||||||
|
\textbf{Issue and branch.} The work is tracked in Gitea issue~\#24 and developed
|
||||||
|
on branch \texttt{feature/issue-24-delivery} of the existing
|
||||||
|
\texttt{SSW-590-08/Scrap-Web} repository. The supplied v1 starter was copied into
|
||||||
|
\texttt{pricing/}, the Ansible files into \texttt{ansible/}, and release-record
|
||||||
|
documentation into \texttt{releases/}.
|
||||||
|
|
||||||
|
\textbf{Locked dependencies.} The starter's \texttt{requirements.txt} gives
|
||||||
|
version ranges (\texttt{Flask>=3.1,<3.2}, \texttt{gunicorn>=23,<24}). These
|
||||||
|
ranges were moved to \texttt{pricing/requirements.in}, and a lockfile with exact
|
||||||
|
versions and SHA-256 hashes for every direct and transitive dependency was
|
||||||
|
generated with:
|
||||||
|
\begin{minted}[breaklines,breakanywhere]{text}
|
||||||
|
uv pip compile requirements.in --universal --python-version 3.13 --generate-hashes -o requirements.txt
|
||||||
|
\end{minted}
|
||||||
|
|
||||||
|
\begin{tabularx}{\linewidth}{L{3.2cm}L{2.4cm}Y}
|
||||||
|
\toprule
|
||||||
|
\textbf{Package} & \textbf{Version} & \textbf{Role}\\ \midrule
|
||||||
|
flask & 3.1.3 & Direct: web framework\\
|
||||||
|
gunicorn & 23.0.0 & Direct: application server\\
|
||||||
|
werkzeug & 3.1.9 & Transitive (Flask)\\
|
||||||
|
jinja2 & 3.1.6 & Transitive (Flask)\\
|
||||||
|
markupsafe & 3.0.4 & Transitive (Jinja2, Werkzeug)\\
|
||||||
|
itsdangerous & 2.2.0 & Transitive (Flask)\\
|
||||||
|
click & 8.5.1 & Transitive (Flask)\\
|
||||||
|
blinker & 1.9.0 & Transitive (Flask)\\
|
||||||
|
packaging & 26.3 & Transitive (Gunicorn)\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabularx}
|
||||||
|
|
||||||
|
\medskip
|
||||||
|
Both the pipeline's test environment and the image build install with
|
||||||
|
\texttt{pip install --require-hashes -r requirements.txt}, so a changed or
|
||||||
|
unlisted package fails the install instead of being used silently. When
|
||||||
|
dependencies are updated, the lockfile is regenerated and the image is rebuilt
|
||||||
|
and rescanned. No claim is made that these versions are free of
|
||||||
|
vulnerabilities; that is the job of the security gates in
|
||||||
|
Section~\ref{sec:del-security}.
|
||||||
|
|
||||||
|
\textbf{Base image.} The Dockerfile pins \texttt{python:3.13-slim} by digest for
|
||||||
|
\texttt{linux/amd64}, the Droplet's architecture:
|
||||||
|
\texttt{python:3.13-slim@sha256:e48f59cdba69a3cbd9ed2cf0f348d90d\allowbreak 45a8d350d98134cf1070bc106ee9ed90}. Python 3.13 is
|
||||||
|
supported by the selected \texttt{ansible-core} release.
|
||||||
|
|
||||||
|
\textbf{Baseline and controlled failure.} The v1 unit tests
|
||||||
|
(\texttt{test\_price}, \texttt{test\_invalid\_quantity},
|
||||||
|
\texttt{test\_release\_identity}) run in the pipeline's \emph{Unit tests} stage
|
||||||
|
inside a fresh virtual environment:
|
||||||
|
\begin{minted}[breaklines,breakanywhere]{text}
|
||||||
|
python3 -m venv .venv
|
||||||
|
.venv/bin/pip install -q --require-hashes -r requirements.txt
|
||||||
|
.venv/bin/python -m py_compile app.py test_app.py
|
||||||
|
.venv/bin/python -m unittest -v
|
||||||
|
\end{minted}
|
||||||
|
|
||||||
|
\begin{itemize}
|
||||||
|
\item \textbf{Controlled failure:} Jenkins run
|
||||||
|
\texttt{feature/issue-24-delivery} \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/6/}{\#6}, started by a push at 11:19 PM EST on
|
||||||
|
November 12, 2026, ran on \texttt{delivery-agent}. The deliberately
|
||||||
|
broken test \texttt{test\_price} failed, so the \emph{Unit tests} stage
|
||||||
|
failed after 6 seconds and every later delivery stage (security scans,
|
||||||
|
build, publish, deploy) was skipped
|
||||||
|
(Figure~\ref{fig:del-test-fail}). A failing test therefore prevents
|
||||||
|
delivery. The test's expected total was changed from 30 to 31, so it
|
||||||
|
failed with \texttt{AssertionError: 30 != 31} while the application itself
|
||||||
|
was unchanged.
|
||||||
|
\item \textbf{Passing baseline and restore:} run \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/5/}{\#5} (11:13 PM EST), before the
|
||||||
|
controlled failure, passed all three tests. The test was then restored to
|
||||||
|
expect 30, and run \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/7/}{\#7} (11:20 PM EST) passed all three tests again. The same tests also
|
||||||
|
pass locally in a fresh virtual environment (\texttt{Ran 3 tests in
|
||||||
|
0.085s, OK}).
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
All times in this chapter are Eastern Standard Time (EST), as displayed by Jenkins.
|
||||||
|
|
||||||
|
\delfig{build6-unit-test-fail.png}{1.0}{November 12, 2026, 11:19 PM EST ---
|
||||||
|
Jenkins \texttt{feature/issue-24-delivery} run \#6 on \texttt{delivery-agent}:
|
||||||
|
\texttt{test\_price} fails, the Unit tests stage stops the run, and the build,
|
||||||
|
publish, and deploy stages are skipped.}{fig:del-test-fail}
|
||||||
|
|
||||||
|
\section{Prepare the Trusted Agent and Target}
|
||||||
|
\label{sec:del-agent}
|
||||||
|
|
||||||
|
\subsection{Trusted Delivery Agent}
|
||||||
|
The Chapter~\ref{Chapter:ContinuousIntegration} pipeline ran only on the
|
||||||
|
controller's built-in node, which has no Docker or Ansible. A dedicated agent
|
||||||
|
was added rather than enabling deployment jobs on the controller. It is built
|
||||||
|
from \texttt{agent/Dockerfile} and started by \texttt{agent/compose.yaml}, both
|
||||||
|
in Gitea, so recreating the container keeps every tool:
|
||||||
|
|
||||||
|
\begin{itemize}
|
||||||
|
\item \textbf{Base:} \texttt{jenkins/inbound-agent:latest-jdk21}.
|
||||||
|
\item \textbf{Tools:} Python 3 with \texttt{venv}; Docker CLI and the
|
||||||
|
\texttt{buildx} plugin (client only; the daemon is the host's); Trivy;
|
||||||
|
\texttt{pip-audit} in \texttt{/opt/tools-venv}; and \texttt{ansible-core}
|
||||||
|
with the \texttt{community.docker} collection~\cite{AnsibleInstall} in
|
||||||
|
\texttt{/opt/ansible-venv}. Every Jenkins deployment step puts
|
||||||
|
\texttt{/opt/ansible-venv/bin} first on its \texttt{PATH}.
|
||||||
|
\item \textbf{Connection:} the agent connects to the controller at
|
||||||
|
\texttt{http://jenkins:8080/} over WebSocket on the internal
|
||||||
|
\texttt{gitea-net} network, so no new port is published. Its secret is
|
||||||
|
read from a file (\texttt{-secret @/run/secrets/jenkins-agent-secret}) that
|
||||||
|
is not in Git, so it does not appear in the process list or
|
||||||
|
\texttt{docker inspect}.
|
||||||
|
\item \textbf{Docker access:} the host Docker socket is mounted so the agent
|
||||||
|
can build and push images. This is effectively root on the Droplet, so only
|
||||||
|
trusted-branch delivery stages may run on this agent
|
||||||
|
(Section~\ref{sec:del-trust}).
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
Installed versions, printed by \texttt{agent/versions.sh} inside the agent:
|
||||||
|
|
||||||
|
\begin{tabularx}{\linewidth}{L{3.6cm}Y}
|
||||||
|
\toprule
|
||||||
|
\textbf{Tool} & \textbf{Version}\\ \midrule
|
||||||
|
Java & OpenJDK 21.0.13 LTS\\
|
||||||
|
Python & 3.13.5\\
|
||||||
|
Docker client / server & 29.9.3 / 29.8.2\\
|
||||||
|
Docker buildx & v0.38.2\\
|
||||||
|
Trivy & 0.76.2\\
|
||||||
|
pip-audit & 2.10.1\\
|
||||||
|
ansible-core & 2.22.0\\
|
||||||
|
community.docker & 5.4.0\\
|
||||||
|
Agent OS & Debian GNU/Linux 13 (trixie), x86\_64\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabularx}
|
||||||
|
|
||||||
|
\medskip
|
||||||
|
The agent image \texttt{ssw590/jenkins-delivery-agent:1} has image ID
|
||||||
|
\texttt{sha256:e8e72e1c89d3\allowbreak 72fff4a920b581b1a0daa7c885164ff6668dfcc2e22f85e6aa83}.
|
||||||
|
|
||||||
|
\subsection{Target Prerequisites}
|
||||||
|
The target is the same Droplet (\texttt{147.182.179.191}). Before the first
|
||||||
|
playbook run its prerequisites were verified:
|
||||||
|
|
||||||
|
\begin{tabularx}{\linewidth}{L{4.2cm}Y}
|
||||||
|
\toprule
|
||||||
|
\textbf{Requirement} & \textbf{Observed}\\ \midrule
|
||||||
|
Python 3 & 3.12.3\\
|
||||||
|
Docker Engine & 29.8.2\\
|
||||||
|
Compose plugin ($\geq$ 2.18) & v5.5.1 (meets the minimum)\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabularx}
|
||||||
|
|
||||||
|
\subsection{Deployment Account and Credentials}
|
||||||
|
\label{sec:del-trust}
|
||||||
|
\begin{itemize}
|
||||||
|
\item \textbf{Deployment account:} a dedicated \texttt{deploy} user on the
|
||||||
|
Droplet, used only by Ansible. Its private key is stored only in the Jenkins
|
||||||
|
credential \texttt{deploy-ssh}. It is an Ed25519 key with comment
|
||||||
|
\texttt{jenkins-deploy} and fingerprint
|
||||||
|
\texttt{SHA256:jy/MveXnRjD+HOLWi6fuR+WNGA3gpkS0kudqPi/prJY}. The Droplet's
|
||||||
|
Ed25519 host key was read on the Droplet itself over the existing
|
||||||
|
administrator SSH session
|
||||||
|
(\texttt{SHA256:zL7qulFmdVDZQ3oBGvXWyWnKjNWUpPh1BDbfAOC+nbk}). The key
|
||||||
|
scanned from \texttt{147.182.179.191} had the same fingerprint, and it was
|
||||||
|
then pinned in the agent's \texttt{known\_hosts}. Its non-interactive
|
||||||
|
\texttt{sudo} rule, in \texttt{/etc/sudoers.d/}, is
|
||||||
|
\texttt{deploy ALL=(root) NOPASSWD: ALL}. This scope is deliberately broad:
|
||||||
|
the playbook uses \texttt{become: true} to create directories under
|
||||||
|
\texttt{/opt/startup} and to drive Docker Compose as \texttt{root}, and
|
||||||
|
Docker access is already equivalent to root on the host. The account
|
||||||
|
therefore effectively administers the Droplet. A separate account limits
|
||||||
|
who holds the key and makes its use auditable, but it does not remove that
|
||||||
|
risk, so the key is held only by Jenkins and used only by trusted-branch
|
||||||
|
delivery stages.
|
||||||
|
\item \textbf{Registry access:} the Gitea package registry was enabled
|
||||||
|
(\texttt{[packages] ENABLED = true}). A package-\emph{write} token is held
|
||||||
|
only in the Jenkins credential \texttt{gitea-registry-push} and used by the
|
||||||
|
\emph{Publish} stage through \texttt{docker login --password-stdin}. A
|
||||||
|
package-\emph{read} token is logged in for \texttt{root} on the Droplet,
|
||||||
|
the account that runs Docker under Ansible escalation. Tokens are never in
|
||||||
|
Git, command arguments, screenshots, or pipeline logs.
|
||||||
|
\item \textbf{Trust boundary:} every branch and pull request runs only the
|
||||||
|
Chapter~\ref{Chapter:ContinuousIntegration} checks on the controller, with
|
||||||
|
no credentials and no Docker socket. The \emph{Delivery} stages run only for
|
||||||
|
the trusted branch pattern \texttt{TRUSTED\_BRANCH}. In the repository, the pattern is currently
|
||||||
|
\texttt{main|feature/issue-24-delivery} (Figure~\ref{fig:del-commit-diff}),
|
||||||
|
so the delivery runs recorded in this chapter (builds \#4 to \#7) ran from the
|
||||||
|
feature branch. Until the pattern is changed back to \texttt{main}, code on
|
||||||
|
that branch can build, publish, and deploy without a merge review. The
|
||||||
|
Jenkinsfile carries a comment to remove the feature branch from the pattern
|
||||||
|
before submission. \FillIn{commit that restores \texttt{main} only, once it is
|
||||||
|
made} No Docker daemon API is published to the Internet.
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
\section{Connect the Application to the Existing Proxy}
|
||||||
|
\label{sec:del-proxy}
|
||||||
|
|
||||||
|
\begin{itemize}
|
||||||
|
\item \textbf{DNS:} \texttt{staging.ssw590-08.me} and
|
||||||
|
\texttt{app.ssw590-08.me} point to the Droplet (\texttt{147.182.179.191}).
|
||||||
|
\item \textbf{Proxy network:} Caddy runs in a container on the existing
|
||||||
|
\texttt{gitea-net} network. The Compose template joins each pricing
|
||||||
|
container to that external network with a distinct alias
|
||||||
|
(\texttt{pricing-staging}, \texttt{pricing-production}) and publishes no
|
||||||
|
host port, so port 8000 is reachable only from containers on
|
||||||
|
\texttt{gitea-net}.
|
||||||
|
\item \textbf{Routes:} added to the existing \texttt{/root/gitea/Caddyfile},
|
||||||
|
keeping the Gitea, Jenkins, and Grafana routes. The file was validated and
|
||||||
|
Caddy reloaded, and Caddy obtained valid TLS certificates for both
|
||||||
|
hostnames automatically.
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
\begin{minted}[breaklines,breakanywhere]{text}
|
||||||
|
staging.ssw590-08.me {
|
||||||
|
reverse_proxy pricing-staging:8000
|
||||||
|
}
|
||||||
|
app.ssw590-08.me {
|
||||||
|
reverse_proxy pricing-production:8000
|
||||||
|
}
|
||||||
|
\end{minted}
|
||||||
|
|
||||||
|
The firewall policy is unchanged: public HTTPS (443, and 80 for redirects),
|
||||||
|
restricted SSH, and no public infrastructure or metrics ports.
|
||||||
|
|
||||||
|
\textbf{Accepted simplification.} Sharing \texttt{gitea-net} means a
|
||||||
|
compromised pricing container could reach Gitea, Jenkins, Grafana, and the
|
||||||
|
agent on that network directly, not only through Caddy. A separate proxy-only
|
||||||
|
network per application would give stronger lateral isolation.
|
||||||
|
|
||||||
|
\section{Build Once and Record an Immutable Release}
|
||||||
|
\label{sec:del-build}
|
||||||
|
|
||||||
|
The \texttt{Jenkinsfile} keeps the Chapter~\ref{Chapter:ContinuousIntegration}
|
||||||
|
checks and adds a \emph{Delivery} block on the \texttt{delivery} agent with
|
||||||
|
these stages: Checkout, Unit tests, Security scan: source, Build image, Security
|
||||||
|
scan: image, Publish, Deploy staging, Staging idempotence, and Approve and deploy
|
||||||
|
production. The pipeline sets \texttt{disableConcurrentBuilds()}, so two runs
|
||||||
|
cannot change staging or production at the same time.
|
||||||
|
|
||||||
|
The image is built once per source commit, with the commit baked in at build
|
||||||
|
time. The \emph{Publish} stage pushes it, deletes the local copy, and pulls it
|
||||||
|
back, so the recorded \gls{imagedigest} is the registry's and not a local image ID~\cite{DockerPullDigest}:
|
||||||
|
|
||||||
|
\begin{minted}[breaklines,breakanywhere]{bash}
|
||||||
|
docker build --build-arg APP_COMMIT="$APP_COMMIT" -t "$IMAGE:$APP_COMMIT" .
|
||||||
|
printf '%s' "$REG_TOKEN" | docker login "$REGISTRY" -u "$REG_USER" --password-stdin
|
||||||
|
docker push "$IMAGE:$APP_COMMIT"
|
||||||
|
docker image rm "$IMAGE:$APP_COMMIT"
|
||||||
|
docker pull "$IMAGE:$APP_COMMIT"
|
||||||
|
docker logout "$REGISTRY"
|
||||||
|
docker image inspect "$IMAGE:$APP_COMMIT" --format '{{index .RepoDigests 0}}'
|
||||||
|
\end{minted}
|
||||||
|
|
||||||
|
The stage archives \texttt{image-digest.txt} and \texttt{build-record.txt}
|
||||||
|
(source commit, tag, digest, and Jenkins build URL) as fingerprinted build
|
||||||
|
artifacts. The image runs Gunicorn as the non-root user \texttt{10001}, and the
|
||||||
|
Compose template drops all capabilities and makes the root filesystem read-only
|
||||||
|
with a \texttt{tmpfs} for \texttt{/tmp}.
|
||||||
|
|
||||||
|
{\small
|
||||||
|
\begin{tabularx}{\linewidth}{L{1.9cm}YYY}
|
||||||
|
\toprule
|
||||||
|
\textbf{Release v1} & \textbf{First build (superseded)} & \textbf{Rebuild (superseded)} & \textbf{Run \#7 (latest)}\\ \midrule
|
||||||
|
Source commit & \texttt{\seqsplit{2a35f97071c95b23bccb8c973099f2991c998599}} & \texttt{\seqsplit{3fcd04010ad115df943d2d001dbc4a1523c2a6d1}} & \texttt{c46f127e8c}\\
|
||||||
|
Jenkins build & \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/8/}{\#8} & \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/4/}{\#4} & \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/7/}{\#7}\\
|
||||||
|
Image digest & \texttt{\seqsplit{sha256:ce91d0552da2a4580557ec65aedec04b278fe918df1f02b23c971ca45cc3d97c}} & \texttt{\seqsplit{sha256:2688685992aa57bc94aaca36ea3cce22fd2cd9ba162ea2e09437531594e15bb7}} & \texttt{\seqsplit{sha256:5e7c72446cfc592fdbef07f085b8045bc366068a2aac039c027da7777a27ad59}}\\
|
||||||
|
Published & November 12, 2026, 11:51 PM EST & November 13, 2026, after the 7:48 PM EST image scan in the same build & November 13, 2026, \FillIn{time from the Publish stage}\\
|
||||||
|
Status & Failed the security policy: 7 fixable High findings (Section~\ref{sec:del-security}) & Passed the policy; replaced by run \#7 & Passed the policy (both scans ran before Publish and the run finished successfully); \FillIn{unfixed High count from the run's image-summary file}\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabularx}}
|
||||||
|
|
||||||
|
\medskip
|
||||||
|
Run \#7 is the first run after the blocked-run test (Section~\ref{sec:del-security}).
|
||||||
|
Its commit \texttt{c46f127e8c} removes the fixture that commit \texttt{05d3c58c3a}
|
||||||
|
had added, and each of those two commits changed only that one file, so the
|
||||||
|
source files are the same as in the rebuild. The digest is different because the
|
||||||
|
commit is baked into each image at build time, so every commit produces a new
|
||||||
|
image. A later run, with a new commit, would again produce a new digest. The
|
||||||
|
release that is promoted to production is therefore the one built by the run that
|
||||||
|
passes the approval stage, and its digest is the one recorded for v1.
|
||||||
|
|
||||||
|
\medskip
|
||||||
|
All digests are in the registry repository \texttt{git.ssw590-08.me/ssw-590-08/pricing}.
|
||||||
|
Earlier builds are kept as a record. They were superseded by new builds, not
|
||||||
|
edited, so their images remain in the registry and their digests are unchanged.
|
||||||
|
|
||||||
|
\delfig{publish-digest.png}{1.0}{November 12, 2026, run \#8 --- Jenkins Publish
|
||||||
|
stage: the v1 image is pushed, the local copy deleted and pulled back from the
|
||||||
|
registry, and its registry digest recorded. The registry token is masked and
|
||||||
|
never printed.}{fig:del-publish}
|
||||||
|
|
||||||
|
\delfig{publish-digest-rebuild.png}{1.0}{November 13, 2026, build \#4 --- Jenkins
|
||||||
|
Publish stage for the rebuild: the registry digest
|
||||||
|
\texttt{sha256:2688685992aa\ldots} is recorded and echoed. The registry token is
|
||||||
|
masked and never printed.}{fig:del-publish-rebuild}
|
||||||
|
|
||||||
|
\section{Apply Proportionate Security Gates}
|
||||||
|
\label{sec:del-security}
|
||||||
|
|
||||||
|
\subsection{Policy}
|
||||||
|
The policy was written before the release was scanned
|
||||||
|
(\texttt{security/POLICY.md} in the repository). The pipeline fails, and no
|
||||||
|
image is published or deployed, when any of these is true:
|
||||||
|
\begin{itemize}
|
||||||
|
\item a secret is detected;
|
||||||
|
\item \texttt{pip-audit} reports a known vulnerability in the locked
|
||||||
|
dependencies;
|
||||||
|
\item a HIGH or CRITICAL vulnerability that \emph{has a fix available} is found
|
||||||
|
in the repository or the built image;
|
||||||
|
\item a scanner errors, a tool is missing, or the vulnerability database
|
||||||
|
cannot be obtained. A failed scan is not a clean scan.
|
||||||
|
\end{itemize}
|
||||||
|
HIGH or CRITICAL vulnerabilities with \emph{no fix yet} (typically operating-system
|
||||||
|
packages in the base image) do not block the build, but they are never hidden:
|
||||||
|
each image scan also writes a full report and a count summary, which Jenkins
|
||||||
|
archives with the build, and the accepted set is recorded below as a time-limited
|
||||||
|
exception. A fixable finding is handled by updating the lockfile or the pinned
|
||||||
|
base-image digest, rebuilding, and rescanning; a fixable finding accepted for a
|
||||||
|
stated reason would be recorded in \texttt{security/.trivyignore} with an
|
||||||
|
expiry date. No claim is made that any scanned version is free of
|
||||||
|
vulnerabilities.
|
||||||
|
|
||||||
|
\subsection{Tools and Versions}
|
||||||
|
The checks are implemented in \texttt{security/scan.sh}, called by the
|
||||||
|
\emph{Security scan: source} and \emph{Security scan: image} stages. It uses
|
||||||
|
no \texttt{|| true}, so a failing scanner fails the stage.
|
||||||
|
|
||||||
|
\begin{tabularx}{\linewidth}{L{4.4cm}Y}
|
||||||
|
\toprule
|
||||||
|
\textbf{Item} & \textbf{Value}\\ \midrule
|
||||||
|
Trivy~\cite{TrivyDocs} & 0.76.2\\
|
||||||
|
Trivy vulnerability database & version 2; updated 2026-11-13 19:05:12 UTC;
|
||||||
|
downloaded to the agent 2026-11-13 22:54:18 UTC (the pipeline image scan at
|
||||||
|
2026-11-14 00:48:38 UTC used this same cached copy)\\
|
||||||
|
pip-audit~\cite{PipAudit} & 2.10.1\\
|
||||||
|
Blocking severities & HIGH and CRITICAL\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabularx}
|
||||||
|
|
||||||
|
\subsection{Source Scans}
|
||||||
|
The source checks were first run by hand inside the \texttt{jenkins-agent}
|
||||||
|
container on November 13, 2026, at 5:58--5:59 PM EST, against the agent's
|
||||||
|
existing \texttt{Scrap-Web\_main} workspace. That workspace was at commit
|
||||||
|
\texttt{fa52a28a0c8ffbf05b77c54e801b88e592522f6d}, not at the v1 release commit,
|
||||||
|
so this run shows the method and the state of the repository at that commit and
|
||||||
|
is not the release gate:
|
||||||
|
\begin{minted}[breaklines,breakanywhere]{text}
|
||||||
|
pip-audit -r pricing/requirements.txt --strict --progress-spinner off
|
||||||
|
trivy fs --scanners vuln,secret --severity HIGH,CRITICAL --exit-code 1 --no-progress --skip-dirs .git,.venv .
|
||||||
|
\end{minted}
|
||||||
|
|
||||||
|
\begin{tabularx}{\linewidth}{L{4.2cm}L{2.2cm}Y}
|
||||||
|
\toprule
|
||||||
|
\textbf{Check} & \textbf{Exit code} & \textbf{Result}\\ \midrule
|
||||||
|
\texttt{pip-audit} & 0 & ``No known vulnerabilities found''\\
|
||||||
|
\texttt{trivy fs} & 0 & \texttt{pricing/requirements.txt}: 0 vulnerabilities; no secrets reported\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabularx}
|
||||||
|
|
||||||
|
\medskip
|
||||||
|
For the release itself, the \emph{Security scan: source} stage runs the same
|
||||||
|
checks on the release commit before the image is built. Stages run in order and
|
||||||
|
the \emph{Publish} stage follows both scans, so the successful publish of the
|
||||||
|
image built from commit \texttt{3fcd04010ad1\ldots} (below) means both scan stages
|
||||||
|
passed for it. Figure~\ref{fig:del-source-scan} shows the start of the source
|
||||||
|
scan output in the Jenkins console: \texttt{pip-audit} 2.10.1 reported ``No known
|
||||||
|
vulnerabilities found'' and exited with status 0 at 2026-11-14 00:47:41 UTC
|
||||||
|
(7:47~PM EST on November 13), after which \texttt{trivy fs} began its secret and
|
||||||
|
vulnerability scan.
|
||||||
|
|
||||||
|
\delfig{del-source-scan-build4.png}{1.0}{November 13, 2026, build \#4 --- Jenkins
|
||||||
|
console output of the \emph{Security scan: source} stage: \texttt{pip-audit} exit
|
||||||
|
status 0 at 00:47:41 UTC (7:47~PM EST) and the start of the \texttt{trivy fs}
|
||||||
|
scan. Screenshot taken at 8:56~PM EST.}{fig:del-source-scan}
|
||||||
|
|
||||||
|
The same build's \texttt{trivy fs} result is in Figure~\ref{fig:del-trivy-fs}:
|
||||||
|
\texttt{pricing/requirements.txt} (type \texttt{pip}) has 0 vulnerabilities, and
|
||||||
|
the stage ends with \texttt{RESULT trivy-fs: exit=0} at 2026-11-14 00:48:00 UTC.
|
||||||
|
|
||||||
|
\delfig{del-trivy-fs-build4.png}{1.0}{November 13, 2026, build \#4 --- Jenkins
|
||||||
|
console output of the \emph{Security scan: source} stage: \texttt{trivy fs}
|
||||||
|
report summary (0 vulnerabilities in \texttt{pricing/requirements.txt}) and
|
||||||
|
\texttt{RESULT trivy-fs: exit=0} at 00:48:00 UTC (7:48~PM EST).}{fig:del-trivy-fs}
|
||||||
|
|
||||||
|
\subsection{Image Scan: First v1 Build and Corrective Rebuild}
|
||||||
|
\textbf{First build (scanned by hand, before the policy was enforced in the
|
||||||
|
pipeline).} The image from source commit \texttt{2a35f97} (digest
|
||||||
|
\texttt{sha256:ce91d055\ldots}) was scanned on November 13, 2026, at 6:18~PM EST
|
||||||
|
with \texttt{trivy image --severity HIGH,CRITICAL}. Trivy identified Debian 13.7.
|
||||||
|
It reported \textbf{54 HIGH and no CRITICAL} findings (49 in operating-system
|
||||||
|
packages, 5 in Python packages): \textbf{7 had a fix available and 47 did
|
||||||
|
not.} The application's own locked dependencies (Flask, Gunicorn, Werkzeug,
|
||||||
|
Jinja2, and the others) showed no findings. Under the policy this image fails the
|
||||||
|
gate because of the 7 fixable findings:
|
||||||
|
|
||||||
|
\begin{tabularx}{\linewidth}{L{2.4cm}L{3.8cm}L{3.2cm}Y}
|
||||||
|
\toprule
|
||||||
|
\textbf{Package} & \textbf{Advisory} & \textbf{Installed} & \textbf{Fixed in}\\ \midrule
|
||||||
|
zlib1g & CVE-2026-76844 & \texttt{\seqsplit{1:1.3.dfsg+really1.3.1-1+b1}} & \texttt{…+deb13u1}\\
|
||||||
|
zlib1g & CVE-2026-85091 & same & \texttt{…+deb13u1}\\
|
||||||
|
msgpack & CVE-2026-114613 & 1.1.2 & 1.2.3\\
|
||||||
|
msgpack & GHSA-6v7p-g79w-8964 & 1.1.2 & 1.2.1\\
|
||||||
|
setuptools & CVE-2025-47273 & 70.3.0 & 78.1.1\\
|
||||||
|
urllib3 & CVE-2026-97687 & 2.7.0 & 2.8.0\\
|
||||||
|
urllib3 & CVE-2026-97689 & 2.7.0 & 2.8.0\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabularx}
|
||||||
|
|
||||||
|
\medskip
|
||||||
|
None of these packages is in the project's lockfile, so they come from the base
|
||||||
|
image's operating system and Python environment, not from the application.
|
||||||
|
|
||||||
|
\textbf{Corrective rebuild.} The image was rebuilt from commit
|
||||||
|
\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/commit/3fcd04010ad115df943d2d001dbc4a1523c2a6d1}{\texttt{3fcd04010ad115df943d2d001dbc4a1523c2a6d1}}
|
||||||
|
in Jenkins build
|
||||||
|
\href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/4/}{\#4}.
|
||||||
|
The new digest is
|
||||||
|
\texttt{sha256:2688685992aa57bc94aaca36ea3cce22fd2cd9ba162ea2e09437531594e15bb7}.
|
||||||
|
The Dockerfile on the delivery branch pins the base image by digest:
|
||||||
|
\texttt{FROM python:3.13-slim@sha256:e48f59cdba69a3cbd9ed2cf0f348d90d\allowbreak 45a8d350d98134cf1070bc106ee9ed90},
|
||||||
|
the same digest named in Section~\ref{sec:del-baseline}, so the base-image digest did
|
||||||
|
not change between the two builds. The rebuild commit adds two lines to the Dockerfile
|
||||||
|
(Figure~\ref{fig:del-commit-diff}): one \texttt{RUN} step that upgrades only the
|
||||||
|
\texttt{zlib1g} package with \texttt{apt-get install -{}-only-upgrade} and
|
||||||
|
removes the apt package lists, and a second command that uninstalls \texttt{pip}
|
||||||
|
and \texttt{setuptools} from the image. The upgrade addresses the two
|
||||||
|
\texttt{zlib1g} findings, and removing \texttt{setuptools} removes its finding.
|
||||||
|
The diff does not mention \texttt{msgpack} or \texttt{urllib3}, but the package
|
||||||
|
list in the rebuilt image's scan (Figure~\ref{fig:del-image-scan}) contains
|
||||||
|
only the nine application packages and no \texttt{pip}, \texttt{setuptools},
|
||||||
|
\texttt{msgpack} or \texttt{urllib3} entry. Two trade-offs follow. The
|
||||||
|
\texttt{apt-get} step makes the result depend on the package archive at build
|
||||||
|
time, so the image digest, not the Dockerfile, is the identity of the release.
|
||||||
|
And the image can no longer install packages at runtime, which suits a service
|
||||||
|
whose dependencies are fixed at build time.
|
||||||
|
|
||||||
|
\delfig{del-commit-diff.png}{1.0}{November 13, 2026 --- commit diff of the rebuild
|
||||||
|
(screenshot taken at 9:15~PM EST): \texttt{pricing/Dockerfile} gains the
|
||||||
|
\texttt{zlib1g} upgrade and the \texttt{pip}/\texttt{setuptools} removal, and the
|
||||||
|
Jenkinsfile \texttt{TRUSTED\_BRANCH} pattern gains
|
||||||
|
\texttt{feature/issue-24-delivery}.}{fig:del-commit-diff} The pipeline's image scan ran at
|
||||||
|
2026-11-14 00:48:38 UTC (7:48~PM EST on November 13) and wrote its summary:
|
||||||
|
|
||||||
|
\begin{minted}[breaklines,breakanywhere]{text}
|
||||||
|
image findings at HIGH/CRITICAL (all, including unfixed):
|
||||||
|
HIGH no fix yet 47
|
||||||
|
total 47
|
||||||
|
\end{minted}
|
||||||
|
|
||||||
|
The 7 fixable findings are gone: no HIGH or CRITICAL finding with a fix remains
|
||||||
|
and no CRITICAL finding exists, so the gate passes for the rebuilt image.
|
||||||
|
Figure~\ref{fig:del-image-scan}, taken from the archived \texttt{trivy-image.txt},
|
||||||
|
shows the gate scan of the image tagged with commit \texttt{3fcd0401}: Debian 13.7
|
||||||
|
with 0 vulnerabilities, and 0 in each of the application's Python packages.
|
||||||
|
|
||||||
|
\delfig{del-image-scan-build4.png}{1.0}{November 13, 2026, build \#4 ---
|
||||||
|
\texttt{trivy-image.txt} from the \emph{Security scan: image} stage (scan at
|
||||||
|
00:48:41 UTC, 7:48~PM EST): 0 fixable High/Critical findings in the operating
|
||||||
|
system and in each Python package. Screenshot taken at 9:21~PM EST.}{fig:del-image-scan}
|
||||||
|
|
||||||
|
\begin{tabularx}{\linewidth}{L{3.0cm}L{2.6cm}L{2.4cm}Y}
|
||||||
|
\toprule
|
||||||
|
\textbf{Build} & \textbf{Source commit} & \textbf{Fixable HIGH/CRIT} & \textbf{Unfixed HIGH}\\ \midrule
|
||||||
|
First v1 (by hand) & \texttt{2a35f97} & 7 & 47\\
|
||||||
|
Rebuild (\#4) & \texttt{3fcd0401} & 0 & 47\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabularx}
|
||||||
|
|
||||||
|
\subsection{Accepted Exception}
|
||||||
|
The 47 remaining HIGH findings have no fixed package version yet. They are
|
||||||
|
accepted for this teaching deployment on these grounds: no fix exists to apply,
|
||||||
|
the pricing service is stateless and processes no customer data, application
|
||||||
|
port 8000 is not published, and the container runs as a non-root user with all
|
||||||
|
capabilities dropped and a read-only root filesystem. The exception was accepted on November 13, 2026. It is time-limited and must be
|
||||||
|
reviewed again by November 20, 2026, or
|
||||||
|
earlier when a fixed package version is released. The full list is in
|
||||||
|
\texttt{trivy-image-full.json}, archived with the Jenkins build.
|
||||||
|
|
||||||
|
\subsection{Blocked Pipeline Run}
|
||||||
|
On November 13, 2026, the gate was tested with a synthetic secret fixture, a file
|
||||||
|
containing a made-up token (see the fixture check below). In Jenkins run \#6
|
||||||
|
(screenshot taken at 9:02~PM EST), the stages after the source scan,
|
||||||
|
\emph{Build image}, \emph{Security scan: image}, \emph{Publish} and
|
||||||
|
\emph{Deploy staging}, were each skipped with the message ``skipped due to earlier
|
||||||
|
failure(s)'' (Figure~\ref{fig:del-blocked-run}), so no image was built or
|
||||||
|
published for that run. After the fixture was removed, run \#7 (screenshot taken at
|
||||||
|
9:08~PM EST) passed the scan stages and reached \emph{Publish}, where the log
|
||||||
|
shows the registry login with the token masked as \texttt{****}
|
||||||
|
(Figure~\ref{fig:del-rerun}).
|
||||||
|
The Trivy output for the fixture (Figure~\ref{fig:del-secret-finding}, from
|
||||||
|
\texttt{trivy-source.txt}, scan time 02:00:42 UTC, which is 9:00~PM EST) reports
|
||||||
|
one \texttt{CRITICAL} secret of type \texttt{github-pat} in
|
||||||
|
\texttt{security/fixture-secret.txt}, line 1, with the value masked. A critical
|
||||||
|
finding makes the source scan exit non-zero under the policy, which is what stops
|
||||||
|
the later stages. The fixture was added in commit \texttt{05d3c58c3a} (message ``testing build
|
||||||
|
block'', parent \texttt{3fcd04010a}) and removed in commit \texttt{c46f127e8c}
|
||||||
|
(message ``removed forced error'', parent \texttt{05d3c58c3a}); the two commit
|
||||||
|
pages are in Figures~\ref{fig:del-fixture-added} and~\ref{fig:del-fixture-removed},
|
||||||
|
with the token value covered. The value is made up, but the commit remains in the
|
||||||
|
repository history. Run \#7, on the removal commit, finished with
|
||||||
|
\texttt{Finished: SUCCESS} (Figure~\ref{fig:del-run7-success}). In that run the
|
||||||
|
\emph{Approve and deploy production} stage was still a placeholder that printed
|
||||||
|
``Not implemented yet'', so no production step ran. Run \#7 also executed the
|
||||||
|
Publish and Deploy staging stages for commit \texttt{c46f127e8c}.
|
||||||
|
\FillIn{image digest published by run \#7, and whether it replaces build \#4 as
|
||||||
|
the v1 release}
|
||||||
|
|
||||||
|
\delfig{del-fixture-added.png}{1.0}{November 13, 2026 --- Gitea commit page for
|
||||||
|
\texttt{05d3c58c3a}, ``testing build block'', which adds
|
||||||
|
\texttt{security/fixture-secret.txt} (token value covered). The commit shows a
|
||||||
|
failed status. Screenshot taken at 9:27~PM EST.}{fig:del-fixture-added}
|
||||||
|
|
||||||
|
\delfig{del-fixture-removed.png}{1.0}{November 13, 2026 --- Gitea commit page for
|
||||||
|
\texttt{c46f127e8c}, ``removed forced error'', which deletes the fixture file
|
||||||
|
(token value covered). The commit shows a passing status. Screenshot taken at
|
||||||
|
9:27~PM EST.}{fig:del-fixture-removed}
|
||||||
|
|
||||||
|
\delfig{del-run7-success.png}{0.9}{November 13, 2026, run \#7 (screenshot taken at
|
||||||
|
9:27~PM EST) --- end of the Jenkins console: the production stage still prints
|
||||||
|
``Not implemented yet'', the pipeline reports ``All stages passed'' and
|
||||||
|
\texttt{Finished: SUCCESS}.}{fig:del-run7-success}
|
||||||
|
|
||||||
|
\delfig{del-blocked-run6.png}{0.9}{November 13, 2026, run \#6 (screenshot taken at
|
||||||
|
9:02~PM EST) --- Jenkins console: \emph{Build image}, \emph{Security scan: image},
|
||||||
|
\emph{Publish} and \emph{Deploy staging} skipped due to earlier failure(s).}{fig:del-blocked-run}
|
||||||
|
|
||||||
|
\delfig{del-rerun7.png}{0.9}{November 13, 2026, run \#7 (screenshot taken at
|
||||||
|
9:08~PM EST) --- Jenkins console after the fixture was removed: the pipeline
|
||||||
|
reaches \emph{Publish}; the registry token is masked as \texttt{****}.}{fig:del-rerun}
|
||||||
|
|
||||||
|
\delfig{del-source-scan-secret.png}{1.0}{November 13, 2026, source scan with the
|
||||||
|
synthetic fixture (scan time 02:00:42 UTC, 9:00~PM EST): Trivy reports 1
|
||||||
|
\texttt{CRITICAL} \texttt{github-pat} secret in \texttt{security/fixture-secret.txt};
|
||||||
|
the value is masked. The exit status line is not in this screenshot.}{fig:del-secret-finding}
|
||||||
|
|
||||||
|
\textbf{Fixture check.} Before it was committed, the fixture format was tested
|
||||||
|
locally in the agent on November 13, 2026, at 6:55~PM EST, in a temporary
|
||||||
|
directory outside the repository. Trivy reported one finding, \texttt{CRITICAL:
|
||||||
|
GitHub (github-pat)}, and exited with status 1. The value is made up and is
|
||||||
|
not a live credential; Trivy masked it in its output.
|
||||||
|
|
||||||
|
\section{Deploy v1 with Ansible and Prove Idempotence}
|
||||||
|
\label{sec:del-ansible}
|
||||||
|
|
||||||
|
\textbf{Inputs.} \texttt{ansible/inventory.ini} names one host,
|
||||||
|
\texttt{startup}, at \texttt{147.182.179.191} with user \texttt{deploy}; it
|
||||||
|
contains no secrets. \texttt{ansible/deploy.yml} and
|
||||||
|
\texttt{ansible/templates/compose.yaml.j2} are the supplied playbook and
|
||||||
|
template with every placeholder replaced.
|
||||||
|
|
||||||
|
\textbf{Release record.} The \emph{Deploy staging} stage writes the
|
||||||
|
\gls{releaserecord} from the build it belongs to, so the digest and commit cannot be
|
||||||
|
mistyped. The expected version and total are read from the application source
|
||||||
|
(\texttt{VERSION} and \texttt{3 $\times$ UNIT\_PRICE}), not from configuration.
|
||||||
|
The record is archived with the build. For the rebuild (build \#4) it contained the following; run \#7 generates the same fields from its own digest and commit:
|
||||||
|
|
||||||
|
\begin{minted}[breaklines,breakanywhere]{yaml}
|
||||||
|
target_env: staging
|
||||||
|
release_image: git.ssw590-08.me/ssw-590-08/pricing@sha256:2688685992aa57bc94aaca36ea3cce22fd2cd9ba162ea2e09437531594e15bb7
|
||||||
|
expected_version: v1
|
||||||
|
expected_commit: 3fcd04010ad115df943d2d001dbc4a1523c2a6d1
|
||||||
|
expected_total: 30
|
||||||
|
public_url: https://staging.ssw590-08.me
|
||||||
|
proxy_network: gitea-net
|
||||||
|
\end{minted}
|
||||||
|
The record holds metadata only, never credentials.
|
||||||
|
|
||||||
|
\textbf{Deployment.} The stage runs a syntax check and then the deployment:
|
||||||
|
\begin{minted}[breaklines,breakanywhere]{bash}
|
||||||
|
ansible-playbook -i ansible/inventory.ini ansible/deploy.yml --syntax-check
|
||||||
|
ansible-playbook -i ansible/inventory.ini ansible/deploy.yml \
|
||||||
|
--private-key "$DEPLOY_KEY" -e @release-v1-staging.yml
|
||||||
|
\end{minted}
|
||||||
|
The playbook validates its inputs, creates \texttt{/opt/startup/pricing-staging},
|
||||||
|
renders the Compose file, starts the selected digest without rebuilding~\cite{AnsibleCompose}, waits
|
||||||
|
for the container health check, and then checks
|
||||||
|
\url{https://staging.ssw590-08.me} for \texttt{/health}, version \texttt{v1},
|
||||||
|
the exact source commit, and a total of USD~30 for \texttt{quantity=3}. It
|
||||||
|
fails the run if any check fails; it does not roll back on its own.
|
||||||
|
|
||||||
|
\textbf{\Gls{idempotence}.} The \emph{Staging idempotence} stage runs exactly the
|
||||||
|
same command again and fails the build unless the recap shows
|
||||||
|
\texttt{changed=0 unreachable=0 failed=0}:
|
||||||
|
|
||||||
|
\begin{tabularx}{\linewidth}{L{3.4cm}L{2.2cm}Y}
|
||||||
|
\toprule
|
||||||
|
\textbf{Build} & \textbf{Run} & \textbf{PLAY RECAP for \texttt{startup}}\\ \midrule
|
||||||
|
First build, \#8 & First & \texttt{ok=9 changed=3 unreachable=0 failed=0 skipped=0}\\
|
||||||
|
& Second & \texttt{ok=9 changed=0 unreachable=0 failed=0 skipped=0}\\ \addlinespace
|
||||||
|
Rebuild, \#4 & First & \texttt{ok=9 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0}\\
|
||||||
|
& Second & \texttt{ok=9 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0}\\ \addlinespace
|
||||||
|
Run \#7 & First & \texttt{ok=9 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0}\\
|
||||||
|
& Second & \texttt{ok=9 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0}\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabularx}
|
||||||
|
|
||||||
|
\medskip
|
||||||
|
\textbf{First build, run \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/8/}{\#8}} (November 12, 2026, 11:51 PM EST): the first
|
||||||
|
run created the environment and started the container (\texttt{changed=3}); the
|
||||||
|
identical second run changed nothing, and the stage's check matched the recap
|
||||||
|
line \texttt{startup : ok=9 changed=0 unreachable=0 failed=0}. In the second run
|
||||||
|
every task reported \texttt{ok}, including the public HTTPS health,
|
||||||
|
release-identity, and price checks (\texttt{"msg": "All assertions passed"}).
|
||||||
|
|
||||||
|
\textbf{Rebuild, run \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/4/}{\#4}} (November 13, 2026): the rebuilt image was
|
||||||
|
deployed to the same staging project. The first run applied the new release
|
||||||
|
(\texttt{changed=2}) and the identical second run changed nothing
|
||||||
|
(\texttt{changed=0}), so the \emph{Staging idempotence} stage passed.
|
||||||
|
Figure~\ref{fig:del-idempotence-rebuild} shows the start of that stage's log. The
|
||||||
|
recap lines above were copied from the build's console output.
|
||||||
|
|
||||||
|
\textbf{Run \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/7/}{\#7}} (November 13, 2026): the image from commit
|
||||||
|
\texttt{c46f127e8c} was deployed to the same staging project. The first run
|
||||||
|
applied the new release (\texttt{changed=2}, Figure~\ref{fig:del-recap7-first}).
|
||||||
|
The identical second run changed nothing (\texttt{changed=0}), and the stage's
|
||||||
|
\texttt{grep} check for \texttt{changed=0 unreachable=0 failed=0} in
|
||||||
|
\texttt{rerun.log} matched (Figure~\ref{fig:del-recap7-second}), so the
|
||||||
|
\emph{Staging idempotence} stage passed.
|
||||||
|
|
||||||
|
\delfig{staging-idempotence.png}{1.0}{November 12, 2026, run \#8 --- Jenkins
|
||||||
|
Staging idempotence stage: the second, unchanged run passes every check and
|
||||||
|
reports \texttt{changed=0}.}{fig:del-idempotence}
|
||||||
|
|
||||||
|
\delfig{staging-idempotence-rebuild.png}{1.0}{November 13, 2026, build \#4 ---
|
||||||
|
start of the Jenkins \emph{Staging idempotence} stage log for the rebuild: the same
|
||||||
|
\texttt{ansible-playbook} command and release record
|
||||||
|
(\texttt{release-v1-staging.yml}) are run again, with the deploy key masked
|
||||||
|
(\texttt{****}) and output copied to \texttt{rerun.log}. Its \texttt{changed=0}
|
||||||
|
recap line is quoted in the text.}{fig:del-idempotence-rebuild}
|
||||||
|
|
||||||
|
\delfig{del-run7-recap-first.png}{1.0}{November 13, 2026, run \#7 (screenshot
|
||||||
|
taken at 9:32~PM EST) --- first \texttt{PLAY RECAP} for \texttt{startup}:
|
||||||
|
\texttt{ok=9 changed=2 unreachable=0 failed=0}, followed by the start of the
|
||||||
|
\emph{Staging idempotence} stage, which runs the same command with the deploy key
|
||||||
|
masked.}{fig:del-recap7-first}
|
||||||
|
|
||||||
|
\delfig{del-run7-recap-second.png}{1.0}{November 13, 2026, run \#7 (screenshot
|
||||||
|
taken at 9:32~PM EST) --- second \texttt{PLAY RECAP}: \texttt{changed=0}, the
|
||||||
|
\texttt{grep} check on \texttt{rerun.log} matching it, the production stage still
|
||||||
|
printing ``Not implemented yet'', and ``All stages passed''.}{fig:del-recap7-second}
|
||||||
|
|
||||||
|
\delfig{staging-check.png}{1.0}{November 13, 2026 --- staging, v1:
|
||||||
|
\url{https://staging.ssw590-08.me/} returns version \texttt{v1} and commit
|
||||||
|
\texttt{2a35f97}, and \texttt{/price?quantity=3} returns a total of USD 30.}{fig:del-staging}
|
||||||
|
|
||||||
|
\delfig{staging-check-rebuild.png}{0.9}{November 13, 2026, about 8:29--8:30~PM
|
||||||
|
EST --- staging, rebuilt v1: \url{https://staging.ssw590-08.me/} returns version
|
||||||
|
\texttt{v1} and commit \texttt{3fcd0401}, and \texttt{/price?quantity=3} returns
|
||||||
|
a total of USD 30.}{fig:del-staging-rebuild}
|
||||||
|
|
||||||
|
\section{Approve and Promote the Same Image}
|
||||||
|
\label{sec:del-promote}
|
||||||
|
|
||||||
|
\FillIn{kholmes: restricted Jenkins input step with timeout, approver and
|
||||||
|
decision, v1-production record with the same digest, production smoke tests}
|
||||||
|
|
||||||
|
\section{Release v2 and Exercise Two Recovery Cases}
|
||||||
|
\label{sec:del-v2}
|
||||||
|
|
||||||
|
\FillIn{kholmes: v2 release in both environments, healthy rollback of
|
||||||
|
production to v1, failed staging deployment (Gunicorn on 8001) and recovery,
|
||||||
|
timeline and measured interruption, state-compatibility discussion}
|
||||||
|
|
||||||
|
\section{Reuse Monitoring and Document Operations}
|
||||||
|
\label{sec:del-ops}
|
||||||
|
|
||||||
|
\FillIn{kholmes: production /health Blackbox probe and Grafana panel, release
|
||||||
|
and rollback timestamps correlated with monitoring, runbooks, approvers,
|
||||||
|
resource use, cleanup plan}
|
||||||
|
|
||||||
|
\section{Traceability}
|
||||||
|
\label{sec:del-trace}
|
||||||
|
|
||||||
|
\begin{tabularx}{\linewidth}{L{3.4cm}YY}
|
||||||
|
\toprule
|
||||||
|
\textbf{Item} & \textbf{v1} & \textbf{v2}\\ \midrule
|
||||||
|
Source commit & \texttt{c46f127e8c} (run \#7; earlier: rebuild \texttt{3fcd0401}, first build \texttt{2a35f97}) & \FillIn{}\\
|
||||||
|
Configuration commit & \texttt{c46f127e8c} (same checkout as the source; Ansible files and release record come from the build's own repository checkout) & \FillIn{}\\
|
||||||
|
Image digest & \texttt{sha256:5e7c7244\ldots} (rebuild \texttt{sha256:26886859\ldots}; first build \texttt{sha256:ce91d055\ldots}) & \FillIn{}\\
|
||||||
|
Jenkins build & \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/7/}{\#7} (staging; earlier \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/4/}{\#4} and \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/8/}{\#8}) & \FillIn{}\\
|
||||||
|
Scan result & Pass: both scan stages passed before Publish in run \#7 (rebuild \#4: 0 fixable High/Critical, 47 unfixed High accepted; first build failed: 7 fixable) & \FillIn{}\\
|
||||||
|
Staging result & Run \#7: rerun \texttt{changed=0}; \FillIn{health, v1, commit and total check for the run \#7 deployment} & \FillIn{}\\
|
||||||
|
Approver and time & \FillIn{} & \FillIn{}\\
|
||||||
|
Production result & \FillIn{} & \FillIn{}\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabularx}
|
||||||
|
|
||||||
|
\fussy
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
__pycache__
|
||||||
|
.venv
|
||||||
|
.ansible-venv
|
||||||
|
.git
|
||||||
|
*.pyc
|
||||||
|
requirements.in
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
# Base image pinned by digest (python:3.13-slim, linux/amd64 for the Droplet).
|
||||||
|
FROM python:3.13-slim@sha256:e48f59cdba69a3cbd9ed2cf0f348d90d45a8d350d98134cf1070bc106ee9ed90
|
||||||
|
ARG APP_COMMIT=development
|
||||||
|
ENV APP_COMMIT=$APP_COMMIT PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
|
||||||
|
WORKDIR /app
|
||||||
|
COPY requirements.txt .
|
||||||
|
# Exact, hash-checked dependency versions (direct + transitive) from requirements.txt
|
||||||
|
RUN pip install --no-cache-dir --require-hashes -r requirements.txt
|
||||||
|
RUN apt-get update && apt-get install -y --only-upgrade zlib1g && rm -rf /var/lib/apt/lists/* \
|
||||||
|
&& pip uninstall -y pip setuptools
|
||||||
|
COPY app.py .
|
||||||
|
USER 10001:10001
|
||||||
|
EXPOSE 8000
|
||||||
|
HEALTHCHECK --interval=10s --timeout=3s --start-period=10s --retries=3 CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=2)"
|
||||||
|
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "1", "--worker-tmp-dir", "/tmp", "app:app"]
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import os
|
||||||
|
from flask import Flask, jsonify, request
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
VERSION = "v1"
|
||||||
|
UNIT_PRICE = 10
|
||||||
|
COMMIT = os.environ.get("APP_COMMIT", "development")
|
||||||
|
|
||||||
|
|
||||||
|
def total_price(quantity):
|
||||||
|
if quantity < 1 or quantity > 1000:
|
||||||
|
raise ValueError("quantity must be between 1 and 1000")
|
||||||
|
return UNIT_PRICE * quantity
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/")
|
||||||
|
def index():
|
||||||
|
return jsonify(service="Startup Pricing", version=VERSION, commit=COMMIT)
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/health")
|
||||||
|
def health():
|
||||||
|
return jsonify(status="ok", version=VERSION)
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/price")
|
||||||
|
def price():
|
||||||
|
try:
|
||||||
|
quantity = int(request.args.get("quantity", "1"))
|
||||||
|
total = total_price(quantity)
|
||||||
|
except ValueError as error:
|
||||||
|
return jsonify(error=str(error)), 400
|
||||||
|
return jsonify(quantity=quantity, total=total, currency="USD")
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
Flask>=3.1,<3.2
|
||||||
|
gunicorn>=23,<24
|
||||||
@@ -0,0 +1,190 @@
|
|||||||
|
# This file was autogenerated by uv via the following command:
|
||||||
|
# uv pip compile requirements.in --universal --python-version 3.13 --generate-hashes -o requirements.txt
|
||||||
|
blinker==1.9.0 \
|
||||||
|
--hash=sha256:b4ce2265a7abece45e7cc896e98dbebe6cead56bcf805a3d23136d145f5445bf \
|
||||||
|
--hash=sha256:ba0efaa9080b619ff2f3459d1d500c57bddea4a6b424b60a91141db6fd2f08bc
|
||||||
|
# via flask
|
||||||
|
click==8.5.1 \
|
||||||
|
--hash=sha256:8bb5376d2006950386f8c6427613334a2acadc5f559cb80e638d00b4df957e37 \
|
||||||
|
--hash=sha256:9bbfada76703fd1d784b83eea012e3e8c6a001a876543ef104fa56aaaeb072b4
|
||||||
|
# via flask
|
||||||
|
flask==3.1.3 \
|
||||||
|
--hash=sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb \
|
||||||
|
--hash=sha256:f4bcbefc124291925f1a26446da31a5178f9483862233b23c0c96a20701f670c
|
||||||
|
# via -r requirements.in
|
||||||
|
gunicorn==23.0.0 \
|
||||||
|
--hash=sha256:ec400d38950de4dfd418cff8328b2c8faed0edb0d517d3394e457c317908ca4d \
|
||||||
|
--hash=sha256:f014447a0101dc57e294f6c18ca6b40227a4c90e9bdb586042628030cba004ec
|
||||||
|
# via -r requirements.in
|
||||||
|
itsdangerous==2.2.0 \
|
||||||
|
--hash=sha256:c6242fc49e35958c8b15141343aa660db5fc54d4f13a1db01a3f5891b98700ef \
|
||||||
|
--hash=sha256:e0050c0b7da1eea53ffaf149c0cfbb5c6e2e2b69c4bef22c81fa6eb73e5f6173
|
||||||
|
# via flask
|
||||||
|
jinja2==3.1.6 \
|
||||||
|
--hash=sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d \
|
||||||
|
--hash=sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67
|
||||||
|
# via flask
|
||||||
|
markupsafe==3.0.4 \
|
||||||
|
--hash=sha256:007e1ffd9bf65bb6ee96df7b258fc632a4868dd5566037986c64781f35a36e98 \
|
||||||
|
--hash=sha256:02fa4acbc6a3fc5c693c34d4dd8c1130b7fe99cc915181b0ddd6f72aeb296002 \
|
||||||
|
--hash=sha256:03470d1a8268e692ecf79ecd565593e59d44219377a7ead61f1f1b94c1f7ff6b \
|
||||||
|
--hash=sha256:04e7902ba80ee4bac1d50a549606527a1dcf0476cd81403db41099d3b60ec653 \
|
||||||
|
--hash=sha256:051417f74bcaaefa316276e0ff723f541616ca51043d070da00249d9bddd3e3c \
|
||||||
|
--hash=sha256:05295589e619b9bed252a86b532b8e27350abc372d18ba89b59375325e91ec1e \
|
||||||
|
--hash=sha256:06de8ef6331f6e822c28d577dc8bf43fe398800477c49498f38fc38b67ff33fc \
|
||||||
|
--hash=sha256:0764a13d34cae40db7bbf3a09b7e9b491bf4603e20b263a7a9d6b8e324975d0a \
|
||||||
|
--hash=sha256:077293e425f28ec737dbcad442a71752e28f8ae27cde3d68acd1fb212091cd92 \
|
||||||
|
--hash=sha256:0930db9bdc62d22944e10b066448bb65dc9abe9112880c7cab8da54db4284d5f \
|
||||||
|
--hash=sha256:0cee7cb0f9a1b6892ea482237d9403b3d1b4603aee057d0ff01f0fac2d019a97 \
|
||||||
|
--hash=sha256:0d9c47709875fdb321452056622e930c52afbc07a7d780762fbb8b4d91ce6fa4 \
|
||||||
|
--hash=sha256:11935df9bf455ed0c04eb87bcd720f02b1fe5e02128a9430f23aed6f93336fc7 \
|
||||||
|
--hash=sha256:12a606a492de952afcb43b59a14aaaaad120e708d3663dd0fdf2d738d427a691 \
|
||||||
|
--hash=sha256:14bd2d845d62ab678eaf81da89d7b621b51756c72346745c1a594c09d49207a2 \
|
||||||
|
--hash=sha256:15ba9e28640feef770374b116a6f019c21f52404aeabe516aa7f800587b98cfc \
|
||||||
|
--hash=sha256:18a801868a884f216e784d7d14db2a4077143ce7610440aee2ce8f734e7cfcde \
|
||||||
|
--hash=sha256:1c0df495a977d10460a94941799c72d5b5ab03d3858d949b55b5a66c8f371c99 \
|
||||||
|
--hash=sha256:1caa2fa5a6184fb233153b35f654e6687bd555476f6170f29d8ee9be1a8b0af9 \
|
||||||
|
--hash=sha256:1e1451fab512d1bcc3dc26988ec1edb0b82c2db909132872cd9356070a6b63df \
|
||||||
|
--hash=sha256:1f1f9477e174582b0a1b583d60b66e1f2cf5d3fe12cee985e4aedf44766600e5 \
|
||||||
|
--hash=sha256:2628d3a8cb648ecebb3c5d6b0a1052d400e4d8b7ac0fb786be8d285b50040d17 \
|
||||||
|
--hash=sha256:26e9867520db70d37f7fb421a7f0d8adb40171011fb84ce869afa1a83370dfa8 \
|
||||||
|
--hash=sha256:2a6ef68ae94aed8721934072b27a3b654ea2100b97e4ab864cf1489c90926fbc \
|
||||||
|
--hash=sha256:2b2b1e18af909b448bb3cf9e3433366f7a8726271fc214e8b10e0f62a78c724b \
|
||||||
|
--hash=sha256:2cb3dd71fc6be918ad4264346a8ed69485f9b7ed7bf35495d8e22807cd6b8bea \
|
||||||
|
--hash=sha256:2d1b7d9308288661f56672b1b157d75fc536714d3638487bbea17b6318a78248 \
|
||||||
|
--hash=sha256:2dad610540cb2e6272855c178f08ae9a1c7ac258a7fb71660553a5f104b42741 \
|
||||||
|
--hash=sha256:2e5a7cd7fdd14fcb1ae5d7d8bf23d24fbd1daefd1fbca2580132e1ea75f098b5 \
|
||||||
|
--hash=sha256:2e9ad7dd851bf45fab9f75cbff4cb493fee9979e8d8c7c9c3ee119022518edd6 \
|
||||||
|
--hash=sha256:340cbb1957ba99929cbf19a75626d36ba1ae21d1730b287d1cf7f824a20c4fc7 \
|
||||||
|
--hash=sha256:34bdde374c5932765d7dc685c4a1d191a3207852d67e8e0a9eb6ea85156181f1 \
|
||||||
|
--hash=sha256:353bd63081912ab8cfa6a0c7d185934cdf8426f04c618bba6bc4b394f2069b67 \
|
||||||
|
--hash=sha256:387d8cd30e69b3f0a72877b9ae717033396404e19095b17fe89753a981fda44f \
|
||||||
|
--hash=sha256:3882fb412298575bae3b9c46868251f15cc69307359f87bb1b382e53d6e5a2c9 \
|
||||||
|
--hash=sha256:38fc55594dab834470b6733dead2ee9e3f657fb0608c769dcafa0ba5ab52f45c \
|
||||||
|
--hash=sha256:396ec4e65cc889f69786b3b89478b471cee5a3bcf468b9d9bb03e1a30fb291fc \
|
||||||
|
--hash=sha256:39dbacefc411633db5b4378b066a9aca70a3d7e2922c9e578d825f844026eeba \
|
||||||
|
--hash=sha256:3a93d9616ddecfb393727a0041a562cf0b15a244e20f2bd25efc7949be4c4f17 \
|
||||||
|
--hash=sha256:3d23795802fc8bd72534836d64489bbf0f67c088959091bdb22e10735a5107bf \
|
||||||
|
--hash=sha256:434139499bb20b502ed3baa1f169e618f924a97e7a777fea1a49446d80106cf6 \
|
||||||
|
--hash=sha256:436e3ffc6310d3c41878c601db29098102fe5d8a467c49da4a4125254e0980f2 \
|
||||||
|
--hash=sha256:489505b03f692c3f376394e49194fa7a7f9e8558d6e293a7056a0032b0c38163 \
|
||||||
|
--hash=sha256:4a540e2d3192792fc84eced57bef37851ccb2b41f73291bb17408eea77bcd278 \
|
||||||
|
--hash=sha256:4a7cdc2a420ca01058182da4253329764d4bfa055564d1eced90e6ba1e8b1d3d \
|
||||||
|
--hash=sha256:4bced6e2a6dba6a28f7dd3c6ce14df1b2dd495923f16ea484cad03decd463b2b \
|
||||||
|
--hash=sha256:4cf3468d5ec187ffffcaca8e61929a37448f215dafc1386a12c750a72fe53634 \
|
||||||
|
--hash=sha256:4e2c4809c14559aa7ef426f27fb35afbb38104c349a903bf8f3600456764bb38 \
|
||||||
|
--hash=sha256:4ed644d75aa94a2baf7ec3a96eaa160ea58c742eb9d27c6506053c5c40fc84ed \
|
||||||
|
--hash=sha256:4f6e0852a0283b1b1fd776eeb7b766a5f440b3e2bd31ab51af3b400585f3965c \
|
||||||
|
--hash=sha256:5066b244f576f91afc8ee3ba029a89f99d39c79b1853fe9d39bea9f0afbec148 \
|
||||||
|
--hash=sha256:5086f9975abb1ab531ee6afca1761e4b59a19b446f3f6522ed776963228cfe5a \
|
||||||
|
--hash=sha256:50b5bedc9ed8a94fc8857a42ef4f84a81ea88f8d4f05dc8705fb23ee6d8dcca7 \
|
||||||
|
--hash=sha256:52704c5d36eb6dda8866493decd61111fff86244c9b1ad225ca01b9e91e5970f \
|
||||||
|
--hash=sha256:55ffd6ce583d97dc71dc92e930324c8c0d25aea7e3ade6ae54ef77cedb096811 \
|
||||||
|
--hash=sha256:569d65055d367e3dcdf30c3f41119467b73d9ee9faf332bdf40402644f5ac08e \
|
||||||
|
--hash=sha256:57f9947a7e57a081c1e3e0a2dd0d2dcf290a4531450e6f611e30084c222a7295 \
|
||||||
|
--hash=sha256:5989cb26b2e1efc6a42216a9f6b5ee495ce5ace2e5b352a9af489976b32d1ee2 \
|
||||||
|
--hash=sha256:5c22873ad1f0532ba40fa1727f3c0fc1bbbaab6d373d4cbe3f0dc74b2e2521c7 \
|
||||||
|
--hash=sha256:5e8b3d0b18fd623afa12ecb2ce8d8becef69f9b5440c6330c7972200e0bb84b0 \
|
||||||
|
--hash=sha256:61631e08084be9e21a8967ec3139c7616ed7c5e9368e05c86d1b39562c8a57b6 \
|
||||||
|
--hash=sha256:64511c54db4e4987aef4c41923235927428729e8174c5dba488429be70a998ed \
|
||||||
|
--hash=sha256:6669c1bf34080161ce49c589cc512ef24d4c704ac9d2b2d3667f519c60418378 \
|
||||||
|
--hash=sha256:672d207103e6b16ca098611b0f9efad6bc00afd47c03d6ef62186495ca677dc0 \
|
||||||
|
--hash=sha256:6768d67d1bce64270e0fdc2e69309d68b9b18ae56ddf6c711d168e9d051c2cac \
|
||||||
|
--hash=sha256:6a45c3d514f2436064db00d7fc8778d888f0236ebfed649b53d13a59e69ad51b \
|
||||||
|
--hash=sha256:6bd9e1788e15bfcf6a9082de42e30387e7b85d211ab21e57a939bb8cfaaf8d96 \
|
||||||
|
--hash=sha256:6d2a9efe686f9de00d0d1ea32a4a5a86d558a2277501bd78d964214eab625e59 \
|
||||||
|
--hash=sha256:6da83a088f8ef93b2d483a8232a4dbf4d69d3d8496b568a03c56becac43e1808 \
|
||||||
|
--hash=sha256:7018d4af1cd272e847aa5917983ab5e83e4f6579f9dbfecd4a79c0ca80b144c2 \
|
||||||
|
--hash=sha256:71f88e749ea29f67f21f3b36433c1dc54c7729ed2a6d9e2da2e0d9e0d7b224eb \
|
||||||
|
--hash=sha256:737c9c3981998eba27f11786f84fddcbabc74068b72a4a1f454ea02094b57b65 \
|
||||||
|
--hash=sha256:73e77980c7207854f00fc4e71fb1626868d5740ab4012623d55c7a99ad122a72 \
|
||||||
|
--hash=sha256:799c39bdf5e2f1292fedd3009f7b3c9e760f10b2420cb9638d56920840ff6db8 \
|
||||||
|
--hash=sha256:7a83aa6e4805df46fed18e989d3d16f86ef60cb50bbc8d9ce3a6be89165fbf6e \
|
||||||
|
--hash=sha256:7d3391b2188d18737cb2fa147028b1096236eaa7e156446c650a489fa2cadc91 \
|
||||||
|
--hash=sha256:7e1636da3d8dfc220b6dd10264db5f2b165e4888c4518594898fbe381049af8a \
|
||||||
|
--hash=sha256:805c8b84534fa10891890f0e4be39f3a99e94615d93e8836bf9fa1fdca2feeb2 \
|
||||||
|
--hash=sha256:811d02d5122171c1941357efd8f9bf4ffe907b7f0a1a4e729a880e4be3f46e3e \
|
||||||
|
--hash=sha256:8138eb83940ec7299024d92d4dee45f601b9e6c5ffde9d25f4e35e326203c707 \
|
||||||
|
--hash=sha256:83b3944fea42a8400edf92fd1770fb8d0d4f7de651353bd2d8525a92dba69a21 \
|
||||||
|
--hash=sha256:849dd2bb0e5e4ab2b71c7191726a4a8d5aa8a610daa584728cbee0b710ddc4ef \
|
||||||
|
--hash=sha256:8698d70a8081ee8c090dbb394768b5789a1da8b131b5499f89d071dd3cfaf6be \
|
||||||
|
--hash=sha256:8781a792a070cf2bd1b86d3aa943894115faaba6e88122a7bf32d62072742453 \
|
||||||
|
--hash=sha256:88d59b473bfb03259722600839af9bbd7fa13a2eb514beefeedb95997882f69a \
|
||||||
|
--hash=sha256:8909c2f1c6dd65e054ac4b573a91c8384d1492281e55d82d159d653f7a13adf6 \
|
||||||
|
--hash=sha256:8965520ac587c94a4ac48b729be3d8b8de00af39699b17585dfb599babe77977 \
|
||||||
|
--hash=sha256:8b5d563170ff8ba3181caa967c99a3c804d1dedb702c7cb93a6a7c32247da978 \
|
||||||
|
--hash=sha256:8e124f974786f831d6043728e38296969d3579db8896fe004682f5758e613581 \
|
||||||
|
--hash=sha256:8f0fac8b13d14bb06c68195f849371924ae53dd7b1c00fed24650f704383b692 \
|
||||||
|
--hash=sha256:9240187afb63d2f9ddc3e032c670356fe941f6e20662ea168a5dc3f1f317e1b3 \
|
||||||
|
--hash=sha256:925f929d6b59a8b3f8b8c6ac363cd0af7eecc81efb3071770b3c6717c450a369 \
|
||||||
|
--hash=sha256:9348cbb300d224fe3b89793262cb093504d4ae927004468463f745188a193e4a \
|
||||||
|
--hash=sha256:9388003072b95f2f1e3fd908604194d653ba21330d811961a78b7da1a77e9e36 \
|
||||||
|
--hash=sha256:9438a2648b2195980cb2dd8e53ed7b8df91319e2d0b70ae61a9e1d1bc8d3bec9 \
|
||||||
|
--hash=sha256:94e4c421742086aeee4c32a506eec8859d7634aad943f7e6aacf70f813478768 \
|
||||||
|
--hash=sha256:94f5407f7bc64fa6463906b896f9904beeeb7dd8dc116ee8e9056c8714ff9916 \
|
||||||
|
--hash=sha256:971a3bbb75d97ae4e2e8f7d4834236f86f85f0c85e04ab2e191db1123b04f80b \
|
||||||
|
--hash=sha256:9e227f3dbe6bde7491cf0a9965d00b88c6b1a4a95d11480ddf88bb96d397c19f \
|
||||||
|
--hash=sha256:9e25feb9e330b63edb0278a0acdf85e50d0cb0fbf49c3084abbe4e24ae195346 \
|
||||||
|
--hash=sha256:9f098115c247e11d138ab83a28fa0323c77015007ea2df73ba5fd714dfefd67c \
|
||||||
|
--hash=sha256:a18f38cafc329bac5e3c2b96c765b4c96d3d103421ed22ab7988c1e3fce27464 \
|
||||||
|
--hash=sha256:a4bbd2d87dd233b9fc5812160c3d0ffbe42edc22a26ce0469f58479ede633fe9 \
|
||||||
|
--hash=sha256:a5fcffb37e602b0b3c1638a97746b9b96125caa9bcf6fa41d337a9261de231ee \
|
||||||
|
--hash=sha256:a8e9f292fcda89b324f2f5c91d13f1424a153e40fc2756f38ee23b15835ff300 \
|
||||||
|
--hash=sha256:a9f54054101545a9a9cccefddf54316aa6e4491611fcbef9e91b3b6bebec04f6 \
|
||||||
|
--hash=sha256:aa2c838cc024642cc04c6854232f32b43e5e22833dd11119c1766c7873b8370d \
|
||||||
|
--hash=sha256:ac0c7c9f1609b0c4c114feb1d7a3409564c7fb77e360bed9e97e5d25dfeaf868 \
|
||||||
|
--hash=sha256:add96447a86d205ab616665d53b2950ee81083757f56e6ea833c8b2917646b46 \
|
||||||
|
--hash=sha256:ae9dcb8fbe244cb82f8a6458b455b927a03685e383d9bacf1ea5ce180b96dc97 \
|
||||||
|
--hash=sha256:b4a635a0487774f841cb1fb62e907e7195cc95bc761e053184b8acc3ceb20733 \
|
||||||
|
--hash=sha256:b4d12837e0203bbace818ff4a7461afdcd78bcd782351cea148139180d7bcffe \
|
||||||
|
--hash=sha256:b61687d0828e72bf5cda24a2690188f37170bd31c9359ac97e4e66569f120a16 \
|
||||||
|
--hash=sha256:b807e598953730f82e4eae3bd30f6a122cf6b31c398c6b504c0e04c13c170429 \
|
||||||
|
--hash=sha256:b8cd1f918b26fd7b1832ece557cc18f2d8747309ff8b3f0ef9d4250c5ad67a39 \
|
||||||
|
--hash=sha256:b91cc9d336957239ff200f30097e6fea2dc6d6fb3c81e853eaa09eac904fd894 \
|
||||||
|
--hash=sha256:bd3ce56ae2cbae3ba82b683bc425cd7e48d2ed8b10f3e818186b6f5646d9271c \
|
||||||
|
--hash=sha256:be6cb0c799abb0e2ba3e618e6d28ddddf7e485f6c2ce938dfa237daf3905072c \
|
||||||
|
--hash=sha256:befb4158af32106b9a93db8d6d1d1cbbd418c0d5aca0cabb7b1780abf0c89169 \
|
||||||
|
--hash=sha256:bf053da3c97a4bc5ecfbb218cdd2983febd91c617be8367d139882aa11e490aa \
|
||||||
|
--hash=sha256:c02e8f18bdedba082cef725942ac823b9b60656db07f7e265cb31618dfd00d77 \
|
||||||
|
--hash=sha256:c1bc67752d5f21013cfe430df4062441714eab79f65a6a05e01505957e9c35fe \
|
||||||
|
--hash=sha256:c61750fadcd119d0825bcb7d7d675dd264dcc89cc05292aab5be68ebdbb374ad \
|
||||||
|
--hash=sha256:c90d5b3d4e944e065a301d741b3c1d784f6bd1f503aa68b4967e32b2ba313d85 \
|
||||||
|
--hash=sha256:c9a7f43c0b202b334cc9184af09bb8f21d3a209e038efaf106936fb69e6b026e \
|
||||||
|
--hash=sha256:cb96e6e088d6cf71c1ea977510948320234824cf226e32f6f6e044f7a9c82b34 \
|
||||||
|
--hash=sha256:cf63c214fe879a65e69a386f915e36104fc84254ab141240f8854602d8e0be2a \
|
||||||
|
--hash=sha256:d1aca03ede943eb80ab3d63bb082c84b7aab85ea83bd0fd0c200260945fb49d9 \
|
||||||
|
--hash=sha256:d2e56fd3b00222722abfb3f5f0759ddbae4b90811b5ad4343c64030ad1bde70c \
|
||||||
|
--hash=sha256:d5f93ebbeb8032d47e349328ec8662d973d9b05a70b3c35df1f91fe419b84749 \
|
||||||
|
--hash=sha256:d882a373d8093c2941e01291b7ced96e9cbe4781da9a7751ca7e6c70385e5214 \
|
||||||
|
--hash=sha256:d920abdfa61279ba1a2ef9484aab07bf03331f8c08a10120fa332353d06e6932 \
|
||||||
|
--hash=sha256:da2af0d7aebfc2074080d72efa6ab8317c62481ef1f896f65d9999c1c01f4494 \
|
||||||
|
--hash=sha256:dd8ea6ebee7aedbf7c749fa80521d9ccf1ba473e0d1e14805caafbaad281c889 \
|
||||||
|
--hash=sha256:de8b364c423ef0a4bad9069657d617f9a5d2b2062457a89b1fa16ee199c399c1 \
|
||||||
|
--hash=sha256:df1ae86ff54725a01fa1a0510b914ca53a161b7050be74f6204e24aded5971d0 \
|
||||||
|
--hash=sha256:dff05cb7016dff1e9fd68f4122c127b65dfc59de5306cfb7ad92f956f230bee2 \
|
||||||
|
--hash=sha256:e1a622f13970d81f95d0c72f9dc090dce9085fccfa4c9f2174377ee32bd15786 \
|
||||||
|
--hash=sha256:e49fb0d1ce92cfa0cb198cc5b1b11cdf9d0638658e2a2db2687e39db7c87fc78 \
|
||||||
|
--hash=sha256:e5c802729725bd07e2bc3ab7b76dc7e0bbfc53129d8f1eb1c002c24cf774717e \
|
||||||
|
--hash=sha256:e841068dc0be4cb6dfb5c890eb88cbdcff2f4a332393c7ec94e8e618bd32c1a8 \
|
||||||
|
--hash=sha256:e916035e3e9930cbdfdd10abf48861340221857f45509565898e012263f7b289 \
|
||||||
|
--hash=sha256:eba154571c16e032112afac0dc2dfe9e63c2ceb7aedd07bb7eecf2ce26d4dd4c \
|
||||||
|
--hash=sha256:f03460ff076f70ab595bb45a0205ccea1971443575b6920c52e755dec2b3fbfe \
|
||||||
|
--hash=sha256:f0ec3b750b59375eab5b0fb2b9254810c00a3375be6d789899f1055a1d556237 \
|
||||||
|
--hash=sha256:f291bcf42ae98eb5107edb162c3c998b4a89648fd8e99ed4cbd12705292788cd \
|
||||||
|
--hash=sha256:f61efe1d2fe0de16158a5fe1d1cf3c14bdb6aecd54d8938fd26512c525c1f624 \
|
||||||
|
--hash=sha256:f68edfc67aabac33708941f26f22a7b8e9f81429bc0cf249fcf7d66b23af8d19 \
|
||||||
|
--hash=sha256:fa95848c929b6a75f6848d3c9793e59db365ee436776e57db835cdbfa79ba977 \
|
||||||
|
--hash=sha256:fd9f8797427910198f95bced71ddfed61130d7e349213bfb8466c9c99e2c46a8 \
|
||||||
|
--hash=sha256:fdb4ca07ab75ffadab4a8b135ad59cdbb3156b99310f3d565370da74a15d6bd3
|
||||||
|
# via
|
||||||
|
# flask
|
||||||
|
# jinja2
|
||||||
|
# werkzeug
|
||||||
|
packaging==26.3 \
|
||||||
|
--hash=sha256:94edc256424af38762eb31306eed28beb9f0efc50a8837492c9d6fd6004aed79 \
|
||||||
|
--hash=sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c
|
||||||
|
# via gunicorn
|
||||||
|
werkzeug==3.1.9 \
|
||||||
|
--hash=sha256:55ca7c70a75689be937aa27f8ff4b018f06ff4838fc73045560bf0f5a1291060 \
|
||||||
|
--hash=sha256:6392e50c78460ba618e5b21f08a71f59c99ce99cdc6cf6e3dd7e6ccca8754fab
|
||||||
|
# via flask
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import unittest
|
||||||
|
from app import app, total_price
|
||||||
|
|
||||||
|
|
||||||
|
class PricingTests(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.client = app.test_client()
|
||||||
|
|
||||||
|
def test_price(self):
|
||||||
|
self.assertEqual(total_price(3), 30)
|
||||||
|
response = self.client.get("/price?quantity=3")
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
self.assertEqual(response.json["total"], 30)
|
||||||
|
|
||||||
|
def test_invalid_quantity(self):
|
||||||
|
for value in ["0", "-1", "1001", "abc", "1.5"]:
|
||||||
|
self.assertEqual(self.client.get("/price?quantity=" + value).status_code, 400)
|
||||||
|
|
||||||
|
def test_release_identity(self):
|
||||||
|
self.assertEqual(self.client.get("/").json["version"], "v1")
|
||||||
|
self.assertEqual(self.client.get("/health").json["status"], "ok")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# Release records
|
||||||
|
|
||||||
|
One file per environment and release, e.g. `v1-staging.yml`, `v1-production.yml`.
|
||||||
|
Each holds metadata only (image digest, full source commit, expected version and
|
||||||
|
total, public URL, proxy network) - never credentials. Production uses the same
|
||||||
|
image digest as staging. Keep old records for rollback.
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# Copy to a release-specific file and replace EVERY placeholder.
|
||||||
|
target_env: staging
|
||||||
|
release_image: gitea.example.edu/team/pricing@sha256:REPLACE_DIGEST
|
||||||
|
expected_version: v1
|
||||||
|
expected_commit: REPLACE_FULL_GIT_COMMIT
|
||||||
|
expected_total: 30
|
||||||
|
public_url: https://staging.example.edu
|
||||||
|
proxy_network: REPLACE_EXISTING_PROXY_NETWORK
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# Security gate policy (defined before the assessed release)
|
||||||
|
|
||||||
|
**Tools:** Trivy (repository and image scanning, secret detection) and pip-audit
|
||||||
|
(Python dependency audit). Tool and vulnerability-database versions, scan time,
|
||||||
|
commands, reports and exit codes are recorded by `security/scan.sh` and archived
|
||||||
|
by Jenkins as `security-reports/**`.
|
||||||
|
|
||||||
|
**Blocking (the pipeline fails):**
|
||||||
|
- any detected secret;
|
||||||
|
- any known vulnerability reported by pip-audit for the locked dependencies;
|
||||||
|
- any HIGH or CRITICAL vulnerability in the repository or the built image that
|
||||||
|
has a fix available;
|
||||||
|
- any scanner error, missing tool, or failure to obtain the vulnerability
|
||||||
|
database. A failed scan is not a clean scan.
|
||||||
|
|
||||||
|
**Not blocking, but recorded:** HIGH or CRITICAL vulnerabilities with no fix yet
|
||||||
|
(typically operating-system packages in the base image). They are listed in the
|
||||||
|
full image report and counted in `image-summary.txt` on every run. The accepted
|
||||||
|
set is recorded in the manual as a time-limited exception with a review date.
|
||||||
|
Nothing is silently ignored.
|
||||||
|
|
||||||
|
**Fixes:** update the dependency lockfile or the pinned base-image digest,
|
||||||
|
rebuild, and rescan. Dependency or base-image updates always trigger a rescan.
|
||||||
|
|
||||||
|
**False positives and exceptions:** a finding that has a fix but is accepted for
|
||||||
|
a stated reason goes in `security/.trivyignore` with an `exp:` date and a
|
||||||
|
comment naming the reason and the approver. Expired entries stop applying.
|
||||||
|
|
||||||
|
**Test fixture:** one blocked run uses a synthetic, scanner-supported fixture
|
||||||
|
(never a live secret) on a branch; it is removed and the run repeated.
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Security gates for the delivery pipeline (manual Chapter 11, "Apply Proportionate
|
||||||
|
# Security Gates"). Usage:
|
||||||
|
# security/scan.sh source dependency audit + secret/vulnerability scan of the repo
|
||||||
|
# security/scan.sh image <image-ref> vulnerability scan of the built image
|
||||||
|
#
|
||||||
|
# Policy (full text in security/POLICY.md):
|
||||||
|
# * Detected secrets always block.
|
||||||
|
# * Dependency vulnerabilities reported by pip-audit always block.
|
||||||
|
# * HIGH/CRITICAL vulnerabilities that HAVE A FIX AVAILABLE block (--ignore-unfixed).
|
||||||
|
# * HIGH/CRITICAL vulnerabilities with no fix yet do not block, but are never
|
||||||
|
# hidden: an informational full report and a summary are saved and archived,
|
||||||
|
# and the accepted set is recorded as a dated exception in the manual.
|
||||||
|
# * A time-limited exception for a fixable finding goes in security/.trivyignore
|
||||||
|
# (with an exp: date and a reason).
|
||||||
|
# FAIL CLOSED: any scanner error, missing tool, or vulnerability-database
|
||||||
|
# download failure ends the script with a non-zero status. A failed scan is not
|
||||||
|
# a clean scan. Nothing here ends in "|| true".
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
MODE="${1:-}"
|
||||||
|
REPORT_DIR="${REPORT_DIR:-security-reports}"
|
||||||
|
SEVERITY="HIGH,CRITICAL"
|
||||||
|
IGNOREFILE="security/.trivyignore"
|
||||||
|
export PATH="/opt/tools-venv/bin:$PATH"
|
||||||
|
|
||||||
|
now() { date -u +%Y-%m-%dT%H:%M:%SZ; }
|
||||||
|
mkdir -p "$REPORT_DIR"
|
||||||
|
|
||||||
|
ignore_args=()
|
||||||
|
if [ -f "$IGNOREFILE" ]; then ignore_args=(--ignorefile "$IGNOREFILE"); fi
|
||||||
|
|
||||||
|
record_versions() {
|
||||||
|
{
|
||||||
|
echo "scan_time_utc: $(now)"
|
||||||
|
echo "--- trivy (tool and vulnerability database versions) ---"
|
||||||
|
trivy --version
|
||||||
|
echo "--- pip-audit ---"
|
||||||
|
pip-audit --version
|
||||||
|
} | tee "$REPORT_DIR/tool-versions.txt"
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$MODE" in
|
||||||
|
source)
|
||||||
|
record_versions
|
||||||
|
echo "== pip-audit: dependency audit of pricing/requirements.txt =="
|
||||||
|
# --strict: a dependency that cannot be audited is a failure, not a pass.
|
||||||
|
pip-audit -r pricing/requirements.txt --strict --progress-spinner off \
|
||||||
|
2>&1 | tee "$REPORT_DIR/pip-audit.txt"
|
||||||
|
echo "RESULT pip-audit: exit=0 at $(now)"
|
||||||
|
|
||||||
|
echo "== trivy fs: secrets and $SEVERITY vulnerabilities in the repository =="
|
||||||
|
trivy fs --scanners vuln,secret --severity "$SEVERITY" --exit-code 1 \
|
||||||
|
--ignore-unfixed --no-progress --skip-dirs .git,.venv "${ignore_args[@]}" . \
|
||||||
|
2>&1 | tee "$REPORT_DIR/trivy-source.txt"
|
||||||
|
echo "RESULT trivy-fs: exit=0 at $(now)"
|
||||||
|
;;
|
||||||
|
image)
|
||||||
|
REF="${2:?usage: scan.sh image <image-ref>}"
|
||||||
|
record_versions
|
||||||
|
echo "== trivy image: fixable $SEVERITY vulnerabilities in $REF (blocking) =="
|
||||||
|
trivy image --severity "$SEVERITY" --exit-code 1 --ignore-unfixed --no-progress \
|
||||||
|
"${ignore_args[@]}" "$REF" \
|
||||||
|
2>&1 | tee "$REPORT_DIR/trivy-image.txt"
|
||||||
|
echo "RESULT trivy-image (fixable findings): exit=0 at $(now)"
|
||||||
|
|
||||||
|
echo "== trivy image: full informational report (does not gate; errors still fail) =="
|
||||||
|
# --exit-code 0 means findings alone do not fail this run; a scanner or
|
||||||
|
# database error still does. This keeps unfixed findings visible, not hidden.
|
||||||
|
trivy image --severity "$SEVERITY" --exit-code 0 --no-progress \
|
||||||
|
--format json -o "$REPORT_DIR/trivy-image-full.json" "$REF"
|
||||||
|
python3 - "$REPORT_DIR/trivy-image-full.json" <<'PY' | tee "$REPORT_DIR/image-summary.txt"
|
||||||
|
import json, sys, collections
|
||||||
|
d = json.load(open(sys.argv[1]))
|
||||||
|
c = collections.Counter()
|
||||||
|
for r in d.get("Results", []):
|
||||||
|
for v in r.get("Vulnerabilities") or []:
|
||||||
|
c[(v["Severity"], "fix available" if v.get("FixedVersion") else "no fix yet")] += 1
|
||||||
|
print("image findings at HIGH/CRITICAL (all, including unfixed):")
|
||||||
|
for k, n in sorted(c.items()):
|
||||||
|
print(" %-9s %-14s %d" % (k[0], k[1], n))
|
||||||
|
print(" total", sum(c.values()))
|
||||||
|
PY
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "usage: security/scan.sh source | image <image-ref>" >&2
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||