Skip to content

Commit 03ad6ac

Browse files
Mossakaclaude
andcommitted
fix(test): use [ -e ] instead of [ -f ] for /dev/null-mounted files
/dev/null-mounted credential files are character special devices, not regular files. [ -f ] returns false for them, causing wc -c to produce no output. Use [ -e ] (exists) to correctly detect these mounts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 15c1f4a commit 03ad6ac

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tests/integration/credential-hiding.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,10 @@ describe('Credential Hiding Security', () => {
292292
// Check all credential files in a single container run for efficiency.
293293
// wc -c reports byte count; /dev/null-mounted files should be 0 bytes.
294294
// Use '|| true' to prevent failures when files don't exist
295+
// Use [ -e ] instead of [ -f ] because /dev/null-mounted files are
296+
// character special devices, not regular files
295297
const result = await runner.runWithSudo(
296-
`sh -c 'for f in ${paths}; do if [ -f "$f" ]; then wc -c "$f"; fi; done 2>&1 || true'`,
298+
`sh -c 'for f in ${paths}; do if [ -e "$f" ]; then wc -c "$f"; fi; done 2>&1 || true'`,
297299
{
298300
allowDomains: ['github.com'],
299301
logLevel: 'debug',
@@ -317,8 +319,10 @@ describe('Credential Hiding Security', () => {
317319
const homeDir = os.homedir();
318320
const paths = untestedPaths.map(p => `/host${homeDir}/${p.path}`).join(' ');
319321

322+
// Use [ -e ] instead of [ -f ] because /dev/null-mounted files are
323+
// character special devices, not regular files
320324
const result = await runner.runWithSudo(
321-
`sh -c 'for f in ${paths}; do if [ -f "$f" ]; then wc -c "$f"; fi; done 2>&1 || true'`,
325+
`sh -c 'for f in ${paths}; do if [ -e "$f" ]; then wc -c "$f"; fi; done 2>&1 || true'`,
322326
{
323327
allowDomains: ['github.com'],
324328
logLevel: 'debug',
@@ -341,8 +345,10 @@ describe('Credential Hiding Security', () => {
341345
const paths = untestedPaths.map(p => `${homeDir}/${p.path}`).join(' ');
342346

343347
// cat all files and concatenate output - should be empty
348+
// Use [ -e ] instead of [ -f ] because /dev/null-mounted files are
349+
// character special devices, not regular files
344350
const result = await runner.runWithSudo(
345-
`sh -c 'for f in ${paths}; do if [ -f "$f" ]; then cat "$f"; fi; done 2>&1 || true'`,
351+
`sh -c 'for f in ${paths}; do if [ -e "$f" ]; then cat "$f"; fi; done 2>&1 || true'`,
346352
{
347353
allowDomains: ['github.com'],
348354
logLevel: 'debug',

0 commit comments

Comments
 (0)