-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat(sandbox): version staleness detection and rebuild command #1870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
ef0edc9
feat(sandbox): add version staleness detection and rebuild command
ericksoa a9551e8
fix(test): remove stderr from CaptureOpenshellResult mock
ericksoa cd93dc8
Merge branch 'main' into fix/sandbox-rebuild-stale-version
ericksoa 0fbcd7d
test(e2e): add nightly rebuild upgrade E2E for OpenClaw and Hermes
ericksoa 82a3b02
merge(main): resolve nightly-e2e.yaml conflict (keep sandbox-operatio…
ericksoa 361f680
fix(e2e): patch blueprint min_openclaw_version for old base image build
ericksoa 68a5c24
fix(rebuild): fix sandbox name override and rewrite E2E tests
ericksoa 1b5fc13
Merge branch 'main' into fix/sandbox-rebuild-stale-version
ericksoa 0306630
fix(e2e): pass --no-tty -- true to openshell sandbox create to avoid …
ericksoa 42ebdae
Merge branch 'fix/sandbox-rebuild-stale-version' of https://github.co…
ericksoa 541f5f2
fix(rebuild): don't tear down gateway or null session during rebuild
ericksoa 32a5ab1
fix(rebuild): mark session resumable before onboard and fix portable sed
ericksoa e9e49e7
fix(rebuild): preserve gateway, add verbose diagnostics to rebuild an…
ericksoa cccadfd
test(e2e): add post-rebuild inference smoke test to verify credential…
ericksoa 9936f11
feat(rebuild): run openclaw doctor --fix after restore for cross-vers…
ericksoa 0dc3bac
docs(rebuild): document why Hermes needs no post-restore migration step
ericksoa b495315
Merge branch 'main' into fix/sandbox-rebuild-stale-version
ericksoa a6a4f9f
feat(rebuild): add backup-all command and pre-upgrade backup in insta…
ericksoa 265d559
Merge branch 'fix/sandbox-rebuild-stale-version' of https://github.co…
ericksoa 7409b48
fix(rebuild): address CodeRabbit review — credential gaps, dead dispa…
ericksoa 0f43fb2
Merge branch 'main' into fix/sandbox-rebuild-stale-version
ericksoa f61977b
fix(rebuild): address remaining CodeRabbit review feedback
ericksoa b18524a
Merge branch 'fix/sandbox-rebuild-stale-version' of https://github.co…
ericksoa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { describe, expect, it, beforeEach, afterEach } from "vitest"; | ||
| import { mkdtempSync, writeFileSync, readFileSync, existsSync, mkdirSync } from "node:fs"; | ||
| import { join } from "node:path"; | ||
| import { tmpdir } from "node:os"; | ||
| import { rmSync } from "node:fs"; | ||
|
|
||
| import { | ||
| isCredentialField, | ||
| stripCredentials, | ||
| sanitizeConfigFile, | ||
| isSensitiveFile, | ||
| CREDENTIAL_SENSITIVE_BASENAMES, | ||
| } from "./credential-filter.js"; | ||
|
|
||
| describe("isCredentialField", () => { | ||
| it("matches explicit field names", () => { | ||
| expect(isCredentialField("apiKey")).toBe(true); | ||
| expect(isCredentialField("api_key")).toBe(true); | ||
| expect(isCredentialField("token")).toBe(true); | ||
| expect(isCredentialField("secret")).toBe(true); | ||
| expect(isCredentialField("password")).toBe(true); | ||
| expect(isCredentialField("resolvedKey")).toBe(true); | ||
| }); | ||
|
|
||
| it("matches pattern-based names", () => { | ||
| expect(isCredentialField("accessToken")).toBe(true); | ||
| expect(isCredentialField("refreshToken")).toBe(true); | ||
| expect(isCredentialField("clientSecret")).toBe(true); | ||
| expect(isCredentialField("bearerToken")).toBe(true); | ||
| expect(isCredentialField("privateKey")).toBe(true); | ||
| expect(isCredentialField("sessionToken")).toBe(true); | ||
| }); | ||
|
|
||
| it("does not match safe field names", () => { | ||
| expect(isCredentialField("name")).toBe(false); | ||
| expect(isCredentialField("model")).toBe(false); | ||
| expect(isCredentialField("provider")).toBe(false); | ||
| expect(isCredentialField("endpoint")).toBe(false); | ||
| expect(isCredentialField("version")).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe("stripCredentials", () => { | ||
| it("strips top-level credential fields", () => { | ||
| const input = { model: "gpt-4", apiKey: "sk-123", name: "test" }; | ||
| const result = stripCredentials(input) as Record<string, unknown>; | ||
| expect(result.model).toBe("gpt-4"); | ||
| expect(result.apiKey).toBe("[STRIPPED_BY_MIGRATION]"); | ||
| expect(result.name).toBe("test"); | ||
| }); | ||
|
|
||
| it("strips nested credential fields", () => { | ||
| const input = { providers: { openai: { apiKey: "sk-123", model: "gpt-4" } } }; | ||
| const result = stripCredentials(input) as Record<string, unknown>; | ||
| const providers = result.providers as Record<string, unknown>; | ||
| const openai = providers.openai as Record<string, unknown>; | ||
| expect(openai.apiKey).toBe("[STRIPPED_BY_MIGRATION]"); | ||
| expect(openai.model).toBe("gpt-4"); | ||
| }); | ||
|
|
||
| it("strips credentials in arrays", () => { | ||
| const input = { items: [{ token: "abc" }, { name: "safe" }] }; | ||
| const result = stripCredentials(input) as Record<string, unknown>; | ||
| const items = result.items as Array<Record<string, unknown>>; | ||
| expect(items[0].token).toBe("[STRIPPED_BY_MIGRATION]"); | ||
| expect(items[1].name).toBe("safe"); | ||
| }); | ||
|
|
||
| it("handles null and primitives", () => { | ||
| expect(stripCredentials(null)).toBeNull(); | ||
| expect(stripCredentials(undefined)).toBeUndefined(); | ||
| expect(stripCredentials("hello")).toBe("hello"); | ||
| expect(stripCredentials(42)).toBe(42); | ||
| }); | ||
| }); | ||
|
|
||
| describe("sanitizeConfigFile", () => { | ||
| let tmpDir: string; | ||
|
|
||
| beforeEach(() => { | ||
| tmpDir = mkdtempSync(join(tmpdir(), "cred-filter-test-")); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| rmSync(tmpDir, { recursive: true, force: true }); | ||
| }); | ||
|
|
||
| it("strips credentials and removes gateway section", () => { | ||
| const configPath = join(tmpDir, "openclaw.json"); | ||
| writeFileSync(configPath, JSON.stringify({ | ||
| model: "gpt-4", | ||
| apiKey: "sk-secret", | ||
| gateway: { port: 8080, authToken: "gw-token" }, | ||
| })); | ||
|
|
||
| sanitizeConfigFile(configPath); | ||
|
|
||
| const result = JSON.parse(readFileSync(configPath, "utf-8")); | ||
| expect(result.model).toBe("gpt-4"); | ||
| expect(result.apiKey).toBe("[STRIPPED_BY_MIGRATION]"); | ||
| expect(result.gateway).toBeUndefined(); | ||
| }); | ||
|
|
||
| it("skips non-existent files", () => { | ||
| sanitizeConfigFile(join(tmpDir, "nonexistent.json")); | ||
| // Should not throw | ||
| }); | ||
|
|
||
| it("skips invalid JSON", () => { | ||
| const configPath = join(tmpDir, "bad.json"); | ||
| writeFileSync(configPath, "not json at all"); | ||
| sanitizeConfigFile(configPath); | ||
| // Should not throw, file unchanged | ||
| expect(readFileSync(configPath, "utf-8")).toBe("not json at all"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("isSensitiveFile", () => { | ||
| it("detects auth-profiles.json", () => { | ||
| expect(isSensitiveFile("auth-profiles.json")).toBe(true); | ||
| expect(isSensitiveFile("Auth-Profiles.json")).toBe(true); | ||
| }); | ||
|
|
||
| it("does not flag normal files", () => { | ||
| expect(isSensitiveFile("openclaw.json")).toBe(false); | ||
| expect(isSensitiveFile("config.yaml")).toBe(false); | ||
| expect(isSensitiveFile("SOUL.md")).toBe(false); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.