Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: update compose schema detection to remove false positive secret detections (#1876)
Kyle Mendell11d385822263
diff --git a/frontend/src/lib/components/code-editor/analysis/compose-analysis.ts b/frontend/src/lib/components/code-editor/analysis/compose-analysis.tsindex aff79e2d8..dce5127a7 100644--- a/frontend/src/lib/components/code-editor/analysis/compose-analysis.ts+++ b/frontend/src/lib/components/code-editor/analysis/compose-analysis.ts@@ -10,6 +10,8 @@ const MAX_SCHEMA_DIAGNOSTICS_DEFAULT = 30;const TAB_INDENT_REGEX = /(^|\n)(\t+)/g;const SECRET_NAME_REGEX = /(password|passwd|secret|token|api[_-]?key|private[_-]?key|credential|aws_secret)/i;const SECRET_VALUE_REGEX = /(?:-----BEGIN [A-Z ]+-----|eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+|[A-Za-z0-9_\/-]{24,})/;+const NON_SECRET_VALUE_KEYS = new Set(['image']);+const NON_SECRET_VALUE_PARENT_KEYS = new Set(['x-arcane']);const VARIABLE_TOKEN_REGEX = /\$\{([A-Za-z_][A-Za-z0-9_]*)(?:(?::[-?+])[^}]*)?\}|\$([A-Za-z_][A-Za-z0-9_]*)/g;const LIST_FIELDS = ['volumes', 'ports', 'env_file', 'dns', 'tmpfs'];@@ -350,18 +352,35 @@ function buildSecretDiagnostics(source: string): Diagnostic[] {const diagnostics: Diagnostic[] = [];const lines = source.split('\n');let offset = 0;+ const keyStack: Array<{ key: string; indent: number }> = [];for (const rawLine of lines) {const line = rawLine.endsWith('\r') ? rawLine.slice(0, -1) : rawLine;- const match = /^(\s*)([A-Za-z0-9_.-]+)\s*:\s*(.+)$/.exec(line);+ const match = /^(\s*)([A-Za-z0-9_.-]+)\s*:\s*(.*)$/.exec(line);if (!match) {offset += rawLine.length + 1;continue;}+ const indent = (match[1] ?? '').length;+ while (keyStack.length > 0 && keyStack[keyStack.length - 1]!.indent >= indent) {+ keyStack.pop();+ }+const key = match[2] ?? '';const value = (match[3] ?? '').trim();- if (!SECRET_NAME_REGEX.test(key) && !SECRET_VALUE_REGEX.test(value)) {+ const isBlockKey = value === '';+ const isSecretKey = SECRET_NAME_REGEX.test(key);+ const lowerKey = key.toLowerCase();+ const isArcaneExtensionKey = lowerKey.startsWith('x-arcane');+ const inArcaneExtensionBlock = keyStack.some((entry) => NON_SECRET_VALUE_PARENT_KEYS.has(entry.key.toLowerCase()));+ const shouldCheckValue = !NON_SECRET_VALUE_KEYS.has(lowerKey) && !isArcaneExtensionKey && !inArcaneExtensionBlock;+ const isSecretValue = shouldCheckValue && SECRET_VALUE_REGEX.test(value);++ if (!isSecretKey && !isSecretValue) {+ if (isBlockKey) {+ keyStack.push({ key, indent });+ }offset += rawLine.length + 1;continue;}@@ -376,6 +395,10 @@ function buildSecretDiagnostics(source: string): Diagnostic[] {message: `"${key}" looks like a secret. Prefer Docker secrets or external secret managers.`});+ if (isBlockKey) {+ keyStack.push({ key, indent });+ }+offset += rawLine.length + 1;}diff --git a/frontend/src/lib/components/code-editor/analysis/compose-schema.ts b/frontend/src/lib/components/code-editor/analysis/compose-schema.tsindex 65e19a14d..8568e4a8c 100644--- a/frontend/src/lib/components/code-editor/analysis/compose-schema.ts+++ b/frontend/src/lib/components/code-editor/analysis/compose-schema.ts@@ -17,9 +17,67 @@ type ComposeSchemaContext = {message?: string;};+type ArcaneCompletionSpec = {+ label: string;+ detail: string;+ info: string;+};+let composeSchemaPromise: Promise<ComposeSchemaContext> | null = null;let composeSchemaContext: ComposeSchemaContext | null = null;+const ARCANE_ROOT_EXTENSION_COMPLETIONS: ArcaneCompletionSpec[] = [+ {+ label: 'x-arcane',+ detail: 'Arcane extension',+ info: 'Arcane compose metadata block for project-level icon and URLs.'+ },+ {+ label: 'x-arcane-icon',+ detail: 'Arcane extension helper',+ info: 'Optional extension key often used for YAML anchors/reuse of icon values.'+ }+];++const ARCANE_BLOCK_COMPLETIONS: ArcaneCompletionSpec[] = [+ {+ label: 'icon',+ detail: 'Arcane project icon',+ info: 'Project icon URL or icon identifier.'+ },+ {+ label: 'icons',+ detail: 'Arcane project icon (alias)',+ info: 'Alias for icon metadata; first non-empty value is used.'+ },+ {+ label: 'urls',+ detail: 'Arcane project URLs',+ info: 'Additional project URLs (for example docs or homepage links).'+ }+];++const ARCANE_SERVICE_EXTENSION_COMPLETIONS: ArcaneCompletionSpec[] = [+ {+ label: 'x-arcane',+ detail: 'Arcane service extension',+ info: 'Arcane service metadata block for service icon overrides.'+ }+];++const ARCANE_SERVICE_BLOCK_COMPLETIONS: ArcaneCompletionSpec[] = [+ {+ label: 'icon',+ detail: 'Arcane service icon',+ info: 'Service icon URL or icon identifier.'+ },+ {+ label: 'icons',+ detail: 'Arcane service icon (alias)',+ info: 'Alias for service icon metadata; first non-empty value is used.'+ }+];+function asSchemaObject(value: unknown): SchemaObject | null {if (!value || typeof value !== 'object' || Array.isArray(value)) return null;return value as SchemaObject;@@ -205,6 +263,111 @@ function extractSchemaDoc(schema: SchemaObject): SchemaDoc {};}+function isRootPath(path: Array<string | number>): boolean {+ return path.length === 0;+}++function isRootArcanePath(path: Array<string | number>): boolean {+ return path.length === 1 && path[0] === 'x-arcane';+}++function isServicePath(path: Array<string | number>): boolean {+ return path.length === 2 && path[0] === 'services' && typeof path[1] === 'string';+}++function isServiceArcanePath(path: Array<string | number>): boolean {+ return path.length === 3 && path[0] === 'services' && typeof path[1] === 'string' && path[2] === 'x-arcane';+}++function toArcaneCompletion(spec: ArcaneCompletionSpec): Completion {+ return {+ label: spec.label,+ type: 'property',+ detail: spec.detail,+ info: spec.info,+ apply: `${spec.label}: `+ };+}++function getArcaneCompletionOptionsForPath(path: Array<string | number>, prefix = ''): Completion[] {+ const normalizedPrefix = prefix.toLowerCase();+ let specs: ArcaneCompletionSpec[] = [];++ if (isRootPath(path)) {+ specs = ARCANE_ROOT_EXTENSION_COMPLETIONS;+ } else if (isRootArcanePath(path)) {+ specs = ARCANE_BLOCK_COMPLETIONS;+ } else if (isServicePath(path)) {+ specs = ARCANE_SERVICE_EXTENSION_COMPLETIONS;+ } else if (isServiceArcanePath(path)) {+ specs = ARCANE_SERVICE_BLOCK_COMPLETIONS;+ }++ return specs+ .filter((item) => item.label.toLowerCase().includes(normalizedPrefix))+ .sort((a, b) => a.label.localeCompare(b.label))+ .map(toArcaneCompletion);+}++function getArcaneSchemaDocForPath(path: Array<string | number>): SchemaDoc | null {+ if (path.length === 1 && path[0] === 'x-arcane') {+ return {+ title: 'x-arcane',+ description: 'Arcane extension block for project-level metadata such as icon and custom URLs.'+ };+ }++ if (path.length === 1 && path[0] === 'x-arcane-icon') {+ return {+ title: 'x-arcane-icon',+ description: 'Optional Arcane helper extension key, commonly used as a YAML anchor value for icon reuse.'+ };+ }++ if (path.length === 2 && path[0] === 'x-arcane' && path[1] === 'icon') {+ return {+ title: 'x-arcane.icon',+ description: 'Project icon URL or icon identifier used for the stack/project display.'+ };+ }++ if (path.length === 2 && path[0] === 'x-arcane' && path[1] === 'icons') {+ return {+ title: 'x-arcane.icons',+ description: 'Alias for icon metadata. Arcane uses the first non-empty value between icon/icons.'+ };+ }++ if (path.length === 2 && path[0] === 'x-arcane' && path[1] === 'urls') {+ return {+ title: 'x-arcane.urls',+ description: 'Additional project URLs (for example docs, homepage, or dashboards).'+ };+ }++ if (path.length === 3 && path[0] === 'services' && typeof path[1] === 'string' && path[2] === 'x-arcane') {+ return {+ title: 'services.<name>.x-arcane',+ description: 'Arcane extension block for service-level metadata.'+ };+ }++ if (+ path.length === 4 &&+ path[0] === 'services' &&+ typeof path[1] === 'string' &&+ path[2] === 'x-arcane' &&+ (path[3] === 'icon' || path[3] === 'icons')+ ) {+ return {+ title: `services.<name>.x-arcane.${String(path[3])}`,+ description: 'Service icon URL or icon identifier override.'+ };+ }++ return null;+}+export async function getComposeSchemaContext(): Promise<ComposeSchemaContext> {if (composeSchemaContext) return composeSchemaContext;if (composeSchemaPromise) return composeSchemaPromise;@@ -259,15 +422,13 @@ export function getCompletionOptionsForPath(path: Array<string | number>,prefix = ''): Completion[] {- if (!schema) return [];- const map = collectPropertySchemas(schema, path);const normalizedPrefix = prefix.toLowerCase();-- return Array.from(map.entries())+ const propertyMap = schema ? collectPropertySchemas(schema, path) : new Map<string, SchemaObject>();+ const schemaCompletions = Array.from(propertyMap.entries()).filter(([key]) => key.toLowerCase().includes(normalizedPrefix)).sort(([a], [b]) => a.localeCompare(b))- .map(([key]) => {- const doc = extractSchemaDoc(map.get(key) ?? {});+ .map(([key, propertySchema]) => {+ const doc = extractSchemaDoc(propertySchema);return {label: key,type: 'property',@@ -276,6 +437,21 @@ export function getCompletionOptionsForPath(apply: `${key}: `} as Completion;});++ const arcaneCompletions = getArcaneCompletionOptionsForPath(path, prefix);+ const merged = new Map<string, Completion>();++ for (const completion of schemaCompletions) {+ merged.set(completion.label, completion);+ }++ for (const completion of arcaneCompletions) {+ if (!merged.has(completion.label)) {+ merged.set(completion.label, completion);+ }+ }++ return Array.from(merged.values()).sort((a, b) => a.label.localeCompare(b.label));}export function getEnumValueCompletions(schema: SchemaObject | null, path: Array<string | number>): Completion[] {@@ -305,7 +481,8 @@ export function getEnumValueCompletions(schema: SchemaObject | null, path: Array}export function getSchemaDocForPath(schema: SchemaObject | null, path: Array<string | number>): SchemaDoc | null {- if (!schema) return null;+ const arcaneDoc = getArcaneSchemaDocForPath(path);+ if (!schema) return arcaneDoc;const candidates = getPathCandidates(schema, path);for (const candidate of candidates) {const doc = extractSchemaDoc(candidate);@@ -313,7 +490,7 @@ export function getSchemaDocForPath(schema: SchemaObject | null, path: Array<strreturn doc;}}- return null;+ return arcaneDoc;}export type { ComposeSchemaContext, SchemaObject };diff --git a/go.work.sum b/go.work.sumindex 0ed43bbdb..e0a61f6ab 100644--- a/go.work.sum+++ b/go.work.sum@@ -1,5 +1,7 @@cel.dev/expr v0.24.0 h1:56OvJKSH3hDGL0ml5uSxZmz3/3Pq4tJ+fb1unVLAFcY=cel.dev/expr v0.24.0/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw=+cel.dev/expr v0.25.1 h1:1KrZg61W6TWSxuNZ37Xy49ps13NUovb66QLprthtwi4=+cel.dev/expr v0.25.1/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4=cloud.google.com/go v0.121.6 h1:waZiuajrI28iAf40cWgycWNgaXPO06dupuS+sgibK6c=cloud.google.com/go v0.121.6/go.mod h1:coChdst4Ea5vUpiALcYKXEpR1S9ZgXbhEzzMcMR66vI=cloud.google.com/go/auth v0.16.4 h1:fXOAIQmkApVvcIn7Pc2+5J8QTMVbUGLscnSVNl11su8=@@ -160,6 +162,8 @@ github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=github.com/cncf/xds/go v0.0.0-20251022180443-0feb69152e9f h1:Y8xYupdHxryycyPlc9Y+bSQAYZnetRJ70VMVKm5CKI0=github.com/cncf/xds/go v0.0.0-20251022180443-0feb69152e9f/go.mod h1:HlzOvOjVBOfTGSRXRyY0OiCS/3J1akRGQQpRO/7zyF4=+github.com/cncf/xds/go v0.0.0-20251210132809-ee656c7534f5 h1:6xNmx7iTtyBRev0+D/Tv1FZd4SCg8axKApyNyRsAt/w=+github.com/cncf/xds/go v0.0.0-20251210132809-ee656c7534f5/go.mod h1:KdCmV+x/BuvyMxRnYBlmVaq4OLiKW6iRQfvC62cvdkI=github.com/cockroachdb/cockroach-go/v2 v2.1.1 h1:3XzfSMuUT0wBe1a3o5C0eOTcArhmmFAg2Jzh/7hhKqo=github.com/cockroachdb/cockroach-go/v2 v2.1.1/go.mod h1:7NtUnP6eK+l6k483WSYNrq3Kb23bWV10IRV1TyeSpwM=github.com/containerd/accelerated-container-image v1.3.0 h1:sFbTgSuMboeKHa9f7MY11hWF1XxVWjFoiTsXYtOtvdU=@@ -225,12 +229,18 @@ github.com/emicklei/go-restful/v3 v3.13.0 h1:C4Bl2xDndpU6nJ4bc1jXd+uTmYPVUwkD6bFgithub.com/emicklei/go-restful/v3 v3.13.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=github.com/envoyproxy/go-control-plane v0.13.5-0.20251024222203-75eaa193e329 h1:K+fnvUM0VZ7ZFJf0n4L/BRlnsb9pL/GuDG6FqaH+PwM=github.com/envoyproxy/go-control-plane v0.13.5-0.20251024222203-75eaa193e329/go.mod h1:Alz8LEClvR7xKsrq3qzoc4N0guvVNSS8KmSChGYr9hs=+github.com/envoyproxy/go-control-plane v0.14.0 h1:hbG2kr4RuFj222B6+7T83thSPqLjwBIfQawTkC++2HA=+github.com/envoyproxy/go-control-plane v0.14.0/go.mod h1:NcS5X47pLl/hfqxU70yPwL9ZMkUlwlKxtAohpi2wBEU=github.com/envoyproxy/go-control-plane/envoy v1.35.0 h1:ixjkELDE+ru6idPxcHLj8LBVc2bFP7iBytj353BoHUo=github.com/envoyproxy/go-control-plane/envoy v1.35.0/go.mod h1:09qwbGVuSWWAyN5t/b3iyVfz5+z8QWGrzkoqm/8SbEs=+github.com/envoyproxy/go-control-plane/envoy v1.36.0 h1:yg/JjO5E7ubRyKX3m07GF3reDNEnfOboJ0QySbH736g=+github.com/envoyproxy/go-control-plane/envoy v1.36.0/go.mod h1:ty89S1YCCVruQAm9OtKeEkQLTb+Lkz0k8v9W0Oxsv98=github.com/envoyproxy/go-control-plane/ratelimit v0.1.0 h1:/G9QYbddjL25KvtKTv3an9lx6VBE2cnb8wp1vEGNYGI=github.com/envoyproxy/go-control-plane/ratelimit v0.1.0/go.mod h1:Wk+tMFAFbCXaJPzVVHnPgRKdUdwW/KdbRt94AzgRee4=github.com/envoyproxy/protoc-gen-validate v1.2.1 h1:DEo3O99U8j4hBFwbJfrz9VtgcDfUKS7KJ7spH3d86P8=github.com/envoyproxy/protoc-gen-validate v1.2.1/go.mod h1:d/C80l/jxXLdfEIhX1W2TmLfsJ31lvEjwamM4DxlWXU=+github.com/envoyproxy/protoc-gen-validate v1.3.0 h1:TvGH1wof4H33rezVKWSpqKz5NXWg5VPuZ0uONDT6eb4=+github.com/envoyproxy/protoc-gen-validate v1.3.0/go.mod h1:HvYl7zwPa5mffgyeTUHA9zHIH36nmrm7oCbo4YKoSWA=github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=github.com/evanphx/json-patch/v5 v5.9.11 h1:/8HVnzMq13/3x9TPvjG08wUGqBTmZBsCWzjTM0wiaDU=github.com/evanphx/json-patch/v5 v5.9.11/go.mod h1:3j+LviiESTElxA4p3EMKAB9HXj3/XEtnUf6OZxqIQTM=@@ -591,6 +601,8 @@ go.mongodb.org/mongo-driver v1.7.5 h1:ny3p0reEpgsR2cfA5cjgwFZg3Cv/ofFh/8jbhGtz9Vgo.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4xhp5Zvxng=go.opentelemetry.io/contrib/detectors/gcp v1.38.0 h1:ZoYbqX7OaA/TAikspPl3ozPI6iY6LiIY9I8cUfm+pJs=go.opentelemetry.io/contrib/detectors/gcp v1.38.0/go.mod h1:SU+iU7nu5ud4oCb3LQOhIZ3nRLj6FNVrKgtflbaf2ts=+go.opentelemetry.io/contrib/detectors/gcp v1.39.0 h1:kWRNZMsfBHZ+uHjiH4y7Etn2FK26LAGkNFw7RHv1DhE=+go.opentelemetry.io/contrib/detectors/gcp v1.39.0/go.mod h1:t/OGqzHBa5v6RHZwrDBJ2OirWc+4q/w2fTbLZwAKjTk=go.opentelemetry.io/otel/exporters/jaeger v1.17.0 h1:D7UpUy2Xc2wsi1Ras6V40q806WM07rqoCWzXu7Sqy+4=go.opentelemetry.io/otel/exporters/jaeger v1.17.0/go.mod h1:nPCqOnEH9rNLKqH/+rrUjiMzHJdV1BlpKcTwRTyKkKI=go.opentelemetry.io/otel/exporters/prometheus v0.42.0 h1:jwV9iQdvp38fxXi8ZC+lNpxjK16MRcZlpDYvbuO1FiA=