fix: avoid clobbering sensitive config fields during configure
Reading the entire plugins tree via openclaw config get returns redacted values for sensitive fields. Writing it back overwrites real secrets with the __OPENCLAW_REDACTED__ sentinel. Changed to set individual leaf paths only when missing.
This commit is contained in:
28
install.mjs
28
install.mjs
@@ -349,23 +349,21 @@ async function configure() {
|
|||||||
if (!allow.includes(PLUGIN_NAME)) { allow.push(PLUGIN_NAME); setOpenclawConfig('plugins.allow', allow); }
|
if (!allow.includes(PLUGIN_NAME)) { allow.push(PLUGIN_NAME); setOpenclawConfig('plugins.allow', allow); }
|
||||||
logOk(`plugins.allow includes ${PLUGIN_NAME}`);
|
logOk(`plugins.allow includes ${PLUGIN_NAME}`);
|
||||||
|
|
||||||
const plugins = getOpenclawConfig('plugins', {});
|
const entryPath = `plugins.entries.${PLUGIN_NAME}`;
|
||||||
plugins.entries = plugins.entries || {};
|
const existingEnabled = getOpenclawConfig(`${entryPath}.enabled`, undefined);
|
||||||
|
if (existingEnabled === undefined) setOpenclawConfig(`${entryPath}.enabled`, true);
|
||||||
|
|
||||||
const existingEntry = plugins.entries[PLUGIN_NAME] || {};
|
const cfgPath = `${entryPath}.config`;
|
||||||
const existingConfig = existingEntry.config || {};
|
const existingCfgEnabled = getOpenclawConfig(`${cfgPath}.enabled`, undefined);
|
||||||
const defaultConfig = { enabled: true, secretMgrPath, openclawProfilePath: openclawPath };
|
if (existingCfgEnabled === undefined) setOpenclawConfig(`${cfgPath}.enabled`, true);
|
||||||
|
|
||||||
plugins.entries[PLUGIN_NAME] = {
|
const existingSecretMgr = getOpenclawConfig(`${cfgPath}.secretMgrPath`, undefined);
|
||||||
...existingEntry,
|
if (existingSecretMgr === undefined) setOpenclawConfig(`${cfgPath}.secretMgrPath`, secretMgrPath);
|
||||||
enabled: existingEntry.enabled ?? true,
|
|
||||||
config: {
|
const existingProfile = getOpenclawConfig(`${cfgPath}.openclawProfilePath`, undefined);
|
||||||
...defaultConfig,
|
if (existingProfile === undefined) setOpenclawConfig(`${cfgPath}.openclawProfilePath`, openclawPath);
|
||||||
...existingConfig,
|
|
||||||
},
|
logOk('Plugin entry configured (set missing defaults only)');
|
||||||
};
|
|
||||||
setOpenclawConfig('plugins', plugins);
|
|
||||||
logOk('Plugin entry configured (preserved existing config, added missing defaults)');
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logWarn(`Config failed: ${err.message}`);
|
logWarn(`Config failed: ${err.message}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user