MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / sensitiveFixture

Function sensitiveFixture

__tests__/security.test.ts:471–502  ·  view source on GitHub ↗

* A temp folder holding a private home with its own `.ssh` and `.config`, and * the links a case makes. Links are removed before the tree, so the cleanup * can never walk into a link's target.

()

Source from the content-addressed store, hash-verified

469 * can never walk into a link's target.
470 */
471function sensitiveFixture() {
472 const state = {
473 tmp: '',
474 home: '',
475 links: [] as string[],
476 savedHome: undefined as string | undefined,
477 savedProfile: undefined as string | undefined,
478 };
479 beforeEach(() => {
480 state.tmp = fs.realpathSync.native(fs.mkdtempSync(path.join(os.tmpdir(), 'cg-sensitive-')));
481 state.home = path.join(state.tmp, 'home');
482 fs.mkdirSync(path.join(state.home, '.ssh'), { recursive: true });
483 fs.mkdirSync(path.join(state.home, '.config', 'nvim'), { recursive: true });
484 fs.mkdirSync(path.join(state.tmp, 'project'));
485 fs.mkdirSync(path.join(state.tmp, 'elsewhere'));
486 state.links = [];
487 state.savedHome = process.env.HOME;
488 state.savedProfile = process.env.USERPROFILE;
489 setHome(state.home);
490 });
491 afterEach(() => {
492 setHome(state.savedHome, state.savedProfile);
493 for (const link of state.links.reverse()) fs.unlinkSync(link);
494 fs.rmSync(state.tmp, { recursive: true, force: true });
495 });
496 const link = (target: string, at: string): string => {
497 linkDir(target, at);
498 state.links.push(at);
499 return at;
500 };
501 return { state, link };
502}
503
504// #1930: the guard compared the path as typed, so a link to a sensitive folder,
505// a case variant of one (Windows, macOS) or a `\\?\` spelling (Windows) passed.

Callers 1

security.test.tsFile · 0.85

Calls 2

setHomeFunction · 0.70
joinMethod · 0.45

Tested by

no test coverage detected