diff --git a/.github/workflows/check-docker-image-is-used.yml b/.github/workflows/check-docker-image-is-used.yml index ecbb012..60e7bde 100644 --- a/.github/workflows/check-docker-image-is-used.yml +++ b/.github/workflows/check-docker-image-is-used.yml @@ -4,10 +4,18 @@ pull_request: branches: [ main ] + permissions: + contents: read + jobs: check-docker-image-is-used: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@a5ad31d6a139d249332a2605b85202e8c0b78450 # v2.19.1 + with: + egress-policy: audit + + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Check action will use image run: yq -e '.runs.image=="docker://ghcr.io/contrast-security-oss/integration-verify:main"' action.yaml || { echo "::error file=action.yaml,line=$(yq '.runs.image|line' action.yaml),column=$(yq '.runs.image|column' action.yaml),endColumn=$(yq '(.runs.image|column)+(.runs.image|length)' action.yaml)::Action is not configured to use built Docker image" && exit 1; } diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index b16fd85..42407d9 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -12,6 +12,9 @@ env: REGISTRY: ghcr.io IMAGE_NAME: contrast-security-oss/integration-verify +permissions: + contents: read + jobs: build-and-push-image: runs-on: ubuntu-latest @@ -20,17 +23,22 @@ jobs: packages: write steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@a5ad31d6a139d249332a2605b85202e8c0b78450 # v2.19.1 + with: + egress-policy: audit + - name: Checkout repository - uses: actions/checkout@v6 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + uses: step-security/setup-qemu-action@109c6ed9f089be1a250c75fd6a534e30df44e030 # v4.0.0 - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v3 + uses: step-security/setup-buildx-action@f931205d68723ad9589fd2a7e2ece238bf9de341 # v4.0.0 - name: Log in to the Container registry - uses: docker/login-action@v3 + uses: step-security/docker-login-action@870af644803bf9f204aed474adbad2958fec048b # v4.1.0 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} @@ -38,7 +46,7 @@ jobs: - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@v5 + uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | @@ -48,7 +56,7 @@ jobs: type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }} - name: Build and push Docker image - uses: docker/build-push-action@v6 + uses: step-security/docker-build-push-action@846549baaf047e867d038826129a64d81df0f704 # v7.1.0 with: context: . platforms: linux/amd64, linux/arm64 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 419f11b..85ef0e1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,12 +19,20 @@ env: PRE_COMMIT_CACHE: ~/.cache/pre-commit # A workflow run is made up of one or more jobs that can run sequentially or in parallel +permissions: + contents: read + jobs: unit-tests: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 - - uses: actions/setup-python@v6 + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@a5ad31d6a139d249332a2605b85202e8c0b78450 # v2.19.1 + with: + egress-policy: audit + + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 with: python-version: ${{ env.DEFAULT_PYTHON }} cache: "pip" @@ -33,7 +41,7 @@ jobs: run: pip install -r requirements-dev.txt - name: Restore pre-commit environment from cache id: cache-precommit - uses: actions/cache@v5.0.2 + uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2 with: path: ${{ env.PRE_COMMIT_CACHE }} key: >- @@ -45,7 +53,7 @@ jobs: run: pre-commit run --hook-stage manual --all-files --show-diff-on-failure - name: Run unit-tests run: python -m pytest --cov --cov-config=tox.ini --cov-report=term --cov-report=html - - uses: actions/upload-artifact@v6 + - uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 with: name: test-coverage path: htmlcov diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8b6eb79..cfbe98f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,3 +35,7 @@ repos: rev: v1.1.406 hooks: - id: pyright + - repo: https://github.com/gitleaks/gitleaks + rev: v8.16.3 + hooks: + - id: gitleaks diff --git a/Dockerfile b/Dockerfile index e21a016..a1b3773 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/astral-sh/uv:python3.13-alpine +FROM ghcr.io/astral-sh/uv:python3.13-alpine@sha256:213ea9e877219e7bcb0f55070c9130c3fc84995475fca9eb8fb362916dc3f808 ENV VIRT_ENV=/opt/venv RUN uv venv $VIRT_ENV --python 3.13