Skip to content

fix: allow git build approvals by repository - #12856

Merged
zkochan merged 4 commits into
pnpm:mainfrom
ychampion:fix-allow-builds-git-repo
Jul 9, 2026
Merged

zkochan merged 4 commits into
pnpm:mainfrom
ychampion:fix-allow-builds-git-repo

Conversation

@ychampion

@ychampion ychampion commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Allows allowBuilds keys for git-hosted packages to omit the resolved commit hash, for example pkg@git+ssh://host/org/repo.git.

Keeps package-name-only approvals registry-only, so pkg: true still does not approve git artifacts. The same policy is implemented in the TypeScript CLI and the Rust pacquet/ port, with a changeset for pnpm and @pnpm/building.policy.

Fixes #12367.

Validation:

  • corepack pnpm --filter @pnpm/building.policy test -- --runTestsByPath test/index.ts
  • corepack pnpm --filter @pnpm/installing.deps-installer compile
  • cargo fmt --check -- pacquet/crates/package-manager/src/build_modules.rs pacquet/crates/package-manager/src/build_modules/tests.rs
  • cargo test -p pacquet-package-manager explicit_allow_by_git_repo_allows_untrusted_package_identity -- --nocapture
  • corepack pnpm exec cspell .changeset/allow-git-repo-builds.md pnpm11/building/policy/src/index.ts pnpm11/building/policy/test/index.ts pnpm11/installing/deps-installer/test/install/lifecycleScripts.ts --no-progress
  • git diff --check

Full Rust workspace pre-push reached cargo clippy --all-targets --workspace -- -D warnings but could not complete in this container because compiling the workspace filled the local filesystem.

Squash Commit Body

Allow git-hosted build approvals to match the package/repository portion of a git depPath before the resolved commit hash.

This lets trusted git repositories continue running build scripts after branch updates without adding a new hash-qualified `allowBuilds` entry for every resolved commit. Exact depPath rules still work, disallow rules still win first, and package-name-only allow rules remain limited to trusted registry-style depPaths so git artifacts are not approved by name alone.

Fixes pnpm/pnpm#12367.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pacquet/ port, or the description notes what still needs porting.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.

Summary by CodeRabbit

  • New Features

    • Added repository URL–based allow/block rules for git-hosted package builds, so trusted repos remain allowed after branch/commit changes.
    • Repository-based build permissions now apply during installation, enabling expected lifecycle script execution for allowed git dependencies.
  • Bug Fixes

    • Improved git-hosted dependency matching across URL fragment and nested package identity variants.
    • Ensures non-git packages aren’t impacted by git-repository rules.
  • Tests

    • Extended coverage for git-repo allow/deny matching and lifecycle script order for allowed git dependencies.

@ychampion
ychampion requested a review from zkochan as a code owner July 8, 2026 18:04
Copilot AI review requested due to automatic review settings July 8, 2026 18:04
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 58331239-ce42-47ef-9507-79d0d92d6f57

📥 Commits

Reviewing files that changed from the base of the PR and between 1f99cbf and 9aa03c2.

📒 Files selected for processing (2)
  • pnpm11/building/policy/src/index.ts
  • pnpm11/building/policy/test/index.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • pnpm11/building/policy/test/index.ts
  • pnpm11/building/policy/src/index.ts

📝 Walkthrough

Walkthrough

allowBuilds now matches git-hosted dependencies by repository URL key instead of requiring the resolved commit hash. The change is implemented in pnpm and pacquet, and is covered by new policy and install tests plus a changeset note.

Changes

Git-repo allowBuilds matching

Layer / File(s) Summary
pnpm git-repo rule handling
pnpm11/building/policy/src/index.ts
Creates git-repo allow/deny sets, routes git-hosted rules into them, derives repository keys during evaluation, and adds helper logic for git depPaths and repository-key extraction.
pnpm tests and changeset
pnpm11/building/policy/test/index.ts, pnpm11/installing/deps-installer/test/install/lifecycleScripts.ts, .changeset/allow-git-repo-builds.md
Adds policy coverage for git-hosted repository-key matching, a lifecycle-script install test for allowed git-hosted dependencies, and a changeset note describing the matching change.
pacquet git-repo rule handling
pacquet/crates/package-manager/src/build_modules.rs, pacquet/crates/package-manager/src/build_modules/tests.rs
Adds git-repo allow/deny rule sets to AllowBuildPolicy, populates them from config, derives git-repo keys during checks, and adds a unit test for git+ssh repository matching and fragment handling.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant createAllowBuildFunction
  participant AllowBuildPolicy
  participant from_config
  participant InstallTest
  participant addAllowBuildRule
  createAllowBuildFunction->>addAllowBuildRule: route git repo allowBuild keys
  from_config->>AllowBuildPolicy: store git-repo allow/deny rules
  AllowBuildPolicy->>AllowBuildPolicy: derive gitRepoKey from depPath
  AllowBuildPolicy->>AllowBuildPolicy: check gitRepo allow/deny sets
  InstallTest->>createAllowBuildFunction: enable build for git-hosted dependency
  InstallTest->>InstallTest: assert lifecycle script execution
Loading

Assessment against linked issues

