mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-16 00:40:43 +00:00
* refactor: extract filesystem safety primitives * refactor: use fs-safe for file access helpers * refactor: reuse fs-safe for media reads * refactor: use fs-safe for image reads * refactor: reuse fs-safe in qqbot media opener * refactor: reuse fs-safe for local media checks * refactor: consume cleaner fs-safe api * refactor: align fs-safe json option names * fix: preserve fs-safe migration contracts * refactor: use fs-safe primitive subpaths * refactor: use grouped fs-safe subpaths * refactor: align fs-safe api usage * refactor: adapt private state store api * chore: refresh proof gate * refactor: follow fs-safe json api split * refactor: follow reduced fs-safe surface * build: default fs-safe python helper off * fix: preserve fs-safe plugin sdk aliases * refactor: consolidate fs-safe usage * refactor: unify fs-safe store usage * refactor: trim fs-safe temp workspace usage * refactor: hide low-level fs-safe primitives * build: use published fs-safe package * fix: preserve outbound recovery durability after rebase * chore: refresh pr checks
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import fs from "node:fs/promises";
|
|
import path from "node:path";
|
|
import { resolveStateDir } from "../config/paths.js";
|
|
import { appendRegularFile } from "../infra/fs-safe.js";
|
|
|
|
type CrestodianAuditEntry = {
|
|
timestamp: string;
|
|
operation: string;
|
|
summary: string;
|
|
configPath?: string;
|
|
configHashBefore?: string | null;
|
|
configHashAfter?: string | null;
|
|
details?: Record<string, unknown>;
|
|
};
|
|
|
|
export function resolveCrestodianAuditPath(
|
|
env: NodeJS.ProcessEnv = process.env,
|
|
stateDir = resolveStateDir(env),
|
|
): string {
|
|
return path.join(stateDir, "audit", "crestodian.jsonl");
|
|
}
|
|
|
|
export async function appendCrestodianAuditEntry(
|
|
entry: Omit<CrestodianAuditEntry, "timestamp">,
|
|
opts: { env?: NodeJS.ProcessEnv; auditPath?: string } = {},
|
|
): Promise<string> {
|
|
const auditPath = opts.auditPath ?? resolveCrestodianAuditPath(opts.env);
|
|
await fs.mkdir(path.dirname(auditPath), { recursive: true });
|
|
const line = JSON.stringify({
|
|
timestamp: new Date().toISOString(),
|
|
...entry,
|
|
} satisfies CrestodianAuditEntry);
|
|
await appendRegularFile({
|
|
filePath: auditPath,
|
|
content: `${line}\n`,
|
|
rejectSymlinkParents: true,
|
|
});
|
|
return auditPath;
|
|
}
|