Files
deepseek-harness/packages/workflow/workflow-worker-thread/tests/egress.spec.ts
T
Yichen Jiang e6dbf85f6c fix(net): address review — containment, opt-out, and syntax-aware discovery
The workflow worker no longer receives proxy configuration: it executes the
model-authored script body, and a proxy URL may carry credentials. A child
process now inherits the values the user exported rather than this process's
normalization, so a SOCKS proxy set for curl survives and no HTTPS_PROXY is
invented. `mode: 'off'` installs a direct dispatcher instead of recording a
policy the global dispatcher ignores, and the environment snapshot is taken
before any write so Windows restores the user's values.

E2B picks its proxy from the control-plane URL the SDK will really call, the
OTLP agent honors `exporter.keepAlive`, and a scheme whose own value was
refused stays direct instead of borrowing another scheme's proxy.

verify-no-bare-dispatcher parses the TypeScript AST as scripts/AGENTS.md
requires; it immediately found the `{ dispatcher }` shorthand the regex missed.
2026-08-29 13:17:12 +08:00

32 lines
1.2 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { PROXY_ENV_NAMES, installGlobalProxy, type ProxyPolicy } from '@deepseek-ai/dsh-http-proxy'
import { workerSpawnEnv } from '../src/host.ts'
/** A policy carrying credentials, the shape that must never reach model-authored code. */
const CREDENTIALED: ProxyPolicy = {
httpProxy: 'http://alice:s3cret@proxy.example:8080',
httpsProxy: 'http://alice:s3cret@proxy.example:8080',
noProxy: '',
source: 'env',
}
describe('workflow worker egress', () => {
it('hands the worker no proxy configuration, credentialed or not', async () => {
const dispose = await installGlobalProxy(CREDENTIALED)
try {
const env = workerSpawnEnv()
// The worker executes the model-authored script body, so a proxy URL that may carry
// `user:password` must not be readable from its environment.
for (const name of PROXY_ENV_NAMES) expect(env).not.toHaveProperty(name)
expect(env).not.toHaveProperty('NODE_USE_ENV_PROXY')
expect(JSON.stringify(env)).not.toContain('s3cret')
} finally {
await dispose()
}
})
it('still carries the platform temp path the worker needs on Windows', () => {
expect(workerSpawnEnv('win32')).toHaveProperty('TMP')
})
})