Skip to content

Commit 8945204

Browse files
CopilotMossaka
andcommitted
feat: always mount /:/host:ro even with custom mounts
Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
1 parent 5c12927 commit 8945204

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

src/docker-manager.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ describe('docker-manager', () => {
270270
const agent = result.services.agent;
271271
const volumes = agent.volumes as string[];
272272

273-
// Should NOT include blanket /:/host:ro mount
274-
expect(volumes).not.toContain('/:/host:ro');
273+
// Should STILL include /:/host:ro mount for chroot functionality
274+
expect(volumes).toContain('/:/host:ro');
275275

276276
// Should include custom mounts
277277
expect(volumes).toContain('/workspace:/workspace:ro');
@@ -282,12 +282,12 @@ describe('docker-manager', () => {
282282
expect(volumes.some((v: string) => v.includes('agent-logs'))).toBe(true);
283283
});
284284

285-
it('should use blanket mount when no custom mounts specified', () => {
285+
it('should always include /:/host:ro mount for chroot functionality', () => {
286286
const result = generateDockerCompose(mockConfig, mockNetworkConfig);
287287
const agent = result.services.agent;
288288
const volumes = agent.volumes as string[];
289289

290-
// Should include blanket /:/host:ro mount
290+
// Should include /:/host:ro mount
291291
expect(volumes).toContain('/:/host:ro');
292292
});
293293

src/docker-manager.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,13 @@ export function generateDockerCompose(
355355
config.volumeMounts.forEach(mount => {
356356
agentVolumes.push(mount);
357357
});
358-
} else {
359-
// If no custom mounts specified, include blanket host filesystem mount for backward compatibility
360-
logger.debug('No custom mounts specified, using blanket /:/host:ro mount');
361-
agentVolumes.unshift('/:/host:ro');
362358
}
363359

360+
// Always include /:/host:ro mount for isolate.sh chroot functionality
361+
// This is added regardless of custom mounts to ensure commands can fall back to host binaries
362+
logger.debug('Adding /:/host:ro mount for chroot functionality');
363+
agentVolumes.unshift('/:/host:ro');
364+
364365
// Agent service configuration
365366
const agentService: any = {
366367
container_name: 'awf-agent',

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export interface WrapperConfig {
180180
* - 'host_path:container_path:rw' (read-write)
181181
*
182182
* These are in addition to essential mounts (Docker socket, HOME, /tmp).
183-
* The blanket /:/host:ro mount is removed when custom mounts are specified.
183+
* The /:/host:ro mount is always included for chroot functionality.
184184
*
185185
* @example ['/workspace:/workspace:ro', '/data:/data:rw']
186186
*/

0 commit comments

Comments
 (0)