Skip to content

Commit 1065f85

Browse files
committed
refactor(model): split DTO types by domain
1 parent 4875a6e commit 1065f85

14 files changed

Lines changed: 1229 additions & 1174 deletions

frontend/src/api/demo/audit.ts

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,47 @@ import { sessions, toolCalls } from './sessions'
33
import { matchesAgent, matchesDateRange } from './utils'
44

55
const auditFindings: AuditFinding[] = [
6-
makeFinding(501, 101, 1001, 'command', 'medium', 'shell.powershell.concatenated-delete', 'Review destructive shell composition', 'Remove command was composed with string interpolation.', 'Remove-Item $target -Recurse', 'powershell'),
7-
makeFinding(502, 102, 1005, 'egress', 'low', 'network.fetch.failed', 'Network access attempted', 'A documentation lookup was attempted while offline demo policy was active.', 'Invoke-WebRequest https://example.invalid/pricing', 'powershell'),
8-
makeFinding(503, 104, 1008, 'privacy', 'high', 'privacy.telemetry.enabled', 'Telemetry setting needs review', 'Demo privacy config shows a setting that is not hardened.', 'telemetry.enabled = true', 'json'),
9-
makeFinding(504, 105, 1009, 'file', 'medium', 'file.output.screenshot', 'Generated artifact requires retention decision', 'A browser screenshot artifact was created during validation.', 'browser_screenshot tools chart', 'browser')
6+
makeFinding({ id: 501, sessionId: 101, toolCallId: 1001, category: 'command', severity: 'medium', ruleId: 'shell.powershell.concatenated-delete', title: 'Review destructive shell composition', description: 'Remove command was composed with string interpolation.', command: 'Remove-Item $target -Recurse', shellFamily: 'powershell' }),
7+
makeFinding({ id: 502, sessionId: 102, toolCallId: 1005, category: 'egress', severity: 'low', ruleId: 'network.fetch.failed', title: 'Network access attempted', description: 'A documentation lookup was attempted while offline demo policy was active.', command: 'Invoke-WebRequest https://example.invalid/pricing', shellFamily: 'powershell' }),
8+
makeFinding({ id: 503, sessionId: 104, toolCallId: 1008, category: 'privacy', severity: 'high', ruleId: 'privacy.telemetry.enabled', title: 'Telemetry setting needs review', description: 'Demo privacy config shows a setting that is not hardened.', command: 'telemetry.enabled = true', shellFamily: 'json' }),
9+
makeFinding({ id: 504, sessionId: 105, toolCallId: 1009, category: 'file', severity: 'medium', ruleId: 'file.output.screenshot', title: 'Generated artifact requires retention decision', description: 'A browser screenshot artifact was created during validation.', command: 'browser_screenshot tools chart', shellFamily: 'browser' })
1010
]
1111

