Skip to content

chore: tighten release artifact inventory and isolate npm publish invocation - #23

Merged
FlyOverCoderKY merged 3 commits into
mainfrom
chore/release-artifact-inventory
Nov 6, 2026
Merged

FlyOverCoderKY merged 3 commits into
mainfrom
chore/release-artifact-inventory

Conversation

@FlyOverCoderKY

Copy link
Copy Markdown
Contributor

Summary

  • require the prepared directory to contain only the named manifest and tarball
  • run npm registry operations from a fresh directory with controlled config files and fixed publish options
  • use package metadata as the source for exact runtime pins and add the release check to CI
  • add release script and workflow coverage

Tests

  • CI=1 pnpm install --frozen-lockfile
  • CI=1 pnpm run format:check
  • CI=1 pnpm run check
  • CI=1 pnpm test
  • CI=1 pnpm run release:check

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-11-06T14:22:36.896059Z 050d1a3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

OpenRouter review posted (clean). #23 (review)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenRouter pull-request review

Verdict: issues
Scope: full-pr (full-pr)
Mode: initial
Commit: 050d1a3cdc9025f7c54fe287c31265c493947319
Judge: openai/gpt-5.6-luna
Cost: $0.2246 (lanes $0.2190 + judge $0.0056)

Lanes

  • meta/muse-spark-1.2: ok (7 finding(s), 106.0s, 111979+12417 tokens (339 cached), 3 tool round(s), via Meta, $0.19)
  • z-ai/glm-5.3-flash: ok (4 finding(s), 167.2s, 250492+18570 tokens (166144 cached), 9 tool round(s), via DeepInfra, $0.0266)

Warning

meta/muse-spark-1.2: coverage claims 4 finding(s) in 'scripts/release-package.mjs' but 5 were reported

Findings

🟠 Issue 1 — Runtime dependency validation loosened from hardcoded pins to generic exact-pin check

scripts/release-package.mjs:24 · risk · identified by meta/muse-spark-1.2

Publishing can succeed with an arbitrary exact version of @​pegma/spine or @​pegma/storage-core as long as package.json and pnpm-lock.yaml agree.

Previously validateRepository() compared manifest.dependencies against REQUIRED_DEPENDENCIES = {"@​pegma/spine":"0.1.1","@​pegma/storage-core":"0.4.0"}. This PR replaces that with REQUIRED_DEPENDENCY_NAMES plus EXACT_PIN (/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/). runtimeDependenciesAreExact only checks that the two keys exist and each value looks like an exact semver, then lockDependenciesMatch(..., runtimeDependencies) validates that the lockfile matches whatever package.json says. An attacker or mistaken bump to "@​pegma/spine":"9.9.9" with a matching lockfile import entry now passes pnpm run release:check and prepareRelease().

Checked scripts/release-package.mjs:24,283-290,319-324 against packages/webhooks/package.json:36-39 (0.1.2 / 0.4.0) and pnpm-lock.yaml importers. The new test scripts/release-package.test.mjs reads PACKAGE_VERSION dynamically and does not assert the old hardcoded versions. If the intent is to keep the pins reviewed, the hardcoded allow-list should be retained or the new behavior documented as intentional shift of trust to package.json diff review.

🟠 Issue 2 — Global Azurite setup now runs for isolated script tests

vitest.config.ts:5 · risk · identified by meta/muse-spark-1.2

Every pnpm test / pnpm run check now starts Azurite even when only scripts/release-package.test.mjs is running.

vitest.config.ts:5 adds "scripts/**/*.test.mjs" to the single include that has globalSetup: ["./test/azurite.ts"]. That setup allocates a port, spawns azurite/dist/src/table/main.js, and waits up to 30s (test/azurite.ts:110-145) before any test file runs. scripts/release-package.test.mjs mocks node:child_process and never uses storage, but still pays the Azurite startup cost and inherits its flake surface (port contention, missing binary).

Verified by reading vitest.config.ts and test/azurite.ts:setup(); no projects split exists. No existing test failure today, but CI=1 pnpm test is slower and can fail spuriously on Azurite startup for a change that only touches release metadata.

Consider a Vitest projects or globalSetup guard that skips Azurite when only scripts/* is included.

🟠 Issue 3 — Isolated npm environment strips only npm_config_*

scripts/release-package.mjs:723 · risk · identified by meta/muse-spark-1.2

A poisoned runner environment can still influence npm publish --provenance via non-npm_config_ variables.

withIsolatedNpmEnvironment() in scripts/release-package.mjs:718-737 builds env by filtering process.env with /^npm_config_/iu and then setting NPM_CONFIG_USERCONFIG/NPM_CONFIG_GLOBALCONFIG. It does not clear NODE_EXTRA_CA_CERTS, NODE_OPTIONS, https_proxy/HTTPS_PROXY, http_proxy, NO_PROXY, NPM_TOKEN, or NPM_CONFIG_PROVENANCE-adjacent state that npm and Node honor. publish.yml already sets persist-credentials: false and runs from mktemp -d (publish.yml:118-125), but the in-process isolation does not match that workflow hardening.

Re-checked scripts/release-package.test.mjs:224-311 – the test only asserts npm_config_registry is stripped and that the cwd is empty and configs are empty files; it does not cover proxy/CA or NODE_OPTIONS injection. This is not exploitable via prepare, but a self-hosted runner with proxy env could cause registryIntegrity() to query the wrong host despite --registry https://registry.npmjs.org/.

Consider explicitly allow-listing or clearing proxy/Node options, or at least documenting the gap.

🔵 Issue 4 — Expected tarball derived from checkout version, not prepared manifest

scripts/release-package.mjs:652 · nit · identified by meta/muse-spark-1.2

Inventory failure message can mislead when the prepared artifact was built from a different version than the current checkout.

verifyPreparedArtifact() at scripts/release-package.mjs:648-680 computes expectedTarball = expectedTarballName(sourceManifest.version) from packages/webhooks/package.json in root, then calls verifyReleaseArtifactInventory(dirname(path), expectedTarball) before reading prepared.package.version. If the artifact directory contains pegma-webhooks-0.1.0.tgz but the checkout is already at 0.1.1, the thrown error is release artifact directory must contain only regular files named package-manifest.json and pegma-webhooks-0.1.1.tgz, which suggests the manifest is wrong rather than reporting the prepared version mismatch that is checked later (prepared.package.tarball !== expectedTarball).

Confirmed by reading verifyReleaseArtifactInventory():504-520 and verifyPreparedArtifact():648-675. No functional bypass, but triage of a failed publish rerun will point at the wrong expected name.

Consider deriving the expected name from prepared.package.version for the inventory check, or include both expected vs actual in the error.

🔵 Issue 5 — Trailing-slash registry constant diverges from workflow registry-url

scripts/release-package.mjs:21 · nit · identified by meta/muse-spark-1.2

Inconsistent normalization of the registry URL between code and workflow.

scripts/release-package.mjs:21 defines NPM_REGISTRY = "https://registry.npmjs.org/" (with trailing slash) and passes it as --registry to npm view/npm publish (:581-590, :781-782). .github/workflows/publish.yml:55 (prepare job) still configures registry-url: https://registry.npmjs.org without slash. npm normalizes both, so no current failure, but safeEqual comparisons of integrity are unaffected – the constant is only used for the CLI flag.

Checked grep for NPM_REGISTRY and registry-url; the new test scripts/release-package.test.mjs:36,292-294 asserts the slash form. Keep one canonical form or document normalization to avoid future string-equality checks on the URL.

🔵 Issue 6 — CI: 1 set as YAML integer

.github/workflows/ci.yml:19 · nit · identified by meta/muse-spark-1.2

CI should be the string "1" for portability.

Both .github/workflows/ci.yml:19 and .github/workflows/publish.yml:21 add env: CI: 1 without quotes. YAML parses 1 as an integer; GitHub Actions stringifies env values, but some tools read process.env.CI with strict === "1" or === "true" checks. scripts/release-package.mjs checks process.env.GITHUB_ACTIONS/GITHUB_EVENT_NAME strictly, not CI, so no current breakage, but the value is semantically a string flag.

Verified by reading both workflow files; neighboring RELEASE_TAG: ${{ github.event.release.tag_name }} are strings. Quote as CI: "1" for consistency with GITHUB_ACTIONS: "true" semantics.

🔵 Issue 7 — Inventory test covers only artifact directory, not output-dir emptiness race

scripts/release-package.mjs:575 · nit · identified by meta/muse-spark-1.2

An extra file created between the empty-directory check and npm pack would not be caught until after packing.

prepareRelease() at scripts/release-package.mjs:573-595 does if ((await readdir(output)).length !== 0) fail(...) then runs runNpm(["pack", ...]). verifyReleaseArtifactInventory() is only called after the smoke test and manifest write (:600). The test helper installPrepareProcessDouble() in scripts/release-package.test.mjs:121-171 injects the extra file during the npm install smoke-test phase, which is after pack, so the new release artifact inventory tests do pass. A file created immediately after the emptiness check but before pack (e.g., by a concurrent process) would still be caught by the final inventory check, but the error would surface as must contain only regular files... rather than the clearer release output directory must be empty. No data loss, but coverage gap for the early check.

Checked prepareRelease ordering and test injection point; no direct exploit, but consider re-checking emptiness right before verifyReleaseArtifactInventory or documenting that the final check is the gate.

🟠 Issue 8 — smokeTest and registry-check npm operations bypass the isolated npm environment

scripts/release-package.mjs:470 · risk · identified by z-ai/glm-5.3-flash

Failure scenario: an environment carries an ambient npm_config_strict_ssl=false, npm_config_proxy, or npm_config_registry override. withIsolatedNpmEnvironment routes only the publish-path npm calls (requireTrustedPublishingNpm, registryIntegrity in publishPrepared, and npm publish) through the controlled empty npmrc files; smokeTest and inspectPreparedRegistry still inherit process.env wholesale.

Concrete instances:

  • smokeTest's npm install <tarball> (~line 470) has no --registry flag at all, so it resolves @​pegma/spine/@​pegma/storage-core from whatever ambient config points at, while the actual publish later runs against NPM_REGISTRY — the 'verified artifact' smoke result is produced under a different trust/network configuration than the publish, which is exactly the gap withIsolatedNpmEnvironment was added to close.
  • inspectPreparedRegistry (~line 706), the documented post-release verification command in docs/RELEASING.md line 97, still inherits ambient npm_config_* (auth, proxy, strict-ssl) for its lookup; the new explicit --registry flag pins the endpoint but not the rest of the config.

Evidence: registryIntegrity now always passes --registry NPM_REGISTRY and publishPrepared wraps everything in withIsolatedNpmEnvironment, but no isolation is applied to smokeTest or the registry-check entry point. Only the explicit --registry flag on npm view mitigates the worst variant for registry-check.

🟠 Issue 9 — No unit coverage for the rewritten exact-dependency-pin validation or the manifest-name guard

scripts/release-package.test.mjs:1 · risk · identified by z-ai/glm-5.3-flash

Failure scenario: a regression in the new validation code — dropping the Array.isArray guard, weakening the name-set comparison to a subset check, or letting a caret pin through EXACT_PIN — passes the whole test suite, because scripts/release-package.test.mjs exercises only the artifact-inventory and publish flows. The rewritten runtimeDependenciesAreExact / REQUIRED_DEPENDENCY_NAMES / lockDependenciesMatch(..., runtimeDependencies) path in validateRepository (~lines 283–323) and the new prepared manifest must be named package-manifest.json guard in verifyPreparedArtifact are covered only by the real-repo happy path via pnpm run release:check, which cannot distinguish a subtly weakened validator (it validates whatever pins the repo happens to carry that day — currently 0.1.1 with exact @​pegma/spine 0.1.2 / @​pegma/storage-core 0.4.0).

Evidence for the absence claim: greps over scripts/release-package.test.mjs show no validateRepository import or call, and no negative-case tests for dependency pins, EXACT_PIN rejection, or the manifest-name guard. The old code had a comparable gap, but this PR rewrote the logic, so the new code ships with no direct pinning tests for its rejection behavior.

🔵 Issue 10 — Workflow publisher directory is redundant: the script forces npm into its own tempdir, so the mktemp step and working-directory do not isolate anything

.github/workflows/publish.yml:118 · nit · identified by z-ai/glm-5.3-flash

Failure scenario: a reader of publish.yml attributes the npm-isolation guarantee to the 'Create a clean publisher directory' step and working-directory:. In reality withIsolatedNpmEnvironment overrides cwd on every runNpm call, so npm publish executes in the script's own os.tmpdir() work directory (pegma-webhooks-publish-*), not the mktemp directory under RUNNER_TEMP.

Concrete costs:

  • the workflow-level directory is created, never used for the registry operation, and left behind on RUNNER_TEMP (the runner cleans it eventually, but it is dead weight);
  • the isolation mechanism lives in the script, while the workflow appears to provide it — a future edit that drops cwd from npmOptions (or from run()) would silently reintroduce publishing from an ambient working directory while the workflow still looks isolated, and the test only pins the script's current behavior, not this coupling.

Evidence: cross-read of run() (cwd: options.cwd) and the test assertion that publishCall.cwd is the script tempdir, not the workflow one.

🔵 Issue 11 — Workflow-invariant tests pin YAML by fragile regex (exact 12-space indentation, exact tail string)

scripts/release-package.test.mjs:320 · nit · identified by z-ai/glm-5.3-flash

Failure scenario: a harmless reformat of publish.yml — e.g. Prettier adjusting indentation inside block scalars, adding a third artifact upload path, or reordering keys so retention-days: 30 is no longer the last key of the step — makes the invariant tests fail on semantically unchanged YAML, or worse, uploadStep?.[0] silently matches a different path: block elsewhere in the file and passes while the real upload block has drifted.

Concrete instances in scripts/release-package.test.mjs (describe("release workflow invariants")):

  • the upload-path test matches /path: \|\r?\n((?:\s{12}.+\r?\n){2})/u, which requires exactly 12-space indentation and exactly two path lines;
  • the CI test matches the literal retention-days: 30 as the step boundary.

Evidence: I verified the current regexes do match the current publish.yml (block entries are at 12 spaces, so the lazy match stops after two lines), but nothing in the test structure prevents future drift from passing vacuously; a YAML parse (e.g. the yaml package) would pin the same invariants without the indentation coupling.

Workflow run

Comment thread scripts/release-package.mjs Resolved
Comment thread vitest.config.ts Resolved
Comment thread scripts/release-package.mjs Resolved
Comment thread scripts/release-package.mjs Resolved
Comment thread scripts/release-package.mjs Resolved
Comment thread .github/workflows/ci.yml Resolved
Comment thread scripts/release-package.mjs Resolved
Comment thread scripts/release-package.test.mjs Resolved
Comment thread .github/workflows/publish.yml Resolved
Comment thread scripts/release-package.test.mjs Resolved

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenRouter pull-request review

Verdict: issues
Scope: latest-commit (commit-range)
Mode: verify
Commit: 2441278a5b4953c11c0e9f583a4252330eca7d1d
Judge: openai/gpt-5.6-luna
Cost: $0.1345 (lanes $0.1344 + judge $0.0001)

Lanes

  • meta/muse-spark-1.2: ok (0 finding(s), 42.2s, 84733+3889 tokens (10195 cached), 3 tool round(s), via Meta, $0.11)
  • z-ai/glm-5.3-flash: ok (0 finding(s), 115.4s, 304043+18621 tokens (252160 cached), 10 tool round(s), via Together, $0.0232)

Round 2 resolution

  • ✅ r1-1 fixed correctly — Runtime dependency validation loosened from hardcoded pins to generic exact-pin check: Fixed: scripts/release-package.mjs:24 now defines REQUIRED_DEPENDENCIES = {"@​pegma/spine":"0.1.2","@​pegma/storage-core":"0.4.0"} frozen and dependencyPinsMatch() requires exact key set match, EXACT_PIN test, and === to reviewed pins; validateRepository now checks both dependencyPinsMatch(manifest.dependencies, REQUIRED_DEPENDENCIES) and `lockDependenciesMatch(... REQUIRED_DEPENDENCIE…
  • ✅ r1-2 fixed correctly — Global Azurite setup now runs for isolated script tests: Fixed: vitest.config.ts:5 now uses projects — webhooks project includes packages/*/src/**/*.test.ts with globalSetup: ["./test/azurite.ts"] and release project includes scripts/**/*.test.mjs without globalSetup. Verified by reading vitest.config.ts and scripts/release-package.test.mjs mocking node:child_process.
  • ✅ r1-3 fixed correctly — Isolated npm environment strips only npm_config_*: Fixed: scripts/release-package.mjs:770 withIsolatedNpmEnvironment now allowlists PUBLISH_ENVIRONMENT_NAMES (+ Windows vars) and builds env only from those keys, then sets NPM_CONFIG_USERCONFIG/GLOBALCONFIG with empty 0o600 files. Test scripts/release-package.test.mjs: uses a clean working directory... asserts DISCARDED_ENVIRONMENT keys (NODE_EXTRA_CA_CERTS, NODE_OPTIONS, `HTTP_PR…
  • ❌ r1-8 not fixed — smokeTest and registry-check npm operations bypass the isolated npm environment: Not fixed: isolate is still only used in publishPrepared via withIsolatedNpmEnvironment. smokeTest (~line 383) still calls runNpm(["install", tarball]) without env isolation and without "--registry", NPM_REGISTRY, inheriting ambient npm_config_registry/proxy etc. inspectPreparedRegistry (~line 590) still calls registryIntegrity without passing isolated env, inheriting `process.…
  • ✅ r1-9 fixed correctly — No unit coverage for the rewritten exact-dependency-pin validation or the manifest-name guard: Fixed: scripts/release-package.test.mjs now covers the rewritten path: release dependency pins tests reject non-reviewed matching pins, lock-mismatch, and caret pins (^0.1.2); release preparation tests output-dir empty guard; prepared publishing tests canonical manifest name guard and full withIsolatedNpmEnvironment allowlist/provenance assertions; release workflow invariants tests c…
  • 6 nit finding(s) from earlier rounds retired (severity floor for follow-up rounds is risk).
  • Open findings after this round: 1 (0 bug-severity).

No structured findings from the successful lane(s).

Workflow run

@FlyOverCoderKY

Copy link
Copy Markdown
Contributor Author

Fixed in dbf0bba: smoke installation and registry inspection now share the controlled npm environment and config helper used by publishing, and both use the fixed registry. Added direct tests for both paths.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenRouter pull-request review

Verdict: clean
Scope: latest-commit (commit-range)
Mode: verify
Commit: dbf0bba382e802edd5181409fb5759b7ecfd8ab0
Judge: openai/gpt-5.6-luna
Cost: $0.0787 (lanes $0.0786 + judge $0.0001)

Lanes

  • meta/muse-spark-1.2: ok (0 finding(s), 48.0s, 47557+2347 tokens (25939 cached), 2 tool round(s), via Meta, $0.0409)
  • z-ai/glm-5.3-flash: ok (0 finding(s), 192.0s, 265012+21225 tokens (96768 cached), 8 tool round(s), via PrimeIntellect, $0.0377)

Round 3 resolution

  • ✅ r1-8 fixed correctly — smokeTest and registry-check npm operations bypass the isolated npm environment: smokeTest now runs via withIsolatedNpmEnvironment with explicit env and --registry https://registry.npmjs.org/ (lines 508-532) and inspectPreparedRegistry now wraps registryIntegrity in withIsolatedNpmEnvironment passing npmOptions (lines 747-764). Both inherit empty user/global npmrc isolation and allowlist filtering of env, matching publish path. New tests capture install/view calls …
  • Open findings after this round: 0 (0 bug-severity).

No structured findings from the successful lane(s).

Workflow run

@FlyOverCoderKY
FlyOverCoderKY merged commit 6a3c8e5 into main Nov 6, 2026
3 checks passed
@FlyOverCoderKY
FlyOverCoderKY deleted the chore/release-artifact-inventory branch November 6, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant