Skip to content

Commit 86734ef

Browse files
authored
fix(config): redact sourceConfig and runtimeConfig alias fields in redactConfigSnapshot [AI] (#66030)
* fix: address issue * docs: add changelog entry for PR merge
1 parent 448a33b commit 86734ef

3 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Docs: https://docs.openclaw.ai
1010

1111
### Fixes
1212

13+
- fix(config): redact sourceConfig and runtimeConfig alias fields in redactConfigSnapshot [AI]. (#66030) Thanks @pgondhi987.
1314
- Agents/context engines: run opt-in turn maintenance as idle-aware background work so the next foreground turn no longer waits on proactive maintenance. (#65233) thanks @100yenadmin
1415

1516
- Plugins/status: report the registered context-engine IDs in `plugins inspect` instead of the owning plugin ID, so non-matching engine IDs and multi-engine plugins are classified correctly. (#58766) thanks @zhuisDEV

‎src/config/redact-snapshot.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,21 @@ describe("redactConfigSnapshot", () => {
565565
});
566566
const result = redactConfigSnapshot(snapshot);
567567
const parsed = result.parsed as Record<string, Record<string, Record<string, string>>>;
568+
const sourceConfig = result.sourceConfig as Record<
569+
string,
570+
Record<string, Record<string, string>>
571+
>;
568572
const resolved = result.resolved as Record<string, Record<string, Record<string, string>>>;
573+
const runtimeConfig = result.runtimeConfig as Record<
574+
string,
575+
Record<string, Record<string, string>>
576+
>;
569577
expect(parsed.channels.discord.token).toBe(REDACTED_SENTINEL);
578+
expect(sourceConfig.gateway.auth.token).toBe(REDACTED_SENTINEL);
570579
expect(resolved.gateway.auth.token).toBe(REDACTED_SENTINEL);
580+
expect(runtimeConfig.channels.discord.token).toBe(REDACTED_SENTINEL);
581+
expect(result.sourceConfig).toBe(result.resolved);
582+
expect(result.runtimeConfig).toBe(result.config);
571583
});
572584

573585
it("handles null raw gracefully", () => {
@@ -610,7 +622,11 @@ describe("redactConfigSnapshot", () => {
610622
const result = redactConfigSnapshot(snapshot);
611623
expect(result.raw).toBeNull();
612624
expect(result.parsed).toBeNull();
625+
expect(result.sourceConfig).toEqual({});
613626
expect(result.resolved).toEqual({});
627+
expect(result.runtimeConfig).toEqual({});
628+
expect(result.sourceConfig).toBe(result.resolved);
629+
expect(result.runtimeConfig).toBe(result.config);
614630
});
615631

616632
it("handles deeply nested tokens in accounts", () => {

‎src/config/redact-snapshot.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,12 +423,16 @@ export function redactConfigSnapshot(
423423
// properly redacted all sensitive data. Handing out a partially or, worse,
424424
// unredacted config string would be bad.
425425
// Therefore, the only safe route is to reject handling out broken configs.
426+
const redactedConfig = {} as ConfigFileSnapshot["config"];
427+
const redactedResolved = {} as ConfigFileSnapshot["resolved"];
426428
return {
427429
...snapshot,
428-
config: {},
430+
sourceConfig: redactedResolved,
431+
runtimeConfig: redactedConfig,
432+
config: redactedConfig,
429433
raw: null,
430434
parsed: null,
431-
resolved: {},
435+
resolved: redactedResolved,
432436
};
433437
}
434438
// else: snapshot.config must be valid and populated, as that is what
@@ -455,6 +459,8 @@ export function redactConfigSnapshot(
455459

456460
return {
457461
...snapshot,
462+
sourceConfig: redactedResolved,
463+
runtimeConfig: redactedConfig,
458464
config: redactedConfig,
459465
raw: redactedRaw,
460466
parsed: redactedParsed,

0 commit comments

Comments
 (0)