Skip to content

fix(security): add trusted root npm audit - #8131

Merged
cv merged 20 commits into
mainfrom
fix/trusted-root-npm-audit-8116
Aug 4, 2026
Merged

fix(security): add trusted root npm audit#8131
cv merged 20 commits into
mainfrom
fix/trusted-root-npm-audit-8116

Conversation

@sandl99

@sandl99 sandl99 commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

The trusted npm audit now covers the NemoClaw CLI production graph in addition to reviewed archives and pinned runtime graphs. It validates the target lock before installation, verifies installed identities, checks registry signatures, and applies the existing advisory policy without a same-tree exemption.

Related Issue

Related to #8116.

Changes

  • Validate the root production lock before npm ci, including registry origin, nested shrinkwrap rejection, production reachability, peer dependencies, optional overrides, and dev: true misuse.
  • Materialize the target production graph with lifecycle scripts disabled and verify installed package names and versions against the unchanged copied lock.
  • Audit the root graph with the existing severity policy and npm registry-signature check.
  • Run the root audit for both separate PR targets and same-tree main executions.
  • Add negative coverage for malformed locks, registry drift, shrinkwrap delegation, missing production dependencies, installed-identity drift, and advisory failures.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Docs updated for user-facing behavior changes
  • Docs not applicable — justification: This changes internal trusted CI dependency validation. It does not change a supported user-facing API, command, configuration, default, or error.
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging)
  • Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: Security review for commit 370fd3679584049f87956c2139a9b7c02fede4c9 passed all nine categories with no findings.
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue: None requested; every required check must pass.

Documentation Writer Review

  • Documentation writer subagent reviewed the completed changes
  • Result: no-docs-needed
  • Evidence: Reviewed the four-file diff at commit 370fd3679584049f87956c2139a9b7c02fede4c9 against current main abae71044a3038f7094944be5ae25d8d37b25155. It changes internal npm audit enforcement and regression tests only. No user-visible CLI, configuration, workflow, default, supported behavior, or documentation changes. Changed comments, errors, and test titles follow the writing guide and controlled vocabulary. GitHub CI provides validation for this commit.
  • Agent: Codex Desktop independent documentation writer

Security Review

  • Result: PASS
  • Reviewed commit: 370fd3679584049f87956c2139a9b7c02fede4c9
  • Base commit: abae71044a3038f7094944be5ae25d8d37b25155
  • Secrets and credentials: PASS — no credentials or secret material are added.
  • Input validation and data sanitization: PASS — lock structure, dependency names, registry origin, paths, integrity, and installed identities are validated.
  • Authentication and authorization: PASS — no authentication or authorization surface changes.
  • Dependencies and third-party libraries: PASS — no dependency is added; production packages remain integrity-pinned and signature-checked.
  • Error handling and logging: PASS — failures stop the audit with specific errors and do not expose credentials.
  • Cryptography and data protection: PASS — lock identities use SHA-256 and npm integrity values use SHA-512.
  • Configuration and security controls: PASS — lifecycle scripts stay disabled during installation and nested shrinkwrap delegation is rejected.
  • Security testing: PASS — denial paths cover registry drift, dependency reachability, development mislabeling, shrinkwrap, identity mismatch, signatures, and blocking advisories.
  • System security: PASS — the former deferred digest constants and both same-tree deferral functions are removed; the root production graph is audited unconditionally.
  • Agent: Codex Desktop independent security reviewer

DGX Station Hardware Evidence

  • Tested on DGX Station
  • Tested commit: Not applicable
  • Station profile/scenario: Not applicable
  • Result: Not applicable
  • Supporting evidence: Not applicable

Verification

  • PR description includes a Signed-off-by: line and every commit appears as Verified in GitHub — verification is pending after commit 370fd3679584049f87956c2139a9b7c02fede4c9 is pushed.
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run validate:pr passed after refreshing origin/main when hooks were skipped or unavailable — commit hooks passed; pre-push is pending.
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — GitHub CI is authoritative and pending.
  • Applicable broad gate passed — GitHub CI is authoritative and pending.
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, credentials, or private keys are added by this diff.
  • npm run docs builds without warnings (doc changes only) — Not applicable; no documentation file changed.
  • Doc pages follow the style guide (doc changes only) — independent writing review passed.
  • New doc pages include SPDX header and frontmatter (new pages only) — Not applicable; no documentation page was added.

GitHub CI is authoritative.
No duplicate local test, documentation, build, or typecheck suite ran after the merge refresh.