12-
function makeFinding(
13-
id: number,
14-
sessionId: number,
15-
toolCallId: number,
16-
category: string,
17-
severity: string,
18-
ruleId: string,
19-
title: string,
20-
description: string,
21-
command: string,
12+
type DemoFindingSpec = {
13+
id: number
14+
sessionId: number
15+
toolCallId: number
16+
category: string
17+
severity: string
18+
ruleId: string
19+
title: string
20+
description: string
21+
command: string
2222
shellFamily: string
23-
): AuditFinding {
24-
const session = sessions.find((item) => item.id === sessionId)
25-
if (!session) throw new Error(`Missing demo session ${sessionId}`)
26-
const tool = toolCalls.find((item) => item.id === toolCallId)
23+
}
24+
25+
function makeFinding(spec: DemoFindingSpec): AuditFinding {
26+
const session = sessions.find((item) => item.id === spec.sessionId)
27+
if (!session) throw new Error(`Missing demo session ${spec.sessionId}`)
28+
const tool = toolCalls.find((item) => item.id === spec.toolCallId)
2729
return {
28-
id,
29-
sessionId,
30-
toolCallId,
30+
id: spec.id,
31+
sessionId: spec.sessionId,
32+
toolCallId: spec.toolCallId,
3133
sourceFileId: session.sourceId || 0,
32-
rawEventId: tool?.rawEventId || id + 5000,
34+
rawEventId: tool?.rawEventId || spec.id + 5000,
3335
sourceLine: tool?.rawEventLine || 1,
3436
timestamp: tool?.endedAt || session.endedAt,
3537
source: 'demo audit',
3638
eventType: tool?.rawEndEventType || 'tool_result',
37-
category,
38-
severity,
39-
ruleId,
40-
title,
41-
description,
42-
evidence: tool?.rawEndEventSummary || description,
43-
command,
44-
shellFamily,
39+
category: spec.category,
40+
severity: spec.severity,
41+
ruleId: spec.ruleId,
42+
title: spec.title,
43+
description: spec.description,
44+
evidence: tool?.rawEndEventSummary || spec.description,
45+
command: spec.command,
46+
shellFamily: spec.shellFamily,
4547
platform: 'windows',
4648
decision: 'review',
4749
createdAt: session.endedAt,

frontend/src/api/demo/privacy.ts

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,40 @@ const profiles: PrivacyConfigProfile[] = [
1111
{ id: 'strict', title: 'Strict', description: 'Disable telemetry, network helpers, memory, and extended local retention.' }
1212
]
1313

14-
function privacySetting(
15-
id: string,
16-
group: string,
17-
title: string,
18-
key: string,
19-
desiredValue: unknown,
20-
strictValue: unknown,
21-
currentValue: unknown,
22-
configured: boolean,
23-
status: string,
24-
valueType: PrivacyConfigSetting['valueType'] = 'bool'
25-
): PrivacyConfigSetting {
14+
type PrivacySettingSpec = {
15+
id: string
16+
group: string
17+
title: string
18+
key: string
19+
desiredValue: unknown
20+
strictValue: unknown
21+
currentValue: unknown
22+
configured: boolean
23+
status: string
24+
valueType?: PrivacyConfigSetting['valueType']
25+
}
26+
27+
function privacySetting(spec: PrivacySettingSpec): PrivacyConfigSetting {
28+
const valueType = spec.valueType || 'bool'
2629
return {
27-
id,
28-
group,
29-
title,
30-
description: `Demo status for ${title.toLowerCase()}.`,
31-
key,
32-
desiredValue,
33-
strictValue,
34-
currentValue,
30+
id: spec.id,
31+
group: spec.group,
32+
title: spec.title,
33+
description: `Demo status for ${spec.title.toLowerCase()}.`,
34+
key: spec.key,
35+
desiredValue: spec.desiredValue,
36+
strictValue: spec.strictValue,
37+
currentValue: spec.currentValue,
3538
valueType,
36-
configured,
39+
configured: spec.configured,
3740
supportsUnset: true,
38-
status,
39-
impact: `Controls ${title.toLowerCase()} behavior for the selected agent.`,
41+
status: spec.status,
42+
impact: `Controls ${spec.title.toLowerCase()} behavior for the selected agent.`,
4043
canApply: true,
4144
profileValues: [
4245
{ profile: 'default', op: 'unset' },
43-
{ profile: 'recommended', op: 'set', value: desiredValue },
44-
{ profile: 'strict', op: 'set', value: strictValue }
46+
{ profile: 'recommended', op: 'set', value: spec.desiredValue },
47+
{ profile: 'strict', op: 'set', value: spec.strictValue }
4548
]
4649
}
4750
}
@@ -54,11 +57,11 @@ export function privacyStatus(target: PrivacyTarget): PrivacyConfigStatus {
5457
codebuddy: 'CodeBuddy'
5558
}
5659
const settings = [
57-
privacySetting('analytics.enabled', 'Telemetry', 'Analytics', 'analytics.enabled', false, false, false, true, 'hardened'),
58-
privacySetting('telemetry.enabled', 'Telemetry', 'Telemetry export', 'telemetry.enabled', false, false, target === 'claude', target !== 'claude', target === 'claude' ? 'attention' : 'hardened'),
59-
privacySetting('web_search', 'Network', 'Web search', 'web_search', false, false, false, target === 'codex', target === 'codex' ? 'hardened' : 'implicit'),
60-
privacySetting('history.persistence', 'Local history', 'Conversation history', 'history.persistence', false, false, true, false, 'implicit'),
61-
privacySetting('retention.days', 'Local retention', 'Retention days', 'retention.days', 14, 7, 14, true, 'hardened', 'number')
60+
privacySetting({ id: 'analytics.enabled', group: 'Telemetry', title: 'Analytics', key: 'analytics.enabled', desiredValue: false, strictValue: false, currentValue: false, configured: true, status: 'hardened' }),
61+
privacySetting({ id: 'telemetry.enabled', group: 'Telemetry', title: 'Telemetry export', key: 'telemetry.enabled', desiredValue: false, strictValue: false, currentValue: target === 'claude', configured: target !== 'claude', status: target === 'claude' ? 'attention' : 'hardened' }),
62+
privacySetting({ id: 'web_search', group: 'Network', title: 'Web search', key: 'web_search', desiredValue: false, strictValue: false, currentValue: false, configured: target === 'codex', status: target === 'codex' ? 'hardened' : 'implicit' }),
63+
privacySetting({ id: 'history.persistence', group: 'Local history', title: 'Conversation history', key: 'history.persistence', desiredValue: false, strictValue: false, currentValue: true, configured: false, status: 'implicit' }),
64+
privacySetting({ id: 'retention.days', group: 'Local retention', title: 'Retention days', key: 'retention.days', desiredValue: 14, strictValue: 7, currentValue: 14, configured: true, status: 'hardened', valueType: 'number' })
6265
]
6366
const hardened = settings.filter((setting) => setting.status === 'hardened').length
6467
const attention = settings.filter((setting) => setting.status === 'attention').length

0 commit comments

Comments
 (0)