-
Notifications
You must be signed in to change notification settings - Fork 19
test: expand credential hiding tests to all 14 protected paths #1163
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 2 commits
e10ad83
df5a3af
15c1f4a
03ad6ac
3cfdcf8
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 | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -227,6 +227,129 @@ | |||||||
| }, 120000); | ||||||||
| }); | ||||||||
|
|
||||||||
| describe('All 14 Credential Paths Coverage', () => { | ||||||||
| // These tests cover the 11 credential paths not tested by Tests 1-4 above. | ||||||||
| // Each path is hidden via /dev/null mount and should return empty content. | ||||||||
|
|
||||||||
| const untestedPaths = [ | ||||||||
| { name: 'SSH id_rsa', path: '.ssh/id_rsa' }, | ||||||||
| { name: 'SSH id_ed25519', path: '.ssh/id_ed25519' }, | ||||||||
| { name: 'SSH id_ecdsa', path: '.ssh/id_ecdsa' }, | ||||||||
| { name: 'SSH id_dsa', path: '.ssh/id_dsa' }, | ||||||||
| { name: 'AWS credentials', path: '.aws/credentials' }, | ||||||||
| { name: 'AWS config', path: '.aws/config' }, | ||||||||
| { name: 'Kube config', path: '.kube/config' }, | ||||||||
| { name: 'Azure credentials', path: '.azure/credentials' }, | ||||||||
| { name: 'GCloud credentials.db', path: '.config/gcloud/credentials.db' }, | ||||||||
| { name: 'Cargo credentials', path: '.cargo/credentials' }, | ||||||||
| { name: 'Composer auth.json', path: '.composer/auth.json' }, | ||||||||
| ]; | ||||||||
|
|
||||||||
| // Track files we create so we only clean up what we added | ||||||||
| const createdFiles: string[] = []; | ||||||||
| const createdDirs: string[] = []; | ||||||||
|
|
||||||||
| beforeAll(() => { | ||||||||
| // Create dummy credential files on the host so AWF will mount /dev/null over them. | ||||||||
| // Without these files existing, AWF skips the /dev/null mount and the files | ||||||||
| // simply don't exist inside the container. | ||||||||
| const homeDir = os.homedir(); | ||||||||
| for (const p of untestedPaths) { | ||||||||
| const fullPath = `${homeDir}/${p.path}`; | ||||||||
| if (!fs.existsSync(fullPath)) { | ||||||||
| const dir = fullPath.substring(0, fullPath.lastIndexOf('/')); | ||||||||
| if (!fs.existsSync(dir)) { | ||||||||
| fs.mkdirSync(dir, { recursive: true }); | ||||||||
| createdDirs.push(dir); | ||||||||
| } | ||||||||
| fs.writeFileSync(fullPath, 'DUMMY_SECRET_VALUE'); | ||||||||
Check failureCode scanning / CodeQL Potential file system race condition High test
The file may have changed since it
was checked Error loading related location Loading |
||||||||
| createdFiles.push(fullPath); | ||||||||
| } | ||||||||
| } | ||||||||
| }); | ||||||||
|
|
||||||||
| afterAll(() => { | ||||||||
| // Clean up only the files/dirs we created | ||||||||
| for (const f of createdFiles) { | ||||||||
| try { fs.unlinkSync(f); } catch { /* ignore */ } | ||||||||
| } | ||||||||
| // Remove dirs in reverse order (deepest first) | ||||||||
| for (const d of createdDirs.reverse()) { | ||||||||
| try { fs.rmdirSync(d); } catch { /* ignore if not empty */ } | ||||||||
| } | ||||||||
| }); | ||||||||
|
|
||||||||
| test('All untested credential files are hidden at direct home path (0 bytes)', async () => { | ||||||||
| const homeDir = os.homedir(); | ||||||||
| const paths = untestedPaths.map(p => `${homeDir}/${p.path}`).join(' '); | ||||||||
|
Comment on lines
+289
to
+290
|
||||||||
| const homeDir = os.homedir(); | |
| const paths = untestedPaths.map(p => `${homeDir}/${p.path}`).join(' '); | |
| const paths = untestedPaths.map(p => `"$HOME/${p.path}"`).join(' '); |
Copilot
AI
Mar 5, 2026
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.
parseInt should be called with an explicit radix to avoid edge-case parsing issues. Use parseInt(value, 10) here (and in the similar parsing block in the /host test) to make the intent unambiguous.
Uh oh!
There was an error while loading. Please reload this page.