Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions .github/actions/ci-reviewed-npm-audit/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,35 @@ runs:
with:
node-version: "22.23.1"

- name: Pin production npm
- name: Download and verify production npm
shell: bash
run: >-
cd "$RUNNER_TEMP" &&
npm install --global npm@10.9.4
--userconfig /dev/null
--registry https://registry.npmjs.org/
--ignore-scripts --no-audit --no-fund
env:
NPM_ARCHIVE_INTEGRITY: >-
sha512-OnUG836FwboQIbqtefDNlyR0gTHzIfwRfE3DuiNewBvnMnWEpB0VEXwBlFVgqpNzIgYo/MHh3d2Hel/pszapAA==
run: |
set -euo pipefail
download_dir="$(mktemp -d "$RUNNER_TEMP/reviewed-npm.XXXXXX")"
npm pack npm@10.9.4 \
--pack-destination "$download_dir" \
--userconfig /dev/null \
--registry https://registry.npmjs.org/ \
--ignore-scripts --no-audit --no-fund >/dev/null
archive="$download_dir/npm-10.9.4.tgz"
actual_sha512="$(
node -e '
const fs = require("node:fs");
const crypto = require("node:crypto");
process.stdout.write(crypto.createHash("sha512").update(fs.readFileSync(process.argv[1])).digest("base64"));
' "$archive"
)"
actual_integrity="sha512-$actual_sha512"
if [ "$actual_integrity" != "$NPM_ARCHIVE_INTEGRITY" ]; then
echo "ERROR: npm@10.9.4 archive integrity mismatch." >&2
exit 1
fi
npm install --global "$archive" \
--userconfig /dev/null \
--ignore-scripts --no-audit --no-fund --offline

- name: Materialize and audit reviewed npm graphs
shell: bash
Expand Down
39 changes: 36 additions & 3 deletions .github/workflows/base-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ on:
# takes effect immediately after merge instead of waiting for another tag.
- ".github/workflows/base-image.yaml"
- ".github/workflows/managed-images.yaml"
- ".github/actions/ci-reviewed-npm-audit/**"
- ".dockerignore"
# Complete managed-image inputs. Keep these reviewed families synchronized
# with tools/e2e/base-image-publication.mts.
Expand Down Expand Up @@ -55,6 +56,7 @@ on:
- "agents/openclaw/mcporter-runtime/package.json"
- "agents/openclaw/mcporter-runtime/package-lock.json"
- "ci/npm-audit-exceptions.json"
- "ci/reviewed-npm-audit.json"
# Dockerfile.base validates min_openclaw_version from this file at build time.
- "nemoclaw-blueprint/blueprint.yaml"
- "scripts/lib/openclaw-npm-remediation.mts"
Expand Down Expand Up @@ -88,12 +90,32 @@ env:
REGISTRY: ghcr.io

jobs:
reviewed-npm-audit:
if: github.repository == 'NVIDIA/NemoClaw'
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Audit reviewed production npm graphs
uses: ./.github/actions/ci-reviewed-npm-audit
with:
target-root: ${{ github.workspace }}
report-dir: artifacts/reviewed-npm-audit

# The complete Perl suite approaches the image-job timeout under QEMU arm64 emulation.
# Build OpenClaw on native runners and publish only immutable per-platform digests here.
# The dependent manifest job updates user-facing tags atomically.
build-openclaw-platforms:
name: Build OpenClaw base image (${{ matrix.arch }})
if: github.repository == 'NVIDIA/NemoClaw'
needs:
- reviewed-npm-audit
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
strategy:
Expand Down Expand Up @@ -212,6 +234,8 @@ jobs:
build-hermes-platforms:
name: Build ${{ matrix.display_name }} base image (${{ matrix.arch }})
if: github.repository == 'NVIDIA/NemoClaw'
needs:
- reviewed-npm-audit
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
strategy:
Expand Down Expand Up @@ -325,6 +349,8 @@ jobs:
build-dcode-platforms:
name: Build ${{ matrix.display_name }} base image (${{ matrix.arch }})
if: github.repository == 'NVIDIA/NemoClaw'
needs:
- reviewed-npm-audit
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
strategy:
Expand Down Expand Up @@ -438,7 +464,9 @@ jobs:
build-and-push-hermes:
name: Build and push Hermes base image
if: github.repository == 'NVIDIA/NemoClaw'
needs: build-hermes-platforms
needs:
- build-hermes-platforms
- reviewed-npm-audit
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
Expand Down Expand Up @@ -605,7 +633,9 @@ jobs:
build-and-push-dcode:
name: Build and push Deep Agents Code base image
if: github.repository == 'NVIDIA/NemoClaw'
needs: build-dcode-platforms
needs:
- build-dcode-platforms
- reviewed-npm-audit
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
Expand Down Expand Up @@ -774,7 +804,9 @@ jobs:
build-and-push-openclaw:
name: Build and push OpenClaw base image
if: github.repository == 'NVIDIA/NemoClaw'
needs: build-openclaw-platforms
needs:
- build-openclaw-platforms
- reviewed-npm-audit
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
Expand Down Expand Up @@ -951,6 +983,7 @@ jobs:
- build-and-push-hermes
- build-and-push-dcode
- build-and-push-openclaw
- reviewed-npm-audit
permissions:
contents: read
packages: write
Expand Down
9 changes: 9 additions & 0 deletions ci/reviewed-npm-audit.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@
"tarballUrl": "https://registry.npmjs.org/mcporter/-/mcporter-0.7.3.tgz",
"directory": "agents/openclaw/mcporter-runtime",
"lockSha256": "962dee34f6b0a493521d1619d1cf030e2630cbdfce8bf0598217202f57078793"
},
{
"id": "mcp-tool-discovery-runtime",
"label": "MCP tool discovery runtime locked production graph",
"packageSpec": "@modelcontextprotocol/sdk@1.30.0",
"integrity": "sha512-xKd8OIzlqNzcqcNumGAa6g+PW2kjD5vrpcKOnfldAUPP3j7lnqMPwlTXQm8gF+UwH72z0lqaRbjr9hqGz0eITA==",
"tarballUrl": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.30.0.tgz",
"directory": "tools/mcp-tool-discovery-runtime",
"lockSha256": "bc7e34d9eb1f72cf3016c8b88c72d3b7682a4f234903cb93b9476b10d7e954eb"
}
]
}
2 changes: 1 addition & 1 deletion ci/source-shape-test-budget.json
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@
},
{
"file": "test/mcp-tool-discovery-image-contract.test.ts",
"test": "pins reviewed packages and retains the production audit command (#8177)",
"test": "pins reviewed packages and audits their lock outside image builds (#8253)",
"category": "security"
},
{
Expand Down
6 changes: 4 additions & 2 deletions test/dcode-base-image-workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ describe("base-image publication behavior", () => {
const platformJob = workflow.jobs?.["build-openclaw-platforms"];
const manifestJob = workflow.jobs?.["build-and-push-openclaw"];

expect(platformJob?.needs).toEqual(["reviewed-npm-audit"]);
expect(platformJob?.["timeout-minutes"]).toBe(60);
expect(platformJob?.strategy?.["fail-fast"]).toBe(false);
expect(
Expand Down Expand Up @@ -430,7 +431,7 @@ describe("base-image publication behavior", () => {
}

expect(manifestJob?.name).toBe("Build and push OpenClaw base image");
expect(manifestJob?.needs).toBe("build-openclaw-platforms");
expect(manifestJob?.needs).toEqual(["build-openclaw-platforms", "reviewed-npm-audit"]);
expect(manifestJob?.["timeout-minutes"]).toBe(10);
expect(
manifestJob?.steps?.some((step) => step.uses?.startsWith("docker/build-push-action@")),
Expand Down Expand Up @@ -516,6 +517,7 @@ describe("base-image publication behavior", () => {

for (const { platformJobName } of imagePublishers) {
const platformJob = workflow.jobs?.[platformJobName];
expect(platformJob?.needs).toEqual(["reviewed-npm-audit"]);
expect(platformJob?.["timeout-minutes"]).toBe(60);
expect(platformJob?.["runs-on"]).toBe("${{ matrix.runner }}");
expect(platformJob?.strategy?.["fail-fast"]).toBe(false);
Expand Down Expand Up @@ -577,7 +579,7 @@ describe("base-image publication behavior", () => {
for (const imagePublisher of imagePublishers) {
const manifestJob = workflow.jobs?.[imagePublisher.manifestJobName];
expect(manifestJob?.name).toBe(imagePublisher.manifestName);
expect(manifestJob?.needs).toBe(imagePublisher.platformJobName);
expect(manifestJob?.needs).toEqual([imagePublisher.platformJobName, "reviewed-npm-audit"]);
expect(manifestJob?.["timeout-minutes"]).toBe(10);
expect(
manifestJob?.steps?.some((step) => step.uses?.startsWith("docker/build-push-action@")),
Expand Down
1 change: 1 addition & 0 deletions test/e2e/support/base-image-publication.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ describe("base-image publication evidence", () => {

expect(parseBaseImagePushPaths(source)).toEqual(
expect.arrayContaining([
".github/actions/ci-reviewed-npm-audit/**",
".github/workflows/base-image.yaml",
"Dockerfile",
"Dockerfile.base",
Expand Down
30 changes: 29 additions & 1 deletion test/managed-image-publication-workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@ const repoRoot = path.resolve(import.meta.dirname, "..");
const fullShaAction = /^[^@]+@[0-9a-f]{40}$/iu;
const managedInputPaths = [
".dockerignore",
".github/actions/ci-reviewed-npm-audit/**",
".github/workflows/managed-images.yaml",
"Dockerfile",
"agents/**",
"ci/npm-audit-exceptions.json",
"ci/reviewed-npm-audit.json",
"nemoclaw/**",
"nemoclaw-blueprint/**",
"scripts/**",
Expand Down Expand Up @@ -324,7 +326,12 @@ describe("complete managed-image publication workflow", () => {
'exact managed image validation is missing path.join(nodeModulesRoot, ...name.split("/"))',
);
expect(publisher).toMatchObject({
needs: ["build-and-push-hermes", "build-and-push-dcode", "build-and-push-openclaw"],
needs: [
"build-and-push-hermes",
"build-and-push-dcode",
"build-and-push-openclaw",
"reviewed-npm-audit",
],
permissions: {
contents: "read",
packages: "write",
Expand All @@ -335,6 +342,25 @@ describe("complete managed-image publication workflow", () => {
expect(publisher.if).toContain("github.ref == 'refs/heads/main'");
expect(publisher.if).toContain("startsWith(github.ref, 'refs/tags/v')");

const reviewedAudit = required(
baseWorkflow.jobs?.["reviewed-npm-audit"],
"base-image workflow is missing the reviewed npm audit",
);
expect(reviewedAudit).toMatchObject({
if: "github.repository == 'NVIDIA/NemoClaw'",
permissions: { contents: "read" },
"runs-on": "ubuntu-latest",
"timeout-minutes": 15,
});
expect(step(reviewedAudit, "Checkout").with?.["persist-credentials"]).toBe(false);
expect(step(reviewedAudit, "Audit reviewed production npm graphs")).toMatchObject({
uses: "./.github/actions/ci-reviewed-npm-audit",
with: {
"report-dir": "artifacts/reviewed-npm-audit",
"target-root": "${{ github.workspace }}",
},
});

const basePublishers = [
{
agent: "hermes",
Expand Down Expand Up @@ -362,6 +388,7 @@ describe("complete managed-image publication workflow", () => {
baseWorkflow.jobs?.[expectedPublisher.job],
`base-image workflow is missing ${expectedPublisher.agent} manifest publisher`,
);
expect(basePublisher.needs).toEqual([expectedPublisher.platformsJob, "reviewed-npm-audit"]);
const manifest = step(basePublisher, "Create and verify multi-platform manifest");
const manifestRun = manifest.run ?? "";
expect(manifest.id).toBe("manifest");
Expand Down Expand Up @@ -395,6 +422,7 @@ describe("complete managed-image publication workflow", () => {
baseWorkflow.jobs?.[expectedPublisher.platformsJob],
`base-image workflow is missing native ${expectedPublisher.agent} platforms`,
);
expect(nativePlatforms.needs).toEqual(["reviewed-npm-audit"]);
expect(nativePlatforms.strategy?.matrix?.include).toEqual(
expect.arrayContaining([
expect.objectContaining({
Expand Down
18 changes: 15 additions & 3 deletions test/mcp-tool-discovery-image-contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ const dockerfiles = [
] as const;

describe("MCP tool discovery image contract", () => {
// source-shape-contract: security -- Exact package pins and the production audit command protect the shipped runtime graph
it("pins reviewed packages and retains the production audit command (#8177)", () => {
// source-shape-contract: security -- Exact package pins and the CI audit mapping protect the shipped runtime graph
it("pins reviewed packages and audits their lock outside image builds (#8253)", () => {
const packageRoot = path.join(repoRoot, "tools", "mcp-tool-discovery-runtime");
const manifest = JSON.parse(fs.readFileSync(path.join(packageRoot, "package.json"), "utf8"));
const lock = JSON.parse(fs.readFileSync(path.join(packageRoot, "package-lock.json"), "utf8"));
const auditConfig = JSON.parse(
fs.readFileSync(path.join(repoRoot, "ci", "reviewed-npm-audit.json"), "utf8"),
);
const review = fs.readFileSync(path.join(packageRoot, "dependency-review.md"), "utf8");
const installer = fs.readFileSync(
path.join(packageRoot, "install-reviewed-runtime.sh"),
Expand Down Expand Up @@ -84,7 +87,16 @@ describe("MCP tool discovery image contract", () => {
.split(/\r?\n/)
.map((line) => line.trim())
.filter((line) => line.startsWith("npm audit")),
).toEqual(["npm audit signatures", "npm audit --omit=dev --audit-level=low"]);
).toEqual(["npm audit signatures"]);
expect(auditConfig.lockedGraphs).toContainEqual({
id: "mcp-tool-discovery-runtime",
label: "MCP tool discovery runtime locked production graph",
packageSpec: `${reviewedSdk.name}@${reviewedSdk.version}`,
integrity: reviewedSdk.integrity,
tarballUrl: reviewedSdk.resolved,
directory: "tools/mcp-tool-discovery-runtime",
lockSha256: "bc7e34d9eb1f72cf3016c8b88c72d3b7682a4f234903cb93b9476b10d7e954eb",
});
});

it.each(
Expand Down
12 changes: 10 additions & 2 deletions test/openclaw-locked-install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ const TARBALL = "https://registry.npmjs.org/openclaw/-/openclaw-2026.7.1.tgz";
const LOCK_SHA256 = "759b31779f40867f35f15065b582eb1d3efb8fddb1fe43c207507c905fa2a421";
const MCPORTER_PACKAGE_SPEC = "mcporter@0.7.3";
const MCPORTER_LOCK_SHA256 = "962dee34f6b0a493521d1619d1cf030e2630cbdfce8bf0598217202f57078793";
const MCP_TOOL_DISCOVERY_PACKAGE_SPEC = "@modelcontextprotocol/sdk@1.30.0";
const MCP_TOOL_DISCOVERY_LOCK_SHA256 =
"bc7e34d9eb1f72cf3016c8b88c72d3b7682a4f234903cb93b9476b10d7e954eb";
const roots: string[] = [];

function sha256(file: string): string {
Expand Down Expand Up @@ -382,12 +385,17 @@ describe("locked OpenClaw production installation (#5896)", () => {
lockSha256: MCPORTER_LOCK_SHA256,
packageSpec: MCPORTER_PACKAGE_SPEC,
}),
expect.objectContaining({
directory: "tools/mcp-tool-discovery-runtime",
lockSha256: MCP_TOOL_DISCOVERY_LOCK_SHA256,
packageSpec: MCP_TOOL_DISCOVERY_PACKAGE_SPEC,
}),
]),
);
expect(audit.lockedGraphs).toHaveLength(2);
expect(audit.lockedGraphs).toHaveLength(3);
expect(
audit.lockedGraphs.map(({ packageSpec }: { packageSpec?: string }) => packageSpec).sort(),
).toEqual([MCPORTER_PACKAGE_SPEC, PACKAGE_SPEC].sort());
).toEqual([MCPORTER_PACKAGE_SPEC, MCP_TOOL_DISCOVERY_PACKAGE_SPEC, PACKAGE_SPEC].sort());
for (const graph of audit.lockedGraphs) {
expect(graph).not.toHaveProperty("replacementLockSha256");
expect(graph).not.toHaveProperty("reviewedLockSha256");
Expand Down
11 changes: 10 additions & 1 deletion test/reviewed-npm-audit-workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,16 @@ describe("trusted reviewed npm audit workflow (#5896)", () => {
);

expect(action).toContain('node-version: "22.23.1"');
expect(action).toContain("npm install --global npm@10.9.4");
expect(action).toContain("npm pack npm@10.9.4");
expect(action).toContain("NPM_ARCHIVE_INTEGRITY: >-");
expect(action).toContain(
"sha512-OnUG836FwboQIbqtefDNlyR0gTHzIfwRfE3DuiNewBvnMnWEpB0VEXwBlFVgqpNzIgYo/MHh3d2Hel/pszapAA==",
);
expect(action).toContain('crypto.createHash("sha512")');
expect(action).toContain('if [ "$actual_integrity" != "$NPM_ARCHIVE_INTEGRITY" ]');
expect(action).toContain('npm install --global "$archive"');
expect(action).toContain("--ignore-scripts --no-audit --no-fund --offline");
expect(action).not.toContain("npm install --global npm@10.9.4");
expect(action).toContain("NEMOCLAW_REVIEWED_NPM_AUDIT_TARGET_ROOT");
expect(action).toContain("NEMOCLAW_REVIEWED_NPM_AUDIT_REPORT_DIR");
expect(action).toContain(
Expand Down
4 changes: 4 additions & 0 deletions tools/e2e/base-image-publication.mts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const MAX_RETRY_DELAY_MS = 10_000;
const SHA_PATTERN = /^[0-9a-f]{40}$/u;
const SAFE_PATH_PATTERN = /^[A-Za-z0-9._/-]+$/u;
const REVIEWED_PATH_GLOBS = new Map<string, RegExp>([
[
".github/actions/ci-reviewed-npm-audit/**",
/^[.]github\/actions\/ci-reviewed-npm-audit\/.+$/u,
],
["agents/**", /^agents\/.+$/u],
["nemoclaw/**", /^nemoclaw\/.+$/u],
["nemoclaw-blueprint/**", /^nemoclaw-blueprint\/.+$/u],
Expand Down
Loading
Loading