diff --git a/src/__tests__/api-key-env-static.test.ts b/src/__tests__/api-key-env-static.test.ts index f463a3e..0652b1c 100644 --- a/src/__tests__/api-key-env-static.test.ts +++ b/src/__tests__/api-key-env-static.test.ts @@ -3,6 +3,7 @@ import { readFileSync } from 'fs'; import { join } from 'path'; const configSource = readFileSync(join(process.cwd(), 'src/config/index.ts'), 'utf8'); +const serverSource = readFileSync(join(process.cwd(), 'src/server.ts'), 'utf8'); const setupScript = readFileSync(join(process.cwd(), 'scripts/setup-api.sh'), 'utf8'); function sourceBlock(startMarker: string, endMarker: string): string { @@ -33,6 +34,11 @@ describe('API key environment handling hardening', () => { expect(block).toContain("join(homedir(), '.t3mp3st', '.env')"); }); + it('the API server does not re-enable caller-cwd dotenv loading', () => { + expect(serverSource).not.toMatch(/from ['"]dotenv['"]/); + expect(serverSource).not.toMatch(/\bdotenv\.config\s*\(/); + }); + it('setup-api.sh writes the same T3MP3ST-owned env file that ConfigManager reads', () => { const block = configLoadEnvBlock(); diff --git a/src/server.ts b/src/server.ts index 362377d..271a6ad 100755 --- a/src/server.ts +++ b/src/server.ts @@ -32,9 +32,6 @@ import type { OperatorArchetype } from './types/index.js'; import { listOperatorPrompts, setOperatorOverride, resetOperatorOverride, type OperatorOverride } from './operators/index.js'; import { ingestRepoToSourceContext, runWhiteboxAnalysis, resolveContainedRepoPath, RepoPathError } from './recon/whitebox.js'; import { redactCredential } from './evidence/index.js'; -import dotenv from 'dotenv'; - -dotenv.config(); const execFileAsync = promisify(execFile);