Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions tests/integration/volume-mounts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,14 @@ describe('Volume Mount Functionality', () => {
}, 120000);

test('Test 4: Blanket mount removed with custom mounts', async () => {
// Create a test file outside the custom mount
const secretFile = '/tmp/secret-file-12345.txt';
fs.writeFileSync(secretFile, 'Secret data');
// Create a test file outside the custom mount in a secure temp directory
const secretDir = fs.mkdtempSync(path.join(os.tmpdir(), 'awf-secret-'));
const secretFile = path.join(secretDir, 'secret.txt');
fs.writeFileSync(secretFile, 'Secret data', { mode: 0o600 });

try {
const result = await runner.runWithSudo(
'sh -c "cat /data/test.txt && cat /tmp/secret-file-12345.txt"',
`sh -c "cat /data/test.txt && cat ${secretFile}"`,
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The secretFile path is directly interpolated into the shell command without proper escaping. If the path contains spaces or special characters (which is possible if os.tmpdir() returns such a path), the command will fail or could potentially be exploited. Consider using proper shell escaping or wrapping the path in quotes.

See below for a potential fix:

      const escapedSecretFile = secretFile.replace(/'/g, `'\\''`);
      const result = await runner.runWithSudo(
        `sh -c "cat /data/test.txt && cat '${escapedSecretFile}'"`,

Copilot uses AI. Check for mistakes.
{
allowDomains: ['github.com'],
logLevel: 'debug',
Expand All @@ -129,13 +130,13 @@ describe('Volume Mount Functionality', () => {
);

// First cat should fail (no file in /data)
// Second cat should fail (no blanket mount, /tmp not accessible from host)
// Second cat should fail (no blanket mount, host paths not accessible)
expect(result).toFail();
expect(result.stderr).toMatch(/No such file or directory/);
} finally {
// Cleanup secret file
if (fs.existsSync(secretFile)) {
fs.unlinkSync(secretFile);
// Cleanup secret directory
if (fs.existsSync(secretDir)) {
fs.rmSync(secretDir, { recursive: true, force: true });
}
}
}, 120000);
Expand Down
Loading