Skip to content

Commit 9225a2c

Browse files
committed
fix(code): reject cross-root credential aliases
1 parent 95c1e22 commit 9225a2c

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎packages/code/src/github.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,11 @@ test('checkout routing follows nested repositories only inside an admitted root'
511511
await gitHubRepositoryForCommand(escaped, admitted, 'checkout'),
512512
undefined,
513513
);
514+
admitted.set(outside, 'acme/outside');
515+
assert.equal(
516+
await gitHubRepositoryForCommand(escaped, admitted, 'checkout'),
517+
undefined,
518+
);
514519
assert.equal(
515520
await gitHubRepositoryForCommand(nested, admitted, 'checkout', 'github.example.test'),
516521
undefined,

‎packages/code/src/github.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,9 @@ export async function gitHubRepositoryForCommand(
181181
signal?.throwIfAborted();
182182
return undefined;
183183
}
184-
if (!admittedRepositoryEntry(canonicalCwd, repositories)) return undefined;
184+
if (admittedRepositoryEntry(canonicalCwd, repositories)?.[0] !== admitted[0]) {
185+
return undefined;
186+
}
185187
return gitHubRepositoryForDirectory(canonicalCwd, host, signal);
186188
}
187189

0 commit comments

Comments
 (0)