diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 0d8bfba..f5c10ee 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -265,10 +265,16 @@ jobs: # it stamps against `Cargo.toml` — so a `main` that has already moved # on would abort the build rather than publish packages whose sources # are not the ones the release was cut from. + # + # On the automated path, pin to the COMMIT the Release run built + # (`workflow_run.head_sha`), not the tag name: a tag can be force-pushed + # between the Release finishing and this job starting, and this job + # runs repo code (`npm/build.mjs`) with OIDC publish rights. A manual + # dispatch has no workflow_run, so it falls back to the typed tag. if: steps.resolve.outputs.should_publish == 'true' uses: actions/checkout@v7 with: - ref: ${{ steps.resolve.outputs.tag }} + ref: ${{ github.event.workflow_run.head_sha || steps.resolve.outputs.tag }} persist-credentials: false - name: Setup Node diff --git a/.gitignore b/.gitignore index 848b21b..0f1fc5e 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,7 @@ Thumbs.db npm/dist/ npm/**/*.tgz npm/cli/vendor/ + +# Python bytecode (scripts/e2e_flows.py) +__pycache__/ +*.pyc diff --git a/scripts/__pycache__/e2e_flows.cpython-314.pyc b/scripts/__pycache__/e2e_flows.cpython-314.pyc deleted file mode 100644 index 4de6c92..0000000 Binary files a/scripts/__pycache__/e2e_flows.cpython-314.pyc and /dev/null differ diff --git a/scripts/e2e_flows.py b/scripts/e2e_flows.py index c276294..fa74a37 100644 --- a/scripts/e2e_flows.py +++ b/scripts/e2e_flows.py @@ -33,7 +33,13 @@ def cappath(name): - return os.path.join(STATE["cap"], name) + # Resolve and verify containment: `name` can come off a request line, and this is + # the check that guarantees a capture file never lands outside the capture dir. + root = os.path.realpath(STATE["cap"]) + path = os.path.realpath(os.path.join(root, name)) + if not path.startswith(root + os.sep): + raise ValueError(f"capture path escapes {root}: {name!r}") + return path class Handler(http.server.BaseHTTPRequestHandler):