mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-29 21:48:37 +00:00
Secrets: reject exec SecretRef traversal ids across schema/runtime/gateway (#42370)
* Secrets: harden exec SecretRef validation and reload LKG coverage * Tests: harden exec fast-exit stdin regression case * Tests: align lifecycle daemon test formatting with oxfmt 0.36
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
INVALID_EXEC_SECRET_REF_IDS,
|
||||
VALID_EXEC_SECRET_REF_IDS,
|
||||
} from "../test-utils/secret-ref-test-vectors.js";
|
||||
import { validateConfigObjectRaw } from "./validation.js";
|
||||
|
||||
function validateOpenAiApiKeyRef(apiKey: unknown) {
|
||||
@@ -173,4 +177,31 @@ describe("config secret refs schema", () => {
|
||||
).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it("accepts valid exec secret reference ids", () => {
|
||||
for (const id of VALID_EXEC_SECRET_REF_IDS) {
|
||||
const result = validateOpenAiApiKeyRef({
|
||||
source: "exec",
|
||||
provider: "vault",
|
||||
id,
|
||||
});
|
||||
expect(result.ok, `expected valid exec ref id: ${id}`).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects invalid exec secret reference ids", () => {
|
||||
for (const id of INVALID_EXEC_SECRET_REF_IDS) {
|
||||
const result = validateOpenAiApiKeyRef({
|
||||
source: "exec",
|
||||
provider: "vault",
|
||||
id,
|
||||
});
|
||||
expect(result.ok, `expected invalid exec ref id: ${id}`).toBe(false);
|
||||
if (!result.ok) {
|
||||
expect(
|
||||
result.issues.some((issue) => issue.path.includes("models.providers.openai.apiKey")),
|
||||
).toBe(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user