Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

fix(eve): redact network policy credentials from logs (#2225)

vercel-gh-bot-2[bot]cda9539d0393
diff --git a/.changeset/safe-network-policy-logs.md b/.changeset/safe-network-policy-logs.md
new file mode 100644
index 000000000..ab8e2122a
--- /dev/null
+++ b/.changeset/safe-network-policy-logs.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+Redact brokered credential transforms when sandbox network policies are written to bootstrap logs.
diff --git a/packages/eve/src/execution/sandbox/logging-session.test.ts b/packages/eve/src/execution/sandbox/logging-session.test.ts
index bf2a706ea..18ff9515e 100644
--- a/packages/eve/src/execution/sandbox/logging-session.test.ts
+++ b/packages/eve/src/execution/sandbox/logging-session.test.ts
@@ -24,6 +24,37 @@ describe("createLoggingSandboxSession", () => {
expect(log.mock.calls.flat().join("\n")).not.toContain("do-not-log");
});
+ it("redacts brokered credential values from network policy logs", async () => {
+ const log = vi.fn();
+ const session = createTestSession();
+ const wrapped = createLoggingSandboxSession({ log, session });
+
+ const policy = {
+ allow: {
+ "api.github.com": [
+ {
+ transform: [
+ {
+ headers: {
+ Authorization: "Bearer ghp_repro-do-not-log",
+ "x-api-key": "repro-api-key-do-not-log",
+ },
+ },
+ ],
+ },
+ ],
+ },
+ };
+ await wrapped.setNetworkPolicy(policy);
+
+ const message = log.mock.calls.flat().join("\n");
+ expect(message).toContain("api.github.com");
+ expect(message).toContain('"transform":"[redacted]"');
+ expect(message).not.toContain("ghp_repro-do-not-log");
+ expect(message).not.toContain("repro-api-key-do-not-log");
+ expect(session.setNetworkPolicy).toHaveBeenCalledWith(policy);
+ });
+
it("wraps the original session when no logger is provided", () => {
const session = createTestSession();
expect(createLoggingSandboxSession({ session })).not.toBe(session);
diff --git a/packages/eve/src/execution/sandbox/logging-session.ts b/packages/eve/src/execution/sandbox/logging-session.ts
index da263a131..760f4cf96 100644
--- a/packages/eve/src/execution/sandbox/logging-session.ts
+++ b/packages/eve/src/execution/sandbox/logging-session.ts
@@ -85,7 +85,13 @@ function formatCommand(command: string): string {
}
function formatNetworkPolicy(policy: SandboxNetworkPolicy): string {
- return truncateOneLine(typeof policy === "string" ? policy : JSON.stringify(policy));
+ return truncateOneLine(
+ typeof policy === "string"
+ ? policy
+ : JSON.stringify(policy, (key, value: unknown) =>
+ key === "transform" ? "[redacted]" : value,
+ ),
+ );
}
function truncateOneLine(value: string): string {