Signed-off-by: San Dang sdang@nvidia.com
Signed-off-by: Prekshi Vyas prekshiv@nvidia.com
Signed-off-by: Carlos Villela cvillela@nvidia.com

@sandl99 sandl99 added the area: security Security controls, permissions, secrets, or hardening label Aug 3, 2026
@sandl99 sandl99 self-assigned this Aug 3, 2026
@coderabbitai

coderabbitai Bot commented Aug 3, 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
📝 Walkthrough

Walkthrough

The workflow validates production lock reachability, materializes and audits distinct target source graphs, verifies signatures and content hashes, records provenance, and applies shared report-threshold checks. It also validates a bounded audit exception.

Changes

Source Graph Audit

Layer / File(s) Summary
Materialize and verify source graph
scripts/audit-reviewed-npm-graph.mts, scripts/lib/reviewed-npm-archive.mts, test/reviewed-npm-audit-workflow.test.ts
Production dependency reachability, development-package filtering, registry metadata, shrinkwrap records, installed-lock identities, and source lockfile hashes are validated.
Audit materialized graph
scripts/audit-reviewed-npm-graph.mts, test/reviewed-npm-audit-workflow.test.ts
Materialized graphs use injectable audit and signature-verification operations. Reports include source-graph identity, provenance, report paths, and audit results.
Integrate target source-graph audit
scripts/audit-reviewed-npm-graph.mts, ci/npm-audit-exceptions.json, test/reviewed-npm-audit-workflow.test.ts, test/reviewed-npm-audit.test.ts
The workflow audits distinct trusted and target roots, skips identical trees and aliases, validates source-graph exceptions, and applies shared report-threshold checks. Tests verify the checked-in bounded brace-expansion exception.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ReviewedNpmWorkflow
  participant reviewed-npm-archive
  participant materializeSourceGraph
  participant auditMaterializedSourceGraph
  participant SignatureVerifier
  participant ReportValidator
  ReviewedNpmWorkflow->>reviewed-npm-archive: validate production lock packages
  reviewed-npm-archive-->>ReviewedNpmWorkflow: verified package specifications
  ReviewedNpmWorkflow->>materializeSourceGraph: materialize target source graph
  materializeSourceGraph-->>ReviewedNpmWorkflow: installed and hash-verified graph
  ReviewedNpmWorkflow->>auditMaterializedSourceGraph: audit materialized graph
  auditMaterializedSourceGraph->>SignatureVerifier: verify audit signature
  SignatureVerifier-->>auditMaterializedSourceGraph: signature result
  auditMaterializedSourceGraph-->>ReviewedNpmWorkflow: source-graph audit report
  ReviewedNpmWorkflow->>ReportValidator: validate all reports against threshold
Loading

Possibly related PRs

Suggested labels: dependencies

Suggested reviewers: jason-ma-nv, cv

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the security fix that adds trusted root npm auditing, which is the main change in the pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/trusted-root-npm-audit-8116

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

@github-code-quality

github-code-quality Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in commit 370fd36 in the fix/trusted-root-npm... branch remains at 96%, unchanged from commit 7e60e11 in the main branch.

TypeScript / code-coverage/cli

The overall coverage in commit 370fd36 in the fix/trusted-root-npm... branch remains at 81%, unchanged from commit 7e60e11 in the main branch.

Show a code coverage summary of the most impacted files.
File main 7e60e11 fix/trusted-root-npm... 370fd36 +/-
src/lib/inferen...ompatibility.ts 95% 94% -1%
src/lib/shields/index.ts 70% 70% 0%
src/lib/messagi...nnels/policy.ts 100% 100% 0%
src/lib/sandbox...rce-identity.ts 88% 88% 0%
src/lib/state/config-io.ts 93% 93% 0%
src/lib/platform.ts 84% 89% +5%

Updated August 04, 2026 03:36 UTC

@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

🧹 Nitpick comments (2)
scripts/audit-reviewed-npm-graph.mts (1)

241-248: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider an options object for materializeSourceGraph.

The function takes four positional string paths plus an injected installer. Callers cannot distinguish sourcePackage, sourceLock, and destination at the call site without checking the declaration. The sibling helper auditMaterializedSourceGraph already uses an options object plus a separate dependencies argument. Aligning both keeps one shape for the new exported surface.

