Skip to content

Harden npm package publishing - #82

Merged
yosriady merged 3 commits into
mainfrom
agent/harden-supply-chain
Aug 5, 2026
Merged

Harden npm package publishing#82
yosriady merged 3 commits into
mainfrom
agent/harden-supply-chain

Conversation

@yosriady

@yosriady yosriady commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

What changed

  • isolates build/test from the OIDC-enabled npm publish job
  • publishes a validated tarball through a protected npm-publish environment
  • pins npm to an exact version and disables publish-job caching
  • adds supply-chain CODEOWNERS coverage
  • repairs duplicated mappings that made the committed pnpm lockfile invalid

Why

The new release boundary prevents dependency code from running with npm publishing identity. The lockfile repair restores reproducible frozen installs.

Validation

  • frozen install succeeded
  • build succeeded
  • 300 tests passed
  • package tarball inspection succeeded
  • production audit reported no known vulnerabilities
  • workflow YAML and embedded shell syntax validated

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Review in cubic

@yosriady
yosriady marked this pull request as ready for review August 5, 2026 05:55
@yosriady

yosriady commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 48be0be54d

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

echo "tarball=${TARBALLS[0]}" >> "$GITHUB_ENV"

- name: Publish with OIDC provenance
run: npm publish "$tarball" --provenance --access public

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Prefix the tarball path before publishing

When this job reaches the publish step, $tarball comes from find package ..., so its value is a bare relative path like package/formo-analytics-react-native-1.0.2.tgz. npm does not treat that shape as a local tarball path unless it is path-qualified (for example ./package/... or an absolute path); it is parsed as a package/GitHub spec and the publish fails before reaching the registry. I reproduced the same parsing with npm by publishing out/foo.tgz versus ./out/foo.tgz, so release tags will build and validate but never publish unless this writes or passes a path-qualified tarball.

Useful? React with 👍 / 👎.

Comment on lines +132 to +134
for (const hook of ['preinstall', 'install', 'postinstall']) {
if (pkg.scripts?.[hook]) throw new Error(`Forbidden lifecycle hook: ${hook}`)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject npm's implicit install hook too

If a package candidate ever contains a root binding.gyp without an explicit install/preinstall, npm's lifecycle rules synthesize an install step that runs node-gyp rebuild, so this check can pass a tarball that still executes install-time code for consumers. Since this publish job is meant to enforce the no-lifecycle-hook boundary, also reject binding.gyp or otherwise account for npm's implicit install behavior before approving the tarball.

Useful? React with 👍 / 👎.

Comment thread .github/workflows/release.yml Outdated
name: npm-package
path: ${{ runner.temp }}/package/*.tgz
if-no-files-found: error
retention-days: 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep release artifacts long enough for approval

Because the publish job waits on the protected npm-publish environment, any required reviewer delay or wait timer longer than one day lets this uploaded candidate expire before actions/download-artifact runs. In that case a valid tag build becomes unreleasable solely because approval took too long, so use the repository default or a longer retention window for the package artifact.

Useful? React with 👍 / 👎.

@yosriady

yosriady commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9aeb93ab22

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/dependency-review.yml Outdated
- name: Reject newly introduced vulnerable dependencies
uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0
with:
fail-on-severity: high

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include build-time scopes in dependency review

For PRs that add a vulnerable dev/build dependency, this configuration still passes because dependency-review-action defaults fail-on-scopes to runtime unless development/unknown are listed (see the action's configuration docs: https://github.com/actions/dependency-review-action#configuration-options). The release workflow installs dev dependencies before building the published tarball, so high-severity issues in build tooling are still able to enter the release path unchecked; add fail-on-scopes for the build-time scopes if this check is meant to reject newly introduced vulnerable dependencies.

Useful? React with 👍 / 👎.

@yosriady
yosriady merged commit 6570fdc into main Aug 5, 2026
12 checks passed
@yosriady
yosriady deleted the agent/harden-supply-chain branch August 5, 2026 06:59
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