mirror of
https://github.com/harivansh-afk/clanker-agent.git
synced 2026-04-18 00:02:45 +00:00
- Copy all pi-mono source into apps/companion-os/ - Update Dockerfile to COPY pre-built binary instead of downloading from GitHub Releases - Update deploy-staging.yml to build pi from source (bun compile) before Docker build - Add apps/companion-os/** to path triggers - No more cross-repo dispatch needed Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
39 lines
1.7 KiB
TypeScript
39 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { inboxPath, sanitizeName, teamDir } from "./paths";
|
|
|
|
describe("Security Audit - Path Traversal (Prevention Check)", () => {
|
|
it("should throw an error for path traversal via teamName", () => {
|
|
const maliciousTeamName = "../../etc";
|
|
expect(() => teamDir(maliciousTeamName)).toThrow();
|
|
});
|
|
|
|
it("should throw an error for path traversal via agentName", () => {
|
|
const teamName = "audit-team";
|
|
const maliciousAgentName = "../../../.ssh/id_rsa";
|
|
expect(() => inboxPath(teamName, maliciousAgentName)).toThrow();
|
|
});
|
|
|
|
it("should throw an error for path traversal via taskId", () => {
|
|
const maliciousTaskId = "../../../etc/passwd";
|
|
// We need to import readTask/updateTask or just sanitizeName directly if we want to test the logic
|
|
// But since we already tested sanitizeName via other paths, this is just for completeness.
|
|
expect(() => sanitizeName(maliciousTaskId)).toThrow();
|
|
});
|
|
});
|
|
|
|
describe("Security Audit - Command Injection (Fixed)", () => {
|
|
it("should not be vulnerable to command injection in spawn_teammate (via parameters)", () => {
|
|
const maliciousCwd = "; rm -rf / ;";
|
|
const name = "attacker";
|
|
const team_name = "audit-team";
|
|
const piBinary = "pi";
|
|
const cmd = `PI_TEAM_NAME=${team_name} PI_AGENT_NAME=${name} ${piBinary}`;
|
|
|
|
// Simulating what happens in spawn_teammate (extensions/index.ts)
|
|
const itermCmd = `cd '${maliciousCwd}' && ${cmd}`;
|
|
|
|
// The command becomes: cd '; rm -rf / ;' && PI_TEAM_NAME=audit-team PI_AGENT_NAME=attacker pi
|
|
expect(itermCmd).toContain("cd '; rm -rf / ;' &&");
|
|
expect(itermCmd).not.toContain("cd ; rm -rf / ; &&");
|
|
});
|
|
});
|