Skip to content

fix(rules): scoped npm registries and same-branch guards (use-trusted-publishing, github-env) - #151

Merged
jdx merged 1 commit into
mainfrom
fix/trusted-publishing-github-env-102
Oct 10, 2026
Merged

jdx merged 1 commit into
mainfrom
fix/trusted-publishing-github-env-102

Conversation

@jdx

@jdx jdx commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Fixes #102

  • use-trusted-publishing: a scoped registry setting (@scope:registry) now hides a publish only when the package is of that scope. The name comes from package.json (step/job/workflow working-directory, or the folder given to npm publish). Unscoped packages and other scopes are reported. Kept conservative (unreported, documented in docs/checks.md) when the name is unknown: no readable manifest, expression or cd-changed directory, tarball or workspace selection, manifest possibly rewritten earlier, or an unscoped private registry.
  • github-env: guards ([[ ]] || exit, if ... exit, case) inside an if/else branch are recorded with a scope and hold for the rest of that branch only. Bare [[ ]] relying on set -e still counts at the top level only; loops, functions and pipelines are not followed.

Positive and negative tests added for both. No change to finding output, so matcher fixtures are unchanged.

🤖 Generated with Claude Code


Note

Medium Risk
Changes when security findings fire for GITHUB_ENV writes and npm publish credential checks; incorrect scope or manifest logic could miss issues or add noise, but only affects static analysis, not workflow execution.

Overview
Tightens two security lint rules so they match documented intent more closely.

github-env: Shell validation guards ([[ ]] || exit, branch exits, case) are now tracked with branch scope—a check inside an if/else body only protects writes later in that same branch. Top-level bare [[ ]] under set -e still counts; guards inside loops, functions, or pipelines are ignored. The github-env flow only applies a guard when the write offset is still within that scope.

use-trusted-publishing: A scoped private registry (npm config set @scope:registry …) no longer suppresses every publish in the job. The rule reads package.json (respecting working-directory and publish path) and treats the registry as private only when the published package name matches that scope; unscoped registry still applies to all packages. When the package name cannot be determined reliably, behavior stays conservative (no finding), with new tests and docs/checks.md updates for both rules.

Reviewed by Cursor Bugbot for commit d32954e. Bugbot is set up for automated code reviews on this repo. Configure here.

…uards inside the branch of the write

use-trusted-publishing: a registry set for one scope (@scope:registry) no longer hides the publish of every package. The package name is read from package.json (working-directory or folder argument); unscoped packages and packages of another scope are reported. When the name cannot be known with confidence the publish stays unreported.

github-env: a validation guard inside the same if/else branch as the write now counts for the rest of that branch.

Refs #102

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Central YAML (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ba7480f8-a891-4c29-9d4e-fa777b84155b

📥 Commits

Reviewing files that changed from the base of the PR and between fec2e75 and d32954e.


📒 Files selected for processing (8)
  • docs/checks.md
  • internal/runscript/flow.go
  • internal/runscript/flow_test.go
  • rule_github_env.go
  • rule_github_env_flow.go
  • rule_github_env_flow_test.go
  • rule_use_trusted_publishing.go
  • rule_use_trusted_publishing_scope_test.go

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jdx
jdx merged commit 92b5064 into main Oct 10, 2026
18 checks passed
@jdx
jdx deleted the fix/trusted-publishing-github-env-102 branch October 10, 2026 13:08
@jdx jdx mentioned this pull request Oct 10, 2026
jdx added a commit that referenced this pull request Oct 10, 2026
🤖 I have created a release *beep* *boop*
---


## [2.1.0](v2.0.2...v2.1.0)
(2026-10-10)


### Features

* add JACTIONLINT_ONLINE to turn the online checks on from the
environment ([#155](#155))
([a17b716](a17b716))
* add the workflow-secret-scope rule
([#136](#136))
([2885719](2885719))
* explain why a finding has no fix
([#135](#135))
([5a65169](5a65169))
* **parallel-steps:** flag reads of a background step's outputs before
its wait ([#132](#132))
([540e948](540e948))
* **pipeline-without-pipefail:** follow PIPESTATUS into a later check
([#145](#145))
([40d579e](40d579e))
* report online check coverage in SARIF
([#140](#140))
([ba654bb](ba654bb))
* revisit three v2 defaults from
[#106](#106)
([#152](#152))
([aa19b18](aa19b18))


### Bug Fixes

* allow runs.env in composite actions
([#123](#123))
([e0a95fc](e0a95fc))
* **bot-conditions:** suggest advice that matches the caller's actual
event ([#141](#141))
([a8dad0e](a8dad0e))
* **cache-poisoning:** evaluate the caller's input expression for
composite actions
([#139](#139))
([48ba93d](48ba93d))
* **cache-poisoning:** treat release branch pushes as releases and know
more publishers ([#150](#150))
([981e623](981e623))
* **ci:** fix problem matcher test and run it on PRs
([#134](#134))
([80b358a](80b358a))
* **concurrency-limits:** avoid caller group collisions and cancelling
release workflows
([#142](#142))
([3f543aa](3f543aa))
* **docs:** say that default-minutes and default-days turn on the --fix
fix ([#147](#147))
([1c43358](1c43358))
* **events:** accept field_added/field_removed for issues
([#130](#130))
([c5ec59a](c5ec59a))
* **fix:** refuse risky unquoted template-injection fixes, fix
flow-style artipacked
([#154](#154))
([ac7f40a](ac7f40a))
* **migrate-ignores:** migrate the root action.yml, report skipped
comments, keep version comments
([#146](#146))
([fec2e75](fec2e75))
* **missing-permissions:** do not require permissions in reusable-only
workflows ([#138](#138))
([387fb67](387fb67))
* **parallel-steps:** allow redundant background: true inside a parallel
group ([#131](#131))
([b1023d8](b1023d8))
* **pipeline-without-pipefail:** ignore pipelines in process
substitutions ([#143](#143))
([f8b0184](f8b0184))
* reject the keys GitHub refuses on wait, wait-all, cancel and parallel
steps ([#128](#128))
([85ee9dd](85ee9dd))
* **rules:** scoped npm registries and same-branch guards
(use-trusted-publishing, github-env)
([#151](#151))
([92b5064](92b5064))
* **untrusted-checkout:** follow a fetched pull request into a script of
the repository ([#149](#149))
([3eed721](3eed721))


### Performance Improvements

* parse each expression once and lex without allocating a scanner
([#153](#153))
([6910e8b](6910e8b))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> <sup>[Cursor Bugbot](https://cursor.com/bugbot) is generating a
summary for commit 858b0d1. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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.

use-trusted-publishing and github-env: scoped registries and same-branch guards

1 participant