mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-24 18:19:05 +02:00
fix: keep host-only variables out of Codex agent shells
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
1f9976e8b9
commit
89dd2f6559
2 files changed
+10
-2
No files matched your search
@@ -89,6 +89,7 @@ describe("codex execute — outbound auth copy-back restore contribution", () =>
|
||||
|
||||
afterEach(async () => {
|
||||
vi.clearAllMocks();
|
||||
vi.unstubAllEnvs();
|
||||
if (savedCodexHomeEnv === undefined) {
|
||||
delete process.env.CODEX_HOME;
|
||||
} else {
|
||||
@@ -190,11 +191,16 @@ describe("codex execute — outbound auth copy-back restore contribution", () =>
|
||||
}
|
||||
|
||||
it("keeps assigned API and tool credentials in the identity-enabled CLI shell", async () => {
|
||||
vi.stubEnv("DATABASE_URL", "postgres://operator:host-password@host/private");
|
||||
vi.stubEnv("HOST_DATABASE_PASSWORD", "host-password");
|
||||
const { commandArgs } = await runTeardown({ sandboxAuth: "{}", hostAuth: "{}", withIdentity: true });
|
||||
const policy = commandArgs.find(arg => arg.startsWith("shell_environment_policy.include_only="));
|
||||
expect(JSON.parse(policy!.slice(policy!.indexOf("=") + 1))).toEqual(expect.arrayContaining([
|
||||
const keys = JSON.parse(policy!.slice(policy!.indexOf("=") + 1));
|
||||
expect(keys).toEqual(expect.arrayContaining([
|
||||
"PAPERCLIP_API_KEY", "MY_SERVICE_TOKEN", "PAPERCLIP_AGENT_PRIVATE_KEY",
|
||||
]));
|
||||
expect(keys).not.toContain("DATABASE_URL");
|
||||
expect(keys).not.toContain("HOST_DATABASE_PASSWORD");
|
||||
expect(commandArgs.join(" ")).not.toContain("assigned-run-token");
|
||||
expect(commandArgs.join(" ")).not.toContain("assigned-tool-token");
|
||||
});
|
||||
|
||||
@@ -1231,7 +1231,9 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
|
||||
if (ctx.agentIdentity) {
|
||||
const identityNames = ["PAPERCLIP_AGENT_KEY_ID", "PAPERCLIP_AGENT_PUBLIC_KEY", "PAPERCLIP_AGENT_PRIVATE_KEY"];
|
||||
const shellKeys = [...new Set([
|
||||
...Object.keys(process.env).filter(key => !/key|secret|token/i.test(key)),
|
||||
"PATH", "HOME", "LANG", "LANGUAGE", "LC_ALL", "LC_CTYPE", "TZ", "TMPDIR", "TEMP", "TMP", "CODEX_HOME",
|
||||
// Only explicitly assigned run/config credentials cross this boundary.
|
||||
// Arbitrary host variables (DATABASE_URL, passwords, etc.) do not.
|
||||
...Object.keys(env), ...identityNames,
|
||||
])];
|
||||
args.unshift("-c", "features.shell_snapshot=false", "-c", 'shell_environment_policy.inherit="all"', "-c", "shell_environment_policy.ignore_default_excludes=true",
|
||||
|
||||
Reference in new issue
Block a user