diff --git a/.github/workflows/ast-grep.yml b/.github/workflows/ast-grep.yml index 056687e..cc8c605 100644 --- a/.github/workflows/ast-grep.yml +++ b/.github/workflows/ast-grep.yml @@ -35,6 +35,15 @@ jobs: runs-on: ubuntu-24.04 timeout-minutes: 10 steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: block + allowed-endpoints: > + api.github.com:443 + github.com:443 + objects.githubusercontent.com:443 + release-assets.githubusercontent.com:443 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false diff --git a/.github/workflows/changed-paths.yml b/.github/workflows/changed-paths.yml index 605d6dd..777e636 100644 --- a/.github/workflows/changed-paths.yml +++ b/.github/workflows/changed-paths.yml @@ -45,6 +45,10 @@ jobs: matched: ${{ steps.match.outputs.matched }} reason: ${{ steps.match.outputs.reason }} steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit # Two commits deep for the merge commit's first parent; trees only, no file contents. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index d6c58e2..11db040 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -110,6 +110,10 @@ jobs: runs-on: ${{ matrix.platform.runner }} timeout-minutes: ${{ inputs.timeout-minutes }} steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit - name: Check out uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -252,6 +256,10 @@ jobs: runs-on: ubuntu-24.04 timeout-minutes: 15 steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit - name: Download digests uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: diff --git a/.github/workflows/flatpak-oci.yml b/.github/workflows/flatpak-oci.yml index 05e72e9..1bd8a16 100644 --- a/.github/workflows/flatpak-oci.yml +++ b/.github/workflows/flatpak-oci.yml @@ -34,6 +34,10 @@ jobs: - { arch: x86_64, runner: ubuntu-24.04 } - { arch: aarch64, runner: ubuntu-24.04-arm } steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml index 3cf787e..fe308b1 100644 --- a/.github/workflows/freebsd.yml +++ b/.github/workflows/freebsd.yml @@ -71,6 +71,10 @@ jobs: CARGO_INCREMENTAL: 0 CARGO_BUILD_JOBS: 4 steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Check out craft-fonts if: inputs.craft-fonts-ref != '' @@ -102,6 +106,19 @@ jobs: prepare: | # Keep rustup/proxies outside the Cargo data cache. unset CARGO_HOME CARGO_TARGET_DIR + # A large test crate's rustc (photocraft-ui-egui's lib tests) was SIGKILLed when the + # 12 GB guest ran out of memory late in a run: the image's root is ZFS with no ARC + # limit, so the ARC kept the target dir's pages. Cap it. (No swap file: swap on a + # ZFS-backed file can hang FreeBSD under memory pressure; the image has a 1 GB swap + # partition.) Print disk, swap and memory so the next OOM is easy to diagnose. + if [ "$(uname -s)" = FreeBSD ]; then + if sysctl -n vfs.zfs.arc_max >/dev/null 2>&1; then + sysctl vfs.zfs.arc_max=2147483648 || echo "::warning::could not cap the ZFS ARC" + fi + df -h / /var/tmp || true + swapctl -l || true + sysctl -n hw.physmem || true + fi if [ "${{ matrix.arch }}" = aarch64 ]; then # The host compiler and the aarch64 standard library come from the amd64 and # aarch64 lang/rust packages, which must be the same build. "latest" can build diff --git a/.github/workflows/gate.yml b/.github/workflows/gate.yml index 8f508b8..eded0bd 100644 --- a/.github/workflows/gate.yml +++ b/.github/workflows/gate.yml @@ -118,6 +118,10 @@ jobs: CARGO_NET_RETRY: 10 RUST_BACKTRACE: 1 steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false diff --git a/.github/workflows/git-sources.yml b/.github/workflows/git-sources.yml index 4b43ad9..1a51ee8 100644 --- a/.github/workflows/git-sources.yml +++ b/.github/workflows/git-sources.yml @@ -27,6 +27,10 @@ jobs: runs-on: ubuntu-24.04 timeout-minutes: 5 steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false diff --git a/.github/workflows/house-rules.yml b/.github/workflows/house-rules.yml index 667f275..b9f9796 100644 --- a/.github/workflows/house-rules.yml +++ b/.github/workflows/house-rules.yml @@ -30,6 +30,13 @@ jobs: runs-on: ubuntu-24.04 timeout-minutes: 10 steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: block + allowed-endpoints: > + api.github.com:443 + github.com:443 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 83a54c6..92d219a 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -18,6 +18,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 15 steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: DeterminateSystems/nix-installer-action@3138316df39ed29be04236d7ffc686fa525866aa # v23 - name: Check flake evaluation diff --git a/.github/workflows/packaging-lint.yml b/.github/workflows/packaging-lint.yml index e12e606..09e3ccb 100644 --- a/.github/workflows/packaging-lint.yml +++ b/.github/workflows/packaging-lint.yml @@ -19,6 +19,28 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 15 steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: block + allowed-endpoints: > + *.github.com:443 + *.githubusercontent.com:443 + *.microsoft.com:443 + *.ubuntu.com:80 + *.ubuntu.com:443 + api.github.com:443 + archive.ubuntu.com:80 + archive.ubuntu.com:443 + azure.archive.ubuntu.com:80 + azure.archive.ubuntu.com:443 + github.com:443 + objects.githubusercontent.com:443 + packages.microsoft.com:443 + release-assets.githubusercontent.com:443 + security.ubuntu.com:80 + security.ubuntu.com:443 + security.ubuntu.com:443 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Run packaging lint uses: storytold/craft-common-actions/actions/packaging-lint@main diff --git a/.github/workflows/refresh-contributors.yml b/.github/workflows/refresh-contributors.yml index 08e3752..8a92483 100644 --- a/.github/workflows/refresh-contributors.yml +++ b/.github/workflows/refresh-contributors.yml @@ -18,6 +18,10 @@ jobs: outputs: artifact-name: contributor-snapshot-${{ github.run_id }}-${{ github.run_attempt }} steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3c4266d..fcaf633 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -148,6 +148,10 @@ jobs: permissions: contents: read steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Git dependencies come from storytold run: | @@ -191,6 +195,10 @@ jobs: date: ${{ steps.v.outputs.date }} prerelease: ${{ steps.v.outputs.prerelease }} steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - id: v name: Resolve version @@ -214,6 +222,10 @@ jobs: BUILD_SHA: ${{ github.sha }} INPUT_VERSION: ${{ inputs.version }} steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit # A signed job reads only the secrets the caller lists in its `secrets:` block; values come # from the repo's `release` environment. An unlisted name is empty, and the app's packaging # would then warn and ship unsigned, so on the release branch fail here instead. @@ -334,6 +346,10 @@ jobs: BUILD_SHA: ${{ github.sha }} INPUT_VERSION: ${{ inputs.version }} steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit # See the macOS job: unlisted secrets are empty, and the build would ship unsigned. # Signing needs either the PFX pair or all six Azure Trusted Signing values. - name: Require signing secrets on the release branch @@ -439,6 +455,10 @@ jobs: BUILD_SHA: ${{ github.sha }} INPUT_VERSION: ${{ inputs.version }} steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Load refreshed contributor credits if: inputs.contributors-artifact != '' @@ -532,6 +552,10 @@ jobs: BUILD_DATE: ${{ needs.version.outputs.date }} BUILD_SHA: ${{ github.sha }} steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Export the app's build variables id: app-env @@ -649,6 +673,10 @@ jobs: matrix: arch: [x86_64, aarch64] steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: @@ -708,6 +736,10 @@ jobs: BUILD_SHA: ${{ github.sha }} INPUT_VERSION: ${{ inputs.version }} steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit - name: Check the FreeBSD architecture env: ARCH: ${{ matrix.arch }} @@ -937,6 +969,10 @@ jobs: BUILD_SHA: ${{ github.sha }} INPUT_VERSION: ${{ inputs.version }} steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Load refreshed contributor credits if: inputs.contributors-artifact != '' @@ -1009,6 +1045,10 @@ jobs: BUILD_SHA: ${{ github.sha }} INPUT_VERSION: ${{ inputs.version }} steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Load refreshed contributor credits if: inputs.contributors-artifact != '' @@ -1103,6 +1143,10 @@ jobs: BUILD_DATE: ${{ needs.version.outputs.date }} BUILD_SHA: ${{ github.sha }} steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Load refreshed contributor credits if: inputs.contributors-artifact != '' @@ -1154,6 +1198,10 @@ jobs: permissions: contents: write steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit - uses: storytold/craft-common-actions/actions/draft-release@main with: version: ${{ needs.version.outputs.version }} diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index b7efd43..ea75519 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -66,6 +66,46 @@ jobs: outputs: matrix: ${{ steps.matrix.outputs.matrix }} steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: block + allowed-endpoints: > + *.amazonaws.com:443 + *.crates.io:443 + *.s3.amazonaws.com:443 + *.s3.eu-central-1.amazonaws.com:443 + *.github.com:443 + *.githubusercontent.com:443 + *.microsoft.com:443 + *.openpgp.org:443 + *.pythonhosted.org:443 + *.sonarcloud.io:443 + *.sonarsource.com:443 + *.ubuntu.com:80 + *.ubuntu.com:443 + api.github.com:443 + archive.ubuntu.com:80 + archive.ubuntu.com:443 + azure.archive.ubuntu.com:80 + azure.archive.ubuntu.com:443 + binaries.sonarsource.com:443 + crates.io:443 + files.pythonhosted.org:443 + github.com:443 + index.crates.io:443 + keys.openpgp.org:443 + keyserver.ubuntu.com:443 + objects.githubusercontent.com:443 + packages.microsoft.com:443 + pypi.org:443 + release-assets.githubusercontent.com:443 + scanner.sonarcloud.io:443 + security.ubuntu.com:80 + security.ubuntu.com:443 + sonarcloud.io:443 + static.crates.io:443 + static.rust-lang.org:443 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false @@ -97,6 +137,46 @@ jobs: runs-on: ubuntu-latest timeout-minutes: ${{ inputs.timeout-minutes }} steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: block + allowed-endpoints: > + *.amazonaws.com:443 + *.crates.io:443 + *.s3.amazonaws.com:443 + *.s3.eu-central-1.amazonaws.com:443 + *.github.com:443 + *.githubusercontent.com:443 + *.microsoft.com:443 + *.openpgp.org:443 + *.pythonhosted.org:443 + *.sonarcloud.io:443 + *.sonarsource.com:443 + *.ubuntu.com:80 + *.ubuntu.com:443 + api.github.com:443 + archive.ubuntu.com:80 + archive.ubuntu.com:443 + azure.archive.ubuntu.com:80 + azure.archive.ubuntu.com:443 + binaries.sonarsource.com:443 + crates.io:443 + files.pythonhosted.org:443 + github.com:443 + index.crates.io:443 + keys.openpgp.org:443 + keyserver.ubuntu.com:443 + objects.githubusercontent.com:443 + packages.microsoft.com:443 + pypi.org:443 + release-assets.githubusercontent.com:443 + scanner.sonarcloud.io:443 + security.ubuntu.com:80 + security.ubuntu.com:443 + sonarcloud.io:443 + static.crates.io:443 + static.rust-lang.org:443 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false @@ -168,6 +248,46 @@ jobs: fail-fast: false matrix: ${{ fromJSON(needs.plan.outputs.matrix) }} steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: block + allowed-endpoints: > + *.amazonaws.com:443 + *.crates.io:443 + *.s3.amazonaws.com:443 + *.s3.eu-central-1.amazonaws.com:443 + *.github.com:443 + *.githubusercontent.com:443 + *.microsoft.com:443 + *.openpgp.org:443 + *.pythonhosted.org:443 + *.sonarcloud.io:443 + *.sonarsource.com:443 + *.ubuntu.com:80 + *.ubuntu.com:443 + api.github.com:443 + archive.ubuntu.com:80 + archive.ubuntu.com:443 + azure.archive.ubuntu.com:80 + azure.archive.ubuntu.com:443 + binaries.sonarsource.com:443 + crates.io:443 + files.pythonhosted.org:443 + github.com:443 + index.crates.io:443 + keys.openpgp.org:443 + keyserver.ubuntu.com:443 + objects.githubusercontent.com:443 + packages.microsoft.com:443 + pypi.org:443 + release-assets.githubusercontent.com:443 + scanner.sonarcloud.io:443 + security.ubuntu.com:80 + security.ubuntu.com:443 + sonarcloud.io:443 + static.crates.io:443 + static.rust-lang.org:443 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false @@ -239,6 +359,46 @@ jobs: runs-on: ubuntu-latest timeout-minutes: ${{ inputs.timeout-minutes }} steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: block + allowed-endpoints: > + *.amazonaws.com:443 + *.crates.io:443 + *.s3.amazonaws.com:443 + *.s3.eu-central-1.amazonaws.com:443 + *.github.com:443 + *.githubusercontent.com:443 + *.microsoft.com:443 + *.openpgp.org:443 + *.pythonhosted.org:443 + *.sonarcloud.io:443 + *.sonarsource.com:443 + *.ubuntu.com:80 + *.ubuntu.com:443 + api.github.com:443 + archive.ubuntu.com:80 + archive.ubuntu.com:443 + azure.archive.ubuntu.com:80 + azure.archive.ubuntu.com:443 + binaries.sonarsource.com:443 + crates.io:443 + files.pythonhosted.org:443 + github.com:443 + index.crates.io:443 + keys.openpgp.org:443 + keyserver.ubuntu.com:443 + objects.githubusercontent.com:443 + packages.microsoft.com:443 + pypi.org:443 + release-assets.githubusercontent.com:443 + scanner.sonarcloud.io:443 + security.ubuntu.com:80 + security.ubuntu.com:443 + sonarcloud.io:443 + static.crates.io:443 + static.rust-lang.org:443 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 diff --git a/.github/workflows/supply-chain.yml b/.github/workflows/supply-chain.yml index 47b168c..64efa45 100644 --- a/.github/workflows/supply-chain.yml +++ b/.github/workflows/supply-chain.yml @@ -22,6 +22,10 @@ jobs: attestations: write artifact-metadata: write steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit - name: Download release artifacts uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: @@ -49,7 +53,7 @@ jobs: done < "$PWD/release-files" - name: Generate the CycloneDX SBOM - uses: anchore/sbom-action@66cbf4bc1f1c0d2edc94016e65bc221b6bb0ad6c # v0.24.3 + uses: step-security/sbom-action@28bb7d0d2869c9ab0e5571c93591747945819d39 # v0.24.2 with: path: subjects format: cyclonedx-json diff --git a/.github/workflows/test-ast-grep.yml b/.github/workflows/test-ast-grep.yml index 51be8f0..d3e078e 100644 --- a/.github/workflows/test-ast-grep.yml +++ b/.github/workflows/test-ast-grep.yml @@ -22,6 +22,15 @@ jobs: runs-on: ubuntu-24.04 timeout-minutes: 10 steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: block + allowed-endpoints: > + api.github.com:443 + github.com:443 + objects.githubusercontent.com:443 + release-assets.githubusercontent.com:443 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false diff --git a/.github/workflows/test-freebsd.yml b/.github/workflows/test-freebsd.yml index bb3ae05..fef7d55 100644 --- a/.github/workflows/test-freebsd.yml +++ b/.github/workflows/test-freebsd.yml @@ -23,6 +23,21 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: block + allowed-endpoints: > + api.github.com:443 + github.com:443 + archive.ubuntu.com:80 + azure.archive.ubuntu.com:80 + azure.archive.ubuntu.com:443 + packages.microsoft.com:443 + security.ubuntu.com:80 + archive.ubuntu.com:443 + azure.archive.ubuntu.com:443 + security.ubuntu.com:443 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Install YAML parser run: sudo apt-get update && sudo apt-get install -y --no-install-recommends python3-yaml tcsh rpm debsigs dpkg-dev skopeo diff --git a/.github/workflows/test-house-rules.yml b/.github/workflows/test-house-rules.yml index 5346617..1d3848b 100644 --- a/.github/workflows/test-house-rules.yml +++ b/.github/workflows/test-house-rules.yml @@ -24,6 +24,13 @@ jobs: runs-on: ubuntu-24.04 timeout-minutes: 10 steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: block + allowed-endpoints: > + api.github.com:443 + github.com:443 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false diff --git a/.github/workflows/test-install-apt-packages.yml b/.github/workflows/test-install-apt-packages.yml index ccf63b1..9eb289d 100644 --- a/.github/workflows/test-install-apt-packages.yml +++ b/.github/workflows/test-install-apt-packages.yml @@ -20,6 +20,21 @@ jobs: runs-on: ubuntu-24.04 timeout-minutes: 15 steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: block + allowed-endpoints: > + api.github.com:443 + github.com:443 + archive.ubuntu.com:80 + azure.archive.ubuntu.com:80 + azure.archive.ubuntu.com:443 + packages.microsoft.com:443 + security.ubuntu.com:80 + archive.ubuntu.com:443 + azure.archive.ubuntu.com:443 + security.ubuntu.com:443 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Install packages uses: ./actions/install-apt-packages diff --git a/.github/workflows/windows-arm64.yml b/.github/workflows/windows-arm64.yml index 4fadd6e..bc64022 100644 --- a/.github/workflows/windows-arm64.yml +++ b/.github/workflows/windows-arm64.yml @@ -55,6 +55,10 @@ jobs: runs-on: windows-latest timeout-minutes: 90 steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Check out craft-i18n uses: storytold/craft-common-actions/actions/checkout-craft-i18n@main @@ -91,6 +95,10 @@ jobs: runs-on: windows-11-arm timeout-minutes: 30 steps: + - name: Harden runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: name: ${{ inputs.app-name }}-windows-arm64 diff --git a/tests/test_changed_paths.py b/tests/test_changed_paths.py index d6b8094..3db20b8 100644 --- a/tests/test_changed_paths.py +++ b/tests/test_changed_paths.py @@ -62,7 +62,7 @@ class ChangedPathsTests(unittest.TestCase): self.assertNotIn('${{', MATCH['run']) def test_checkout_is_pinned_and_keeps_no_credentials(self): - checkout = STEPS[0] + checkout = next(s for s in STEPS if s.get('uses', '').startswith('actions/checkout@')) self.assertRegex(checkout['uses'], r'^actions/checkout@[0-9a-f]{40}$') self.assertEqual(checkout['with']['persist-credentials'], 'false') self.assertEqual(checkout['with']['fetch-depth'], '2') diff --git a/tests/test_check_git_sources.py b/tests/test_check_git_sources.py index 83189a7..5f69eb5 100644 --- a/tests/test_check_git_sources.py +++ b/tests/test_check_git_sources.py @@ -167,7 +167,8 @@ class CheckGitSourcesWiringTests(unittest.TestCase): job = WORKFLOW["jobs"]["git-sources"] self.assertEqual(WORKFLOW["permissions"], {"contents": "read"}) self.assertIn("timeout-minutes", job) - checkout, check = job["steps"] + steps = [s for s in job["steps"] if s.get("name") != "Harden runner"] + checkout, check = steps self.assertTrue(checkout["uses"].startswith("actions/checkout@")) self.assertEqual(checkout["with"]["persist-credentials"], "false") self.assertEqual(check["uses"], "storytold/craft-common-actions/actions/check-git-sources@main") diff --git a/tests/test_contributor_refresh.py b/tests/test_contributor_refresh.py index 870dbed..7845179 100644 --- a/tests/test_contributor_refresh.py +++ b/tests/test_contributor_refresh.py @@ -81,7 +81,7 @@ Path('contributors/contributors.json').write_text(json.dumps(credits)) """Keep refresh read-only and publish the validated file under its output name.""" workflow = load('refresh-contributors.yml') self.assertEqual(workflow['permissions'], {'contents': 'read', 'pull-requests': 'read'}) - steps = workflow['jobs']['refresh']['steps'] + steps = [s for s in workflow['jobs']['refresh']['steps'] if s.get('name') != 'Harden runner'] checkout = steps[0] self.assertEqual(checkout['with']['fetch-depth'], '0') self.assertEqual(checkout['with']['persist-credentials'], 'false') @@ -97,7 +97,7 @@ Path('contributors/contributors.json').write_text(json.dumps(credits)) def test_generator_is_shared_and_paired_with_the_workflow_revision(self): """Pinned and forked workflows select their own generator, with literal path arguments.""" - steps = load('refresh-contributors.yml')['jobs']['refresh']['steps'] + steps = [s for s in load('refresh-contributors.yml')['jobs']['refresh']['steps'] if s.get('name') != 'Harden runner'] self.assertEqual(steps[1]['uses'], '$/actions/refresh-contributors') action = shared_action()['runs']['steps'][0] self.assertEqual(action['env']['GENERATOR_PATH'], '${{ github.action_path }}/refresh_contributors.py') diff --git a/tests/test_freebsd.py b/tests/test_freebsd.py index 44b04ee..980df65 100644 --- a/tests/test_freebsd.py +++ b/tests/test_freebsd.py @@ -389,7 +389,7 @@ fi def test_release_workflow_rejects_unsupported_architectures_before_the_vm(self): release = yaml.load((ROOT / ".github/workflows/release.yml").read_text(), Loader=yaml.BaseLoader) steps = release["jobs"]["freebsd"]["steps"] - check = steps[0] + check = next(step for step in steps if step.get("name") == "Check the FreeBSD architecture") self.assertEqual(check["name"], "Check the FreeBSD architecture") self.assertEqual(check["env"]["ARCH"], "${{ matrix.arch }}") for arch, code in (("x86_64", 0), ("aarch64", 0), ("riscv64", 1), ("amd64", 1), ("", 1)): diff --git a/tests/test_house_rules.py b/tests/test_house_rules.py index 161b49c..fd87f8c 100644 --- a/tests/test_house_rules.py +++ b/tests/test_house_rules.py @@ -166,7 +166,8 @@ class HouseRulesWiringTests(unittest.TestCase): job = workflow["jobs"]["house-rules"] self.assertEqual(workflow["permissions"], {"contents": "read"}) self.assertIn("timeout-minutes", job) - app, source, check = job["steps"] + steps = [s for s in job["steps"] if s.get("name") != "Harden runner"] + app, source, check = steps self.assertTrue(app["uses"].startswith("actions/checkout@")) self.assertEqual(app["with"]["persist-credentials"], "false") self.assertEqual(source["with"]["repository"], "storytold/craft-contrib") diff --git a/tests/test_supply_chain.py b/tests/test_supply_chain.py index 1c53f5c..49b5ac4 100644 --- a/tests/test_supply_chain.py +++ b/tests/test_supply_chain.py @@ -50,8 +50,8 @@ class SupplyChainOptInTests(unittest.TestCase): self.assertEqual(permissions["contents"], "write") uses = [step["uses"] for step in job["steps"] if "uses" in step] self.assertTrue(any(item.startswith("actions/attest@") for item in uses)) - self.assertTrue(any(item.startswith("anchore/sbom-action@") for item in uses)) - sbom = next(step for step in job["steps"] if step.get("uses", "").startswith("anchore/sbom-action@")) + self.assertTrue(any(item.startswith(("anchore/sbom-action@", "step-security/sbom-action@")) for item in uses)) + sbom = next(step for step in job["steps"] if step.get("uses", "").startswith(("anchore/sbom-action@", "step-security/sbom-action@"))) self.assertEqual(sbom["with"]["upload-release-assets"], "false") self.assertEqual(sbom["with"]["format"], "cyclonedx-json") @@ -64,7 +64,7 @@ class SupplyChainOptInTests(unittest.TestCase): steps = self.supply["jobs"]["attest"]["steps"] collection = next(step for step in steps if step.get("name") == "Collect release files") for index, step in enumerate(steps): - if step.get("uses", "").startswith(("anchore/sbom-action@", "actions/attest@")): + if step.get("uses", "").startswith(("anchore/sbom-action@", "step-security/sbom-action@", "actions/attest@")): self.assertLess(steps.index(collection), index) self.assertNotIn("if", step) self.assertNotIn("continue-on-error", collection)