fix(ai-vault): validate SSH history inventory ids

This commit is contained in:
Brennan Benson
2026-08-14 15:40:27 -07:00
parent d9b00956d2
commit 3b6bb20ee4
4 changed files with 13 additions and 4 deletions
@@ -63,7 +63,7 @@ describe('runtime-owned SSH AI Vault inventory', () => {
it('skips malformed target rows from a paired runtime', async () => {
mocks.callRuntimeEnvironment.mockResolvedValueOnce({
ok: true,
result: { targets: [null, 42, { id: 'hub-owned-host', connected: true }] }
result: { targets: [null, 42, { id: '\ud800' }, { id: 'hub-owned-host', connected: true }] }
})
await expect(listRuntimeOwnedSshAiVaultTargets('/user-data', 'hub-runtime')).resolves.toEqual([
@@ -87,11 +87,17 @@ async function loadRuntimeOwnedSshAiVaultTargets(
if (isRuntimeOwnedSshTargetId(target.id)) {
return []
}
let executionHostId: `ssh:${string}`
try {
executionHostId = toSshExecutionHostId(target.id)
} catch {
return []
}
return [
{
environmentId,
targetId: target.id,
executionHostId: toSshExecutionHostId(target.id),
executionHostId,
...('connected' in target && typeof target.connected === 'boolean'
? { connected: target.connected }
: {})
+3 -2
View File
@@ -1941,14 +1941,14 @@ describe('web AI Vault preload API', () => {
await expect(
globals.window.api.aiVault.listSessions({
executionHostScope: 'ssh:hub-owned-host',
limit: 25
unlimited: true
})
).resolves.toEqual(scanResult)
expect(runtimeCalls).toEqual([
{
method: 'aiVault.listSessions',
params: {
limit: 25,
unlimited: true,
executionHostId: 'ssh:hub-owned-host'
}
}
@@ -1985,6 +1985,7 @@ describe('web AI Vault preload API', () => {
issues: [
expect.objectContaining({
executionHostId: 'ssh:hub-owned-host',
kind: 'host',
message: expect.stringContaining('cannot scan Agent Session History on its SSH hosts')
})
],
+2
View File
@@ -1608,6 +1608,7 @@ function createAiVaultApi(): NonNullable<Partial<PreloadApi>['aiVault']> {
if (parsedScope?.kind === 'ssh') {
return callRuntimeResult<AiVaultListResult>('aiVault.listSessions', {
limit: args?.limit,
unlimited: args?.unlimited,
force: args?.force,
scopePaths: args?.scopePaths,
executionHostId: parsedScope.id
@@ -1700,6 +1701,7 @@ function webAiVaultUnsupportedSshHostResult(executionHostId: ExecutionHostId): A
{
executionHostId,
agent: 'codex',
kind: 'host',
path: executionHostId,
message: translate(
'auto.web.webPreloadApi.aiVaultUnsupportedSshHost',