openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 2.29 kB
JavaScript
import{g as scrubConfigAuditLog,m as resolveLegacyConfigAuditLogPath}from"./io.audit-DXCsuLiP.mjs";import{t as note}from"./note-e4DtVgg2.mjs";import os from"node:os";
//!src/commands/doctor-config-audit-scrub.ts
const NOTE_TITLE=`Config audit`;const CONFIG_AUDIT_SCRUB_CHECK_ID=`core/doctor/config-audit-scrub`;function formatEntryCount(e){return`${e} ${e===1?`entry`:`entries`}`}async function detectConfigAuditScrubIssue(e){const t=e?.env??process.env;const n=e?.homedir??os.homedir;return{...await scrubConfigAuditLog({env:t,homedir:n,dryRun:true}),auditPath:resolveLegacyConfigAuditLogPath(t,n)}}function configAuditScrubToHealthFinding(e){return{checkId:CONFIG_AUDIT_SCRUB_CHECK_ID,severity:`warning`,category:`fix-now`,docsUrl:`https://docs.openclaw.ai/gateway/audit`,message:`${formatEntryCount(e.rewritten)} in config-audit.jsonl still contain pre-redactor argv values.`,path:e.auditPath,fixHint:"Run `openclaw doctor --fix` to rewrite argv/execArgv fields through the current redactor."}}function configAuditScrubToRepairEffect(e){return{kind:`file`,action:`would-scrub-config-audit-log`,target:e.auditPath}}async function maybeScrubConfigAuditLog(e){const t=e.env??process.env;try{const n=await scrubConfigAuditLog({env:t,homedir:os.homedir,...!e.shouldRepair?{dryRun:true}:{}});if(e.shouldRepair&&n.aborted){note("Config audit scrub was aborted because new entries were appended to config-audit.jsonl during the rewrite. No records were modified. Stop the gateway (or wait until it is idle) and rerun `openclaw doctor --fix`.",NOTE_TITLE);return}if(n.rewritten>0){const t=formatEntryCount(n.rewritten);note(e.shouldRepair?`Scrubbed ${t} in config-audit.jsonl that still contained pre-redactor argv values. Rotate any credentials that may have been written to the log before the forward redactor shipped.`:`${t} in config-audit.jsonl still contain pre-redactor argv values (likely plaintext credentials at rest). Run \`openclaw doctor --fix\` to rewrite the argv/execArgv fields through the same redactor used for new entries.`,NOTE_TITLE)}}catch(e){note(`Config audit scrub failed: ${e instanceof Error?e.message:String(e)}`,NOTE_TITLE)}}export{maybeScrubConfigAuditLog as i,configAuditScrubToRepairEffect as n,detectConfigAuditScrubIssue as r,configAuditScrubToHealthFinding as t};