mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 22:01:24 +00:00
fix: Finish credential redaction that was merged unfinished (#13073)
* Squash * Removed unused files Not mine, someone merged that stuff in earlier. * fix: patch redaction regressions and schema breakages --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type { ConfigUiHint, ConfigUiHints } from "./schema.hints.js";
|
||||
import { CHANNEL_IDS } from "../channels/registry.js";
|
||||
import { VERSION } from "../version.js";
|
||||
import { applySensitiveHints, buildBaseHints } from "./schema.hints.js";
|
||||
import { applySensitiveHints, buildBaseHints, mapSensitivePaths } from "./schema.hints.js";
|
||||
import { OpenClawSchema } from "./zod-schema.js";
|
||||
|
||||
export type { ConfigUiHint, ConfigUiHints } from "./schema.hints.js";
|
||||
@@ -88,6 +88,28 @@ export type ChannelUiMetadata = {
|
||||
configUiHints?: Record<string, ConfigUiHint>;
|
||||
};
|
||||
|
||||
function collectExtensionHintKeys(
|
||||
hints: ConfigUiHints,
|
||||
plugins: PluginUiMetadata[],
|
||||
channels: ChannelUiMetadata[],
|
||||
): Set<string> {
|
||||
const pluginPrefixes = plugins
|
||||
.map((plugin) => plugin.id.trim())
|
||||
.filter(Boolean)
|
||||
.map((id) => `plugins.entries.${id}`);
|
||||
const channelPrefixes = channels
|
||||
.map((channel) => channel.id.trim())
|
||||
.filter(Boolean)
|
||||
.map((id) => `channels.${id}`);
|
||||
const prefixes = [...pluginPrefixes, ...channelPrefixes];
|
||||
|
||||
return new Set(
|
||||
Object.keys(hints).filter((key) =>
|
||||
prefixes.some((prefix) => key === prefix || key.startsWith(`${prefix}.`)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function applyPluginHints(hints: ConfigUiHints, plugins: PluginUiMetadata[]): ConfigUiHints {
|
||||
const next: ConfigUiHints = { ...hints };
|
||||
for (const plugin of plugins) {
|
||||
@@ -299,7 +321,7 @@ function buildBaseConfigSchema(): ConfigSchemaResponse {
|
||||
unrepresentable: "any",
|
||||
});
|
||||
schema.title = "OpenClawConfig";
|
||||
const hints = applySensitiveHints(buildBaseHints());
|
||||
const hints = mapSensitivePaths(OpenClawSchema, "", buildBaseHints());
|
||||
const next = {
|
||||
schema: stripChannelSchema(schema),
|
||||
uiHints: hints,
|
||||
@@ -320,12 +342,16 @@ export function buildConfigSchema(params?: {
|
||||
if (plugins.length === 0 && channels.length === 0) {
|
||||
return base;
|
||||
}
|
||||
const mergedHints = applySensitiveHints(
|
||||
applyHeartbeatTargetHints(
|
||||
applyChannelHints(applyPluginHints(base.uiHints, plugins), channels),
|
||||
channels,
|
||||
),
|
||||
const mergedWithoutSensitiveHints = applyHeartbeatTargetHints(
|
||||
applyChannelHints(applyPluginHints(base.uiHints, plugins), channels),
|
||||
channels,
|
||||
);
|
||||
const extensionHintKeys = collectExtensionHintKeys(
|
||||
mergedWithoutSensitiveHints,
|
||||
plugins,
|
||||
channels,
|
||||
);
|
||||
const mergedHints = applySensitiveHints(mergedWithoutSensitiveHints, extensionHintKeys);
|
||||
const mergedSchema = applyChannelSchemas(applyPluginSchemas(base.schema, plugins), channels);
|
||||
return {
|
||||
...base,
|
||||
|
||||
Reference in New Issue
Block a user