Skip to content

fix(audit): surface unresolvable lockfile entries in audit signatures - #13733

Closed
hamodywe wants to merge 7 commits into
pnpm:mainfrom
hamodywe:fix/audit-signatures-unresolvable-lockfile-entries
Closed

hamodywe wants to merge 7 commits into
pnpm:mainfrom
hamodywe:fix/audit-signatures-unresolvable-lockfile-entries

Conversation

@hamodywe

@hamodywe hamodywe commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

lockfileToAuditRequest walks the lockfile via
lockfileWalkerGroupImporterSteps, whose LockfileWalkerStep already separates dependencies it resolved to a packages:/snapshots: entry from ones it couldn't (step.missing) -- but the visitor only ever read .dependencies, so a dangling reference (e.g. an importer still citing [email protected] after packages: was edited to only contain [email protected]) was silently dropped instead of counted or reported.

auditSignatures builds its package list directly from lockfileToAuditRequest's output, so those entries never reached verifySignatures either: the audited/verified counts shrank, missing and invalid stayed empty, and the command exited 0 against a lockfile it could not actually audit.

Collect step.missing at every level of the walk into a new unresolvable field on AuditIndexRequest, and have auditSignatures report each one as an invalid signature issue (there is no registry lookup to attempt for a reference the lockfile itself can't stand behind), folding it into audited so the denominator isn't quietly smaller than the lockfile actually claims.

Closes #13638

Written by an agent (Claude Code, claude-sonnet-5).

Summary

pnpm audit signatures silently dropped lockfile entries it couldn't resolve to a packages:/snapshots: entry, so a dangling dependency reference shrank the audited/verified counts instead of being reported, and the command exited 0 against a lockfile it could not actually audit. Collect those unresolvable entries and report each as an invalid signature issue, folding it into audited so the denominator matches what the lockfile actually claims.

Squash Commit Body

fix(audit): surface unresolvable lockfile entries in audit signatures

lockfileToAuditRequest walks the lockfile via lockfileWalkerGroupImporterSteps,
whose LockfileWalkerStep already separates dependencies it resolved to a
packages:/snapshots: entry from ones it couldn't (step.missing) -- but the
visitor only ever read .dependencies, so a dangling reference (e.g. an
importer still citing [email protected] after packages: was edited to only contain
[email protected]) was silently dropped instead of counted or reported.

auditSignatures builds its package list directly from lockfileToAuditRequest's
output, so those entries never reached verifySignatures either: the
audited/verified counts shrank, missing and invalid stayed empty, and the
command exited 0 against a lockfile it could not actually audit.

Collect step.missing at every level of the walk into a new unresolvable field
on AuditIndexRequest, and have auditSignatures report each one as an invalid
signature issue (there is no registry lookup to attempt for a reference the
lockfile itself can't stand behind), folding it into audited so the
denominator isn't quietly smaller than the lockfile actually claims.

Closes #13638

Checklist

  • I checked the referenced issue and verified that none of the PRs
    already linked to it solves it.
  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
    (Not ported -- I did not find an equivalent audit-signatures code path
    in the Rust port; flagging for a maintainer to confirm whether one exists.)
  • 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.
  • Updated the documentation if needed. (No user-facing docs cover this
    internal audit behavior.)

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

Summary by CodeRabbit

Bug Fixes

  • pnpm audit signatures now reports unresolved lockfile entries as invalid signature issues instead of silently ignoring them.
  • Audit results include affected package names and lockfile integrity errors, including when all entries are unresolved.
  • Invalid issues count toward audited packages and are sorted consistently with other findings.
  • Terminal output safely sanitizes package and registry values.

Tests

  • Added regression coverage for unresolved and duplicate dependency references across lockfiles.

@hamodywe
hamodywe requested a review from zkochan as a code owner August 8, 2026 17:39
@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 →

@coderabbitai

coderabbitai Bot commented Aug 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: 00a7d364-02bb-4daa-a48f-c45c3e3890b5

📥 Commits

Reviewing files that changed from the base of the PR and between f099209 and 3baad38.

⛔ Files ignored due to path filters (1)
  • pnpm11/deps/compliance/commands/test/audit/fixtures/only-broken-lockfile/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • pnpm11/deps/compliance/commands/test/audit/fixtures/only-broken-lockfile/package.json
  • pnpm11/deps/compliance/commands/test/audit/index.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • pnpm11/deps/compliance/commands/test/audit/fixtures/only-broken-lockfile/package.json
  • pnpm11/deps/compliance/commands/test/audit/index.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

pnpm audit signatures now reports unresolved lockfile references as invalid signature issues. The audit index records missing dependency paths separately from resolvable dependencies. Regression coverage verifies mixed and fully unresolved lockfiles.

Changes

Unresolvable lockfile audit entries

Layer / File(s) Summary
Collect unresolved lockfile entries
pnpm11/deps/compliance/audit/src/lockfileToAuditIndex.ts, pnpm11/deps/compliance/audit/test/index.ts
The lockfile walker records unresolved root and nested dependency references. The audit request returns their package names and dependency paths separately from resolvable dependencies. Tests verify exclusion from audit requests and counts, plus deduplication across lockfiles.
Report invalid signature issues
pnpm11/deps/security/signatures/src/verifySignatures.ts, pnpm11/deps/compliance/commands/src/audit/signatures.ts, pnpm11/deps/compliance/commands/test/audit/*, .changeset/audit-signatures-unresolvable-lockfile-entries.md
sortIssue is exported for reuse. auditSignatures converts unresolved references into sorted invalid issues, includes them in the audited count, sanitizes terminal values, and tests mixed and fully unresolved lockfiles. The changeset documents package releases.

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

Sequence Diagram(s)

sequenceDiagram
  participant lockfileToAuditRequest
  participant auditSignatures
  participant sortIssue
  lockfileToAuditRequest->>auditSignatures: return unresolvable dependency references
  auditSignatures->>sortIssue: sort invalid signature issues
  sortIssue-->>auditSignatures: return ordered issues
  auditSignatures-->>auditSignatures: count and render unresolved references as invalid
Loading

Possibly related issues

Suggested labels: product: pnpm@11

Suggested reviewers: zkochan

Merge Risk: ⚪ Minimal · up to 3baad

This change is localized to reporting unresolvable lockfile entries and includes accompanying tests; no actionable merge-blocking risk remains beyond normal checks and review.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@greptile-apps

greptile-apps Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5

The PR does not appear safe to merge until pacquet reports dangling lockfile references consistently with the TypeScript CLI.

Pacquet still constructs its signature-verification list solely from resolved audit entries, so a mixed valid/dangling lockfile can omit the dangling reference and produce a clean result while the TypeScript CLI reports an invalid audit.

Files Needing Attention: pnpm/crates/cli/src/cli_args/audit/request.rs, pnpm/crates/cli/src/cli_args/audit.rs

Reviews (6): Last reviewed commit: "fix(audit): follow the AuditOptions regi..." | Re-trigger Greptile

@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: 6

🧹 Nitpick comments (1)
pnpm11/deps/compliance/audit/src/lockfileToAuditIndex.ts (1)

71-76: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Deduplicate unresolved paths across the main and env lockfile walks.

recordUnresolvable() appends duplicates when both lockfiles reference the same missing DepPath, because each lockfileWalkerGroupImporterSteps() call keeps its own walked set. If packageManagerDependencies in both lockfiles reference the same unresolved pkg/1.0.0, auditSignatures() can add duplicate entries to invalid and increment audited twice. Track unresolved DepPaths in one Map or Set before returning unresolvable.

🤖 Prompt for 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.

In `@pnpm11/deps/compliance/audit/src/lockfileToAuditIndex.ts` around lines 71 -
76, Update recordUnresolvable to deduplicate unresolved DepPath values across
all lockfile walks by tracking each path in a shared Set or Map before adding to
unresolvable. Ensure repeated references to the same DepPath produce only one
entry, so auditSignatures does not count or report it twice.

Sources: Path instructions, MCP tools

🤖 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 @.changeset/audit-signatures-unresolvable-lockfile-entries.md:
- Around line 2-4: Update the changeset entries for `@pnpm/deps.compliance.audit`
and `@pnpm/deps.security.signatures` from patch to minor to reflect their additive
public APIs, while leaving `@pnpm/deps.compliance.commands` as patch.

In `@pnpm11/deps/compliance/audit/src/lockfileToAuditIndex.ts`:
- Around line 29-35: The regular audit() request path must also handle
auditRequest.unresolvable instead of sending only auditRequest.request and
omitting these failures. Update audit() to surface unresolved lockfile entries
consistently with auditSignatures(), or remove unresolvable from the shared
public contract if it is intentionally exclusive to signature auditing; preserve
the existing links behavior.

In `@pnpm11/deps/compliance/audit/test/index.ts`:
- Around line 34-56: Extend the compliance audit tests around
lockfileToAuditRequest() with a nested nextStep.missing case, verifying
unresolved entries are reported and counted. Add command-level coverage for
auditSignatures() that checks audited aggregation, sorted invalid results, and
exit code 1, including a lockfile containing only unresolved entries.

In `@pnpm11/deps/compliance/commands/src/audit/signatures.ts`:
- Around line 41-46: Move the auditRequest.unresolvable handling before the
empty-packages guard in the audit flow, so unresolved-only lockfiles are
reported as invalid issues and contribute to audited instead of triggering
AUDIT_NO_PACKAGES. Preserve the existing behavior for requests with no packages
and for resolvable references.
- Around line 47-51: The unresolvable-issue mapping must escape raw lockfile
values before they reach renderSignatureVerificationResult(). Update the mapping
around unresolvableIssues and apply terminal-safe encoding such as
JSON.stringify to depPath and name wherever they populate the rendered name or
reason, while preserving the underlying audit data and registry lookup behavior.
- Around line 41-55: Update the Rust signature-audit flow in `auditSignatures`
to mirror the TypeScript handling of `auditRequest.unresolvable`: create invalid
signature issues with the package name, selected registry, empty version, and
lockfile-missing-entry reason, increment `audited`, append them to `invalid`,
sort with the existing issue ordering, and preserve the nonzero exit behavior.
If this parity cannot be implemented, explicitly document it as deferred pacquet
parity in the changeset.

---

Nitpick comments:
In `@pnpm11/deps/compliance/audit/src/lockfileToAuditIndex.ts`:
- Around line 71-76: Update recordUnresolvable to deduplicate unresolved DepPath
values across all lockfile walks by tracking each path in a shared Set or Map
before adding to unresolvable. Ensure repeated references to the same DepPath
produce only one entry, so auditSignatures does not count or report it twice.
🪄 Autofix

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: c10f5093-72bf-42c2-93ca-e5c02b5f01ed

📥 Commits

Reviewing files that changed from the base of the PR and between 4e68132 and dd97ed9.

📒 Files selected for processing (5)
  • .changeset/audit-signatures-unresolvable-lockfile-entries.md
  • pnpm11/deps/compliance/audit/src/lockfileToAuditIndex.ts
  • pnpm11/deps/compliance/audit/test/index.ts
  • pnpm11/deps/compliance/commands/src/audit/signatures.ts
  • pnpm11/deps/security/signatures/src/verifySignatures.ts

hamodywe added a commit to hamodywe/pnpm that referenced this pull request Aug 8, 2026
Applies the review feedback on pnpm#13733:

- De-duplicate unresolvable depPaths across the main and env lockfile
  walks, so a reference broken in both is reported and counted once.
- Stop throwing AUDIT_NO_PACKAGES when the lockfile's references are
  all unresolvable: that is a finding to report (exit 1), not an empty
  install. verifySignatures handles the empty package list without any
  network access, so the unresolvable-only path still works offline.
- Strip control characters from lockfile/registry-sourced strings
  (name, version, registry, reason) before rendering the signature
  tables, so a forged entry cannot inject terminal escapes or break
  the table layout.
- Document on AuditIndexRequest.unresolvable why the bulk
  vulnerability audit intentionally does not consume it: its output is
  the registry's advisory report, which has no slot for
  lockfile-integrity failures, and inventing one would break --json
  consumers. Signature auditing is where those belong.
- Bump `@pnpm/deps.compliance.audit` and `@pnpm/deps.security.signatures`
  to minor: the new AuditIndexRequest field and the sortIssue export
  are additive public API.
- Extend tests: nested (below-importer) unresolvable references,
  cross-lockfile de-duplication, and two command-level cases covering
  aggregation into audited/invalid, sorting, exit code 1, and the
  unresolvable-only lockfile that previously died on AUDIT_NO_PACKAGES.

Written by an agent (Claude Code, claude-sonnet-5).
greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 11, 2026
@hamodywe

Copy link
Copy Markdown
Contributor Author

Ping on this one - the review rounds are done (CodeRabbit's points are all addressed and greptile signed off after the Rust-parity question was answered in the changeset). It's waiting on a maintainer read whenever there's bandwidth.

@greptile-apps
greptile-apps Bot dismissed their stale review August 17, 2026 17:47

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@hamodywe

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

All six points from the first pass are addressed and the threads are resolved with the details. The last one — asserting that invalid is actually sorted — was a real gap and is now covered by a revert-checked test, pushed in 3baad38222.

hamodywe and others added 7 commits September 25, 2026 11:05
lockfileToAuditRequest walks the lockfile via
lockfileWalkerGroupImporterSteps, whose LockfileWalkerStep already
separates dependencies it resolved to a packages:/snapshots: entry
from ones it couldn't (step.missing) -- but the visitor only ever read
.dependencies, so a dangling reference (e.g. an importer still citing
[email protected] after packages: was edited to only contain [email protected])
was silently dropped instead of counted or reported.

auditSignatures builds its package list directly from
lockfileToAuditRequest's output, so those entries never reached
verifySignatures either: the audited/verified counts shrank, missing
and invalid stayed empty, and the command exited 0 against a lockfile
it could not actually audit.

Collect step.missing at every level of the walk into a new
unresolvable field on AuditIndexRequest, and have auditSignatures
report each one as an invalid signature issue (there is no registry
lookup to attempt for a reference the lockfile itself can't stand
behind), folding it into `audited` so the denominator isn't quietly
smaller than the lockfile actually claims.

Closes pnpm#13638

Written by an agent (Claude Code, claude-sonnet-5).
Applies the review feedback on pnpm#13733:

- De-duplicate unresolvable depPaths across the main and env lockfile
  walks, so a reference broken in both is reported and counted once.
- Stop throwing AUDIT_NO_PACKAGES when the lockfile's references are
  all unresolvable: that is a finding to report (exit 1), not an empty
  install. verifySignatures handles the empty package list without any
  network access, so the unresolvable-only path still works offline.
- Strip control characters from lockfile/registry-sourced strings
  (name, version, registry, reason) before rendering the signature
  tables, so a forged entry cannot inject terminal escapes or break
  the table layout.
- Document on AuditIndexRequest.unresolvable why the bulk
  vulnerability audit intentionally does not consume it: its output is
  the registry's advisory report, which has no slot for
  lockfile-integrity failures, and inventing one would break --json
  consumers. Signature auditing is where those belong.
- Bump `@pnpm/deps.compliance.audit` and `@pnpm/deps.security.signatures`
  to minor: the new AuditIndexRequest field and the sortIssue export
  are additive public API.
- Extend tests: nested (below-importer) unresolvable references,
  cross-lockfile de-duplication, and two command-level cases covering
  aggregation into audited/invalid, sorting, exit code 1, and the
  unresolvable-only lockfile that previously died on AUDIT_NO_PACKAGES.

Written by an agent (Claude Code, claude-sonnet-5).
CodeRabbit and Greptile both flagged that the Rust CLI's audit-
signatures request builder still has the same unresolvable-entry gap
this PR fixes on the TypeScript side, and Greptile scored the PR
not-yet-mergeable on that basis. Document the gap explicitly in the
changeset, per the review's own suggested resolution, rather than
leave it unacknowledged.
Per review: the comments narrated the condition and the assertions sitting
directly below them, which is the kind of duplication that drifts as soon
as either side changes.

Kept the two that say something the code does not: why an unresolvable
reference is reported instead of looked up in a registry, and what makes
the fixture lockfile inconsistent.

Comments only -- no line of code changed.

Written by an agent (Claude Code, claude-fable-5).
…ockfile order

The unresolvable entries are folded into result.invalid through sortIssue, but
nothing pinned that: the only-unresolvable fixture carried a single entry, so
the sort could have been dropped without a test noticing.

Give the fixture a second unresolvable reference, absent-pkg, listed after
gone-pkg in the lockfile but sorting before it. LockfileWalkerStep.missing
preserves the order the references are declared in, so the rendered order can
only be absent-pkg first if the sort actually ran.

Revert-checked: dropping .sort(sortIssue) makes the new assertion fail with
absent-pkg rendered at index 815 instead of ahead of gone-pkg at 317.
upstream renamed AuditOptions.registries to registriesByScope, so the
unresolvable-entry branch added by this PR no longer typechecks against
current main and TS CI fails with TS2339. Read the renamed field.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@zkochan
zkochan force-pushed the fix/audit-signatures-unresolvable-lockfile-entries branch from d7ee05a to d15ba38 Compare September 25, 2026 09:17

@zkochan zkochan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (2) 🔗 Cross-repo conflicts (1) 📜 Skill insights (1)

Grey Divider


Action required

1. Broken lockfiles pass audit in v12 📜 Skill insight ⌂ Architecture
Description
audit signatures in v12 registers dependency keys before checking for a snapshot, so it can send a
dangling reference to the registry as an ordinary package while this PR marks it invalid only in
v11. If that package has a valid registry signature, the Rust command can exit successfully for the
broken lockfile, and no Rust regression test covers this scenario.
Code

pnpm11/deps/compliance/commands/src/audit/signatures.ts[R49-52]

+  if (auditRequest.unresolvable.length > 0) {
+    const unresolvableIssues: SignatureIssue[] = auditRequest.unresolvable.map(({ name, depPath }) => ({
+      name,
+      registry: pickRegistryForPackage(opts.registriesByScope, name),
Relevance

●●● Strong

Cross-stack audit defects and regression coverage are commonly aligned across TypeScript and Rust
implementations.

PR-#13832

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rules 713428 and 3365404 require shared CLI defects and their regression coverage to be aligned
across v11 and v12. The changed TypeScript path explicitly creates invalid issues for unresolved
references, while the Rust request traversal registers a dependency key before children discovers
that its snapshot is absent; signature_packages then forwards that key to normal registry
verification, where a valid registry signature can produce no invalid issue, and the PR adds tests
only under pnpm11.

Rule 713428: Keep pnpm v11 and v12 observable behavior aligned when fixing shared bugs
pnpm11/deps/compliance/commands/src/audit/signatures.ts[49-57]
pnpm/crates/cli/src/cli_args/audit/request.rs[260-279]
pnpm/crates/cli/src/cli_args/audit/advisories.rs[204-218]
pnpm/crates/cli/src/cli_args/audit/importers.rs[49-82]
pnpm/crates/cli/src/cli_args/audit/signatures.rs[124-148]
Skill: review-code

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

## Issue description
The dangling-lockfile-reference defect affects both implementations, but this PR only makes the TypeScript command fail closed. The Rust implementation can still treat a dependency missing from `snapshots` as an ordinary registry package, and it has no equivalent regression coverage.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/audit/request.rs[260-279]
- pnpm/crates/cli/src/cli_args/audit/importers.rs[49-82]
- pnpm/crates/cli/src/cli_args/audit/signatures.rs[115-148]
- pnpm/crates/cli/tests/suite/audit/signatures.rs[1-302]

## Recommended Fix
Carry unresolved dependency references through the Rust audit request, convert them into invalid signature issues, include them in the audited count, and return a nonzero exit code. Add a Rust CLI regression test using a dangling lockfile reference and assert the count, invalid issue, diagnostic output, and exit code; alternatively, explicitly document the deferred v12 implementation in the PR description.

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



Remediation recommended

2. Terminal sanitizer precedes its usage 📘 Rule violation ⚙ Maintainability
Description
sanitizeForTerminal is a new top-level TypeScript function declaration at line 73, while its first
same-file calls are at lines 90 and 97. A later reader encounters the helper before either rendering
context that explains where its sanitization is required.
Code

pnpm11/deps/compliance/commands/src/audit/signatures.ts[R73-75]

+function sanitizeForTerminal (value: string): string {
+  return value.replace(CONTROL_CHARS, '')
+}
Relevance

●●● Strong

This is a deterministic local ordering/style correction explicitly required by the repository rule.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 713432 requires a used top-level TypeScript function declaration to appear after at least one
same-file usage. The new declaration is at lines 73-75, but its calls occur later in the table
rendering at lines 90 and 97.

Rule 713432: Declare TypeScript functions only after their first usage
pnpm11/deps/compliance/commands/src/audit/signatures.ts[73-75]
pnpm11/deps/compliance/commands/src/audit/signatures.ts[90-97]

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

## Issue description
The new top-level `sanitizeForTerminal` declaration appears before every same-file usage, contrary to the required TypeScript declaration order.

## Fix Focus Areas
- pnpm11/deps/compliance/commands/src/audit/signatures.ts[73-75]
- pnpm11/deps/compliance/commands/src/audit/signatures.ts[77-111]

## Recommended Fix
Move the `sanitizeForTerminal` function declaration below `renderSignatureVerificationResult`, leaving the control-character regular expression available to the moved function.

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


3. Release note merges old and new behavior 📘 Rule violation ⚙ Maintainability
Description
The changeset's only sentence appends rather than silently dropping them to the new nonzero-exit
behavior. Readers encounter the former behavior as a trailing contrast instead of a separate
past-tense sentence, making the fix history harder to scan.
Code

.changeset/audit-signatures-unresolvable-lockfile-entries.md[8]

+`pnpm audit signatures` now reports lockfile entries that cannot be resolved to a package in the lockfile as invalid entries with a nonzero exit code, rather than silently dropping them [pnpm/pnpm#13638](https://github.com/pnpm/pnpm/issues/13638).
Relevance

●●● Strong

Recent changeset precedents accept separating old behavior from new behavior in release notes.

PR-#14932
PR-#15600

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 3058498 requires previous buggy behavior to appear in its own past-tense sentence rather than
as a trailing rather than clause. The added changeset uses exactly that prohibited combined
construction.

Rule 3058498: Describe previous buggy behavior in a separate past-tense sentence
.changeset/audit-signatures-unresolvable-lockfile-entries.md[8-8]

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

## Issue description
The bug-fix release note combines the corrected behavior and the former behavior in one sentence using `rather than`.

## Fix Focus Areas
- .changeset/audit-signatures-unresolvable-lockfile-entries.md[8-8]

## Recommended Fix
End the first sentence after the nonzero exit-code behavior. Add a separate past-tense sentence such as `Previously, the command silently dropped these entries.`

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


4. Audit output disguises package names 🐞 Bug ⛨ Security
Description
sanitizeForTerminal removes C0/C1 bytes but leaves Unicode bidirectional formatting characters in
the lockfile-derived depPath embedded in each invalid-signature reason. A repository can place
U+202E or related formatting controls in an unresolvable dependency reference, which reaches the
invalid-signature table and visually reorders the package identity in terminals or CI logs.
Code

pnpm11/deps/compliance/commands/src/audit/signatures.ts[54]

+      reason: `Lockfile entry "${depPath}" has no corresponding package in the lockfile's packages/snapshots section. The lockfile may be broken or tampered with; try reinstalling with --frozen-lockfile to confirm.`,
Relevance

●●● Strong

Recent security precedents accept sanitizing repository-controlled terminal output to prevent
control-sequence injection.

PR-#11384

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The walker records raw missing dependency paths from the untrusted lockfile, and the new audit issue
interpolates that path directly into reason. Although the table passes the reason through
sanitizeForTerminal, its regular expression covers only C0, DEL, and C1 ranges; Unicode
bidirectional formatting characters remain and reach the rendered table.

pnpm11/deps/compliance/audit/src/lockfileToAuditIndex.ts[93-98]
pnpm11/deps/compliance/commands/src/audit/signatures.ts[50-57]
pnpm11/deps/compliance/commands/src/audit/signatures.ts[66-75]
pnpm11/deps/compliance/commands/src/audit/signatures.ts[94-97]

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

## Issue description
Unresolvable dependency references are attacker-controlled lockfile text and are rendered in terminal output. The current sanitizer removes C0/C1 characters but preserves Unicode bidirectional formatting characters, allowing package identities to be visually reordered in terminal and CI output.

## Fix Focus Areas
- pnpm11/deps/compliance/commands/src/audit/signatures.ts[50-54]
- pnpm11/deps/compliance/commands/src/audit/signatures.ts[66-75]

## Recommended Fix
Extend the terminal sanitizer to remove Unicode bidirectional formatting and isolation characters, including U+061C, U+200E–U+200F, U+202A–U+202E, and U+2066–U+2069, before any lockfile- or registry-derived value is passed to the table renderer. Add a regression test with an unresolvable dependency containing a bidirectional override and assert that the rendered output contains no such formatting character.

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


View medium (1)
5. Docs omit lockfile audit failures 🔗 Cross-repo conflict ≡ Correctness
Description
auditSignatures now adds unresolvable lockfile references to invalid and includes them in the
audited count without updating pnpm.io's command contract. When a lockfile contains a dangling
reference, pnpm exits with code 1 and emits a synthetic invalid JSON entry even though both current
and versioned documentation say this occurs only for missing or invalid registry signatures.
Code

pnpm11/deps/compliance/commands/src/audit/signatures.ts[R54-57]

+      reason: `Lockfile entry "${depPath}" has no corresponding package in the lockfile's packages/snapshots section. The lockfile may be broken or tampered with; try reinstalling with --frozen-lockfile to confirm.`,
+    }))
+    result.audited += unresolvableIssues.length
+    result.invalid = [...result.invalid, ...unresolvableIssues].sort(sortIssue)
Relevance

●● Moderate

Documentation contract changes are plausible, but no closely matching cross-repository documentation
precedent was found.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR explicitly creates invalid issues for unresolved lockfile references and increments the
audited count, while pnpm.io limits the documented exit-code contract to invalid or absent registry
signatures. The same outdated contract is published in both the current and versioned pnpm 11
documentation.

pnpm -> pnpm.io
pnpm11/deps/compliance/commands/src/audit/signatures.ts[47-62]
External repo: pnpm/pnpm.io, docs/cli/audit.md [37-39]
External repo: pnpm/pnpm.io, versioned_docs/version-11.x/cli/audit.md [37-39]

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

## Issue description
The signature audit now reports unresolvable lockfile references as invalid entries and exits with code 1, but pnpm.io documents only missing or invalid registry signatures as failure conditions.

## Fix Focus Areas
- /cross_repos/pnpm.io/docs/cli/audit.md[37-39]
- /cross_repos/pnpm.io/versioned_docs/version-11.x/cli/audit.md[37-39]

## Recommended Fix
Update both the current and pnpm 11 audit documentation to state that dangling lockfile references also produce invalid entries and a nonzero exit code. Mention that these entries appear in the machine-readable `invalid` collection so JSON consumers understand the broadened schema semantics.

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


Grey Divider

Context sources
✅ Compliance rules (platform): 53 rules
✅ Skills: review-code
✅ Cross-repo context — repo relationships
  Explored: repo: pnpm/pnpm.io (sha: e3bc12c9) — View relationship
Review mode: ⚖️ Balanced: This changes audit integrity reporting across lockfile traversal, signature verification, counts, sorting, and terminal output, creating meaningful security-sensitive behavior with several interacting paths.
ⓘ  1 issues published inline · 5 in summary

Grey Divider

Tip of the day
💡 Did you know, you can enable the Remediation agent and Qodo fixes findings in a dedicated fix PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment on lines +49 to +52
if (auditRequest.unresolvable.length > 0) {
const unresolvableIssues: SignatureIssue[] = auditRequest.unresolvable.map(({ name, depPath }) => ({
name,
registry: pickRegistryForPackage(opts.registriesByScope, name),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Broken lockfiles pass audit in v12 📜 Skill insight ⌂ Architecture

audit signatures in v12 registers dependency keys before checking for a snapshot, so it can send a
dangling reference to the registry as an ordinary package while this PR marks it invalid only in
v11. If that package has a valid registry signature, the Rust command can exit successfully for the
broken lockfile, and no Rust regression test covers this scenario.
Agent Prompt
## Issue description
The dangling-lockfile-reference defect affects both implementations, but this PR only makes the TypeScript command fail closed. The Rust implementation can still treat a dependency missing from `snapshots` as an ordinary registry package, and it has no equivalent regression coverage.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/audit/request.rs[260-279]
- pnpm/crates/cli/src/cli_args/audit/importers.rs[49-82]
- pnpm/crates/cli/src/cli_args/audit/signatures.rs[115-148]
- pnpm/crates/cli/tests/suite/audit/signatures.rs[1-302]

## Recommended Fix
Carry unresolved dependency references through the Rust audit request, convert them into invalid signature issues, include them in the audited count, and return a nonzero exit code. Add a Rust CLI regression test using a dangling lockfile reference and assert the count, invalid issue, diagnostic output, and exit code; alternatively, explicitly document the deferred v12 implementation in the PR description.

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

@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.

@zkochan

zkochan commented Sep 26, 2026

Copy link
Copy Markdown
Member

the referenced issue is fixed.

@zkochan zkochan closed this Sep 26, 2026
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.

pnpm audit signatures silently excludes packages it cannot resolve in the lockfile (fail-open, exit 0)

2 participants