mirror of
https://github.com/openclaw/clawhub.git
synced 2026-07-21 19:25:25 -04:00
2deb1b75e9
* fix: redact scan worker artifact errors * fix: harden worker secret logging * fix: keep worker claim failures failing * fix: scan diagnostics as files * fix: pin diagnostics scanner image * fix: narrow worker redaction boundary * fix: avoid custom worker secret patterns * fix: centralize worker transport redaction * fix: redact persisted worker failure secrets * fix: fail security worker on claim outages * fix: redact structured diagnostic secret fields * fix: harden worker failure redaction boundaries * fix: cover bracketed worker secret values * test: enforce worker workflow secret references * fix: redact quoted worker secret values * fix: redact diagnostic artifact path labels * test: cover claim failure redaction * fix: simplify worker redaction boundary * test: prove worker logger emits structured events
60 lines
1.2 KiB
TypeScript
60 lines
1.2 KiB
TypeScript
import pino, { type DestinationStream, type Logger } from "pino";
|
|
|
|
export const WORKER_LOG_REDACTION_PATHS = [
|
|
"token",
|
|
"secret",
|
|
"password",
|
|
"apiKey",
|
|
"api_key",
|
|
"authorization",
|
|
"Authorization",
|
|
"headers.authorization",
|
|
"headers.Authorization",
|
|
"request.headers.authorization",
|
|
"request.headers.Authorization",
|
|
"artifact.url",
|
|
"artifact.downloadUrl",
|
|
"artifact.clawpackUrl",
|
|
"artifact.signedUrl",
|
|
"artifacts[*].url",
|
|
"target.files[*].url",
|
|
"target.clawpackUrl",
|
|
"url",
|
|
"downloadUrl",
|
|
"clawpackUrl",
|
|
"signedUrl",
|
|
"error",
|
|
"reason",
|
|
"err.message",
|
|
"err.stack",
|
|
"stderr",
|
|
"stdout",
|
|
"rawResult",
|
|
] as const;
|
|
|
|
function stdoutDestination(): DestinationStream {
|
|
return {
|
|
write(line: string) {
|
|
process.stdout.write(line);
|
|
},
|
|
};
|
|
}
|
|
|
|
export function createWorkerLogger(options?: {
|
|
destination?: DestinationStream;
|
|
level?: string;
|
|
name: string;
|
|
}): Logger {
|
|
return pino(
|
|
{
|
|
base: { service: options?.name },
|
|
level: options?.level ?? process.env.WORKER_LOG_LEVEL ?? "info",
|
|
redact: {
|
|
censor: "[redacted-secret]",
|
|
paths: [...WORKER_LOG_REDACTION_PATHS],
|
|
},
|
|
},
|
|
options?.destination ?? stdoutDestination(),
|
|
);
|
|
}
|