惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
A
About on SuperTechFans
The Cloudflare Blog
G
Google Developers Blog
博客园_首页
Martin Fowler
Martin Fowler
Apple Machine Learning Research
Apple Machine Learning Research
L
LangChain Blog
D
Docker
C
Check Point Blog
T
Tailwind CSS Blog
博客园 - 司徒正美
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Hugging Face - Blog
Hugging Face - Blog
Microsoft Security Blog
Microsoft Security Blog
V
V2EX
博客园 - 叶小钗
T
The Blog of Author Tim Ferriss
酷 壳 – CoolShell
酷 壳 – CoolShell
IT之家
IT之家
M
MIT News - Artificial intelligence
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 【当耐特】
GbyAI
GbyAI

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
test: tighten exec approvals store assertions · openclaw/...
steipete · 2026-05-11 · via Recent Commits to openclaw:main

@@ -87,6 +87,27 @@ function listExecApprovalTempFiles(homeDir: string): string[] {

8787

return fs.readdirSync(dir).filter((name) => name.endsWith(".tmp"));

8888

}

898990+

function requireRecord(value: unknown): Record<string, unknown> {

91+

expect(value).toBeTruthy();

92+

expect(typeof value).toBe("object");

93+

expect(Array.isArray(value)).toBe(false);

94+

return value as Record<string, unknown>;

95+

}

96+97+

function allowlistEntries(homeDir: string, agentId: string): Record<string, unknown>[] {

98+

const file = readApprovalsFile(homeDir);

99+

return (file.agents?.[agentId]?.allowlist ?? []).map((entry) => requireRecord(entry));

100+

}

101+102+

function expectAllowlistEntryFields(

103+

entry: Record<string, unknown>,

104+

fields: Record<string, unknown>,

105+

): void {

106+

for (const [key, value] of Object.entries(fields)) {

107+

expect(entry[key]).toEqual(value);

108+

}

109+

}

110+90111

