Compare commits
4 Commits
9cba668088
...
v1.6.0
| Author | SHA1 | Date | |
|---|---|---|---|
| f92d92355a | |||
| 364171ebca | |||
| 2be1150eec | |||
| 1434f75112 |
@@ -9,6 +9,12 @@ on:
|
|||||||
dockerfile_path:
|
dockerfile_path:
|
||||||
type: string
|
type: string
|
||||||
default: "."
|
default: "."
|
||||||
|
run_image_scan:
|
||||||
|
type: boolean
|
||||||
|
default: true
|
||||||
|
scan_severity:
|
||||||
|
type: string
|
||||||
|
default: "HIGH,CRITICAL"
|
||||||
secrets:
|
secrets:
|
||||||
REGISTRY_USERNAME: { required: true }
|
REGISTRY_USERNAME: { required: true }
|
||||||
REGISTRY_PASSWORD: { required: true }
|
REGISTRY_PASSWORD: { required: true }
|
||||||
@@ -74,6 +80,38 @@ jobs:
|
|||||||
docker tag "${FULL_IMAGE}:${SHA_SHORT}" "${FULL_IMAGE}:${MAJOR}"
|
docker tag "${FULL_IMAGE}:${SHA_SHORT}" "${FULL_IMAGE}:${MAJOR}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Image Vulnerability Scan
|
||||||
|
if: ${{ inputs.run_image_scan }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Fallback for runner images without Trivy baked in. Pinned version +
|
||||||
|
# checksum, never "latest": Trivy releases were compromised in the
|
||||||
|
# March 2026 supply-chain incident (malicious v0.69.4). Keep in sync
|
||||||
|
# with the ARGs in the PipelineImage Dockerfiles.
|
||||||
|
TRIVY_VERSION=0.71.0
|
||||||
|
TRIVY_SHA256=30a3d22b23f88c233f1658f562fb477cae3b3e8b4761109d515b7698daf85814
|
||||||
|
if ! command -v trivy >/dev/null 2>&1; then
|
||||||
|
echo "=== Trivy not in runner image, installing v${TRIVY_VERSION} ==="
|
||||||
|
curl -sSfLO "https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz"
|
||||||
|
echo "${TRIVY_SHA256} trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz" | sha256sum -c -
|
||||||
|
tar -xzf "trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz" -C /usr/local/bin trivy
|
||||||
|
rm "trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz"
|
||||||
|
fi
|
||||||
|
trivy --version
|
||||||
|
|
||||||
|
SHA_SHORT="$(git rev-parse --short HEAD)"
|
||||||
|
FULL_IMAGE="${{ secrets.DOCKER_REGISTRY }}/${{ inputs.image_name }}"
|
||||||
|
|
||||||
|
echo "=== Scanning ${FULL_IMAGE}:${SHA_SHORT} (fail on fixable ${{ inputs.scan_severity }}) ==="
|
||||||
|
trivy image \
|
||||||
|
--exit-code 1 \
|
||||||
|
--severity "${{ inputs.scan_severity }}" \
|
||||||
|
--ignore-unfixed \
|
||||||
|
--scanners vuln,secret \
|
||||||
|
"${FULL_IMAGE}:${SHA_SHORT}"
|
||||||
|
|
||||||
- name: Push image
|
- name: Push image
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
name: Reusable Image Security Checks
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
image_name:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
image_tag:
|
||||||
|
type: string
|
||||||
|
default: "latest"
|
||||||
|
scan_severity:
|
||||||
|
type: string
|
||||||
|
default: "HIGH,CRITICAL"
|
||||||
|
secrets:
|
||||||
|
REGISTRY_USERNAME: { required: true }
|
||||||
|
REGISTRY_PASSWORD: { required: true }
|
||||||
|
DOCKER_REGISTRY: { required: true }
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
scan:
|
||||||
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: gitea.tech-buddy.at/bitbuddydev/gitea_runner_python314:dev-bda315b82bb23d83065b77d91fedf0e20d9accf1
|
||||||
|
credentials:
|
||||||
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Docker Login
|
||||||
|
run: |
|
||||||
|
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login "${{ secrets.DOCKER_REGISTRY }}" -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin
|
||||||
|
|
||||||
|
- name: Pull Image
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
FULL_IMAGE="${{ secrets.DOCKER_REGISTRY }}/${{ inputs.image_name }}:${{ inputs.image_tag }}"
|
||||||
|
echo "=== Pulling ${FULL_IMAGE} ==="
|
||||||
|
docker pull "${FULL_IMAGE}"
|
||||||
|
|
||||||
|
- name: Image Vulnerability Scan
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Fallback for runner images without Trivy baked in. Pinned version +
|
||||||
|
# checksum, never "latest": Trivy releases were compromised in the
|
||||||
|
# March 2026 supply-chain incident (malicious v0.69.4). Keep in sync
|
||||||
|
# with the ARGs in the PipelineImage Dockerfiles.
|
||||||
|
TRIVY_VERSION=0.71.0
|
||||||
|
TRIVY_SHA256=30a3d22b23f88c233f1658f562fb477cae3b3e8b4761109d515b7698daf85814
|
||||||
|
if ! command -v trivy >/dev/null 2>&1; then
|
||||||
|
echo "=== Trivy not in runner image, installing v${TRIVY_VERSION} ==="
|
||||||
|
curl -sSfLO "https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz"
|
||||||
|
echo "${TRIVY_SHA256} trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz" | sha256sum -c -
|
||||||
|
tar -xzf "trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz" -C /usr/local/bin trivy
|
||||||
|
rm "trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz"
|
||||||
|
fi
|
||||||
|
trivy --version
|
||||||
|
|
||||||
|
FULL_IMAGE="${{ secrets.DOCKER_REGISTRY }}/${{ inputs.image_name }}:${{ inputs.image_tag }}"
|
||||||
|
|
||||||
|
echo "=== Scanning ${FULL_IMAGE} (fail on fixable ${{ inputs.scan_severity }}) ==="
|
||||||
|
trivy image \
|
||||||
|
--exit-code 1 \
|
||||||
|
--severity "${{ inputs.scan_severity }}" \
|
||||||
|
--ignore-unfixed \
|
||||||
|
--scanners vuln,secret \
|
||||||
|
"${FULL_IMAGE}"
|
||||||
@@ -147,7 +147,11 @@ jobs:
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
COMMIT_SUBJECT="$(git log -1 --pretty=%s 2>/dev/null || echo 'Commit info unavailable')"
|
COMMIT_SUBJECT="$(curl -fsS \
|
||||||
|
-H "Authorization: Bearer ${{ secrets.API_GITEA_TOKEN }}" \
|
||||||
|
"${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/git/commits/${{ gitea.sha }}" \
|
||||||
|
| python3 -c "import json,sys; d=json.load(sys.stdin); print(d.get('RepoCommit',{}).get('message','').split('\n')[0])" \
|
||||||
|
2>/dev/null || echo 'Commit info unavailable')"
|
||||||
RUN_URL="${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_number }}"
|
RUN_URL="${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_number }}"
|
||||||
|
|
||||||
cat <<EOF >/tmp/ntfy-payload.json
|
cat <<EOF >/tmp/ntfy-payload.json
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ on:
|
|||||||
default: "coverage run -m pytest"
|
default: "coverage run -m pytest"
|
||||||
coverage_fail_under:
|
coverage_fail_under:
|
||||||
type: string
|
type: string
|
||||||
default: "60"
|
default: "80"
|
||||||
run_security_scan:
|
run_security_scan:
|
||||||
type: boolean
|
type: boolean
|
||||||
default: true
|
default: true
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
name: Reusable Python Security Checks
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
install_command:
|
||||||
|
type: string
|
||||||
|
default: 'python -m pip install "bandit[toml]"'
|
||||||
|
security_command:
|
||||||
|
type: string
|
||||||
|
default: "python -m bandit -r app -c pyproject.toml"
|
||||||
|
working_directory:
|
||||||
|
type: string
|
||||||
|
default: "."
|
||||||
|
secrets:
|
||||||
|
REGISTRY_USERNAME: { required: true }
|
||||||
|
REGISTRY_PASSWORD: { required: true }
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: gitea.tech-buddy.at/bitbuddydev/gitea_runner_python314:dev-bda315b82bb23d83065b77d91fedf0e20d9accf1
|
||||||
|
credentials:
|
||||||
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install security tools
|
||||||
|
working-directory: ${{ inputs.working_directory }}
|
||||||
|
run: ${{ inputs.install_command }}
|
||||||
|
|
||||||
|
- name: Run security scan
|
||||||
|
working-directory: ${{ inputs.working_directory }}
|
||||||
|
run: ${{ inputs.security_command }}
|
||||||
Reference in New Issue
Block a user