mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
fix(terminal-dev-loop): address branch review findings
Security: - Reject same-site and cross-site state-changing requests on cookie-authenticated routes unless the origin is trusted - Drop Manager and ocm_preview Set-Cookie headers from preview responses - Show and hash the full executable content of .ocm/project.json at trust time - Restrict action URLs to http(s) and refuse symlinked repo config paths - Keep the preview start redirect on the gateway origin Lifecycle: - Stop terminals in OpenCode workspace siblings when a repo is deleted - Report preview as unavailable instead of crashing when the gateway port cannot be bound Performance: - Skip branch lookups when validating terminal and project-config directories - Stop the /proc scan once all listening sockets are mapped and pause port polling while a preview is open - Close slow WebSocket clients with 1013 so they reconnect with replay - Lazy-load the xterm terminal view and skip unchanged resize requests - Request uncompressed responses from preview targets Cleanup: - Share one repo directory resolver, trusted-origins parser, cookie prefix, WebSocket frame forwarder, header filter, icon map and dialog-param helper - Remove unused props, options and exports Docs: update terminal, preview, project actions, sandboxing, internal API and environment pages
This commit is contained in:
1 parent
16b91ccf02
commit
c60a9b35f2
72 files changed
+2039
-596
No files matched your search
@@ -167,6 +167,12 @@ export const getOpenCodeConfigFilePath = () => path.join(ENV.WORKSPACE.BASE_PATH
|
||||
export const getAgentsMdPath = () => path.join(ENV.WORKSPACE.BASE_PATH, ENV.WORKSPACE.CONFIG_DIR, 'AGENTS.md')
|
||||
export const getDatabasePath = () => ENV.DATABASE.PATH
|
||||
|
||||
export const getTrustedOrigins = (): string[] =>
|
||||
ENV.AUTH.TRUSTED_ORIGINS
|
||||
.split(',')
|
||||
.map((origin) => origin.trim())
|
||||
.filter((origin) => origin.length > 0)
|
||||
|
||||
export const getApiUrl = (port: number = ENV.SERVER.PORT): string => {
|
||||
const host = ENV.SERVER.HOST
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ export const PreviewPortSchema = z.object({
|
||||
pid: z.number().int().nullable(),
|
||||
command: z.string().nullable(),
|
||||
cwd: z.string().nullable(),
|
||||
inDirectory: z.boolean(),
|
||||
})
|
||||
|
||||
export const PreviewPortsResponseSchema = z.object({
|
||||
|
||||
@@ -17,7 +17,12 @@ export const ProjectActionSchema = z.object({
|
||||
name: z.string().trim().min(1).max(60),
|
||||
command: z.string().trim().min(1).max(4000),
|
||||
icon: ProjectActionIconSchema.optional(),
|
||||
url: z.string().trim().max(500).optional(),
|
||||
url: z
|
||||
.string()
|
||||
.trim()
|
||||
.max(500)
|
||||
.refine((value) => /^https?:\/\//i.test(value), 'URL must start with http:// or https://')
|
||||
.optional(),
|
||||
autoOpenUrl: z.boolean().default(false),
|
||||
})
|
||||
|
||||
@@ -49,6 +54,20 @@ export const ProjectConfigResponseSchema = z.object({
|
||||
exists: z.boolean(),
|
||||
trusted: z.boolean(),
|
||||
hash: z.string().nullable(),
|
||||
executable: z
|
||||
.object({
|
||||
actions: z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
command: z.string(),
|
||||
url: z.string().nullable(),
|
||||
autoOpenUrl: z.boolean(),
|
||||
}),
|
||||
),
|
||||
setup: z.array(z.string()),
|
||||
})
|
||||
.nullable(),
|
||||
error: z.string().optional(),
|
||||
warnings: z.array(z.string()),
|
||||
}),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { TerminalKind } from '../schemas/terminal'
|
||||
import type { TerminalInfo, TerminalKind } from '../schemas/terminal'
|
||||
|
||||
const ACTION_TITLE_PREFIX = 'ocm:action:'
|
||||
const SETUP_TITLE_PREFIX = 'ocm:setup:'
|
||||
@@ -31,6 +31,12 @@ export function formatTerminalTitle(input: FormatTerminalTitleInput): string {
|
||||
return input.name
|
||||
}
|
||||
|
||||
export type RunningActionTerminal = Pick<TerminalInfo, 'kind' | 'actionId' | 'status'>
|
||||
|
||||
export function isRunningActionTerminal(terminal: RunningActionTerminal, actionId: string): boolean {
|
||||
return terminal.kind === 'action' && terminal.actionId === actionId && terminal.status === 'running'
|
||||
}
|
||||
|
||||
export function parseTerminalTitle(raw: string): ParsedTerminalTitle {
|
||||
if (raw.startsWith(ACTION_TITLE_PREFIX)) {
|
||||
const rest = raw.slice(ACTION_TITLE_PREFIX.length)
|
||||
|
||||
Reference in new issue
Block a user