♻️ Proposed signature change
 export function materializeSourceGraph(
-  sourcePackage: string,
-  sourceLock: string,
-  destination: string,
-  registryOrigin: string,
-  installProductionDependencies: (directory: string) => void = (directory) =>
-    void run("npm", ["ci", "--ignore-scripts", "--omit=dev", "--no-audit", "--no-fund"], directory),
+  options: Readonly<{
+    destination: string;
+    registryOrigin: string;
+    sourceLock: string;
+    sourcePackage: string;
+  }>,
+  dependencies: Readonly<{
+    installProductionDependencies?: (directory: string) => void;
+  }> = {},
 ): string {
🤖 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 `@scripts/audit-reviewed-npm-graph.mts` around lines 241 - 248, Update the
exported materializeSourceGraph function to accept an options object containing
sourcePackage, sourceLock, destination, registryOrigin, and the injectable
installProductionDependencies value, rather than multiple positional arguments.
Align its parameter shape with auditMaterializedSourceGraph while preserving the
existing defaults and behavior, and update all call sites accordingly.
scripts/lib/reviewed-npm-archive.mts (1)

349-360: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Replace the positional boolean flags with a named options argument.

readReviewedLockPackages now takes two trailing booleans. The call site reads request.omitDev, true, which does not state which guard the true disables. An options object states the intent and prevents a future argument-order mistake.

♻️ Proposed refactor
 function readReviewedLockPackages(
   packages: Readonly<Record<string, Record<string, unknown>>>,
   lockfilePath: string,
   registryOrigin: string,
-  omitDev = false,
-  allowEmpty = false,
+  options: Readonly<{ allowEmpty?: boolean; omitDev?: boolean }> = {},
 ): readonly ReviewedNpmArchiveRequest[] {
   return readReviewedLockPackages(
     readReviewedLock(request.lockfilePath),
     request.lockfilePath,
     registryOrigin,
-    request.omitDev,
-    true,
+    { allowEmpty: true, omitDev: request.omitDev },
   ).map(({ packageSpec }) => packageSpec);

Update the internal references to omitDev and allowEmpty inside the reader, and the existing call at Line 413.

🤖 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 `@scripts/lib/reviewed-npm-archive.mts` around lines 349 - 360, Replace the
positional boolean arguments passed to readReviewedLockPackages with a named
options object, explicitly identifying omitDev and the true value’s allowEmpty
meaning. Update readReviewedLockPackages to read omitDev and allowEmpty from
that options object, and apply the same change to the existing call near the
other reference at line 413.
🤖 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 `@scripts/audit-reviewed-npm-graph.mts`:
- Around line 449-454: Update shouldAuditTargetSourceGraph to normalize both
trustedRepoRoot and targetRepoRoot with fs.realpathSync before comparing them,
replacing the asymmetric path.resolve usage while preserving the boolean
same-tree exemption behavior.

In `@test/reviewed-npm-audit-workflow.test.ts`:
- Around line 187-215: Update the test around materializeSourceGraph to pass a
no-op installer stub, preventing a real npm ci subprocess and preserving the
lockfile assertion. Reuse the existing writeProductionSourceGraph fixture helper
used by the sibling tests instead of duplicating the manifest and lockfile
setup.

---

Nitpick comments:
In `@scripts/audit-reviewed-npm-graph.mts`:
- Around line 241-248: Update the exported materializeSourceGraph function to
accept an options object containing sourcePackage, sourceLock, destination,
registryOrigin, and the injectable installProductionDependencies value, rather
than multiple positional arguments. Align its parameter shape with
auditMaterializedSourceGraph while preserving the existing defaults and
behavior, and update all call sites accordingly.

In `@scripts/lib/reviewed-npm-archive.mts`:
- Around line 349-360: Replace the positional boolean arguments passed to
readReviewedLockPackages with a named options object, explicitly identifying
omitDev and the true value’s allowEmpty meaning. Update readReviewedLockPackages
to read omitDev and allowEmpty from that options object, and apply the same
change to the existing call near the other reference at line 413.
🪄 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: Enterprise

Run ID: 494db941-de46-4529-9c45-4baf07f25874

📥 Commits

Reviewing files that changed from the base of the PR and between d09b530 and 48172b9.

📒 Files selected for processing (3)
  • scripts/audit-reviewed-npm-graph.mts
  • scripts/lib/reviewed-npm-archive.mts
  • test/reviewed-npm-audit-workflow.test.ts

Comment thread scripts/audit-reviewed-npm-graph.mts Outdated
Comment thread test/reviewed-npm-audit-workflow.test.ts
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — No blocking findings reported

Advisor assessment: No blocking advisor findings reported
Next action: No advisor follow-up needed.
Findings: 0 blockers · 0 warnings · 0 suggestions

Model lanes

  • GPT-5.6 Terra (primary): Completed · high confidence · 0 blockers · 0 warnings · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Completed · high confidence · 0 blockers · 0 warnings · 0 suggestions
  • Model comparison: normalized findings match; normalized terminology decisions differ; normalized E2E selections match; severity counts match.
5 terminology differences from the second opinion

Advisory only. These are normalized differences from the primary terminology receipt.

  • production dependency at scripts/lib/reviewed-npm-archive.mts:345: primary classified it as established; the second opinion classified it as justified.
  • production graph at scripts/audit-reviewed-npm-graph.mts:60: selected only by the second-opinion lane as justified.
  • shrinkwrap at scripts/lib/reviewed-npm-archive.mts:435: selected only by the second-opinion lane as justified.
  • source graph at scripts/audit-reviewed-npm-graph.mts:422: selected only by the second-opinion lane as justified.
  • dev: true at scripts/lib/reviewed-npm-archive.mts:345: selected only by the second-opinion lane as justified.

Second-opinion terminology and E2E selections are advisory. They do not change the primary assessment or E2E / PR Gate.

3 semantic terminology decisions

Terminology decisions are advisory. They affect the assessment only when a separate finding identifies concrete semantic impact.

  • justified — root production graph at test/reviewed-npm-audit-workflow.test.ts:275: Keep this modifier when the audit target could otherwise be confused with archive or runtime graphs.
  • established — nested shrinkwrap at scripts/lib/reviewed-npm-archive.mts:437: Keep the established term for lock delegation that the audit rejects.
  • established — production dependency at scripts/lib/reviewed-npm-archive.mts:345: Keep the established term for dependencies that the production audit must validate.

E2E guidance

Advisory only. E2E / PR Gate selects and runs jobs independently.

Recommended E2E: None

Workflow run details

This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge.

Signed-off-by: San Dang <sdang@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv

cv commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Sensitive-path security review: FAIL

Reviewed PR #8131 at commit SHA dc7d6acf13826be98a94bcf978d98ce78df06ddf against base SHA d6ac4027b75b15b8acd1456984acbbfb623cb231.

Do not merge this commit. A high-severity validation gap allows an untrusted lockfile dev: true flag to exclude a package that remains reachable from root production dependencies.

scripts/lib/reviewed-npm-archive.mts skips records marked dev: true before registry, shrinkwrap, and installed-identity validation. scripts/audit-reviewed-npm-graph.mts enables those omissions while running npm ci --omit=dev. A pull request can mark a package reached through root dependencies as dev: true; that package is then omitted from origin, identity, advisory, and signature evaluation even though the published package still declares the production path.

Required remediation:

  1. Derive production-reachable lock locations from root dependencies and optionalDependencies, including transitive edges.
  2. Reject dev: true for every production-reachable location before invoking npm.
  3. Use the derived location set for both pre-install validation and post-install identity verification.
  4. Do not use the untrusted dev field as the sole omission decision.
  5. Add a regression titled rejects dev: true when root production dependencies reach the package (#8116). It must prove that materializeSourceGraph rejects, the installer callback is not invoked, and the destination directory is not created.

Security categories:

  • Secrets and credentials — PASS
  • Input validation and data sanitization — FAIL
  • Authentication and authorization — PASS
  • Dependencies and third-party libraries — PASS
  • Error handling and logging — PASS
  • Cryptography and data protection — PASS
  • Configuration and security headers — PASS
  • Security testing — FAIL
  • System security — FAIL

All required checks currently pass for this commit, but passing checks do not resolve this security finding. A new independent documentation and security review is required after remediation.

cv added 3 commits August 3, 2026 08:10
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Reject production-reachable lock records marked dev before npm runs.

Preserve non-dev record review and add pre-install regression coverage.

Signed-off-by: Carlos Villela <cvillela@nvidia.com>

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

🧹 Nitpick comments (1)
scripts/lib/reviewed-npm-archive.mts (1)

383-385: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the duplicated production-reachable dev check.

The same rule is now written twice: derive productionLocations when omitDev is set, then reject dev: true on a reachable location with an identical error message. Both sites are correct today. If the rule changes, the two sites can drift, and a drift in the post-install site would silently weaken the guarantee the security review requires.

  • scripts/lib/reviewed-npm-archive.mts#L383-L385: replace the inline check with a shared helper, for example assertNotProductionDev(productionLocations, location, record).
  • scripts/lib/reviewed-npm-archive.mts#L520-L522: call the same helper instead of repeating the condition and the error string.
🤖 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 `@scripts/lib/reviewed-npm-archive.mts` around lines 383 - 385, Extract the
duplicated production-reachable dev check into a shared helper, such as
assertNotProductionDev(productionLocations, location, record), preserving the
existing condition and error message. Update
scripts/lib/reviewed-npm-archive.mts lines 383-385 and 520-522 to call the
helper instead of containing the inline check.
🤖 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 `@scripts/lib/reviewed-npm-archive.mts`:
- Around line 272-292: Update the dependency aggregation loop in the reviewed
npm lock parsing function so duplicate names retain the strictest
classification: once a name is recorded with optional false from dependencies,
optionalDependencies must not overwrite it with true. Preserve optional true for
names appearing only in optionalDependencies and return the existing dependency
list format.
- Around line 518-523: Guard each `record` in the `packages` loop before
accessing `record.dev`, using the same record-validation guard and descriptive
error behavior as `readReviewedLockPackages`. Preserve the existing
production-dependency check and `omitDev` filtering for valid records.
- Around line 272-275: Update the dependency traversal loop around the
dependencies and optionalDependencies fields to also traverse production
peerDependencies. Use peerDependenciesMeta to mark peer entries as optional when
applicable, while preserving the existing handling for required and optional
dependency fields so peer-only packages are included in the audit.

---

Nitpick comments:
In `@scripts/lib/reviewed-npm-archive.mts`:
- Around line 383-385: Extract the duplicated production-reachable dev check
into a shared helper, such as assertNotProductionDev(productionLocations,
location, record), preserving the existing condition and error message. Update
scripts/lib/reviewed-npm-archive.mts lines 383-385 and 520-522 to call the
helper instead of containing the inline check.
🪄 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: Enterprise

Run ID: 118a2c71-014d-44e6-904f-1bd9f0d725a4

📥 Commits

Reviewing files that changed from the base of the PR and between e24b65b and 1c7fa32.

📒 Files selected for processing (2)
  • scripts/lib/reviewed-npm-archive.mts
  • test/reviewed-npm-audit-workflow.test.ts

Comment thread scripts/lib/reviewed-npm-archive.mts
Comment thread scripts/lib/reviewed-npm-archive.mts
Comment thread scripts/lib/reviewed-npm-archive.mts
Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>
Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>

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

🤖 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 `@test/reviewed-npm-audit-workflow.test.ts`:
- Around line 340-370: Update the reviewed npm audit tests around
materializeSourceGraph so a package present in both dependencies and
optionalDependencies is treated as optional, not required. Remove shared-package
from optionalDependencies in the existing required-dependency test, then add a
passing test covering the duplicate-map case and preserving the expected
materialization behavior.
🪄 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: Enterprise

Run ID: 37229abe-a98e-49c5-8989-b0508213920d

📥 Commits

Reviewing files that changed from the base of the PR and between 1c7fa32 and 631063f.

📒 Files selected for processing (3)
  • scripts/audit-reviewed-npm-graph.mts
  • scripts/lib/reviewed-npm-archive.mts
  • test/reviewed-npm-audit-workflow.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • scripts/audit-reviewed-npm-graph.mts
  • scripts/lib/reviewed-npm-archive.mts

Comment thread test/reviewed-npm-audit-workflow.test.ts Outdated
Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>
Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>

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

🧹 Nitpick comments (1)
ci/npm-audit-exceptions.json (1)

11-14: 🔒 Security & Privacy | 🔵 Trivial

Confirm the expiry boundary and remediation handoff.

expires is 2026-08-10, seven days after the current review date, August 3, 2026. The rationale depends on PR #8126, which is still open as of August 3, 2026. (github.com) Confirm whether parseAuditExceptionRegistry treats this date as inclusive and ensure the upgrade lands before the cutoff. Otherwise, this high-severity exception may expire before remediation and cause an audit failure.

Based on the PR objective, this is a temporary risk acceptance that must be removed with the dependency upgrade.

🤖 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 `@ci/npm-audit-exceptions.json` around lines 11 - 14, Verify that
parseAuditExceptionRegistry treats the expires date as inclusive, and ensure the
dependency upgrade referenced by trackingIssue PR `#8126` lands before 2026-08-10.
Remove this temporary exception and its rationale once the upgrade is applied;
otherwise adjust the expiry only through the established exception policy.

Source: 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 `@test/reviewed-npm-audit.test.ts`:
- Line 122: Update the test title in the test case beginning “bounds the
OpenClaw brace-expansion exception” to remove the “(`#8126`)” suffix unless a
valid local issue reference is available; do not use the pull request number as
the title suffix.

---

Nitpick comments:
In `@ci/npm-audit-exceptions.json`:
- Around line 11-14: Verify that parseAuditExceptionRegistry treats the expires
date as inclusive, and ensure the dependency upgrade referenced by trackingIssue
PR `#8126` lands before 2026-08-10. Remove this temporary exception and its
rationale once the upgrade is applied; otherwise adjust the expiry only through
the established exception policy.
🪄 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: Enterprise

Run ID: c31eb959-a84e-4dfc-a601-c2c277572ab5

📥 Commits

Reviewing files that changed from the base of the PR and between 631063f and a737a99.

📒 Files selected for processing (5)
  • ci/npm-audit-exceptions.json
  • scripts/audit-reviewed-npm-graph.mts
  • scripts/lib/reviewed-npm-archive.mts
  • test/reviewed-npm-audit-workflow.test.ts
  • test/reviewed-npm-audit.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • scripts/audit-reviewed-npm-graph.mts
  • scripts/lib/reviewed-npm-archive.mts

Comment thread test/reviewed-npm-audit.test.ts Outdated
Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>
@github-actions github-actions Bot added v0.0.102 and removed v0.0.101 labels Aug 3, 2026

@prekshivyas prekshivyas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved at exact head bf102dc. Sensitive-path security review: PASS with no findings across (1) secrets and credentials, (2) input validation and sanitization, (3) authentication and authorization, (4) dependencies and third-party libraries, (5) error handling and logging, (6) cryptography and data protection, (7) configuration and security headers, (8) security testing, and (9) system security. Untrusted lock and package records fail closed; install scripts remain disabled; registry, digest, package-name, version, and signature controls are pinned and checked before/after materialization; negative tests cover peer reachability, optional overrides, dev-flag misuse, nested shrinkwraps, malformed records, source drift, identity mismatches, and advisory blocking. CodeRabbit is green with all threads resolved; the exact-head PR Advisor reports merge-as-is; all ordinary code lanes, eight CLI shards, macOS E2E, WSL E2E, DCO, commit verification, and the exact-head documentation writer review pass. The sole expected failure is reviewed-npm-audit: the trusted base intentionally cannot accept this head-created, advisory/package/version/graph/owner/tracking/expiry-bounded bootstrap exception. PR #8126 removes the exception by upgrading brace-expansion to 5.0.9.

prekshivyas and others added 2 commits August 3, 2026 12:35
@copy-pr-bot

copy-pr-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

cv

This comment was marked as outdated.

@cv cv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Security re-review for exact head 1662208e678ebc9fe72c518b6bb1908898ab4280: changes requested.

The branch now has the required audit-only scope, the prior production-reachable dev: true gap is fixed, and the focused reviewed-audit tests pass 55/55. One security blocker remains.

Blocking finding — stale same-tree deferral bypasses the root audit

scripts/audit-reviewed-npm-graph.mts:62-67 says to remove the two deferred digests after the root lock remediation. That remediation landed in #8156. The current main manifest and lock no longer match those digests, but shouldAuditTargetSourceGraph still returns false for the exact old pair at lines 505-515.

A same-tree main run whose package.json and package-lock.json return to those pre-remediation vulnerable identities therefore skips the new nemoclaw-cli audit entirely. PR runs use a separate trusted checkout and still audit, but the main-branch security control remains bypassable for the one graph this temporary exception was created to defer.

Remove the deferred manifest and lock constants, shouldDeferSameTreeSourceGraph, and their positive deferral test. The source graph should now run for same-tree and separate-target executions.

Required cleanup before approval

  • Remove the no-op indentation-only change in ci/reviewed-npm-audit.json.
  • Refresh the PR body. It still says the PR is not merge-eligible and describes the obsolete same-tree deferral and temporary advisory exception.
  • Repeat the exact-head security and documentation reviews and refresh the receipt metadata.
  • Let all required checks finish successfully; ten checks are currently pending.

No other security finding remains in the five-file audit-only diff.

cv and others added 4 commits August 3, 2026 19:17
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv
cv merged commit 265c18f into main Aug 4, 2026
3 checks passed
@cv
cv deleted the fix/trusted-root-npm-audit-8116 branch August 4, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: security Security controls, permissions, secrets, or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants