From 71292975c314c51712b1f8e1f64ba7e120bfd35a Mon Sep 17 00:00:00 2001 From: Julie Yaunches Date: Fri, 12 Jun 2026 10:20:45 -0400 Subject: [PATCH 1/4] test(e2e): migrate credential sanitization --- .github/workflows/e2e-vitest-scenarios.yaml | 94 ++++- .../live/credential-sanitization.test.ts | 372 ++++++++++++++++++ .../e2e-scenarios-workflow.test.ts | 31 ++ tools/e2e-scenarios/workflow-boundary.mts | 7 + 4 files changed, 501 insertions(+), 3 deletions(-) create mode 100644 test/e2e-scenario/live/credential-sanitization.test.ts diff --git a/.github/workflows/e2e-vitest-scenarios.yaml b/.github/workflows/e2e-vitest-scenarios.yaml index 174b24ae263..971c17d809f 100644 --- a/.github/workflows/e2e-vitest-scenarios.yaml +++ b/.github/workflows/e2e-vitest-scenarios.yaml @@ -40,7 +40,7 @@ jobs: SCENARIOS: ${{ inputs.scenarios }} run: | set -euo pipefail - allowed_jobs="openshell-version-pin-vitest,onboard-negative-paths-vitest,inference-routing-vitest,credential-migration-vitest,runtime-overrides-vitest,hermes-e2e-vitest,hermes-root-entrypoint-smoke-vitest,network-policy-vitest,rebuild-openclaw-vitest,token-rotation-vitest,launchable-smoke-vitest,openclaw-tui-chat-correlation-vitest,gateway-guard-recovery,double-onboard-vitest,issue-4434-tui-unreachable-inference-vitest,model-router-provider-routed-inference-vitest" + allowed_jobs="openshell-version-pin-vitest,onboard-negative-paths-vitest,inference-routing-vitest,credential-migration-vitest,runtime-overrides-vitest,hermes-e2e-vitest,hermes-root-entrypoint-smoke-vitest,network-policy-vitest,rebuild-openclaw-vitest,token-rotation-vitest,launchable-smoke-vitest,openclaw-tui-chat-correlation-vitest,gateway-guard-recovery,double-onboard-vitest,issue-4434-tui-unreachable-inference-vitest,model-router-provider-routed-inference-vitest,credential-sanitization-vitest" if [ -n "${JOBS}" ] && [ -n "${SCENARIOS}" ]; then echo "::error::Use either scenarios or jobs, not both." >&2 exit 1 @@ -93,12 +93,12 @@ jobs: SCENARIOS: ${{ inputs.scenarios }} run: | set -euo pipefail - allowed_jobs="openshell-version-pin-vitest,onboard-negative-paths-vitest,inference-routing-vitest,credential-migration-vitest,runtime-overrides-vitest,hermes-e2e-vitest,hermes-root-entrypoint-smoke-vitest,network-policy-vitest,rebuild-openclaw-vitest,token-rotation-vitest,launchable-smoke-vitest,openclaw-tui-chat-correlation-vitest,gateway-guard-recovery,double-onboard-vitest,issue-4434-tui-unreachable-inference-vitest,model-router-provider-routed-inference-vitest" + allowed_jobs="openshell-version-pin-vitest,onboard-negative-paths-vitest,inference-routing-vitest,credential-migration-vitest,runtime-overrides-vitest,hermes-e2e-vitest,hermes-root-entrypoint-smoke-vitest,network-policy-vitest,rebuild-openclaw-vitest,token-rotation-vitest,launchable-smoke-vitest,openclaw-tui-chat-correlation-vitest,gateway-guard-recovery,double-onboard-vitest,issue-4434-tui-unreachable-inference-vitest,model-router-provider-routed-inference-vitest,credential-sanitization-vitest" args=(--emit-live-matrix) matrix="" hermes_selected=false registry_scenarios=() - free_standing_scenarios=(openshell-version-pin onboard-negative-paths inference-routing runtime-overrides hermes-e2e hermes-root-entrypoint-smoke network-policy rebuild-openclaw token-rotation openclaw-tui-chat-correlation double-onboard issue-4434-tui-unreachable-inference model-router-provider-routed-inference) + free_standing_scenarios=(openshell-version-pin onboard-negative-paths inference-routing runtime-overrides hermes-e2e hermes-root-entrypoint-smoke network-policy rebuild-openclaw token-rotation openclaw-tui-chat-correlation double-onboard issue-4434-tui-unreachable-inference model-router-provider-routed-inference credential-sanitization) is_free_standing_scenario() { local id="$1" local known @@ -144,6 +144,9 @@ jobs: hermes_selected=true ;; esac + if [[ "${scenario}" == "credential-sanitization" ]]; then + continue + fi if is_free_standing_scenario "${scenario}"; then continue fi @@ -551,6 +554,90 @@ jobs: retention-days: 14 + credential-sanitization-vitest: + needs: [validate-jobs, generate-matrix] + if: ${{ (inputs.jobs == '' && inputs.scenarios == '') || contains(format(',{0},', inputs.jobs), ',credential-sanitization-vitest,') || contains(format(',{0},', inputs.scenarios), ',credential-sanitization,') }} + runs-on: ubuntu-latest + timeout-minutes: 65 + env: + E2E_ARTIFACT_DIR: ${{ github.workspace }}/e2e-artifacts/vitest/credential-sanitization + NEMOCLAW_CLI_BIN: ${{ github.workspace }}/bin/nemoclaw.js + NEMOCLAW_RUN_E2E_SCENARIOS: "1" + NEMOCLAW_SANDBOX_NAME: "e2e-credential-sanitization" + OPENSHELL_GATEWAY: "nemoclaw" + steps: + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + with: + persist-credentials: false + + - name: Authenticate to Docker Hub + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + shell: bash + run: | + set -euo pipefail + if [[ -z "${DOCKERHUB_USERNAME}" || -z "${DOCKERHUB_TOKEN}" ]]; then + echo "::notice::Docker Hub credentials not configured; continuing with anonymous pulls." + exit 0 + fi + login_succeeded=0 + for attempt in 1 2 3; do + if echo "${DOCKERHUB_TOKEN}" | timeout 30s docker login docker.io --username "${DOCKERHUB_USERNAME}" --password-stdin; then + login_succeeded=1 + break + fi + if [[ "$attempt" -lt 3 ]]; then + echo "::warning::Docker Hub login attempt ${attempt} failed; retrying." + sleep 5 + fi + done + if [[ "$login_succeeded" -ne 1 ]]; then + echo "::warning::Docker Hub login failed after 3 attempts; continuing with anonymous pulls." + fi + + - name: Set up Node + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.0.0 + with: + node-version: 22 + cache: npm + + - name: Install root dependencies + run: npm ci --ignore-scripts + + - name: Build CLI + run: npm run build:cli + + - name: Run credential sanitization live test + # Migrated from test/e2e/test-credential-sanitization.sh. Preserves the + # same ubuntu-latest + Docker/OpenShell + NVIDIA_API_KEY lane by running + # install.sh, onboarding a real sandbox, and probing sandbox state from + # Vitest while fixture redaction owns evidence logs. + env: + NVIDIA_API_KEY: ${{ secrets.NVIDIA_API_KEY }} + run: | + set -euo pipefail + npx vitest run --project e2e-scenarios-live \ + test/e2e-scenario/live/credential-sanitization.test.ts \ + --silent=false --reporter=default + + - name: Upload credential sanitization artifacts + if: always() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: e2e-vitest-scenarios-credential-sanitization + path: e2e-artifacts/vitest/credential-sanitization/ + include-hidden-files: false + if-no-files-found: ignore + retention-days: 14 + + - name: Clean up Docker auth + if: always() + shell: bash + run: | + docker logout docker.io >/dev/null 2>&1 || true + + credential-migration-vitest: needs: validate-jobs if: ${{ (inputs.jobs == '' && inputs.scenarios == '') || contains(format(',{0},', inputs.jobs), ',credential-migration-vitest,') }} @@ -1401,6 +1488,7 @@ jobs: launchable-smoke-vitest, double-onboard-vitest, model-router-provider-routed-inference-vitest, + credential-sanitization-vitest, openclaw-tui-chat-correlation-vitest, gateway-guard-recovery, issue-4434-tui-unreachable-inference-vitest, diff --git a/test/e2e-scenario/live/credential-sanitization.test.ts b/test/e2e-scenario/live/credential-sanitization.test.ts new file mode 100644 index 00000000000..d7958f24121 --- /dev/null +++ b/test/e2e-scenario/live/credential-sanitization.test.ts @@ -0,0 +1,372 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +/** + * Live Vitest migration for test/e2e/test-credential-sanitization.sh. + * + * Keep the replacement direct and small: local product-code assertions cover the + * sanitization/digest contract, then a real install/onboard verifies the + * sandbox filesystem does not expose credential artifacts or secret-shaped + * values. No new scenario framework, registry, or shared helper is introduced. + */ + +import fs from "node:fs"; +import os from "node:os"; +import path from "node:path"; + +import YAML from "yaml"; + +import { + isCredentialField, + isSensitiveFile, + sanitizeConfigFile, + stripCredentials, +} from "../../../src/lib/security/credential-filter.ts"; +import { buildAvailabilityProbeEnv } from "../fixtures/availability-env.ts"; +import type { HostCliClient } from "../fixtures/clients/host.ts"; +import { type SandboxClient, validateSandboxName } from "../fixtures/clients/sandbox.ts"; +import { expect, test } from "../fixtures/e2e-test.ts"; + +const REPO_ROOT = path.resolve(import.meta.dirname, "../../.."); +const CLI_ENTRYPOINT = path.join(REPO_ROOT, "bin", "nemoclaw.js"); +const BLUEPRINT_FILE = path.join(REPO_ROOT, "nemoclaw-blueprint", "blueprint.yaml"); +const SANDBOX_NAME = + process.env.NEMOCLAW_SANDBOX_NAME ?? `e2e-credential-sanitization-${process.pid}`; +const INSTALL_TIMEOUT_MS = 45 * 60_000; +const SANDBOX_PROBE_TIMEOUT_MS = 120_000; +validateSandboxName(SANDBOX_NAME); + +const runCredentialSanitizationTest = test; + +type CommandText = { stdout: string; stderr: string }; + +type Blueprint = { + digest?: unknown; + components?: { sandbox?: { image?: unknown } }; +}; + +function resultText(result: CommandText): string { + return [result.stdout, result.stderr].filter(Boolean).join("\n"); +} + +function testEnv(home: string, extra: NodeJS.ProcessEnv = {}): NodeJS.ProcessEnv { + const base = buildAvailabilityProbeEnv(); + return { + ...base, + HOME: home, + PATH: [path.join(home, ".local", "bin"), base.PATH].filter(Boolean).join(":"), + NEMOCLAW_NON_INTERACTIVE: "1", + NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE: "1", + OPENSHELL_GATEWAY: process.env.OPENSHELL_GATEWAY ?? "nemoclaw", + ...extra, + }; +} + +async function bestEffort(run: () => Promise): Promise { + try { + await run(); + } catch { + // Cleanup probes are intentionally best-effort: local failures can happen + // before install.sh has put OpenShell on this test HOME's PATH. + } +} + +async function cleanupCredentialSanitizationState( + host: HostCliClient, + home: string, +): Promise { + const env = testEnv(home); + await bestEffort(() => + host.command("node", [CLI_ENTRYPOINT, SANDBOX_NAME, "destroy", "--yes"], { + artifactName: "cleanup-nemoclaw-destroy-credential-sanitization", + env, + timeoutMs: 120_000, + }), + ); + await bestEffort(() => + host.command("openshell", ["sandbox", "delete", SANDBOX_NAME], { + artifactName: "cleanup-openshell-sandbox-delete-credential-sanitization", + env, + timeoutMs: 60_000, + }), + ); + await bestEffort(() => + host.command("openshell", ["gateway", "destroy", "-g", "nemoclaw"], { + artifactName: "cleanup-openshell-gateway-destroy-credential-sanitization", + env, + timeoutMs: 120_000, + }), + ); +} + +function removeSensitiveFiles(dir: string): void { + for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { + const fullPath = path.join(dir, entry.name); + if (entry.isSymbolicLink()) continue; + if (entry.isDirectory()) { + removeSensitiveFiles(fullPath); + } else if (entry.isFile() && isSensitiveFile(entry.name)) { + fs.rmSync(fullPath, { force: true }); + } + } +} + +function assertLocalCredentialSanitizationContract(): void { + const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-cred-sanitize-")); + try { + const bundleDir = path.join(tmp, "bundle", "openclaw"); + const authDir = path.join(bundleDir, "agents", "main", "agent"); + const workspaceDir = path.join(bundleDir, "workspace"); + fs.mkdirSync(authDir, { recursive: true }); + fs.mkdirSync(workspaceDir, { recursive: true }); + + const fakeNvidiaKey = "test-fake-nvidia-key-0000000000000000"; + const fakeGithubToken = "test-fake-github-token-1111111111111111"; + const fakeNpmToken = "test-fake-npm-token-2222222222222222"; + const fakeGatewayToken = "test-fake-gateway-token-333333333333"; + + fs.writeFileSync( + path.join(bundleDir, "openclaw.json"), + JSON.stringify( + { + agents: { + defaults: { + model: { primary: "nvidia/nemotron-3-super-120b-a12b" }, + workspace: workspaceDir, + }, + }, + gateway: { mode: "local", auth: { token: fakeGatewayToken } }, + nvidia: { apiKey: fakeNvidiaKey }, + mcpServers: { github: { env: { GITHUB_TOKEN: fakeGithubToken } } }, + }, + null, + 2, + ), + ); + fs.writeFileSync( + path.join(authDir, "auth-profiles.json"), + JSON.stringify({ + "github:pat": { token: fakeGithubToken }, + "npm:publish": { token: fakeNpmToken }, + }), + ); + fs.writeFileSync(path.join(workspaceDir, "project.md"), "# My Project\n"); + + sanitizeConfigFile(path.join(bundleDir, "openclaw.json")); + removeSensitiveFiles(bundleDir); + + const serialized = fs.readFileSync(path.join(bundleDir, "openclaw.json"), "utf8"); + expect(serialized).not.toContain(fakeNvidiaKey); + expect(serialized).not.toContain(fakeGithubToken); + expect(serialized).not.toContain(fakeGatewayToken); + expect(fs.existsSync(path.join(authDir, "auth-profiles.json"))).toBe(false); + + const sanitized = JSON.parse(serialized) as { + agents?: { defaults?: { model?: { primary?: string } } }; + nvidia?: { apiKey?: string }; + mcpServers?: { github?: { env?: { GITHUB_TOKEN?: string } } }; + gateway?: unknown; + }; + expect(sanitized.nvidia?.apiKey).toBe("[STRIPPED_BY_MIGRATION]"); + expect(sanitized.mcpServers?.github?.env?.GITHUB_TOKEN).toBe("[STRIPPED_BY_MIGRATION]"); + expect(sanitized.gateway).toBeUndefined(); + expect(sanitized.agents?.defaults?.model?.primary).toBe("nvidia/nemotron-3-super-120b-a12b"); + expect(fs.readFileSync(path.join(workspaceDir, "project.md"), "utf8")).toBe("# My Project\n"); + } finally { + fs.rmSync(tmp, { recursive: true, force: true }); + } +} + +function assertCredentialFieldDetectionContract(): void { + const credentialFields = [ + "accessToken", + "refreshToken", + "privateKey", + "clientSecret", + "signingKey", + "bearerToken", + "sessionToken", + "authKey", + ]; + for (const field of credentialFields) { + expect(isCredentialField(field), `${field} should be credential-bearing`).toBe(true); + } + + const config = { + provider: Object.fromEntries( + credentialFields.map((field) => [field, `test-${field}-value`]), + ) as Record, + displayName: "should-be-preserved", + sortKey: "should-also-be-preserved", + modelName: "nvidia/nemotron-3-super-120b-a12b", + keyRef: { source: "env", id: "NVIDIA_API_KEY" }, + description: "A secret garden (but not a real secret)", + tokenizer: "sentencepiece", + endpoint: "https://api.nvidia.com/v1", + sessionId: "abc-123", + accessLevel: "admin", + publicUrl: "https://example.com", + }; + + const sanitized = stripCredentials(config); + for (const value of Object.values(sanitized.provider)) { + expect(value).toBe("[STRIPPED_BY_MIGRATION]"); + } + expect(sanitized.displayName).toBe(config.displayName); + expect(sanitized.sortKey).toBe(config.sortKey); + expect(sanitized.modelName).toBe(config.modelName); + expect(sanitized.keyRef).toEqual(config.keyRef); + expect(sanitized.description).toBe(config.description); + expect(sanitized.tokenizer).toBe(config.tokenizer); + expect(sanitized.endpoint).toBe(config.endpoint); + expect(sanitized.sessionId).toBe(config.sessionId); + expect(sanitized.accessLevel).toBe(config.accessLevel); + expect(sanitized.publicUrl).toBe(config.publicUrl); +} + +function assertBlueprintDigestContract(): void { + const blueprint = YAML.parse(fs.readFileSync(BLUEPRINT_FILE, "utf8")) as Blueprint; + const topLevelDigest = typeof blueprint.digest === "string" ? blueprint.digest : ""; + expect(topLevelDigest).toMatch(/^sha256:[0-9a-f]{64}$/); + + const image = + typeof blueprint.components?.sandbox?.image === "string" + ? blueprint.components.sandbox.image + : ""; + const imageDigest = image.match(/@sha256:([0-9a-f]{64})$/)?.[1] ?? ""; + expect(`sha256:${imageDigest}`).toBe(topLevelDigest); +} + +async function assertSandboxCredentialBoundary( + sandbox: SandboxClient, + home: string, + apiKey: string, +): Promise { + const env = testEnv(home); + const authProbe = await sandbox.exec( + SANDBOX_NAME, + [ + "sh", + "-lc", + "find /sandbox -name auth-profiles.json -not -path '*/node_modules/*' -not -path '*/dist/*' -print 2>/dev/null | head -5", + ], + { + artifactName: "sandbox-auth-profiles-probe-credential-sanitization", + env, + timeoutMs: SANDBOX_PROBE_TIMEOUT_MS, + }, + ); + expect(authProbe.exitCode, resultText(authProbe)).toBe(0); + expect(authProbe.stdout.trim(), "auth-profiles.json must not be present in sandbox state").toBe( + "", + ); + + const secretProbe = await sandbox.exec( + SANDBOX_NAME, + [ + "sh", + "-lc", + String.raw`for dir in /sandbox/.openclaw /sandbox/.nemoclaw; do + [ -d "$dir" ] || continue + grep -rE 'nvapi-|ghp_|npm_' "$dir" 2>/dev/null \ + | grep -v 'STRIPPED' \ + | grep -v '/policies/' \ + | grep -v '/plugin-runtime-deps/' \ + | grep -Ev '/extensions/[^/]+/(dist|node_modules)/' \ + | head -5 || true +done`, + ], + { + artifactName: "sandbox-secret-pattern-probe-credential-sanitization", + env, + redactionValues: [apiKey], + timeoutMs: SANDBOX_PROBE_TIMEOUT_MS, + }, + ); + expect(secretProbe.exitCode, resultText(secretProbe)).toBe(0); + expect(secretProbe.stdout.trim(), "sandbox config must not contain secret-shaped tokens").toBe( + "", + ); +} + +runCredentialSanitizationTest( + "credential sanitization strips migration bundles and keeps sandbox secrets out of agent state", + { timeout: INSTALL_TIMEOUT_MS + 10 * 60_000 }, + async ({ artifacts, cleanup, host, sandbox, secrets, skip }) => { + expect( + fs.existsSync(CLI_ENTRYPOINT), + "run `npm run build:cli` before live repo CLI scenarios", + ).toBe(true); + + await artifacts.writeJson("scenario.json", { + id: "credential-sanitization", + runner: "vitest", + boundary: "install-sh-onboard-and-sandbox-exec", + legacySource: "test/e2e/test-credential-sanitization.sh", + sandboxName: SANDBOX_NAME, + contracts: [ + "credential fields are stripped from migration bundle config while non-secret state survives", + "auth-profiles.json is removed from migration bundle state", + "pattern-based credential field detection strips token/key/secret/password suffixes without corrupting benign fields", + "shipped blueprint digest is non-empty and matches the pinned sandbox image digest", + "install.sh onboards a real Docker/OpenShell sandbox on the ubuntu-latest runner class", + "sandbox filesystem does not expose auth-profiles.json or secret-shaped token values in agent state", + ], + }); + + assertLocalCredentialSanitizationContract(); + assertCredentialFieldDetectionContract(); + assertBlueprintDigestContract(); + + const apiKey = secrets.required("NVIDIA_API_KEY"); + expect(apiKey.startsWith("nvapi-"), "NVIDIA_API_KEY must start with nvapi-").toBe(true); + + const docker = await host.command("docker", ["info"], { + artifactName: "prereq-docker-info-credential-sanitization", + env: buildAvailabilityProbeEnv(), + timeoutMs: 30_000, + }); + if (docker.exitCode !== 0) { + if (process.env.GITHUB_ACTIONS === "true") { + throw new Error( + `Docker is required for credential sanitization live E2E: ${resultText(docker)}`, + ); + } + skip("Docker is required for credential sanitization live E2E"); + } + + const home = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-cred-sanitization-home-")); + cleanup.add(`remove credential sanitization state for ${SANDBOX_NAME}`, async () => { + await cleanupCredentialSanitizationState(host, home); + fs.rmSync(home, { recursive: true, force: true }); + }); + + await cleanupCredentialSanitizationState(host, home); + + const install = await host.command( + "bash", + ["install.sh", "--non-interactive", "--yes-i-accept-third-party-software"], + { + artifactName: "install-and-onboard-credential-sanitization", + cwd: REPO_ROOT, + env: testEnv(home, { + NVIDIA_API_KEY: apiKey, + NEMOCLAW_SANDBOX_NAME: SANDBOX_NAME, + NEMOCLAW_RECREATE_SANDBOX: "1", + }), + redactionValues: [apiKey], + timeoutMs: INSTALL_TIMEOUT_MS, + }, + ); + expect(install.exitCode, resultText(install)).toBe(0); + + const status = await host.command("node", [CLI_ENTRYPOINT, SANDBOX_NAME, "status"], { + artifactName: "nemoclaw-status-credential-sanitization", + env: testEnv(home), + timeoutMs: 60_000, + }); + expect(status.exitCode, resultText(status)).toBe(0); + + await assertSandboxCredentialBoundary(sandbox, home, apiKey); + }, +); diff --git a/test/e2e-scenario/support-tests/e2e-scenarios-workflow.test.ts b/test/e2e-scenario/support-tests/e2e-scenarios-workflow.test.ts index c4cfe853e5c..dc52bcc594d 100644 --- a/test/e2e-scenario/support-tests/e2e-scenarios-workflow.test.ts +++ b/test/e2e-scenario/support-tests/e2e-scenarios-workflow.test.ts @@ -114,6 +114,22 @@ describe("e2e-vitest-scenarios workflow boundary", () => { selectedFreeStandingJobs: ["openshell-version-pin-vitest"], registryScenarios: [], }); + expect( + evaluateE2eVitestWorkflowDispatchSelectors({ scenarios: "credential-sanitization" }), + ).toMatchObject({ + valid: true, + liveScenariosRuns: false, + selectedFreeStandingJobs: ["credential-sanitization-vitest"], + registryScenarios: [], + }); + expect( + evaluateE2eVitestWorkflowDispatchSelectors({ jobs: "credential-sanitization-vitest" }), + ).toMatchObject({ + valid: true, + liveScenariosRuns: false, + selectedFreeStandingJobs: ["credential-sanitization-vitest"], + registryScenarios: [], + }); expect( evaluateE2eVitestWorkflowDispatchSelectors({ jobs: "runtime-overrides-vitest" }), ).toMatchObject({ @@ -213,6 +229,18 @@ describe("e2e-vitest-scenarios workflow boundary", () => { hermes_selected: "false", matrix: "[]", }); + expect( + generateMatrixForDispatch({ JOBS: "credential-sanitization-vitest", SCENARIOS: "" }), + ).toMatchObject({ + hermes_selected: "false", + matrix: "[]", + }); + expect( + generateMatrixForDispatch({ JOBS: "", SCENARIOS: "credential-sanitization" }), + ).toMatchObject({ + hermes_selected: "false", + matrix: "[]", + }); expect(generateMatrixForDispatch({ JOBS: "hermes-e2e-vitest", SCENARIOS: "" })).toMatchObject({ hermes_selected: "true", matrix: "[]", @@ -594,6 +622,8 @@ jobs: "onboard-negative-paths-vitest artifact upload retention-days must be 14", "credential-migration-vitest job must depend on validate-jobs", "credential-migration-vitest job must use the shared jobs selector condition", + "credential-sanitization-vitest job must depend on validate-jobs and generate-matrix", + "credential-sanitization-vitest job must use the shared jobs selector condition", "workflow missing runtime-overrides-vitest job", "network-policy-vitest checkout action must be pinned to a full commit SHA", "network-policy-vitest checkout step must set persist-credentials=false", @@ -618,6 +648,7 @@ jobs: "network-policy-vitest artifact upload must ignore missing fixture artifacts", "network-policy-vitest artifact upload retention-days must be 14", "report-to-pr job must wait for credential-migration-vitest", + "report-to-pr job must wait for credential-sanitization-vitest", "report-to-pr job must wait for runtime-overrides-vitest", "report-to-pr job must wait for network-policy-vitest", "double-onboard-vitest job must depend on validate-jobs", diff --git a/tools/e2e-scenarios/workflow-boundary.mts b/tools/e2e-scenarios/workflow-boundary.mts index 0f259f6d11b..74e301619ff 100644 --- a/tools/e2e-scenarios/workflow-boundary.mts +++ b/tools/e2e-scenarios/workflow-boundary.mts @@ -31,10 +31,12 @@ const FREE_STANDING_SCENARIO_JOBS = new Map([ ["openclaw-tui-chat-correlation", "openclaw-tui-chat-correlation-vitest"], ["issue-4434-tui-unreachable-inference", "issue-4434-tui-unreachable-inference-vitest"], ["model-router-provider-routed-inference", "model-router-provider-routed-inference-vitest"], + ["credential-sanitization", "credential-sanitization-vitest"], ]); const ALLOWED_FREE_STANDING_JOBS = new Set([ ...FREE_STANDING_SCENARIO_JOBS.values(), "credential-migration-vitest", + "credential-sanitization-vitest", "gateway-guard-recovery", "double-onboard-vitest", ]); @@ -284,6 +286,7 @@ function validateJobsSelector(errors: string[], jobs: WorkflowRecord): void { requireRunContains(errors, validate, "onboard-negative-paths-vitest"); requireRunContains(errors, validate, "inference-routing-vitest"); requireRunContains(errors, validate, "credential-migration-vitest"); + requireRunContains(errors, validate, "credential-sanitization-vitest"); requireRunContains(errors, validate, "runtime-overrides-vitest"); requireRunContains(errors, validate, "double-onboard-vitest"); requireRunContains(errors, validate, "hermes-e2e-vitest"); @@ -1531,6 +1534,8 @@ export function validateE2eVitestScenariosWorkflowBoundary( requireRunContains(errors, generate, "token-rotation-vitest"); requireRunContains(errors, generate, "model-router-provider-routed-inference-vitest"); requireRunContains(errors, generate, "model-router-provider-routed-inference"); + requireRunContains(errors, generate, "credential-sanitization-vitest"); + requireRunContains(errors, generate, "credential-sanitization"); requireRunContains(errors, generate, 'matrix="[]"'); requireRunContains(errors, generate, "npx tsx test/e2e-scenario/scenarios/run.ts"); requireRunContains(errors, generate, "--emit-live-matrix"); @@ -1684,6 +1689,7 @@ export function validateE2eVitestScenariosWorkflowBoundary( validateOpenShellVersionPinVitestJob(errors, jobs); validateOnboardNegativePathsVitestJob(errors, jobs); validateFreeStandingJobSelector(errors, jobs, "credential-migration-vitest"); + validateFreeStandingJobSelector(errors, jobs, "credential-sanitization-vitest", "credential-sanitization"); validateFreeStandingJobSelector(errors, jobs, "inference-routing-vitest", "inference-routing"); validateRuntimeOverridesVitestJob(errors, jobs); validateDoubleOnboardVitestJob(errors, jobs); @@ -1720,6 +1726,7 @@ export function validateE2eVitestScenariosWorkflowBoundary( "onboard-negative-paths-vitest", "inference-routing-vitest", "credential-migration-vitest", + "credential-sanitization-vitest", "runtime-overrides-vitest", "hermes-e2e-vitest", "hermes-root-entrypoint-smoke-vitest", From b8a9a8581b8437e5db1050e74f370723376c067b Mon Sep 17 00:00:00 2001 From: Julie Yaunches Date: Fri, 12 Jun 2026 10:25:48 -0400 Subject: [PATCH 2/4] fix(e2e): keep vitest workflow dispatch parseable --- .github/workflows/e2e-vitest-scenarios.yaml | 2 +- tools/e2e-scenarios/workflow-boundary.mts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-vitest-scenarios.yaml b/.github/workflows/e2e-vitest-scenarios.yaml index 971c17d809f..9865fdff301 100644 --- a/.github/workflows/e2e-vitest-scenarios.yaml +++ b/.github/workflows/e2e-vitest-scenarios.yaml @@ -1213,7 +1213,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 env: - DOCKER_CONFIG: ${{ runner.temp }}/docker-config-model-router-provider-routed-inference + DOCKER_CONFIG: ${{ github.workspace }}/.docker-auth/model-router-provider-routed-inference E2E_ARTIFACT_DIR: ${{ github.workspace }}/e2e-artifacts/vitest/model-router-provider-routed-inference NEMOCLAW_CLI_BIN: ${{ github.workspace }}/bin/nemoclaw.js NEMOCLAW_RUN_E2E_SCENARIOS: "1" diff --git a/tools/e2e-scenarios/workflow-boundary.mts b/tools/e2e-scenarios/workflow-boundary.mts index 74e301619ff..b025c072b8f 100644 --- a/tools/e2e-scenarios/workflow-boundary.mts +++ b/tools/e2e-scenarios/workflow-boundary.mts @@ -1302,7 +1302,7 @@ function validateModelRouterProviderRoutedInferenceVitestJob( const jobEnv = asRecord(job.env); if ( jobEnv.DOCKER_CONFIG !== - "${{ runner.temp }}/docker-config-model-router-provider-routed-inference" + "${{ github.workspace }}/.docker-auth/model-router-provider-routed-inference" ) { errors.push( "model-router-provider-routed-inference-vitest job must isolate Docker auth with DOCKER_CONFIG under runner.temp", From d192526fdd54ea23d9a995aa21c74edaa505bf17 Mon Sep 17 00:00:00 2001 From: Julie Yaunches Date: Fri, 12 Jun 2026 10:36:05 -0400 Subject: [PATCH 3/4] fix(e2e): avoid multiline sandbox credential probe --- .../live/credential-sanitization.test.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/e2e-scenario/live/credential-sanitization.test.ts b/test/e2e-scenario/live/credential-sanitization.test.ts index d7958f24121..0c9bd56f75a 100644 --- a/test/e2e-scenario/live/credential-sanitization.test.ts +++ b/test/e2e-scenario/live/credential-sanitization.test.ts @@ -266,15 +266,15 @@ async function assertSandboxCredentialBoundary( [ "sh", "-lc", - String.raw`for dir in /sandbox/.openclaw /sandbox/.nemoclaw; do - [ -d "$dir" ] || continue - grep -rE 'nvapi-|ghp_|npm_' "$dir" 2>/dev/null \ - | grep -v 'STRIPPED' \ - | grep -v '/policies/' \ - | grep -v '/plugin-runtime-deps/' \ - | grep -Ev '/extensions/[^/]+/(dist|node_modules)/' \ - | head -5 || true -done`, + "for dir in /sandbox/.openclaw /sandbox/.nemoclaw; do " + + '[ -d "$dir" ] || continue; ' + + "grep -rE 'nvapi-|ghp_|npm_' \"$dir\" 2>/dev/null " + + "| grep -v 'STRIPPED' " + + "| grep -v '/policies/' " + + "| grep -v '/plugin-runtime-deps/' " + + "| grep -Ev '/extensions/[^/]+/(dist|node_modules)/' " + + "| head -5 || true; " + + "done", ], { artifactName: "sandbox-secret-pattern-probe-credential-sanitization", From f2cd7cc4698f1736e18205b89d64c4cf8972e0da Mon Sep 17 00:00:00 2001 From: Julie Yaunches Date: Fri, 12 Jun 2026 13:36:09 -0400 Subject: [PATCH 4/4] fix(e2e): align credential job dependency --- .github/workflows/e2e-vitest-scenarios.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-vitest-scenarios.yaml b/.github/workflows/e2e-vitest-scenarios.yaml index 30bec49946f..f199050c83d 100644 --- a/.github/workflows/e2e-vitest-scenarios.yaml +++ b/.github/workflows/e2e-vitest-scenarios.yaml @@ -694,7 +694,7 @@ jobs: credential-sanitization-vitest: - needs: [validate-jobs, generate-matrix] + needs: generate-matrix if: ${{ (inputs.jobs == '' && inputs.scenarios == '') || contains(format(',{0},', inputs.jobs), ',credential-sanitization-vitest,') || contains(format(',{0},', inputs.scenarios), ',credential-sanitization,') }} runs-on: ubuntu-latest timeout-minutes: 65