mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 21:04:23 +01:00
Fix review findings validating OM-84
This commit is contained in:
1 parent
c1b8220bc3
commit
d6e5ef0b1f
4 files changed
+53
-8
No files matched your search
@@ -333,7 +333,7 @@ describe('RepoEnvService', () => {
|
||||
expect(result.maskValues).toEqual(['plain-value'])
|
||||
expect(result.hiddenSecrets).toEqual([hiddenBinding])
|
||||
expect(placeholderFor).toHaveBeenCalledTimes(2)
|
||||
expect(placeholderFor).toHaveBeenCalledWith('HID')
|
||||
expect(placeholderFor).toHaveBeenCalledWith('HID', hiddenBinding)
|
||||
})
|
||||
|
||||
it('keeps a hidden secret with an empty host list hidden', async () => {
|
||||
|
||||
@@ -353,7 +353,7 @@ function hiddenRepoEnv(secrets: TestHiddenSecret[]) {
|
||||
policy.kind === 'reveal'
|
||||
? secret.value
|
||||
: policy.kind === 'placeholder'
|
||||
? policy.placeholderFor(secret.name)
|
||||
? policy.placeholderFor(secret.name, secret)
|
||||
: ''
|
||||
}
|
||||
return { env, maskValues: [], hiddenSecrets }
|
||||
@@ -1004,7 +1004,7 @@ describe('SandboxRuntimeService', () => {
|
||||
policy.kind === 'reveal'
|
||||
? binding.value
|
||||
: policy.kind === 'placeholder'
|
||||
? policy.placeholderFor(binding.name)
|
||||
? policy.placeholderFor(binding.name, binding)
|
||||
: ''
|
||||
}
|
||||
return { env, maskValues: [], hiddenSecrets: bindings.map((binding) => ({ ...binding })) }
|
||||
@@ -1025,6 +1025,40 @@ describe('SandboxRuntimeService', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('withholds a working directory hidden secret whose value differs from the session secret', async () => {
|
||||
enableEnforcement()
|
||||
installFakeMsb(new Map())
|
||||
const nested = path.join(repoADir, 'nested')
|
||||
mkdirSync(nested, { recursive: true })
|
||||
const sessionSecret: TestHiddenSecret = { name: 'TOKEN', value: 'hunter2', allowedHosts: ['api.example.com'] }
|
||||
const workingSecret: TestHiddenSecret = { name: 'TOKEN', value: 'other-value', allowedHosts: ['api.example.com'] }
|
||||
const repoEnv = {
|
||||
resolveForDirectory: vi.fn(async (dir: string, policy: HiddenSecretPolicy = { kind: 'withhold' }) => {
|
||||
const bindings = dir === repoADir ? [sessionSecret] : [workingSecret]
|
||||
const env: Record<string, string> = {}
|
||||
for (const binding of bindings) {
|
||||
env[binding.name] =
|
||||
policy.kind === 'reveal'
|
||||
? binding.value
|
||||
: policy.kind === 'placeholder'
|
||||
? policy.placeholderFor(binding.name, binding)
|
||||
: ''
|
||||
}
|
||||
return { env, maskValues: [], hiddenSecrets: bindings.map((binding) => ({ ...binding })) }
|
||||
}),
|
||||
} satisfies Pick<RepoEnvService, 'resolveForDirectory'>
|
||||
const withSecrets = new SandboxRuntimeService(db, repoEnv)
|
||||
|
||||
const plan = await withSecrets.planShell(nested, shellTarget(repoADir))
|
||||
|
||||
expect(plan).toEqual({
|
||||
mode: 'sandbox',
|
||||
name: VM_NAME,
|
||||
workdir: nested,
|
||||
env: { TOKEN: '' },
|
||||
})
|
||||
})
|
||||
|
||||
it('leaves a hidden secret with no allowed hosts out of the VM and withholds it', async () => {
|
||||
enableEnforcement()
|
||||
installFakeMsb(new Map())
|
||||
|
||||
Reference in new issue
Block a user