feat: complete catalog sensitivity enhancements
This commit is contained in:
@@ -130,6 +130,11 @@ export interface DiagnosticAdapters {
|
||||
probeEmbedding(request: EmbeddingDiagnosticRequest): Promise<EmbeddingDiagnosticResult>;
|
||||
}
|
||||
|
||||
export interface WorkspaceDiagnosticOptions {
|
||||
writeProbe: boolean;
|
||||
skipDwh?: boolean;
|
||||
}
|
||||
|
||||
export const DEFAULT_WORKSPACE_DIAGNOSTIC_TIMEOUT_MS = 5_000;
|
||||
|
||||
async function secretPresent(file: string): Promise<boolean> {
|
||||
@@ -421,6 +426,7 @@ async function diagnoseValidatedWorkspace(
|
||||
adapters: DiagnosticAdapters,
|
||||
timeoutMs: number,
|
||||
semanticRuntime: SemanticRuntimeConfig,
|
||||
skipDwh: boolean,
|
||||
): Promise<ConnectorDiagnostics> {
|
||||
const evidenceField = descriptor.evidence?.source.type === "http"
|
||||
? "evidence.source.authentication"
|
||||
@@ -432,75 +438,79 @@ async function diagnoseValidatedWorkspace(
|
||||
variable,
|
||||
}));
|
||||
const diagnostics = [
|
||||
...[...bindings.dwh.missing].sort().map((field) => diagnosticError("binding_missing", field)),
|
||||
...(skipDwh
|
||||
? []
|
||||
: [...bindings.dwh.missing].sort().map((field) => diagnosticError("binding_missing", field))),
|
||||
...evidenceDiagnostics,
|
||||
];
|
||||
if (diagnostics.length > 0) return { activatable: false, diagnostics };
|
||||
|
||||
const dwhTimeout = boundedTimeout(descriptor.dwh.timeout_ms, timeoutMs);
|
||||
let activatable = true;
|
||||
const dwhValues = bindings.dwh.values;
|
||||
const dwhField = (suffix: string) => bindingName(descriptor, suffix);
|
||||
const dwhResource = { database: descriptor.dwh.database, schema: descriptor.dwh.schema };
|
||||
let dwhRequest: ConnectorDiagnosticRequest | undefined;
|
||||
if (bindings.dwh.transport === "rest_api") {
|
||||
const diagnostic = descriptor.diagnostics?.dwh_rest;
|
||||
const baseUrl = dwhValues[dwhField("BASE_URL")];
|
||||
if (diagnostic && baseUrl) {
|
||||
const credentialFile = diagnostic.auth === "none" ? undefined : dwhValues[dwhField("API_KEY_FILE")];
|
||||
if (diagnostic.auth === "none" || credentialFile !== undefined) {
|
||||
if (!skipDwh) {
|
||||
const dwhTimeout = boundedTimeout(descriptor.dwh.timeout_ms, timeoutMs);
|
||||
const dwhValues = bindings.dwh.values;
|
||||
const dwhField = (suffix: string) => bindingName(descriptor, suffix);
|
||||
const dwhResource = { database: descriptor.dwh.database, schema: descriptor.dwh.schema };
|
||||
let dwhRequest: ConnectorDiagnosticRequest | undefined;
|
||||
if (bindings.dwh.transport === "rest_api") {
|
||||
const diagnostic = descriptor.diagnostics?.dwh_rest;
|
||||
const baseUrl = dwhValues[dwhField("BASE_URL")];
|
||||
if (diagnostic && baseUrl) {
|
||||
const credentialFile = diagnostic.auth === "none" ? undefined : dwhValues[dwhField("API_KEY_FILE")];
|
||||
if (diagnostic.auth === "none" || credentialFile !== undefined) {
|
||||
dwhRequest = {
|
||||
role: "dwh",
|
||||
transport: "rest_api",
|
||||
baseUrl,
|
||||
credentialFile,
|
||||
tlsCaFile: dwhValues[dwhField("TLS_CA_FILE")],
|
||||
resource: dwhResource,
|
||||
timeoutMs: dwhTimeout,
|
||||
signal: new AbortController().signal,
|
||||
diagnostic,
|
||||
};
|
||||
}
|
||||
}
|
||||
} else if (bindings.dwh.transport === "postgres_direct") {
|
||||
const host = dwhValues[dwhField("HOST")];
|
||||
const port = numericBinding(dwhValues, dwhField("PORT"));
|
||||
const user = dwhValues[dwhField("USER")];
|
||||
const credentialFile = dwhValues[dwhField("PASSWORD_FILE")];
|
||||
if (host && port && user && credentialFile) {
|
||||
dwhRequest = {
|
||||
role: "dwh",
|
||||
transport: "rest_api",
|
||||
baseUrl,
|
||||
transport: "postgres_direct",
|
||||
host,
|
||||
port,
|
||||
user,
|
||||
credentialFile,
|
||||
tlsCaFile: dwhValues[dwhField("TLS_CA_FILE")],
|
||||
resource: dwhResource,
|
||||
timeoutMs: dwhTimeout,
|
||||
signal: new AbortController().signal,
|
||||
diagnostic,
|
||||
};
|
||||
}
|
||||
}
|
||||
} else if (bindings.dwh.transport === "postgres_direct") {
|
||||
const host = dwhValues[dwhField("HOST")];
|
||||
const port = numericBinding(dwhValues, dwhField("PORT"));
|
||||
const user = dwhValues[dwhField("USER")];
|
||||
const credentialFile = dwhValues[dwhField("PASSWORD_FILE")];
|
||||
if (host && port && user && credentialFile) {
|
||||
dwhRequest = {
|
||||
role: "dwh",
|
||||
transport: "postgres_direct",
|
||||
host,
|
||||
port,
|
||||
user,
|
||||
credentialFile,
|
||||
tlsCaFile: dwhValues[dwhField("TLS_CA_FILE")],
|
||||
resource: dwhResource,
|
||||
timeoutMs: dwhTimeout,
|
||||
signal: new AbortController().signal,
|
||||
};
|
||||
|
||||
if (!dwhRequest) {
|
||||
diagnostics.push(diagnosticError("workspace_not_activatable"));
|
||||
return { activatable: false, diagnostics };
|
||||
}
|
||||
}
|
||||
|
||||
if (!dwhRequest) {
|
||||
diagnostics.push(diagnosticError("workspace_not_activatable"));
|
||||
return { activatable: false, diagnostics };
|
||||
}
|
||||
|
||||
try {
|
||||
const dwhResult = await withTimeout(dwhTimeout, (signal) => adapters.probeConnector({
|
||||
...dwhRequest,
|
||||
signal,
|
||||
timeoutMs: dwhTimeout,
|
||||
}));
|
||||
if (!hasRequiredConnectorChecks(dwhResult, dwhRequest.resource)) {
|
||||
try {
|
||||
const dwhResult = await withTimeout(dwhTimeout, (signal) => adapters.probeConnector({
|
||||
...dwhRequest,
|
||||
signal,
|
||||
timeoutMs: dwhTimeout,
|
||||
}));
|
||||
if (!hasRequiredConnectorChecks(dwhResult, dwhRequest.resource)) {
|
||||
diagnostics.push(diagnosticError("connector_unavailable"));
|
||||
activatable = false;
|
||||
}
|
||||
} catch {
|
||||
diagnostics.push(diagnosticError("connector_unavailable"));
|
||||
activatable = false;
|
||||
}
|
||||
} catch {
|
||||
diagnostics.push(diagnosticError("connector_unavailable"));
|
||||
activatable = false;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -571,11 +581,18 @@ export function createWorkspaceDiagnoser(
|
||||
return async function diagnose(
|
||||
workspace: WorkspaceDescriptor,
|
||||
bindings: RuntimeBindings,
|
||||
_options: { writeProbe: boolean },
|
||||
diagnosticOptions: WorkspaceDiagnosticOptions,
|
||||
): Promise<ConnectorDiagnostics> {
|
||||
requireSupportedDescriptor(workspace);
|
||||
const descriptor = validateWorkspaceDescriptor(workspace);
|
||||
return await diagnoseValidatedWorkspace(descriptor, bindings, adapters, timeoutMs, semanticRuntime);
|
||||
return await diagnoseValidatedWorkspace(
|
||||
descriptor,
|
||||
bindings,
|
||||
adapters,
|
||||
timeoutMs,
|
||||
semanticRuntime,
|
||||
diagnosticOptions.skipDwh ?? false,
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user