-
Notifications
You must be signed in to change notification settings - Fork 9
feat: hide /tmp/gh-aw/mcp-logs/ from agent containers #706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0eff01a
8203261
ade525e
069a255
88995f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -718,6 +718,17 @@ export function generateDockerCompose( | |
| dns_search: [], // Disable DNS search domains to prevent embedded DNS fallback | ||
| volumes: agentVolumes, | ||
| environment, | ||
| // Hide /tmp/gh-aw/mcp-logs directory using tmpfs (empty in-memory filesystem) | ||
| // This prevents the agent from accessing MCP server logs while still allowing | ||
| // the host to write logs to /tmp/gh-aw/mcp-logs/ (e.g., /tmp/gh-aw/mcp-logs/safeoutputs/) | ||
| // For normal mode: hide /tmp/gh-aw/mcp-logs | ||
| // For chroot mode: hide both /tmp/gh-aw/mcp-logs and /host/tmp/gh-aw/mcp-logs | ||
| tmpfs: config.enableChroot | ||
|
Comment on lines
+721
to
+726
|
||
| ? [ | ||
| '/tmp/gh-aw/mcp-logs:rw,noexec,nosuid,size=1m', | ||
| '/host/tmp/gh-aw/mcp-logs:rw,noexec,nosuid,size=1m', | ||
| ] | ||
| : ['/tmp/gh-aw/mcp-logs:rw,noexec,nosuid,size=1m'], | ||
| depends_on: { | ||
| 'squid-proxy': { | ||
| condition: 'service_healthy', | ||
|
|
@@ -861,9 +872,28 @@ export async function writeConfigs(config: WrapperConfig): Promise<void> { | |
| const squidLogsDir = config.proxyLogsDir || path.join(config.workDir, 'squid-logs'); | ||
| if (!fs.existsSync(squidLogsDir)) { | ||
| fs.mkdirSync(squidLogsDir, { recursive: true, mode: 0o777 }); | ||
| // Explicitly set permissions to 0o777 (not affected by umask) | ||
| fs.chmodSync(squidLogsDir, 0o777); | ||
| } | ||
| logger.debug(`Squid logs directory created at: ${squidLogsDir}`); | ||
|
|
||
| // Create /tmp/gh-aw/mcp-logs directory | ||
| // This directory exists on the HOST for MCP gateway to write logs | ||
| // Inside the AWF container, it's hidden via tmpfs mount (see generateDockerCompose) | ||
| // Uses mode 0o777 to allow GitHub Actions workflows and MCP gateway to create subdirectories | ||
| // even when AWF runs as root (e.g., sudo awf --enable-chroot) | ||
| const mcpLogsDir = '/tmp/gh-aw/mcp-logs'; | ||
| if (!fs.existsSync(mcpLogsDir)) { | ||
| fs.mkdirSync(mcpLogsDir, { recursive: true, mode: 0o777 }); | ||
| // Explicitly set permissions to 0o777 (not affected by umask) | ||
| fs.chmodSync(mcpLogsDir, 0o777); | ||
| logger.debug(`MCP logs directory created at: ${mcpLogsDir}`); | ||
| } else { | ||
| // Fix permissions if directory already exists (e.g., created by a previous run) | ||
| fs.chmodSync(mcpLogsDir, 0o777); | ||
| logger.debug(`MCP logs directory permissions fixed at: ${mcpLogsDir}`); | ||
| } | ||
|
|
||
| // Use fixed network configuration (network is created by host-iptables.ts) | ||
| const networkConfig = { | ||
| subnet: '172.30.0.0/24', | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test writes to a global host path (/tmp/gh-aw/mcp-logs) and assumes it can enforce 0777 permissions, which can be flaky if the directory already exists from prior runs (possibly owned by root) or tests run in parallel. Consider mocking fs.mkdirSync/chmodSync to assert the intended calls, or adding a test-only hook/config to redirect the MCP logs dir to a per-test temp directory.