Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions .github/workflows/pipeline-bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ jobs:
if: ${{ inputs.dry_run != 'true' }}
env:
GOVERNED_PIPELINE_REPOSITORY: Consiliency/governed-pipeline
GOVERNED_PIPELINE_REF: main
# Pinned from governed-pipeline main on 2026-10-19; lock hash read independently.
# Bumps require an exact-SHA PR, lock digest verification and review; never a branch.
GOVERNED_PIPELINE_REF: 798109d271405378c9f15bdf9db9a383814d5f42
GOVERNED_PIPELINE_LOCK_SHA256: 72ce0d6e867d66a99ba8965802b8740135b40d204a3fa49196a4f2079eed3afc
GOVERNED_PIPELINE_TOKEN: ${{ secrets.GOVERNED_PIPELINE_READ_TOKEN || secrets.BOOTSTRAP_CLONE_TOKEN }}
run: |
if [ -z "$GOVERNED_PIPELINE_TOKEN" ]; then
Expand All @@ -95,14 +98,20 @@ jobs:
fi

gp_dir="$RUNNER_TEMP/governed-pipeline"
repo_url="https://x-access-token:${GOVERNED_PIPELINE_TOKEN}@github.com/${GOVERNED_PIPELINE_REPOSITORY}.git"

git clone --depth 1 --branch "$GOVERNED_PIPELINE_REF" "$repo_url" "$gp_dir" || {
git clone --depth 1 "$repo_url" "$gp_dir"
git -C "$gp_dir" checkout "$GOVERNED_PIPELINE_REF"
}

npm install --ignore-scripts --prefix "$gp_dir"
git init "$gp_dir"
git -C "$gp_dir" remote add origin "https://github.com/${GOVERNED_PIPELINE_REPOSITORY}.git"
# Use the existing read token only for this fetch, not a persisted URL.
auth_base64=$(printf 'x-access-token:%s' "$GOVERNED_PIPELINE_TOKEN" | base64 -w0)
echo "::add-mask::$auth_base64"
auth_header="AUTHORIZATION: basic $auth_base64"
GIT_CONFIG_COUNT=1 \
GIT_CONFIG_KEY_0=http.https://github.com/.extraheader \
GIT_CONFIG_VALUE_0="$auth_header" \
git -C "$gp_dir" fetch --depth 1 origin "$GOVERNED_PIPELINE_REF"
test "$(git -C "$gp_dir" rev-parse FETCH_HEAD)" = "$GOVERNED_PIPELINE_REF"
git -C "$gp_dir" checkout --detach FETCH_HEAD
echo "${GOVERNED_PIPELINE_LOCK_SHA256} ${gp_dir}/package-lock.json" | sha256sum -c -
npm ci --ignore-scripts --prefix "$gp_dir"
echo "GOVERNED_PIPELINE_NODE_MODULES=$gp_dir/node_modules" >> "$GITHUB_ENV"

mkdir -p "$RUNNER_TEMP/pipeline-bin"
Expand Down
53 changes: 53 additions & 0 deletions tests/test_bootstrap_pin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""Privileged bootstrap must fail closed before any mutable tool install."""

from pathlib import Path

import yaml

ROOT = Path(__file__).resolve().parents[1]


def test_bootstrap_installs_only_exact_verified_lock() -> None:
doc = yaml.safe_load(
(ROOT / ".github/workflows/pipeline-bootstrap.yml").read_text()
)
step = next(
s
for s in doc["jobs"]["bootstrap"]["steps"]
if s.get("name") == "Install governed-pipeline CLI"
)
assert (
step["env"]["GOVERNED_PIPELINE_REF"]
== "798109d271405378c9f15bdf9db9a383814d5f42"
)
assert (
step["env"]["GOVERNED_PIPELINE_LOCK_SHA256"]
== "72ce0d6e867d66a99ba8965802b8740135b40d204a3fa49196a4f2079eed3afc"
)
assert (
step["env"]["GOVERNED_PIPELINE_REPOSITORY"] == "Consiliency/governed-pipeline"
)
script = step["run"]
assert script.index("::add-mask::") < script.index("GIT_CONFIG_VALUE_0=")
assert "||" not in script and "git clone" not in script
assert "npm install" not in script
assert 'npm ci --ignore-scripts --prefix "$gp_dir"' in script
assert "rev-parse FETCH_HEAD)" in script
assert (
script.index("rev-parse FETCH_HEAD)")
< script.index("sha256sum -c -")
< script.index("npm ci")
)
assert "x-access-token:${" not in script
assert doc["jobs"]["bootstrap"]["permissions"] == {
"id-token": "write",
"contents": "write",
}


def test_bootstrap_dispatch_boundary_remains_separate() -> None:
doc = yaml.safe_load(
(ROOT / ".github/workflows/pipeline-bootstrap.yml").read_text()
)
events = doc.get("on", doc.get(True))
assert set(events) == {"repository_dispatch", "workflow_dispatch"}
Loading