MCPcopy Create free account
hub / github.com/garrytan/gstack / tempStubCodex

Function tempStubCodex

test/codex-hardening.test.ts:171–183  ·  view source on GitHub ↗
(versionOutput: string, bool_command_fails = false)

Source from the content-addressed store, hash-verified

169// --- Group 2: Version check -------------------------------------------------
170// Stub `codex --version` by putting a fake `codex` executable on PATH.
171function tempStubCodex(versionOutput: string, bool_command_fails = false): {
172 dir: string;
173 pathEntry: string;
174} {
175 const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-codex-stub-'));
176 const bin = path.join(dir, 'codex');
177 const script = bool_command_fails
178 ? '#!/bin/bash\nexit 1\n'
179 : `#!/bin/bash\nif [ "$1" = "--version" ]; then printf '%s' ${JSON.stringify(versionOutput)}; fi\n`;
180 fs.writeFileSync(bin, script);
181 fs.chmodSync(bin, 0o755);
182 return { dir, pathEntry: dir };
183}
184
185function runVersionCheck(versionOutput: string): string {
186 const stub = tempStubCodex(versionOutput);

Callers 1

runVersionCheckFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected