Skip to content
Merged
Show file tree
Hide file tree
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: 17 additions & 0 deletions packages/core/src/utils/workspaceContext.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,21 @@ describe('WorkspaceContext with optional directories', () => {
}
});

it('should reject GitHub Actions Workload Identity credentials', () => {
const workspaceContext = new WorkspaceContext(cwd);

const sensitivePaths = [
path.join(cwd, 'gha-creds-12345.json'),
path.join(cwd, 'gha-creds-abcde.json'),
path.join(cwd, 'GHA-CREDS-abcde.JSON'), // Case-insensitivity check
path.join(cwd, 'subfolder', 'gha-creds-12345.json'), // Nested
];

for (const p of sensitivePaths) {
expect(workspaceContext.isPathWithinWorkspace(p)).toBe(false);
}
});

it('should allow standard non-sensitive paths', () => {
const workspaceContext = new WorkspaceContext(cwd);

Expand All @@ -531,6 +546,8 @@ describe('WorkspaceContext with optional directories', () => {
path.join(cwd, '.gitignore'),
path.join(cwd, '.env.example'),
path.join(cwd, 'package.json'),
path.join(cwd, 'tsconfig.json'),
path.join(cwd, 'gha-creds.json'), // Doesn't match the pattern
];

for (const p of safePaths) {
Expand Down
15 changes: 12 additions & 3 deletions packages/core/src/utils/workspaceContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,18 @@ export class WorkspaceContext {
const clean = trimTrailingSpacesAndDots(
segment.split(':')[0],
).toLowerCase();
return (
clean === '.git' || clean === '.env' || clean === 'node_modules'
);
if (
clean === '.git' ||
clean === '.env' ||
clean === 'node_modules'
) {
return true;
}
// Block GitHub Actions Workload Identity credentials
if (clean.startsWith('gha-creds-') && clean.endsWith('.json')) {
return true;
}
return false;
});
if (hasBlockedSegment) {
return false;
Expand Down
Loading