Skip to content

armgit / Ix

Public Imported from GitHub
0

Understand any codebase instantly. System intelligence for codebases, built for humans and AI.

ci(security): REL-07 CI security tooling sweep (gitleaks history scan, harden-runner, compass token scrub) (#833)

Ian Hock1f705e1a119d
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index ad9753c9..dd5fbecd 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -74,3 +74,23 @@ updates:
dependency-type: development
production-dependencies:
dependency-type: production
+
+ - package-ecosystem: npm
+ directory: /docs-site
+ schedule:
+ interval: weekly
+ open-pull-requests-limit: 5
+ groups:
+ dev-dependencies:
+ dependency-type: development
+ production-dependencies:
+ dependency-type: production
+
+ # docker-compose.standalone.yml (shipped in the release tarball, backs
+ # `ix docker start`). Only arangodb:3.12.11 gets bumps; memory-layer is
+ # `:latest`. Bump PRs are exercised by ci.yml's e2e job and by release.yml's
+ # PR dry-run, whose paths include that file.
+ - package-ecosystem: docker-compose
+ directory: /
+ schedule:
+ interval: weekly
diff --git a/.github/workflows/actions-lint.yml b/.github/workflows/actions-lint.yml
index 3bb5a032..ae3ef685 100644
--- a/.github/workflows/actions-lint.yml
+++ b/.github/workflows/actions-lint.yml
@@ -30,5 +30,5 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
- pipx install zizmor
+ pipx install zizmor==1.30.1
zizmor --min-severity=medium .github/workflows/
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 0bd90cc0..d26567c2 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -22,6 +22,9 @@ jobs:
name: Lint & Typecheck
runs-on: ubuntu-latest
steps:
+ - uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
+ with:
+ egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
@@ -89,8 +92,8 @@ jobs:
# Pinned by version and checksum, like every action here is pinned by SHA,
# because this runs a downloaded binary. Dependabot's github-actions
# ecosystem updates `uses:` refs and not `run:` downloads, so the bump is
- # manual — same as the `pipx install zizmor` next door, which pins nothing
- # at all.
+ # manual — same as the pinned `pipx install zizmor==...` in
+ # actions-lint.yml.
- name: Workflows are wired up (actionlint)
env:
ACTIONLINT_VERSION: 1.7.7
@@ -160,6 +163,10 @@ jobs:
run:
shell: bash
steps:
+ - uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
+ if: runner.os == 'Linux'
+ with:
+ egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
@@ -240,6 +247,9 @@ jobs:
name: E2E (real backend)
runs-on: ubuntu-latest
steps:
+ - uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
+ with:
+ egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
@@ -364,6 +374,9 @@ jobs:
name: API-reference parity
runs-on: ubuntu-latest
steps:
+ - uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
+ with:
+ egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
@@ -395,6 +408,7 @@ jobs:
name: Harness install smoke
runs-on: ubuntu-latest
container: node:22-bookworm
+ # No harden-runner: it runs on the host and does not support container jobs.
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
@@ -606,6 +620,9 @@ jobs:
name: Dead-link check
runs-on: ubuntu-latest
steps:
+ - uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
+ with:
+ egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
@@ -627,6 +644,9 @@ jobs:
run:
working-directory: docs-site
steps:
+ - uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
+ with:
+ egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
@@ -653,6 +673,9 @@ jobs:
name: Flag-reference parity
runs-on: ubuntu-latest
steps:
+ - uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
+ with:
+ egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
@@ -677,6 +700,9 @@ jobs:
needs: [static, test, e2e, api-parity, doc-parity, links, docs-site, harness-install-smoke, harness-install-smoke-windows]
runs-on: ubuntu-latest
steps:
+ - uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
+ with:
+ egress-policy: audit
- name: Verify all required jobs succeeded
run: |
echo "static=${{ needs.static.result }}"
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 3721105f..fbc286de 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -69,8 +69,11 @@ jobs:
# system-compass's package.json version is not maintained against the
# ix-compass-dist release series (it read 0.2.0 while dist was on v0.3.0),
# so the commit is the only reliable identity the bundle has.
- sha: ${{ steps.build-compass.outputs.sha }}
+ sha: ${{ steps.fetch-compass.outputs.sha }}
steps:
+ - uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
+ with:
+ egress-policy: audit
- name: Set up Node.js
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
@@ -80,12 +83,15 @@ jobs:
# the explicit ::error:: guard below, so an expired COMPASS_TOKEN produced
# a fully green release that shipped an empty compass/ directory and a
# broken `ix view` for every user. A compass failure must fail the release.
- - name: Build System Compass
- id: build-compass
+ # The token lives only in this step. It is used as a one-off fetch URL
+ # rather than a remote, so it is never written to system-compass/.git/config
+ # where the build's npm install scripts could read it. It fetches the
+ # default branch's HEAD, as the earlier `git clone` did.
+ - name: Fetch System Compass
+ id: fetch-compass
env:
COMPASS_TOKEN: ${{ secrets.COMPASS_TOKEN }}
run: |
- mkdir -p compass-dist
if [ -z "$COMPASS_TOKEN" ]; then
echo "::error::COMPASS_TOKEN is not set. It is required to build System Compass from the private ix-infrastructure/system-compass repo. Add a fine-grained PAT with Contents:read on that repo as the COMPASS_TOKEN secret."
exit 1
@@ -96,23 +102,37 @@ jobs:
# output, or an App token minted in-job, the automatic mask silently
# stops applying. This line does not care about the source.
echo "::add-mask::$COMPASS_TOKEN"
- # Do not pipe this clone through a redaction filter. This job runs on
+ # Do not pipe this fetch through a redaction filter. This job runs on
# the runner's default `bash -e {0}`, which has no `pipefail`, so the
# pipeline would exit with the filter's status (0) and the guard below
- # could never fire — the failure would surface as a confusing `cd:
- # system-compass: No such file or directory` two lines down instead of
- # the message telling you to rotate the token. Git withholds the
+ # could never fire — the failure would surface as a confusing `git
+ # checkout` error about a missing FETCH_HEAD instead of the message
+ # telling you to rotate the token. Git withholds the
# credential from its own error output regardless, and the mask above
# covers the value if anything else ever echoes it.
- git clone "https://x-access-token:${COMPASS_TOKEN}@github.com/ix-infrastructure/system-compass.git" 2>&1 \
+ git init -q system-compass
+ git -C system-compass fetch -q --depth 1 "https://x-access-token:${COMPASS_TOKEN}@github.com/ix-infrastructure/system-compass.git" HEAD 2>&1 \
|| {
- echo "::error::Could not clone ix-infrastructure/system-compass. COMPASS_TOKEN is set but was rejected — it is most likely expired or lacks Contents:read on that repo. Rotate it and re-run."
+ echo "::error::Could not fetch ix-infrastructure/system-compass. COMPASS_TOKEN is set but was rejected — it is most likely expired or lacks Contents:read on that repo. Rotate it and re-run."
exit 1
}
+ git -C system-compass checkout -q --detach FETCH_HEAD
+ # The token must not have been persisted anywhere under .git (config,
+ # FETCH_HEAD, logs) where the next step's npm install scripts could
+ # read it.
+ if grep -rqF -e "$COMPASS_TOKEN" -e x-access-token system-compass/.git; then
+ echo "::error::COMPASS_TOKEN was written under system-compass/.git"
+ exit 1
+ fi
+ # Record the source commit so the stamp written in the package job can
+ # identify this bundle (see the job's `outputs`).
+ echo "sha=$(git -C system-compass rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
+
+ # No token in this step's environment: npm install scripts run here.
+ - name: Build System Compass
+ run: |
+ mkdir -p compass-dist
cd system-compass
- # Capture the source commit before building, so the stamp written in
- # the package job can identify this bundle (see the job's `outputs`).
- echo "sha=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
npm ci --legacy-peer-deps
npm run build
if [ ! -f dist/index.html ]; then
@@ -164,6 +184,10 @@ jobs:
run:
shell: bash
steps:
+ - uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
+ if: runner.os == 'Linux'
+ with:
+ egress-policy: audit
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
@@ -468,6 +492,9 @@ jobs:
id-token: write # keyless signing for provenance attestation
attestations: write # record the build provenance attestation
steps:
+ - uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
+ with:
+ egress-policy: audit
- name: Checkout
# Credentials are intentionally persisted here: the Homebrew step pushes a
# branch and opens a PR with this token (see .github/zizmor.yml).
diff --git a/.github/workflows/secret-scan.yml b/.github/workflows/secret-scan.yml
index c422510f..bb0ae9a1 100644
--- a/.github/workflows/secret-scan.yml
+++ b/.github/workflows/secret-scan.yml
@@ -30,9 +30,22 @@ jobs:
- name: Install gitleaks
env:
GITLEAKS_VERSION: "8.30.1"
+ GITLEAKS_SHA256: 551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb
+ # Pinned by version and checksum because this runs a downloaded binary.
+ # Dependabot does not bump `run:` downloads, so the version and checksum
+ # are updated by hand (checksums are in the release's
+ # gitleaks_<version>_checksums.txt).
run: |
- curl -sSL "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" \
- | tar -xz -C /usr/local/bin gitleaks
- gitleaks version
+ set -euo pipefail
+ cd "$RUNNER_TEMP"
+ TARBALL="gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz"
+ curl -fsSL --retry 3 --retry-delay 2 --retry-all-errors -o "$TARBALL" \
+ "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/${TARBALL}"
+ echo "${GITLEAKS_SHA256} ${TARBALL}" | sha256sum --check --strict -
+ tar -xzf "$TARBALL" gitleaks
+ ./gitleaks version
- name: Scan repository
- run: gitleaks dir . --redact --verbose --exit-code 1
+ # `git` scans the commit history that fetch-depth: 0 checked out;
+ # `dir` would only scan the working tree.
+ run: |
+ "$RUNNER_TEMP/gitleaks" git . --redact --verbose --exit-code 1
diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml
index 1bed54f3..8a84f0a6 100644
--- a/.github/workflows/security.yml
+++ b/.github/workflows/security.yml
@@ -6,7 +6,8 @@ on:
pull_request:
branches: [main]
-# Least privilege at the top; the scanning job elevates to upload SARIF.
+# Least privilege. Nothing here uploads SARIF (findings fail the job instead),
+# so no job needs security-events: write.
permissions:
contents: read
@@ -14,9 +15,6 @@ jobs:
trivy-repo:
name: Trivy (repo)
runs-on: ubuntu-latest
- permissions:
- contents: read
- security-events: write # upload SARIF to code scanning
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
@@ -28,6 +26,8 @@ jobs:
scan-ref: .
severity: CRITICAL,HIGH
exit-code: 1
- scanners: vuln,misconfig
+ # vuln only: the misconfig scan runs once, in config-security.yml
+ # (trivy-misconfig).
+ scanners: vuln
# Docker image scanning is handled in the private Ix-memory repo