describe("exec approvals store helpers", () => {

91112

it("expands home-prefixed default file and socket paths", () => {

92113

const dir = createHomeDir();

@@ -417,13 +438,13 @@ describe("exec approvals store helpers", () => {

417438

addAllowlistEntry(approvals, "worker", "/usr/bin/rg");

418439

addAllowlistEntry(approvals, "worker", " ");

419440420-

expect(readApprovalsFile(dir).agents?.worker?.allowlist).toEqual([

421-

expect.objectContaining({

422-

pattern: "/usr/bin/rg",

423-

lastUsedAt: 123_456,

424-

}),

425-

]);

426-

expect(readApprovalsFile(dir).agents?.worker?.allowlist?.[0]?.id).toMatch(/^[0-9a-f-]{36}$/i);

441+

const allowlist = allowlistEntries(dir, "worker");

442+

expect(allowlist).toHaveLength(1);

443+

expectAllowlistEntryFields(allowlist[0] ?? {}, {

444+

pattern: "/usr/bin/rg",

445+

lastUsedAt: 123_456,

446+

});

447+

expect(allowlist[0]?.id).toMatch(/^[0-9a-f-]{36}$/i);

427448

});

428449429450

it("persists durable command approvals without storing plaintext command text", () => {

@@ -433,56 +454,36 @@ describe("exec approvals store helpers", () => {

433454

const approvals = ensureExecApprovals();

434455

addDurableCommandApproval(approvals, "worker", 'printenv API_KEY="secret-value"');

435456436-

expect(readApprovalsFile(dir).agents?.worker?.allowlist).toEqual([

437-

expect.objectContaining({

438-

source: "allow-always",

439-

lastUsedAt: 321_000,

440-

}),

441-

]);

442-

expect(readApprovalsFile(dir).agents?.worker?.allowlist?.[0]?.pattern).toMatch(

443-

/^=command:[0-9a-f]{16}$/i,

444-

);

445-

expect(readApprovalsFile(dir).agents?.worker?.allowlist?.[0]).not.toHaveProperty("commandText");

457+

const allowlist = allowlistEntries(dir, "worker");

458+

expect(allowlist).toHaveLength(1);

459+

expectAllowlistEntryFields(allowlist[0] ?? {}, {

460+

source: "allow-always",

461+

lastUsedAt: 321_000,

462+

});

463+

expect(allowlist[0]?.pattern).toMatch(/^=command:[0-9a-f]{16}$/i);

464+

expect(allowlist[0]).not.toHaveProperty("commandText");

446465

});

447466448467

it("strips legacy plaintext command text during normalization", () => {

449-

expect(

450-

normalizeExecApprovals({

451-

version: 1,

452-

agents: {

453-

main: {

454-

allowlist: [

455-

{

456-

pattern: "=command:test",

457-

source: "allow-always",

458-

commandText: "echo secret-token",

459-

},

460-

],

461-

},

462-

},

463-

}).agents?.main?.allowlist,

464-

).toEqual([

465-

expect.objectContaining({

466-

pattern: "=command:test",

467-

source: "allow-always",

468-

}),

469-

]);

470-

expect(

471-

normalizeExecApprovals({

472-

version: 1,

473-

agents: {

474-

main: {

475-

allowlist: [

476-

{

477-

pattern: "=command:test",

478-

source: "allow-always",

479-

commandText: "echo secret-token",

480-

},

481-

],

482-

},

468+

const normalized = normalizeExecApprovals({

469+

version: 1,

470+

agents: {

471+

main: {

472+

allowlist: [

473+

{

474+

pattern: "=command:test",

475+

source: "allow-always",

476+

commandText: "echo secret-token",

477+

},

478+

],

483479

},

484-

}).agents?.main?.allowlist?.[0],

485-

).not.toHaveProperty("commandText");

480+

},

481+

});

482+

const allowlist = normalized.agents?.main?.allowlist ?? [];

483+

expect(allowlist).toHaveLength(1);

484+

expect(allowlist[0]?.pattern).toBe("=command:test");

485+

expect(allowlist[0]?.source).toBe("allow-always");

486+

expect(allowlist[0]).not.toHaveProperty("commandText");

486487

});

487488488489

it("preserves source and argPattern metadata for allow-always entries", () => {

@@ -503,20 +504,20 @@ describe("exec approvals store helpers", () => {

503504

source: "allow-always",

504505

});

505506506-

expect(readApprovalsFile(dir).agents?.worker?.allowlist).toEqual([

507-

expect.objectContaining({

508-

pattern: "/usr/bin/python3",

509-

argPattern: "^script\\.py\x00$",

510-

source: "allow-always",

511-

lastUsedAt: 321_000,

512-

}),

513-

expect.objectContaining({

514-

pattern: "/usr/bin/python3",

515-

argPattern: "^other\\.py\x00$",

516-

source: "allow-always",

517-

lastUsedAt: 321_000,

518-

}),

519-

]);

507+

const allowlist = allowlistEntries(dir, "worker");

508+

expect(allowlist).toHaveLength(2);

509+

expectAllowlistEntryFields(allowlist[0] ?? {}, {

510+

pattern: "/usr/bin/python3",

511+

argPattern: "^script\\.py\x00$",

512+

source: "allow-always",

513+

lastUsedAt: 321_000,

514+

});

515+

expectAllowlistEntryFields(allowlist[1] ?? {}, {

516+

pattern: "/usr/bin/python3",

517+

argPattern: "^other\\.py\x00$",

518+

source: "allow-always",

519+

lastUsedAt: 321_000,

520+

});

520521

});

521522522523

it("records allowlist usage on the matching entry and backfills missing ids", () => {

@@ -542,16 +543,16 @@ describe("exec approvals store helpers", () => {

542543

"/opt/homebrew/bin/rg",

543544

);

544545545-

expect(readApprovalsFile(dir).agents?.main?.allowlist).toEqual([

546-

expect.objectContaining({

547-

pattern: "/usr/bin/rg",

548-

lastUsedAt: 999_000,

549-

lastUsedCommand: "rg needle",

550-

lastResolvedPath: "/opt/homebrew/bin/rg",

551-

}),

552-

{ pattern: "/usr/bin/jq", id: "keep-id" },

553-

]);

554-

expect(readApprovalsFile(dir).agents?.main?.allowlist?.[0]?.id).toMatch(/^[0-9a-f-]{36}$/i);

546+

const allowlist = allowlistEntries(dir, "main");

547+

expect(allowlist).toHaveLength(2);

548+

expectAllowlistEntryFields(allowlist[0] ?? {}, {

549+

pattern: "/usr/bin/rg",

550+

lastUsedAt: 999_000,

551+

lastUsedCommand: "rg needle",

552+

lastResolvedPath: "/opt/homebrew/bin/rg",

553+

});

554+

expect(allowlist[0]?.id).toMatch(/^[0-9a-f-]{36}$/i);

555+

expect(allowlist[1]).toEqual({ pattern: "/usr/bin/jq", id: "keep-id" });

555556

});

556557557558

it("dedupes allowlist usage by pattern and argPattern", () => {

@@ -584,18 +585,18 @@ describe("exec approvals store helpers", () => {

584585

resolvedPath: "/usr/bin/python3",

585586

});

586587587-

expect(readApprovalsFile(dir).agents?.main?.allowlist).toEqual([

588-

expect.objectContaining({

589-

pattern: "/usr/bin/python3",

590-

argPattern: "^a\\.py\x00$",

591-

lastUsedAt: 777_000,

592-

}),

593-

expect.objectContaining({

594-

pattern: "/usr/bin/python3",

595-

argPattern: "^b\\.py\x00$",

596-

lastUsedAt: 777_000,

597-

}),

598-

]);

588+

const allowlist = allowlistEntries(dir, "main");

589+

expect(allowlist).toHaveLength(2);

590+

expectAllowlistEntryFields(allowlist[0] ?? {}, {

591+

pattern: "/usr/bin/python3",

592+

argPattern: "^a\\.py\x00$",

593+

lastUsedAt: 777_000,

594+

});

595+

expectAllowlistEntryFields(allowlist[1] ?? {}, {

596+

pattern: "/usr/bin/python3",

597+

argPattern: "^b\\.py\x00$",

598+

lastUsedAt: 777_000,

599+

});

599600

});

600601601602

it("persists allow-always patterns with shared helper", () => {

@@ -633,14 +634,14 @@ describe("exec approvals store helpers", () => {

633634

argPattern: "^a\\.py\x00$",

634635

},

635636

]);

636-

expect(readApprovalsFile(dir).agents?.worker?.allowlist).toEqual([

637-

expect.objectContaining({

638-

pattern: "/usr/bin/custom-tool.exe",

639-

argPattern: "^a\\.py\x00$",

640-

source: "allow-always",

641-

lastUsedAt: 654_321,

642-

}),

643-

]);

637+

const allowlist = allowlistEntries(dir, "worker");

638+

expect(allowlist).toHaveLength(1);

639+

expectAllowlistEntryFields(allowlist[0] ?? {}, {

640+

pattern: "/usr/bin/custom-tool.exe",

641+

argPattern: "^a\\.py\x00$",

642+

source: "allow-always",

643+

lastUsedAt: 654_321,

644+

});

644645

});

645646646647

it("returns null when approval socket credentials are missing", async () => {