Objective Addressed Explanation
allowBuilds should match git-hosted packages by repository URL without requiring the resolved commit hash [#12367] ✅
Branch-ref and URL-based git-hosted allowlist entries should continue matching after the lockfile hash changes [#12367] ✅
Package-name-only rules should not approve git-hosted artifacts [#12367] ✅

Suggested labels: product: pnpm@11, product: pacquet

Suggested reviewers: zkochan

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pacquet/crates/package-manager/src/build_modules.rs`:
- Around line 303-308: The helper git_repo_allow_build_key_from_dep_path
currently returns None for valid git dependency paths that do not include a
fragment, which prevents allow rules from matching no-hash forms. Update this
function so that after confirming the path is a git repo dep path, it returns
the full dep_path when find('#') yields no fragment, and only truncates at the
hash when one is present. Keep the change localized to
git_repo_allow_build_key_from_dep_path so matching behavior stays aligned with
pnpm for both hash and no-hash git URLs.

In `@pacquet/crates/package-manager/src/build_modules/tests.rs`:
- Around line 121-128: The policy test coverage in build_modules/tests.rs should
also verify the no-hash dep-path form that is now stored as the repo key. Add an
assertion alongside the existing policy.check cases in the test that exercises
this helper so it covers the plain git URL without a `#hash`, ensuring it matches
the same policy result as the hashed form and would fail without the no-hash
handling fix.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: bfcd49bc-2376-4d50-95ff-7f9249f034e5

📥 Commits

Reviewing files that changed from the base of the PR and between eb12194 and 725ca0d.

📒 Files selected for processing (6)
  • .changeset/allow-git-repo-builds.md
  • pacquet/crates/package-manager/src/build_modules.rs
  • pacquet/crates/package-manager/src/build_modules/tests.rs
  • pnpm11/building/policy/src/index.ts
  • pnpm11/building/policy/test/index.ts
  • pnpm11/installing/deps-installer/test/install/lifecycleScripts.ts

Copilot AI review requested due to automatic review settings July 8, 2026 18:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings July 8, 2026 18:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 8, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.62%. Comparing base (692c449) to head (b20aa9d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #12856   +/-   ##
=======================================
  Coverage   85.61%   85.62%           
=======================================
  Files         449      449           
  Lines       69986    70031   +45     
=======================================
+ Hits        59922    59966   +44     
- Misses      10064    10065    +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: b20aa9d2af36

Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD.

Scenario: Isolated linker: fresh restore, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.823 ± 0.166 3.659 4.181 1.75 ± 0.13
pacquet@main 3.905 ± 0.134 3.731 4.098 1.79 ± 0.13
pnpr@HEAD 2.210 ± 0.136 2.064 2.433 1.01 ± 0.09
pnpr@main 2.182 ± 0.133 2.063 2.410 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.8227770295,
      "stddev": 0.1656203951034561,
      "median": 3.761444922,
      "user": 3.5937845200000007,
      "system": 3.45859922,
      "min": 3.6588393625,
      "max": 4.1807424975,
      "times": [
        4.1807424975,
        3.7598190015,
        3.7945235015,
        4.0176856055,
        3.7630708425,
        3.7032656514999998,
        3.6588393625,
        3.6870130205000002,
        3.7517928685,
        3.9110179435
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.9051812511999997,
      "stddev": 0.13412630160593483,
      "median": 3.9100606165,
      "user": 3.60443142,
      "system": 3.4424573200000004,
      "min": 3.7305012755,
      "max": 4.0984941065,
      "times": [
        3.9898562775,
        3.7662234525000002,
        3.8265324395,
        4.0241561975,
        3.7453608875,
        3.9255355755,
        3.8945856575,
        4.0984941065,
        3.7305012755,
        4.0505666425
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.2099483898,
      "stddev": 0.13612761873866228,
      "median": 2.1750113564999998,
      "user": 2.7387490199999998,
      "system": 3.18518582,
      "min": 2.0635940765,
      "max": 2.4328356355,
      "times": [
        2.4046040105,
        2.0635940765,
        2.0727326215,
        2.1246292975,
        2.1998313845,
        2.4328356355,
        2.2808675125,
        2.0808345495,
        2.2893634815,
        2.1501913285
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.1822068163,
      "stddev": 0.13343101581390274,
      "median": 2.1357091695,
      "user": 2.7180071199999998,
      "system": 3.10812532,
      "min": 2.0625702695,
      "max": 2.4095424055,
      "times": [
        2.1224836815,
        2.4095424055,
        2.0665689945,
        2.1060914435,
        2.0625702695,
        2.2846606115,
        2.3970481475,
        2.1489346575,
        2.1563140675,
        2.0678538845
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 689.9 ± 34.1 655.5 769.4 1.00
pacquet@main 774.1 ± 79.2 696.3 978.3 1.12 ± 0.13
pnpr@HEAD 805.9 ± 56.2 745.3 921.1 1.17 ± 0.10
pnpr@main 774.2 ± 55.5 730.8 923.3 1.12 ± 0.10
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6898896265200001,
      "stddev": 0.03411556656208651,
      "median": 0.6805122670200001,
      "user": 0.43483928,
      "system": 1.3680863999999997,
      "min": 0.6554751335200001,
      "max": 0.7694198385200001,
      "times": [
        0.6720463695200001,
        0.6554751335200001,
        0.69367441852,
        0.69628339752,
        0.6728792355200001,
        0.66138899752,
        0.66796732252,
        0.6881452985200001,
        0.72161625352,
        0.7694198385200001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.7740907457199999,
      "stddev": 0.07922934352099995,
      "median": 0.75110159302,
      "user": 0.43937007999999994,
      "system": 1.4530442999999997,
      "min": 0.69633380852,
      "max": 0.97833475652,
      "times": [
        0.76796196752,
        0.73850138552,
        0.73774517752,
        0.69633380852,
        0.71743350652,
        0.78759661952,
        0.75215539552,
        0.97833475652,
        0.8147970495200001,
        0.75004779052
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.8058837678199999,
      "stddev": 0.05623524704922743,
      "median": 0.79448868052,
      "user": 0.4625905799999999,
      "system": 1.4515255999999999,
      "min": 0.74532845952,
      "max": 0.92105766552,
      "times": [
        0.7973509415200001,
        0.81638457852,
        0.77247255652,
        0.7538486805200001,
        0.76282541652,
        0.92105766552,
        0.81937229052,
        0.79162641952,
        0.74532845952,
        0.8785706695200001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.7741939146200001,
      "stddev": 0.05552479067374141,
      "median": 0.76241498502,
      "user": 0.42870828000000005,
      "system": 1.4019689,
      "min": 0.7307701335200001,
      "max": 0.92333790352,
      "times": [
        0.77355444352,
        0.7905348855200001,
        0.7583789925200001,
        0.76645097752,
        0.73752609552,
        0.7461047135200001,
        0.74425388552,
        0.92333790352,
        0.77102711552,
        0.7307701335200001
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.538 ± 0.132 4.320 4.692 2.01 ± 0.15
pacquet@main 4.334 ± 0.052 4.220 4.396 1.92 ± 0.13
pnpr@HEAD 2.253 ± 0.156 2.020 2.487 1.00 ± 0.10
pnpr@main 2.252 ± 0.154 2.095 2.509 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.53806287742,
      "stddev": 0.13193054687401257,
      "median": 4.5729266077199995,
      "user": 3.95042006,
      "system": 3.5753686999999994,
      "min": 4.32029893022,
      "max": 4.69245997322,
      "times": [
        4.68602449222,
        4.629377992219999,
        4.5612647082199995,
        4.635215094219999,
        4.46387646222,
        4.37691570122,
        4.32029893022,
        4.69245997322,
        4.43060691322,
        4.584588507219999
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.333936432819999,
      "stddev": 0.0515424838088394,
      "median": 4.35568015922,
      "user": 3.8204290599999995,
      "system": 3.4583748,
      "min": 4.21970513122,
      "max": 4.395836839219999,
      "times": [
        4.367283264219999,
        4.21970513122,
        4.395836839219999,
        4.34041047422,
        4.28167583522,
        4.35625539722,
        4.3609809322199995,
        4.3041312312199995,
        4.35798030222,
        4.35510492122
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.2534681598199997,
      "stddev": 0.1557867243211459,
      "median": 2.24512505722,
      "user": 2.5686377599999997,
      "system": 3.0339655,
      "min": 2.01973687622,
      "max": 2.48727894722,
      "times": [
        2.0628651012200003,
        2.25978925922,
        2.4199457362200003,
        2.3048248942200003,
        2.48727894722,
        2.20445944722,
        2.41183296122,
        2.01973687622,
        2.23046085522,
        2.13348752022
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.25236528332,
      "stddev": 0.15397379600742633,
      "median": 2.20002827372,
      "user": 2.57716356,
      "system": 3.0282750000000003,
      "min": 2.09451605322,
      "max": 2.50888647322,
      "times": [
        2.09493051422,
        2.24182570822,
        2.10540959822,
        2.1582308392200003,
        2.09451605322,
        2.50888647322,
        2.1512750562200003,
        2.3981126332200002,
        2.40149088922,
        2.36897506822
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.447 ± 0.032 1.411 1.494 2.08 ± 0.06
pacquet@main 1.439 ± 0.053 1.398 1.581 2.06 ± 0.09
pnpr@HEAD 0.697 ± 0.015 0.679 0.728 1.00
pnpr@main 0.709 ± 0.043 0.680 0.827 1.02 ± 0.07
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.44710866328,
      "stddev": 0.031694428859977634,
      "median": 1.44375113658,
      "user": 1.43377096,
      "system": 1.7445084999999998,
      "min": 1.41091515408,
      "max": 1.49366226008,
      "times": [
        1.41163010008,
        1.41986214808,
        1.42308217308,
        1.45211610708,
        1.43538616608,
        1.48397429308,
        1.48427500308,
        1.45618322808,
        1.41091515408,
        1.49366226008
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.4387706198799999,
      "stddev": 0.05292686387449125,
      "median": 1.4248707785799999,
      "user": 1.3767431599999997,
      "system": 1.7338383999999998,
      "min": 1.39794963908,
      "max": 1.58113297208,
      "times": [
        1.44037706308,
        1.41859357008,
        1.58113297208,
        1.41255609008,
        1.43114798708,
        1.43712193008,
        1.39794963908,
        1.40406467008,
        1.4119604100799998,
        1.45280186708
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6972556193799999,
      "stddev": 0.014793781115819655,
      "median": 0.69633724308,
      "user": 0.36531176,
      "system": 1.3110274,
      "min": 0.67904781308,
      "max": 0.72813180208,
      "times": [
        0.69565848808,
        0.71283693708,
        0.68915333208,
        0.67904781308,
        0.70061799608,
        0.6990762820799999,
        0.72813180208,
        0.67905854808,
        0.69701599808,
        0.69195899708
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.70864078788,
      "stddev": 0.04289809896145628,
      "median": 0.69636853458,
      "user": 0.36602485999999995,
      "system": 1.3363899,
      "min": 0.68034473608,
      "max": 0.82710125908,
      "times": [
        0.68940878208,
        0.70188747908,
        0.69020240708,
        0.69171172008,
        0.68034473608,
        0.71480174708,
        0.70102534908,
        0.82710125908,
        0.70536575508,
        0.68455864408
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.224 ± 0.054 3.171 3.367 4.78 ± 0.16
pacquet@main 3.177 ± 0.054 3.085 3.278 4.72 ± 0.15
pnpr@HEAD 0.713 ± 0.019 0.676 0.738 1.06 ± 0.04
pnpr@main 0.674 ± 0.019 0.658 0.721 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.22384558678,
      "stddev": 0.05420699946631418,
      "median": 3.2115135390800003,
      "user": 1.9826539199999995,
      "system": 2.06525186,
      "min": 3.17135583908,
      "max": 3.36731034308,
      "times": [
        3.17135583908,
        3.20358709608,
        3.23140141608,
        3.20802887708,
        3.2149982010800002,
        3.19009250908,
        3.22176455508,
        3.36731034308,
        3.19247767208,
        3.23743935908
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.17740576718,
      "stddev": 0.05360269557130354,
      "median": 3.17205868558,
      "user": 1.89985262,
      "system": 2.0774332600000003,
      "min": 3.08460657008,
      "max": 3.27849926208,
      "times": [
        3.08460657008,
        3.11939263008,
        3.16546788608,
        3.16609011308,
        3.2019756520800002,
        3.20022240108,
        3.22115534408,
        3.17802725808,
        3.27849926208,
        3.15862055508
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.71344553578,
      "stddev": 0.019385841027871588,
      "median": 0.7068191835800001,
      "user": 0.37980632000000003,
      "system": 1.3487300600000003,
      "min": 0.6757030150800001,
      "max": 0.73844832808,
      "times": [
        0.73844832808,
        0.70555457608,
        0.7319558740800001,
        0.7336272690800001,
        0.70537201108,
        0.70442703608,
        0.72859448508,
        0.7080837910800001,
        0.70268897208,
        0.6757030150800001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.67382527088,
      "stddev": 0.018939754804808192,
      "median": 0.66901814258,
      "user": 0.34426772,
      "system": 1.30535466,
      "min": 0.65757785408,
      "max": 0.7210882280800001,
      "times": [
        0.66729246708,
        0.65757785408,
        0.65855747308,
        0.6669019580800001,
        0.67074381808,
        0.68302948608,
        0.68104950608,
        0.65769145608,
        0.6743204620800001,
        0.7210882280800001
      ]
    }
  ]
}

Scenario: Isolated linker: fresh resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 654.2 ± 8.6 641.3 667.1 6.07 ± 0.08
pacquet@main 645.4 ± 7.9 627.8 655.9 5.99 ± 0.08
pnpr@HEAD 107.8 ± 0.3 106.8 108.3 1.00
pnpr@main 107.8 ± 0.3 107.2 108.5 1.00 ± 0.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6541802381400001,
      "stddev": 0.008633016095990348,
      "median": 0.65293871864,
      "user": 0.6191783199999998,
      "system": 0.15619388,
      "min": 0.64131437164,
      "max": 0.66711755664,
      "times": [
        0.66711755664,
        0.64131437164,
        0.66328560664,
        0.65158533064,
        0.66174609364,
        0.65014793364,
        0.64193922964,
        0.6534626316400001,
        0.65878882164,
        0.65241480564
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.64538431434,
      "stddev": 0.007931950833139073,
      "median": 0.64685326664,
      "user": 0.60868132,
      "system": 0.15751618,
      "min": 0.6277867406400001,
      "max": 0.65593468464,
      "times": [
        0.65593468464,
        0.65103221664,
        0.6277867406400001,
        0.64284030764,
        0.64065989664,
        0.64829654464,
        0.65228463664,
        0.64540998864,
        0.64852636564,
        0.64107176164
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.10775311140000003,
      "stddev": 0.00029275483734436143,
      "median": 0.10778754764000001,
      "user": 0.02798298,
      "system": 0.0193655,
      "min": 0.10680127564000001,
      "max": 0.10828467064000001,
      "times": [
        0.10773289564,
        0.10751237664,
        0.10758794364,
        0.10780845564000001,
        0.10793474364000001,
        0.10805804764,
        0.10778754764000001,
        0.10779174564,
        0.10745308364,
        0.10782838364000001,
        0.10785341964,
        0.10828467064000001,
        0.10772430964,
        0.10778464264000001,
        0.10811410364000001,
        0.10749029564000001,
        0.10761923564,
        0.10798456264,
        0.10797537564000001,
        0.10810304664,
        0.10785473264,
        0.10760863564,
        0.10755411364,
        0.10758014164,
        0.10680127564000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.10780621348000002,
      "stddev": 0.000329698646010348,
      "median": 0.10777265864,
      "user": 0.0276827,
      "system": 0.01948846,
      "min": 0.10723527964000001,
      "max": 0.10848195364,
      "times": [
        0.10755804264,
        0.10768221264000001,
        0.10801043064,
        0.10803292364000001,
        0.10761431564000001,
        0.10783294364000001,
        0.10790620664,
        0.10834678664000001,
        0.10791375164000001,
        0.10777265864,
        0.10796636164000001,
        0.10746962664000001,
        0.10766485064,
        0.10734244264000001,
        0.10766392764,
        0.10723527964000001,
        0.10806712864000001,
        0.10812607564000001,
        0.10762562664000001,
        0.10839648864000001,
        0.10742861164,
        0.10760116864000001,
        0.10848195364,
        0.10798528264000001,
        0.10743023964000001
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 6.675 ± 0.110 6.435 6.816 1.33 ± 0.03
pacquet@main 6.770 ± 0.168 6.543 7.037 1.35 ± 0.04
pnpr@HEAD 5.027 ± 0.056 4.939 5.095 1.00
pnpr@main 5.135 ± 0.085 5.009 5.342 1.02 ± 0.02
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 6.674515779219999,
      "stddev": 0.1102833686261086,
      "median": 6.680519948920001,
      "user": 3.8049622399999996,
      "system": 3.78382152,
      "min": 6.43451481092,
      "max": 6.81590817092,
      "times": [
        6.61419083792,
        6.81590817092,
        6.6078274949199995,
        6.71369655292,
        6.43451481092,
        6.65818719592,
        6.72917369492,
        6.69462006092,
        6.66641983692,
        6.81061913592
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 6.769811771120001,
      "stddev": 0.16760197089169793,
      "median": 6.77282062992,
      "user": 3.901581840000001,
      "system": 3.78713212,
      "min": 6.54311285792,
      "max": 7.03700794992,
      "times": [
        6.54450761692,
        7.03700794992,
        6.54311285792,
        6.65673606092,
        6.93700683592,
        6.72945472492,
        6.67157451192,
        6.81618653492,
        6.87004765292,
        6.89248296492
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 5.02738178212,
      "stddev": 0.05585895238822975,
      "median": 5.04594656842,
      "user": 2.81862924,
      "system": 3.31663272,
      "min": 4.93856346892,
      "max": 5.09470615792,
      "times": [
        4.98116244792,
        4.94511272892,
        5.07746284192,
        5.01188864292,
        4.93856346892,
        5.0663083559199995,
        5.09470615792,
        5.03463096892,
        5.05726216792,
        5.06672003992
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 5.13540047022,
      "stddev": 0.08471470093327164,
      "median": 5.12530966642,
      "user": 2.8731301399999998,
      "system": 3.4155437199999996,
      "min": 5.00919482992,
      "max": 5.34233356492,
      "times": [
        5.00919482992,
        5.09663347892,
        5.09936209192,
        5.34233356492,
        5.12976417892,
        5.17334530692,
        5.09963955092,
        5.14011289992,
        5.14276364592,
        5.12085515392
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12856
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
4,538.06 ms
(+7.01%)Baseline: 4,240.98 ms
5,089.17 ms
(89.17%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
3,223.85 ms
(+6.37%)Baseline: 3,030.72 ms
3,636.86 ms
(88.64%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,447.11 ms
(+7.29%)Baseline: 1,348.82 ms
1,618.58 ms
(89.41%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
654.18 ms
(+2.45%)Baseline: 638.51 ms
766.21 ms
(85.38%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
3,822.78 ms
(-4.41%)Baseline: 3,999.28 ms
4,799.14 ms
(79.66%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
6,674.52 ms
(-2.28%)Baseline: 6,830.41 ms
8,196.49 ms
(81.43%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
689.89 ms
(+7.84%)Baseline: 639.74 ms
767.69 ms
(89.87%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12856
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,253.47 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
713.45 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
697.26 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
107.75 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,209.95 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
5,027.38 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
805.88 ms
🐰 View full continuous benchmarking report in Bencher

ychampion added 3 commits July 9, 2026 16:24
Allow git-hosted build approvals to survive commit changes without restoring
package-name trust for artifact dep paths.

Constraint: `allowBuilds` package-name rules must stay registry-only.
Rejected: matching git artifacts by package name | restores trust bypass risk.
Confidence: high
Scope-risk: moderate
Directive: Keep TS `createAllowBuildFunction` and pacquet `AllowBuildPolicy` in sync.
Tested: `@pnpm/building.policy` focused Jest suite.
Tested: `@pnpm/installing.deps-installer` compile.
Tested: `cargo fmt --check` for changed pacquet files.
Tested: `git diff --check`.
Tested: `cspell` for changeset and changed TypeScript files.
Not-tested: registry-backed lifecycle Jest; missing `pnpr` binary build hit ENOSPC.
Not-tested: pacquet unit execution; avoid heavy Rust build on full filesystem.
Use explicit String clones when populating git build policy sets so Rust CI's Clippy step passes with warnings denied.

Tested: cargo fmt --check -- pacquet/crates/package-manager/src/build_modules.rs

Tested: cargo clippy -p pacquet-package-manager --lib -- -D warnings

Tested: cargo test -p pacquet-package-manager explicit_allow_by_git_repo_allows_untrusted_package_identity -- --nocapture

Tested: git diff --check
Treat a git dependency path without a fragment as its own repository key, while still stripping fragments from hashed git dependency paths.

Tested: cargo fmt --check -- pacquet/crates/package-manager/src/build_modules.rs pacquet/crates/package-manager/src/build_modules/tests.rs

Tested: cargo test -p pacquet-package-manager explicit_allow_by_git_repo_allows_untrusted_package_identity -- --nocapture

Tested: cargo clippy -p pacquet-package-manager --lib -- -D warnings

Tested: git diff --check
@zkochan
zkochan force-pushed the fix-allow-builds-git-repo branch from b20aa9d to 1f99cbf Compare July 9, 2026 14:27
Copilot AI review requested due to automatic review settings July 9, 2026 14:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qodo-code-review

qodo-code-review Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 51 rules

Grey Divider


Action required

1. git_repo_allow_build_key_from_dep_path matches hashless depPaths ✓ Resolved 📘 Rule violation ⌂ Architecture
Description
Pacquet’s git_repo_allow_build_key_from_dep_path() and pnpm’s TypeScript
getGitRepoAllowBuildKeyFromDepPath() disagree on how to derive a git-repo allowBuild key when a
git depPath lacks a #... ref/hash: pacquet derives a repo key anyway while pnpm does not. This
mismatch changes user-visible approval semantics, either broadening what pacquet considers approved
by repo-level allowBuilds or preventing pnpm repo-level allow/disallow rules from matching
ref-less git depPaths, and conflicts with the intended cross-implementation sync.
Code

pacquet/crates/package-manager/src/build_modules.rs[R303-311]

+fn git_repo_allow_build_key_from_dep_path(dep_path: &str) -> Option<&str> {
+    if !is_git_repo_dep_path(dep_path) {
+        return None;
+    }
+    Some(match dep_path.find('#') {
+        Some(ref_start) => &dep_path[..ref_start],
+        None => dep_path,
+    })
+}
Evidence
The cited implementations encode opposite behaviors for ref-less git depPaths: pnpm’s TypeScript
code returns undefined when depPath.indexOf('#') === -1, which means no git-repo key is produced
and repo-level allow/disallow matching cannot occur for depPaths without #, while pacquet’s Rust
function returns Some(dep_path) when # is absent, explicitly treating the whole depPath as the
repo key. The pacquet unit test further demonstrates (and asserts) this broader matching by
expecting a ref-less git depPath like foo@git+ssh://.../foo.git to be allowed by a repo key, and
the sync rule requires these user-visible semantics to be aligned between pnpm TypeScript and
pacquet Rust.

Rule 713428: Keep pnpm TypeScript and pacquet Rust user-visible behavior changes in sync
Rule 713429: Pacquet must not introduce new user-visible behavior beyond pnpm
pnpm11/building/policy/src/index.ts[124-128]
pacquet/crates/package-manager/src/build_modules.rs[303-311]
pacquet/crates/package-manager/src/build_modules/tests.rs[111-123]
pnpm11/building/policy/src/index.ts[120-132]
pacquet/crates/package-manager/src/build_modules.rs[299-315]
pacquet/crates/package-manager/src/build_modules/tests.rs[111-130]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
pnpm TypeScript and pacquet Rust currently derive git-repo allowBuild keys differently for git depPaths that do not include a `#...` ref/hash: pnpm returns `undefined` (so repo-level allow/disallow rules never match ref-less depPaths) while pacquet returns a repo key anyway (so a repo-level `allowBuilds` entry can approve hashless depPaths). Align the implementations so repo-based approvals/disapprovals behave consistently and do not unintentionally broaden or block matching for ref-less git depPaths.

## Issue Context
- Sync requirement: pnpm TypeScript policy and pacquet Rust behavior must be aligned for user-visible approval semantics.
- pnpm TS: `getGitRepoAllowBuildKeyFromDepPath()` returns `undefined` when `depPath.indexOf('#') === -1`.
- pacquet Rust: `git_repo_allow_build_key_from_dep_path()` returns `Some(dep_path)` when no `#` is present, treating the entire depPath as the repo key.
- Repo-level approvals for git-hosted packages are being introduced/relied upon, so behavior must cover depPaths both with and without a `#ref`.
- A pacquet unit test currently asserts that `policy.check("foo@git+ssh://.../foo.git")` is allowed by a repo key; this test and/or pnpm behavior will need to be updated depending on the chosen alignment.
- Suggested TS-side behavior (if aligning pnpm to pacquet): return `undefined` only when it’s not a git depPath; otherwise return `depPath` when `#` is absent; otherwise return `depPath.slice(0, refStart)`, and add a unit test that a ref-less git depPath matches a repo allow/disallow rule.

## Fix Focus Areas
- pacquet/crates/package-manager/src/build_modules.rs[303-311]
- pacquet/crates/package-manager/src/build_modules.rs[215-239]
- pacquet/crates/package-manager/src/build_modules/tests.rs[111-130]
- pnpm11/building/policy/src/index.ts[124-128]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Repo keys include URL secrets 🐞 Bug ⛨ Security ⭐ New
Description
getGitRepoAllowBuildKeyFromDepPath() derives the git-repo allowBuild key from the raw depPath
prefix, so any embedded URL userinfo (tokens/basic-auth) becomes part of the key and must be
repeated in allowBuilds for repo-level matching to work. This creates a high-risk footgun where
users may paste/commit credentials into pnpm-workspace.yaml just to allow builds for private git
repos.
Code

pnpm11/building/policy/src/index.ts[R124-132]

+function getGitRepoAllowBuildKeyFromDepPath (depPath: string): string | undefined {
+  if (!isGitRepoDepPath(depPath)) return undefined
+  const refStart = depPath.indexOf('#')
+  return refStart === -1 ? depPath : depPath.slice(0, refStart)
+}
+
+function isGitRepoDepPath (depPath: string): boolean {
+  return depPath.startsWith('git+') || depPath.includes('@git+')
+}
Evidence
The policy’s repo-key extraction returns the raw depPath prefix (up to #), so any URL userinfo
remains part of the key; git resolution IDs can include OAuth/basic-auth userinfo, meaning secrets
can be present in depPaths and therefore in required allowBuild keys.

pnpm11/building/policy/src/index.ts[124-132]
pnpm11/resolving/git-resolver/test/createGitHostedPkgId.test.ts[4-11]
pnpm11/core/error/src/index.ts[65-101]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`allowBuilds` repo-key matching uses raw string equality on a depPath-derived key. When the resolved git URL contains userinfo (e.g. `https://TOKEN:x-oa*******[email protected]/...`), the repo key will also contain that secret, effectively forcing users to put credentials into `allowBuilds` for the rule to match.

### Issue Context
- Git resolution IDs can legitimately include embedded userinfo.
- The codebase already has a safe, non-regex credential stripping utility (`redactUrlCredentials`) designed to avoid leaking URL-embedded credentials.

### Fix Focus Areas
- pnpm11/building/policy/src/index.ts[124-132]

### Suggested fix approach
- Canonicalize git repo allowBuild keys by removing URL userinfo for `git+http://` and `git+https://` before storing rules and before matching depPaths.
 - Example: transform `foo@git+https://TOKEN:x-oa*******[email protected]/org/repo.git` -> `foo@git+https://github.com/org/repo.git`.
 - Consider using `redactUrlCredentials()` on just the URL portion (after the `name@` prefix) so ssh usernames like `git@host` are not unintentionally stripped unless you explicitly want that behavior.
- Add a unit test demonstrating that a repo rule without userinfo matches a depPath that includes userinfo (or vice versa), to prevent regressions.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Previous review results

Review updated until commit 9aa03c2

Results up to commit 1f99cbf


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Action required
1. git_repo_allow_build_key_from_dep_path matches hashless depPaths ✓ Resolved 📘 Rule violation ⌂ Architecture
Description
Pacquet’s git_repo_allow_build_key_from_dep_path() and pnpm’s TypeScript
getGitRepoAllowBuildKeyFromDepPath() disagree on how to derive a git-repo allowBuild key when a
git depPath lacks a #... ref/hash: pacquet derives a repo key anyway while pnpm does not. This
mismatch changes user-visible approval semantics, either broadening what pacquet considers approved
by repo-level allowBuilds or preventing pnpm repo-level allow/disallow rules from matching
ref-less git depPaths, and conflicts with the intended cross-implementation sync.
Code

pacquet/crates/package-manager/src/build_modules.rs[R303-311]

+fn git_repo_allow_build_key_from_dep_path(dep_path: &str) -> Option<&str> {
+    if !is_git_repo_dep_path(dep_path) {
+        return None;
+    }
+    Some(match dep_path.find('#') {
+        Some(ref_start) => &dep_path[..ref_start],
+        None => dep_path,
+    })
+}
Evidence
The cited implementations encode opposite behaviors for ref-less git depPaths: pnpm’s TypeScript
code returns undefined when depPath.indexOf('#') === -1, which means no git-repo key is produced
and repo-level allow/disallow matching cannot occur for depPaths without #, while pacquet’s Rust
function returns Some(dep_path) when # is absent, explicitly treating the whole depPath as the
repo key. The pacquet unit test further demonstrates (and asserts) this broader matching by
expecting a ref-less git depPath like foo@git+ssh://.../foo.git to be allowed by a repo key, and
the sync rule requires these user-visible semantics to be aligned between pnpm TypeScript and
pacquet Rust.

Rule 713428: Keep pnpm TypeScript and pacquet Rust user-visible behavior changes in sync
Rule 713429: Pacquet must not introduce new user-visible behavior beyond pnpm
pnpm11/building/policy/src/index.ts[124-128]
pacquet/crates/package-manager/src/build_modules.rs[303-311]
pacquet/crates/package-manager/src/build_modules/tests.rs[111-123]
pnpm11/building/policy/src/index.ts[120-132]
pacquet/crates/package-manager/src/build_modules.rs[299-315]
pacquet/crates/package-manager/src/build_modules/tests.rs[111-130]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
pnpm TypeScript and pacquet Rust currently derive git-repo allowBuild keys differently for git depPaths that do not include a `#...` ref/hash: pnpm returns `undefined` (so repo-level allow/disallow rules never match ref-less depPaths) while pacquet returns a repo key anyway (so a repo-level `allowBuilds` entry can approve hashless depPaths). Align the implementations so repo-based approvals/disapprovals behave consistently and do not unintentionally broaden or block matching for ref-less git depPaths.

## Issue Context
- Sync requirement: pnpm TypeScript policy and pacquet Rust behavior must be aligned for user-visible approval semantics.
- pnpm TS: `getGitRepoAllowBuildKeyFromDepPath()` returns `undefined` when `depPath.indexOf('#') === -1`.
- pacquet Rust: `git_repo_allow_build_key_from_dep_path()` returns `Some(dep_path)` when no `#` is present, treating the entire depPath as the repo key.
- Repo-level approvals for git-hosted packages are being introduced/relied upon, so behavior must cover depPaths both with and without a `#ref`.
- A pacquet unit test currently asserts that `policy.check("foo@git+ssh://.../foo.git")` is allowed by a repo key; this test and/or pnpm behavior will need to be updated depending on the chosen alignment.
- Suggested TS-side behavior (if aligning pnpm to pacquet): return `undefined` only when it’s not a git depPath; otherwise return `depPath` when `#` is absent; otherwise return `depPath.slice(0, refStart)`, and add a unit test that a ref-less git depPath matches a repo allow/disallow rule.

## Fix Focus Areas
- pacquet/crates/package-manager/src/build_modules.rs[303-311]
- pacquet/crates/package-manager/src/build_modules.rs[215-239]
- pacquet/crates/package-manager/src/build_modules/tests.rs[111-130]
- pnpm11/building/policy/src/index.ts[124-128]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Qodo Logo

@qodo-code-review

qodo-code-review Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

CategorySuggestion                                                                                                                                    Impact
Possible issue
✅ Handle hashless git paths
Suggestion Impact:The commit directly changes getGitRepoAllowBuildKeyFromDepPath to return depPath instead of undefined when the git dependency path has no #, matching the suggested fix.

code diff:

-  return refStart === -1 ? undefined : depPath.slice(0, refStart)
+  return refStart === -1 ? depPath : depPath.slice(0, refStart)

Fix the handling of hashless git paths by returning the depPath itself when no #
is found.

pnpm11/building/policy/src/index.ts [124-128]

 function getGitRepoAllowBuildKeyFromDepPath (depPath: string): string | undefined {
   if (!isGitRepoDepPath(depPath)) return undefined
   const refStart = depPath.indexOf('#')
-  return refStart === -1 ? undefined : depPath.slice(0, refStart)
+  return refStart === -1 ? depPath : depPath.slice(0, refStart)
 }

[Suggestion processed]

Suggestion importance[1-10]: 9

__

Why: This suggestion fixes a bug where hashless git repository dependency paths are not correctly processed, failing to match against allowed repository keys (which aligns the TypeScript behavior with the correct Rust implementation).

High
  • More

Mirror the pacquet fix from b20aa9d in the TypeScript CLI: a git
depPath without a ref must match its own hash-less allowBuilds key.
Previously getGitRepoAllowBuildKeyFromDepPath returned undefined for
the no-hash form, so such a depPath matched no rule at all.

Co-Authored-By: Claude Fable 5 <[email protected]>
Copilot AI review requested due to automatic review settings July 9, 2026 14:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 9aa03c2

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

Auto-approved notes - no code suggestions found
- 'approve_pr_on_self_review' flag enabled

@zkochan
zkochan merged commit c70e33e into pnpm:main Jul 9, 2026
15 of 16 checks passed
n3dst4 added a commit to n3dst4/pnpm that referenced this pull request Jul 13, 2026
pnpm 11.11 (pnpm#12856) let an `allowBuilds` entry approve a git dependency's build
scripts by its repository URL without the resolved commit hash, but only for dependencies pnpm
clones, whose dep path looks like `name@git+https://host/org/repo.git#<commit>`. The common
`github:` case is not cloned: pnpm downloads it as a tarball from codeload.github.com, giving a
dep path of the form `name@https://codeload.github.com/org/repo/tar.gz/<commit>`. That form has
neither the `git+` prefix nor the `#` separator the hashless matcher keys on, so the entry was
ignored and the build stayed unapproved unless it pinned the exact commit hash.

Normalize a git-hosted tarball dep path back to the canonical
`name@git+https://host/org/repo.git` key that a clone of the same repository produces, so one
hashless entry approves the package whether pnpm clones it or downloads a tarball. GitHub
(codeload), GitLab archive, and Bitbucket download URLs are covered, and the download host of
each is anchored so a look-alike host cannot be rewritten into an unrelated repository key.
Approving or denying a specific resolved commit by its full tarball dep path continues to work.

The change is mirrored in both stacks, `@pnpm/building.policy` and `pacquet-package-manager`,
with unit tests on each side.

Closes pnpm#12367
n3dst4 added a commit to n3dst4/pnpm that referenced this pull request Jul 13, 2026
pnpm 11.11 (pnpm#12856) let an `allowBuilds` entry approve a git dependency's build
scripts by its repository URL without the resolved commit hash, but only for dependencies pnpm
clones, whose dep path looks like `name@git+https://host/org/repo.git#<commit>`. The common
`github:` case is not cloned: pnpm downloads it as a tarball from codeload.github.com, giving a
dep path of the form `name@https://codeload.github.com/org/repo/tar.gz/<commit>`. That form has
neither the `git+` prefix nor the `#` separator the hashless matcher keys on, so the entry was
ignored and the build stayed unapproved unless it pinned the exact commit hash.

Normalize a git-hosted tarball dep path back to the canonical
`name@git+https://host/org/repo.git` key that a clone of the same repository produces, so one
hashless entry approves the package whether pnpm clones it or downloads a tarball. GitHub
(codeload), GitLab archive, and Bitbucket download URLs are covered, and the download host of
each is anchored so a look-alike host cannot be rewritten into an unrelated repository key.
Approving or denying a specific resolved commit by its full tarball dep path continues to work.

The change is mirrored in both stacks, `@pnpm/building.policy` and `pacquet-package-manager`,
with unit tests on each side.
n3dst4 added a commit to n3dst4/pnpm that referenced this pull request Jul 14, 2026
pnpm 11.11 (pnpm#12856) let an `allowBuilds` entry approve a git dependency's build
scripts by its repository URL without the resolved commit hash, but only for dependencies pnpm
clones, whose dep path looks like `name@git+https://host/org/repo.git#<commit>`. The common
`github:` case is not cloned: pnpm downloads it as a tarball from codeload.github.com, giving a
dep path of the form `name@https://codeload.github.com/org/repo/tar.gz/<commit>`. That form has
neither the `git+` prefix nor the `#` separator the hashless matcher keys on, so the entry was
ignored and the build stayed unapproved unless it pinned the exact commit hash.

Normalize a git-hosted tarball dep path back to the canonical
`name@git+https://host/org/repo.git` key that a clone of the same repository produces, so one
hashless entry approves the package whether pnpm clones it or downloads a tarball. GitHub
(codeload), GitLab archive, and Bitbucket download URLs are covered, and the download host of
each is anchored so a look-alike host cannot be rewritten into an unrelated repository key.
Approving or denying a specific resolved commit by its full tarball dep path continues to work.

The change is mirrored in both stacks, `@pnpm/building.policy` and `pacquet-package-manager`,
with unit tests on each side.
n3dst4 added a commit to n3dst4/pnpm that referenced this pull request Jul 14, 2026
pnpm 11.11 (pnpm#12856) let an `allowBuilds` entry approve a git dependency's build
scripts by its repository URL without the resolved commit hash, but only for dependencies pnpm
clones, whose dep path looks like `name@git+https://host/org/repo.git#<commit>`. The common
`github:` case is not cloned: pnpm downloads it as a tarball from codeload.github.com, giving a
dep path of the form `name@https://codeload.github.com/org/repo/tar.gz/<commit>`. That form has
neither the `git+` prefix nor the `#` separator the hashless matcher keys on, so the entry was
ignored and the build stayed unapproved unless it pinned the exact commit hash.

Normalize a git-hosted tarball dep path back to the canonical
`name@git+https://host/org/repo.git` key that a clone of the same repository produces, so one
hashless entry approves the package whether pnpm clones it or downloads a tarball. GitHub
(codeload), GitLab archive, and Bitbucket download URLs are covered, and the download host of
each is anchored so a look-alike host cannot be rewritten into an unrelated repository key.
Approving or denying a specific resolved commit by its full tarball dep path continues to work.

The change is mirrored in both stacks, `@pnpm/building.policy` and `pacquet-package-manager`,
with unit tests on each side.
n3dst4 added a commit to n3dst4/pnpm that referenced this pull request Jul 21, 2026
pnpm 11.11 (pnpm#12856) let an `allowBuilds` entry approve a git dependency's build
scripts by its repository URL without the resolved commit hash, but only for dependencies pnpm
clones, whose dep path looks like `name@git+https://host/org/repo.git#<commit>`. The common
`github:` case is not cloned: pnpm downloads it as a tarball from codeload.github.com, giving a
dep path of the form `name@https://codeload.github.com/org/repo/tar.gz/<commit>`. That form has
neither the `git+` prefix nor the `#` separator the hashless matcher keys on, so the entry was
ignored and the build stayed unapproved unless it pinned the exact commit hash.

Normalize a git-hosted tarball dep path back to the canonical
`name@git+https://host/org/repo.git` key that a clone of the same repository produces, so one
hashless entry approves the package whether pnpm clones it or downloads a tarball. GitHub
(codeload), GitLab archive, and Bitbucket download URLs are covered, and the download host of
each is anchored so a look-alike host cannot be rewritten into an unrelated repository key.
Approving or denying a specific resolved commit by its full tarball dep path continues to work.

The change is mirrored in both stacks, `@pnpm/building.policy` and `pacquet-package-manager`,
with unit tests on each side.
zkochan pushed a commit to n3dst4/pnpm that referenced this pull request Jul 30, 2026
pnpm 11.11 (pnpm#12856) let an `allowBuilds` entry approve a git dependency's build
scripts by its repository URL without the resolved commit hash, but only for dependencies pnpm
clones, whose dep path looks like `name@git+https://host/org/repo.git#<commit>`. The common
`github:` case is not cloned: pnpm downloads it as a tarball from codeload.github.com, giving a
dep path of the form `name@https://codeload.github.com/org/repo/tar.gz/<commit>`. That form has
neither the `git+` prefix nor the `#` separator the hashless matcher keys on, so the entry was
ignored and the build stayed unapproved unless it pinned the exact commit hash.

Normalize a git-hosted tarball dep path back to the canonical
`name@git+https://host/org/repo.git` key that a clone of the same repository produces, so one
hashless entry approves the package whether pnpm clones it or downloads a tarball. GitHub
(codeload), GitLab archive, and Bitbucket download URLs are covered, and the download host of
each is anchored so a look-alike host cannot be rewritten into an unrelated repository key.
Approving or denying a specific resolved commit by its full tarball dep path continues to work.

The change is mirrored in both stacks, `@pnpm/building.policy` and `pacquet-package-manager`,
with unit tests on each side.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

allowBuilds does not match git-hosted packages by package name — requires exact commit hash

4 participants