Files
deepseek-harness/scripts/verify-config-source-ownership.ts
Tianyi Cui 55fca161e6 cleanup(config): remove textual process env audit
The gate treated a literal process.env substring search as repository-wide source-ownership enforcement. It missed equivalent syntax while matching comments and strings, so the allowlist projected a security guarantee the implementation could not provide.

Remove the scanner and its allowlist. Keep the independently useful shipped-config inline tripwire, and narrow both the module contract and bilingual Agent Note to its actual source-shape claim.
2026-08-07 21:05:04 +08:00

58 lines
2.2 KiB
TypeScript

/**
* Gate: shipped Cordis configuration does not use the ordinary inline form
* for a credential or endpoint from the environment. This narrow source-shape
* lint prevents checked-in composition from bypassing the credential seam and
* endpoint ladder; adapters remain responsible for actual value resolution.
* @module scripts/verify-config-source-ownership
*/
import { globSync, readFileSync } from 'node:fs'
import { resolve, sep } from 'node:path'
const ROOT = resolve(import.meta.dirname, '..')
/** Shipped Cordis configuration these rules apply to. */
const SHIPPED_CONFIG_GLOBS = [
'apps/*/config/*.yml',
'examples/*/*.cordis.yml',
'examples/*/cordis.yml',
// The Python runtime ships its own default composition inside the wheel.
'python/*/src/**/cordis.yml',
]
/**
* Config keys that must never be inlined from the environment. Line-anchored
* on purpose: this is a tripwire for the shape people actually write, not a
* YAML analysis. A folded scalar or a block-literal spelling would slip past
* it, which is acceptable because the rule it guards is also stated in the
* owning Agent Note and enforced by the adapters' own resolution.
*/
const INLINE_DENY = /^\s*(apiKey|baseURL|apiKeyEnv|authToken|headers)\s*:\s*!!js\b/
const failures: string[] = []
for (const glob of SHIPPED_CONFIG_GLOBS) {
for (const file of globSync(glob, { cwd: ROOT })) {
const rel = file.split(sep).join('/')
readFileSync(resolve(ROOT, rel), 'utf8').split('\n').forEach((line, index) => {
if (!INLINE_DENY.test(line)) return
failures.push(
`${rel}:${String(index + 1)}: inlines a credential or endpoint from the environment.`
+ ' The adapter resolves apiKeyEnv through ctx.credentials and the endpoint through the'
+ ' environment snapshot; inlining here bypasses both ladders.',
)
})
}
}
if (failures.length > 0) {
process.stderr.write('verify-config-source-ownership: configuration source ownership violated:\n')
for (const failure of failures) process.stderr.write(` ${failure}\n`)
process.exit(1)
}
process.stdout.write(
'verify-config-source-ownership: no credential or endpoint uses the ordinary inline environment form'
+ ' in shipped configuration.\n',
)