Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

feat(cli): allow opting out of log redaction (#1176)

mldangelo-oai4096958d026f
diff --git a/sdk/typescript/README.md b/sdk/typescript/README.md
index bcd2d33e7..de7f5abda 100644
--- a/sdk/typescript/README.md
+++ b/sdk/typescript/README.md
@@ -934,7 +934,8 @@ restrictions.
| `CODEX_SECURITY_LINEAR_TEAM`, `CODEX_SECURITY_LINEAR_PROJECT` | Default team and project for completed-scan publication. |
| `CODEX_SECURITY_LINEAR_API_KEY` | Personal API key for Linear patching and direct publication. |
| `CODEX_SECURITY_LOG_LEVEL` | CLI-only; `debug` enables verbose diagnostics. |
-| `LOG_LEVEL` | CLI-only fallback when `CODEX_SECURITY_LOG_LEVEL` is unset. |
+| `CODEX_SECURITY_REDACT_LOGS` | CLI-only; `0` disables diagnostic redaction. Unset or any other value keeps it enabled. |
+| `LOG_LEVEL` | CLI-only fallback when `CODEX_SECURITY_LOG_LEVEL` is unset or blank. |
| `CODEX_SECURITY_STATE_DIR` | Private scan-history, workbench, and default artifact directory. |
| `CODEX_SECURITY_PROJECT_CONFIG` | Trusted project file for `scan`, `bulk-scan`, `scan-components`, and `info`; `-c` wins. Unset by default. |
| `CODEX_HOME` | Ambient Codex home for file-based sign-in and default state; defaults to `~/.codex`. |
@@ -955,6 +956,69 @@ Python lookup order: `--python` (on `scan`, `bulk-scan`, or `export`) or SDK
on `PATH` (`py` also works on Windows). `CODEX_SECURITY_STATE_DIR` overrides
`CODEX_HOME` for state storage. Keep state and results outside the repository.
+### Troubleshooting redacted output
+
+Verbosity and redaction are independent controls. By default, scans show progress,
+state transitions, warnings, and summaries. Add `--verbose` or set
+`CODEX_SECURITY_LOG_LEVEL=debug` to include lifecycle, configuration, retry,
+and worker diagnostics on stderr. `LOG_LEVEL=debug` is the fallback when
+`CODEX_SECURITY_LOG_LEVEL` is unset or blank. Verbosity does not disable redaction.
+
+Only the exact value `CODEX_SECURITY_REDACT_LOGS=0` disables CLI diagnostic
+redaction. An unset variable or any other value retains the default redaction
+behavior. Disabling redaction does not enable verbose diagnostics.
+
+| Verbose diagnostics | CLI redaction | Behavior |
+| ------------------- | ------------- | ---------------------------------------------------- |
+| Off (default) | On (default) | Normal progress and summaries with redaction. |
+| On | On | Additional diagnostics on stderr with redaction. |
+| Off | Off | Normal output detail with diagnostic redaction off. |
+| On | Off | Additional diagnostics on stderr with redaction off. |
+
+Scan errors and warnings use the same checks in plain stderr, verbose message
+fields, and JSON errors. Progress/dashboard redaction also honors the setting.
+The checks detect recognizable credentials and sensitive field assignments.
+A match replaces the whole message or value
+with `[redacted]`. For example, `token=example` triggers redaction even if the
+value is synthetic. Diagnostic event names, error classifications, counters,
+and fixed metadata remain available when a message is redacted. Dedicated path
+fields keep their paths, and observer warnings keep the observer's name while
+redacting the error detail.
+
+For local troubleshooting with verbose diagnostics and redaction disabled:
+
+```bash
+CODEX_SECURITY_REDACT_LOGS=0 npx @openai/codex-security scan . --verbose
+```
+
+In PowerShell, set it in the current shell and remove it afterward:
+
+```powershell
+$env:CODEX_SECURITY_REDACT_LOGS = "0"
+npx @openai/codex-security scan . --verbose
+Remove-Item Env:CODEX_SECURITY_REDACT_LOGS
+```
+
+Deep Scan discovery and reducer worker displays, including resumed workers,
+follow the current CLI invocation's diagnostic settings. These settings are not
+saved in scan recipes; select them again when running `scans resume` or
+`scans rerun` if needed.
+
+Neither control enables additional raw session capture or uploads logs. Raw
+session log capture and the original model output and results remain unchanged;
+paths are not generally redacted. Output can still contain source code,
+credentials, and other sensitive information, especially with redaction disabled.
+Keep it private and review it before sharing or uploading it.
+
+The redaction setting does not change credential configuration, SDK error
+sanitization, stored failure summaries, or publication receipts. It cannot recover
+content already replaced with `[redacted]`, including errors sanitized before
+reaching the CLI, and does not control native Codex or OpenTelemetry log and
+trace redaction. Deep Scan workers use native Codex; this setting applies when
+the parent CLI displays their diagnostics. Patch-risk report diagnostics honor
+the opt-out, but the summary used in a published pull request keeps its credential
+redaction.
+
### Progress and cost
Interactive scans show full-screen progress; CI, redirected output, and
diff --git a/sdk/typescript/src/cli.ts b/sdk/typescript/src/cli.ts
index e8fa98ff5..0b3ba4b79 100644
--- a/sdk/typescript/src/cli.ts
+++ b/sdk/typescript/src/cli.ts
@@ -139,6 +139,7 @@ import {
PluginPythonUnavailableError,
errorMessage,
safeErrorMessage,
+ logErrorMessage,
ScanCostLimitExceededError,
ScanInterruptedError,
} from "./errors.js";
@@ -647,7 +648,8 @@ class PublicationProgressPresenter {
presentation: "publication",
clock: this.#dependencies,
color: this.#dependencies.environment["NO_COLOR"] === undefined,
- sanitize: safeErrorMessage,
+ sanitize: (value) =>
+ logErrorMessage(value, this.#dependencies.environment),
});
dashboard.setStage("Connecting to Linear");
try {
@@ -767,7 +769,9 @@ class PublicationProgressPresenter {
}
#write(message: string, compact = false): void {
- const sanitized = diagnosticValue(safeErrorMessage(message));
+ const sanitized = diagnosticValue(
+ logErrorMessage(message, this.#dependencies.environment),
+ );
if (!compact) {
this.#stream.write(`${sanitized}\n`);
return;
@@ -818,7 +822,8 @@ class FindingProgressPresenter {
presentation: "verification",
clock: this.#dependencies,
color: this.#dependencies.environment["NO_COLOR"] === undefined,
- sanitize: safeErrorMessage,
+ sanitize: (value) =>
+ logErrorMessage(value, this.#dependencies.environment),
});
dashboard.setPublicationProgress(0, this.#total);
dashboard.setStage(`Verifying findings · 0/${this.#total}`);
@@ -841,7 +846,7 @@ class FindingProgressPresenter {
public startPatch(finding: Finding, index: number): void {
try {
this.#progress.startTimer(
- `Patching ${index + 1}/${this.#total} · ${safePatchText(finding.title)}`,
+ `Patching ${index + 1}/${this.#total} · ${safePatchText(finding.title, this.#dependencies.environment)}`,
);
} catch {
this.stop();
@@ -948,7 +953,9 @@ class FindingProgressPresenter {
#write(message: string): void {
try {
this.#progress.writeAboveTimer(() => {
- this.#stream.write(`${safePatchText(message)}\n`);
+ this.#stream.write(
+ `${safePatchText(message, this.#dependencies.environment)}\n`,
+ );
});
} catch {}
}
@@ -2244,7 +2251,9 @@ export async function main(
verbose: z
.boolean()
.default(false)
- .describe("Print scan diagnostics to stderr."),
+ .describe(
+ "Print additional scan diagnostics to stderr without disabling redaction. Set CODEX_SECURITY_REDACT_LOGS=0 to opt out (may expose credentials).",
+ ),
}),
output: z.record(z.string(), z.unknown()).optional(),
async run({ args, error: incurError, options }) {
@@ -2332,7 +2341,9 @@ export async function main(
verbose: z
.boolean()
.default(false)
- .describe("Print scan diagnostics to stderr."),
+ .describe(
+ "Print additional scan diagnostics to stderr without disabling redaction. Set CODEX_SECURITY_REDACT_LOGS=0 to opt out (may expose credentials).",
+ ),
}),
output: z.record(z.string(), z.unknown()).optional(),
async run({ args, error: incurError, format, options }) {
@@ -2533,7 +2544,9 @@ export async function main(
? "Publication canceled by Ctrl-C."
: "Publication terminated by SIGTERM.";
const recovery =
- error === signal ? "" : ` ${diagnosticValue(safeErrorMessage(error))}`;
+ error === signal
+ ? ""
+ : ` ${diagnosticValue(logErrorMessage(error, dependencies.environment))}`;
errorOutput.write(`codex-security: ${reason}${recovery}\n`);
exitCode = signal === "SIGINT" ? 130 : 143;
} else {
@@ -2657,7 +2670,7 @@ export async function main(
const recovery =
error === undefined || error === signal
? ""
- : ` ${diagnosticValue(safeErrorMessage(error))}`;
+ : ` ${diagnosticValue(logErrorMessage(error, dependencies.environment))}`;
errorOutput.write(`codex-security: ${reason}${recovery}\n`);
exitCode = signal === "SIGINT" ? 130 : 143;
return true;
@@ -3022,7 +3035,10 @@ export async function main(
});
cloudBatch.results.push({ scanDir: directory, ...result });
} catch (error) {
- const message = safeErrorMessage(error);
+ const message = logErrorMessage(
+ error,
+ dependencies.environment,
+ );
cloudBatch.failed.push({
scanDir: directory,
...(scanId === undefined ? {} : { scanId }),
@@ -3031,7 +3047,7 @@ export async function main(
if (controller.signal.aborted) throw error;
exitCode = 2;
errorOutput.write(
- `codex-security: ${diagnosticValue(safeErrorMessage(scanId ?? directory))}: ${diagnosticValue(message)}\n`,
+ `codex-security: ${diagnosticValue(logErrorMessage(scanId ?? directory, dependencies.environment))}: ${diagnosticValue(message)}\n`,
);
}
}
@@ -3112,7 +3128,7 @@ export async function main(
for (const warning of result.warnings) {
if (typeof warning !== "string") continue;
errorOutput.write(
- `codex-security: ${diagnosticValue(safeErrorMessage(warning))}\n`,
+ `codex-security: ${diagnosticValue(logErrorMessage(warning, dependencies.environment))}\n`,
);
}
}
@@ -3133,7 +3149,7 @@ export async function main(
} catch (error) {
if (!finishCancellation(error)) {
errorOutput.write(
- `codex-security: ${options.to === "cloud" ? safeErrorMessage(error) : errorMessage(error)}\n`,
+ `codex-security: ${options.to === "cloud" ? logErrorMessage(error, dependencies.environment) : errorMessage(error)}\n`,
);
exitCode = 2;
}
@@ -3263,7 +3279,7 @@ export async function main(
});
const cli = Cli.create("codex-security", {
description:
- "Draft security policies; run, import, validate, patch, verify fixes, export, and publish Codex Security findings.",
+ "Draft security policies; run, import, validate, patch, verify fixes, export, and publish Codex Security findings. Set CODEX_SECURITY_REDACT_LOGS=0 to disable CLI diagnostic redaction (may expose credentials).",
version: VERSION,
mcp: {
command: "npx --yes @openai/codex-security --mcp",
@@ -3457,7 +3473,7 @@ export async function main(
? policyDisplayData(outcome.data)
: outcome.data;
} catch (error) {
- const message = safeErrorMessage(error);
+ const message = logErrorMessage(error, dependencies.environment);
try {
errorOutput.write(`codex-security: ${message}\n`);
} catch {}
@@ -3495,7 +3511,9 @@ export async function main(
verbose: z
.boolean()
.default(false)
- .describe("Print scan diagnostics to stderr."),
+ .describe(
+ "Print additional scan diagnostics to stderr without disabling redaction. Set CODEX_SECURITY_REDACT_LOGS=0 to opt out (may expose credentials).",
+ ),
safetyIdentifier: optionValue("--safety-identifier")
.optional()
.describe(
@@ -3736,7 +3754,10 @@ export async function main(
exitCode = outcome.exitCode;
if (outcome.error !== undefined) {
if (format === "json" || format === "jsonl") {
- const message = safeErrorMessage(outcome.error);
+ const message = logErrorMessage(
+ outcome.error,
+ dependencies.environment,
+ );
if (!argv.includes("--full-output"))
return { status: "failed", code: "SCAN_FAILED", message };
// Incur would wrap returned data in an ok: true envelope.
@@ -3901,7 +3922,7 @@ export async function main(
} catch (error) {
const signal = controller.signal.reason;
errorOutput.write(
- `codex-security: ${signal === "SIGINT" || signal === "SIGTERM" ? "Owner suggestions canceled." : safeErrorMessage(error)}\n`,
+ `codex-security: ${signal === "SIGINT" || signal === "SIGTERM" ? "Owner suggestions canceled." : logErrorMessage(error, dependencies.environment)}\n`,
);
exitCode = signal === "SIGINT" ? 130 : signal === "SIGTERM" ? 143 : 2;
return undefined;
@@ -4005,7 +4026,7 @@ export async function main(
} catch (error) {
const signal = controller.signal.reason;
errorOutput.write(
- `codex-security: ${signal === "SIGINT" || signal === "SIGTERM" ? "Severity classification canceled." : safeErrorMessage(error)}\n`,
+ `codex-security: ${signal === "SIGINT" || signal === "SIGTERM" ? "Severity classification canceled." : logErrorMessage(error, dependencies.environment)}\n`,
);
exitCode = signal === "SIGINT" ? 130 : signal === "SIGTERM" ? 143 : 2;
return undefined;
@@ -4134,7 +4155,7 @@ export async function main(
`codex-security: ${
signal === "SIGINT" || signal === "SIGTERM"
? "Deduplication canceled. Findings are unchanged."
- : safeErrorMessage(error)
+ : logErrorMessage(error, dependencies.environment)
}\n`,
);
exitCode = signal === "SIGINT" ? 130 : signal === "SIGTERM" ? 143 : 2;
@@ -4328,7 +4349,8 @@ export async function main(
showCost: options.showCost,
clock: dependencies,
color: dependencies.environment["NO_COLOR"] === undefined,
- sanitize: safeErrorMessage,
+ sanitize: (value) =>
+ logErrorMessage(value, dependencies.environment),
input: process.stdin,
onInterrupt,
});
@@ -5079,13 +5101,15 @@ export async function main(
}
for (const result of results) {
output.write(
- `${result.status.toUpperCase()} ${safePatchText(result.id)}: ${safePatchText(result.evidence)}\n`,
+ `${result.status.toUpperCase()} ${safePatchText(result.id, dependencies.environment)}: ${safePatchText(result.evidence, dependencies.environment)}\n`,
);
}
return undefined;
} catch (error) {
exitCode = 2;
- errorOutput.write(`codex-security: ${safeErrorMessage(error)}\n`);
+ errorOutput.write(
+ `codex-security: ${logErrorMessage(error, dependencies.environment)}\n`,
+ );
return undefined;
}
},
@@ -5445,7 +5469,7 @@ export async function main(
};
} catch (error) {
if (exitCode === 0) exitCode = 2;
- const message = safeErrorMessage(error);
+ const message = logErrorMessage(error, dependencies.environment);
errorOutput.write(`codex-security: ${message}\n`);
if (!structuredOutput) return;
patchStructuredError = true;
@@ -5982,7 +6006,7 @@ async function runScanImport(
const message =
signal === "SIGINT" || signal === "SIGTERM"
? "Scan import canceled."
- : safeErrorMessage(error);
+ : logErrorMessage(error, dependencies.environment);
errorOutput.write(`codex-security: ${message}\n`);
return {
exitCode: signal === "SIGINT" ? 130 : signal === "SIGTERM" ? 143 : 2,
@@ -6835,12 +6859,12 @@ async function publishPatchBranch(
);
}
stderr.write(
- `${gitlab ? "Merge" : "Pull"} request: ${safePatchText(url)}\n`,
+ `${gitlab ? "Merge" : "Pull"} request: ${safePatchText(url, dependencies.environment)}\n`,
);
return { branch, url };
} catch (error) {
stderr.write(
- `Patch commit saved. Retry from this repository with: codex-security patch --resume-pr ${safePatchText(branch)}\n`,
+ `Patch commit saved. Retry from this repository with: codex-security patch --resume-pr ${safePatchText(branch, dependencies.environment)}\n`,
);
throw error;
}
@@ -7043,15 +7067,24 @@ async function snapshotPatchDirectory(
return files;
}
-function safePatchText(value: string): string {
- return stripVTControlCharacters(safeErrorMessage(value)).replaceAll(
- /[\u0000-\u001F\u007F-\u009F\u2028\u2029]/gu,
- " ",
- );
+function safePatchText(
+ value: string,
+ environment: NodeJS.ProcessEnv = {},
+): string {
+ return stripVTControlCharacters(
+ logErrorMessage(value, environment),
+ ).replaceAll(/[\u0000-\u001F\u007F-\u009F\u2028\u2029]/gu, " ");
}
-function safePatchReport(value: string): string {
- return value.split(/\r?\n/gu).map(safePatchText).join("\n").trim();
+function safePatchReport(
+ value: string,
+ environment: NodeJS.ProcessEnv = {},
+): string {
+ return value
+ .split(/\r?\n/gu)
+ .map((line) => safePatchText(line, environment))
+ .join("\n")
+ .trim();
}
function parsePatchRiskReport(report: string): PatchRiskAssessment {
@@ -7098,7 +7131,7 @@ async function runPatchRiskAssessment(
}
const assessment = parsePatchRiskReport(result.report);
stderr.write(
- `Patch risk assessment:\n${safePatchReport(assessment.report)}\n`,
+ `Patch risk assessment:\n${safePatchReport(assessment.report, dependencies.environment)}\n`,
);
return assessment;
}
@@ -7360,9 +7393,9 @@ async function runFindingPatches(
}
}
- const title = safePatchText(finding.title);
+ const title = safePatchText(finding.title, dependencies.environment);
stderr.write(
- ` ${patch.status.toUpperCase()} ${title}${patch.reason === undefined ? "" : `: ${safePatchText(patch.reason)}`}\n`,
+ ` ${patch.status.toUpperCase()} ${title}${patch.reason === undefined ? "" : `: ${safePatchText(patch.reason, dependencies.environment)}`}\n`,
);
patches.push(patch);
}
@@ -8213,6 +8246,8 @@ async function executeScan(
const verbose =
arguments_.verbose === true ||
configuredLogLevel?.toLowerCase() === "debug";
+ const diagnosticMessage = (value: unknown): string =>
+ diagnosticValue(logErrorMessage(value, dependencies.environment));
const writeAboveProgress = (write: () => void): void => {
if (progress === null) {
write();
@@ -8225,13 +8260,17 @@ async function executeScan(
fields: Readonly<Record<string, VerboseDiagnosticValue>> = {},
): void => {
if (!verbose) return;
- const attributes = Object.entries(fields).flatMap(([name, value]) =>
- value === undefined
- ? []
- : [
- `${name}=${JSON.stringify(typeof value === "string" ? diagnosticValue(value) : value)}`,
- ],
- );
+ const attributes = Object.entries(fields).flatMap(([name, value]) => {
+ if (value === undefined) return [];
+ // Redact free-form messages, preserving structured metadata and paths.
+ const displayed =
+ typeof value !== "string"
+ ? value
+ : name === "message"
+ ? diagnosticMessage(value)
+ : diagnosticValue(value);
+ return [`${name}=${JSON.stringify(displayed)}`];
+ });
writeAboveProgress(() => {
errorOutput.write(
`codex-security: debug: ${event}${attributes.length === 0 ? "" : ` ${attributes.join(" ")}`}\n`,
@@ -8405,7 +8444,7 @@ async function executeScan(
: { maxCostUsd: arguments_.maxCostUsd }),
clock: dependencies,
color: dependencies.environment["NO_COLOR"] === undefined,
- sanitize: safeErrorMessage,
+ sanitize: (value) => logErrorMessage(value, dependencies.environment),
input: scanInput,
onInterrupt,
});
@@ -8682,7 +8721,9 @@ async function executeScan(
}
writeAboveProgress(() => {
diagnostic("scan.warning", { message });
- errorOutput.write(`codex-security: warning: ${message}\n`);
+ errorOutput.write(
+ `codex-security: warning: ${diagnosticMessage(warning)}\n`,
+ );
});
},
onObserverError: (observer, error) => {
@@ -8690,7 +8731,7 @@ async function executeScan(
observer,
classification: classifyConnectionFailure(error),
});
- const warning = `${observer} observer failed: ${diagnosticValue(error)}`;
+ const warning = `${observer} observer failed: ${diagnosticMessage(error)}`;
if (dashboard === null) {
writeAboveProgress(() => {
errorOutput.write(`codex-security: warning: ${warning}\n`);
@@ -8749,7 +8790,11 @@ async function executeScan(
const message =
failure instanceof OutputInsideProtectedRootError
? errorMessage(protectedRootErrorMessage(failure))
- : scanFailureMessage(failure, selectedAuthentication);
+ : scanFailureMessage(
+ failure,
+ selectedAuthentication,
+ dependencies.environment,
+ );
diagnostic("scan.failed", {
classification:
costLimitFailure !== undefined
@@ -8972,7 +9017,9 @@ async function executeScan(
}
}
} catch (error) {
- errorOutput.write(`codex-security: ${safeErrorMessage(error)}\n`);
+ errorOutput.write(
+ `codex-security: ${logErrorMessage(error, dependencies.environment)}\n`,
+ );
scanData = { ...scanData, patches };
return completedScan(2);
}
@@ -9082,8 +9129,10 @@ function authenticationFailureMessage(
function scanFailureMessage(
error: unknown,
authentication: ScanAuthentication | null,
+ environment: NodeJS.ProcessEnv,
): string {
- // A local failure keeps its own message. Classification matches bare words
+ // A local failure keeps its own diagnostic, subject to log redaction.
+ // Classification matches bare words
// such as "permission denied" anywhere in the text, so an EACCES from a
// read-only TMPDIR would otherwise be reported as a credential problem.
//
@@ -9091,7 +9140,8 @@ function scanFailureMessage(
// appending it. That is deliberate: upstream authentication and authorization
// errors can name the organization or project, which must not reach stderr or
// the JSON error field.
- if (isLocalScanFailure(error)) return diagnosticValue(error);
+ if (isLocalScanFailure(error))
+ return diagnosticValue(logErrorMessage(error, environment));
const message = errorMessage(error);
const nativeRefreshRecovery = message.match(
/\b(?:your access token could not be refreshed because you have since logged out or signed in to another account\. Please sign in again\.|your authentication session could not be refreshed automatically\. Please log out and sign in again\.)/iu,
@@ -9132,7 +9182,7 @@ function scanFailureMessage(
case "network_error":
case "timeout":
case "unknown":
- return diagnosticValue(error);
+ return diagnosticValue(logErrorMessage(error, environment));
}
}
diff --git a/sdk/typescript/src/errors.ts b/sdk/typescript/src/errors.ts
index 0c160db3a..f8dbfec4b 100644
--- a/sdk/typescript/src/errors.ts
+++ b/sdk/typescript/src/errors.ts
@@ -23,6 +23,16 @@ export function safeErrorMessage(error: unknown): string {
return recognizableCredential || sensitiveField ? "[redacted]" : message;
}
+/** Format CLI diagnostics; persistence continues to use safeErrorMessage. */
+export function logErrorMessage(
+ error: unknown,
+ environment: NodeJS.ProcessEnv,
+): string {
+ return environment["CODEX_SECURITY_REDACT_LOGS"] === "0"
+ ? errorMessage(error)
+ : safeErrorMessage(error);
+}
+
/** Base error for Codex Security SDK failures. */
export class CodexSecurityError extends Error {
public constructor(message: string, options?: ErrorOptions) {
diff --git a/sdk/typescript/src/security-policy-cli.ts b/sdk/typescript/src/security-policy-cli.ts
index 19a740267..543cb61e3 100644
--- a/sdk/typescript/src/security-policy-cli.ts
+++ b/sdk/typescript/src/security-policy-cli.ts
@@ -2,7 +2,7 @@ import type { CodexSecurity, ScanAuthMode } from "./api.js";
import type { BulkScanPrompt } from "./bulk-scan-discovery.js";
import type { CodexSecurityConfig } from "./config.js";
import { formatScanCost } from "./cost-model.js";
-import { safeErrorMessage } from "./errors.js";
+import { logErrorMessage } from "./errors.js";
import {
formatSecurityPolicyText as display,
type SecurityPolicyOptions,
@@ -132,7 +132,9 @@ export async function runPolicyCommand(
},
onStage: (stage) => write(STAGES[stage]),
onWarning: (warning) =>
- write(`codex-security: ${display(safeErrorMessage(warning))}`),
+ write(
+ `codex-security: ${display(logErrorMessage(warning, dependencies.environment))}`,
+ ),
...(interactive
? {
answerQuestions: async (
@@ -171,7 +173,7 @@ export async function runPolicyCommand(
controller.signal.throwIfAborted();
diff = "Preview unavailable. Review the saved draft.";
write(
- `codex-security: Could not preview the policy: ${display(safeErrorMessage(error))}`,
+ `codex-security: Could not preview the policy: ${display(logErrorMessage(error, dependencies.environment))}`,
);
}
const preview = [
@@ -230,7 +232,7 @@ export async function runPolicyCommand(
? "Policy generation canceled by Ctrl-C."
: signal === "SIGTERM"
? "Policy generation terminated by SIGTERM."
- : display(safeErrorMessage(error));
+ : display(logErrorMessage(error, dependencies.environment));
write(`codex-security: ${message}`);
if (outputDir !== undefined)
write(`Saved artifacts: ${display(outputDir)}`);
@@ -244,7 +246,7 @@ export async function runPolicyCommand(
await security?.close();
} catch (error) {
write(
- `codex-security: Could not clean up the policy runtime: ${display(safeErrorMessage(error))}`,
+ `codex-security: Could not clean up the policy runtime: ${display(logErrorMessage(error, dependencies.environment))}`,
);
}
}
diff --git a/sdk/typescript/tests-ts/cli-patch.test.ts b/sdk/typescript/tests-ts/cli-patch.test.ts
index 0ea6b9ce0..1c5e52bc3 100644
--- a/sdk/typescript/tests-ts/cli-patch.test.ts
+++ b/sdk/typescript/tests-ts/cli-patch.test.ts
@@ -729,6 +729,81 @@ describe("scan and patch workflow", () => {
}
});
+ test.each([undefined, "0", "1"])(
+ "applies redaction setting %p to patch-risk display while protecting publication summaries",
+ async (value) => {
+ const result = resultWithFindings(["high"]);
+ const detail = "Diagnostic detail: token=SYNTHETIC_RISK_VALUE";
+ const report = patchRiskAssessment().report.replace(
+ patchRiskSummary(),
+ `${patchRiskSummary()}\n\n${detail}`,
+ );
+ const repositoryCommands: Array<{
+ command: string;
+ args: readonly string[];
+ }> = [];
+ const outcome = await runWorkflow(
+ [
+ "patch",
+ "--scan",
+ "scan-1",
+ "--assess-patch-risk",
+ "--create-pr",
+ "--json",
+ ],
+ {
+ environment: { CODEX_SECURITY_REDACT_LOGS: value },
+ onWorkbench: () => savedScan(result),
+ onRepositoryCommand: (command, args) => {
+ repositoryCommands.push({ command, args });
+ if (command === "git") {
+ if (args[0] === "remote") {
+ return "https://github.example.test/example/repository.git";
+ }
+ return args.includes("--name-only") ? "src/finding-1.ts\0" : "";
+ }
+ return args[1] === "create"
+ ? "https://github.example.test/example/repository/pull/15"
+ : "";
+ },
+ },
+ {
+ configure: (current) => {
+ Object.assign(current, {
+ assessPatchRisk: async () => ({ report }),
+ });
+ },
+ },
+ );
+
+ expect(outcome.exitCode, outcome.stderr).toBe(0);
+ expect(outcome.stderr).toContain("Patch risk assessment:");
+ expect(outcome.stderr).toContain(patchRiskSummary());
+ expect(outcome.stderr).toContain(value === "0" ? detail : "[redacted]");
+ expect(outcome.stderr.includes("SYNTHETIC_RISK_VALUE")).toBe(
+ value === "0",
+ );
+ // The report is result data; only its CLI display follows the log setting.
+ expect(JSON.parse(outcome.stdout).patchRisk.report).toContain(detail);
+ const published = repositoryCommands.find(
+ ({ command, args }) => command === "gh" && args[1] === "create",
+ )?.args;
+ const persisted = repositoryCommands.find(
+ ({ command, args }) =>
+ command === "git" &&
+ args[0] === "config" &&
+ args[2]?.endsWith(".codexSecurityPatchPullRequestBody"),
+ )?.args;
+ expect(published).toBeDefined();
+ expect(persisted).toBeDefined();
+ for (const body of [published?.at(-1), persisted?.at(-1)]) {
+ expect(body).toContain(patchRiskSummary());
+ expect(body).toContain("[redacted]");
+ expect(body).not.toContain("SYNTHETIC_RISK_VALUE");
+ }
+ },
+ );
+
test("assesses only changes made during a literal patch run", async () => {
const directory = await mkdtemp(
join(tmpdir(), "codex-security-patch-risk-"),
diff --git a/sdk/typescript/tests-ts/cli-redaction.test.ts b/sdk/typescript/tests-ts/cli-redaction.test.ts
new file mode 100644
index 000000000..ec22aeb1d
--- /dev/null
+++ b/sdk/typescript/tests-ts/cli-redaction.test.ts
@@ -0,0 +1,402 @@
+import { stripVTControlCharacters } from "node:util";
+import { describe, expect, test } from "bun:test";
+import { main } from "../src/cli.js";
+import { CodexSecurityError, OutputDirectoryError } from "../src/errors.js";
+import {
+ capture,
+ dependencies,
+ fakePreflight,
+ fakeResult,
+} from "./cli-fixtures.js";
+
+describe("CLI log redaction", () => {
+ test("documents the opt-out in scan help and its generated schema", async () => {
+ const help = capture();
+ expect(
+ await main(
+ ["scan", "--help"],
+ help.stream,
+ capture().stream,
+ dependencies(),
+ ),
+ ).toBe(0);
+ expect(help.text()).toContain("CODEX_SECURITY_REDACT_LOGS=0");
+
+ const schema = capture();
+ expect(
+ await main(
+ ["scan", "--schema", "--format", "json"],
+ schema.stream,
+ capture().stream,
+ dependencies(),
+ ),
+ ).toBe(0);
+ expect(JSON.parse(schema.text())).toMatchObject({
+ options: {
+ properties: {
+ verbose: {
+ description: expect.stringContaining(
+ "CODEX_SECURITY_REDACT_LOGS=0",
+ ),
+ },
+ },
+ },
+ });
+ });
+
+ test.each([
+ [false, false],
+ [false, true],
+ [true, false],
+ [true, true],
+ ])(
+ "isolates concurrent scan error settings with full output %p and verbose %p",
+ async (fullOutput, verbose) => {
+ const message = "request failed: token=SYNTHETIC_LOG_VALUE";
+ const selections = [undefined, "0", "1"];
+ let started = 0;
+ let release!: () => void;
+ const allStarted = new Promise<void>((resolve) => {
+ release = resolve;
+ });
+
+ await Promise.all(
+ selections.map(async (value) => {
+ const stdout = capture();
+ const stderr = capture();
+ const deps = dependencies({
+ environment: { CODEX_SECURITY_REDACT_LOGS: value },
+ });
+ deps.createSecurity = () => ({
+ run: async () => {
+ started += 1;
+ if (started === selections.length) release();
+ await allStarted;
+ throw new CodexSecurityError(message);
+ },
+ preflight: async () => fakePreflight(),
+ close: async () => {},
+ });
+
+ expect(
+ await main(
+ [
+ "scan",
+ ".",
+ "--json",
+ ...(fullOutput ? ["--full-output"] : []),
+ ...(verbose ? ["--verbose"] : []),
+ ],
+ stdout.stream,
+ stderr.stream,
+ deps,
+ ),
+ ).toBe(2);
+ const output = JSON.parse(stdout.text());
+ const expected = {
+ code: "SCAN_FAILED",
+ message: value === "0" ? message : "[redacted]",
+ };
+ if (fullOutput) {
+ expect(output.ok).toBe(false);
+ expect(output.error).toEqual(expected);
+ expect(output).not.toHaveProperty("data");
+ } else {
+ expect(output).toEqual({ status: "failed", ...expected });
+ }
+ expect(stderr.text()).toContain(expected.message);
+ expect(stderr.text().includes(message)).toBe(value === "0");
+ expect(stderr.text().includes("codex-security: debug:")).toBe(
+ verbose,
+ );
+ }),
+ );
+ },
+ );
+
+ test.each([
+ { name: "dashboard", args: [], environment: {}, tty: true, verbose: false },
+ { name: "plain", args: [], environment: {}, tty: false, verbose: false },
+ {
+ name: "headless",
+ args: ["--headless"],
+ environment: {},
+ tty: true,
+ verbose: false,
+ },
+ {
+ name: "verbose flag",
+ args: ["--verbose"],
+ environment: {},
+ tty: true,
+ verbose: true,
+ },
+ {
+ name: "debug environment",
+ args: [],
+ environment: { CODEX_SECURITY_LOG_LEVEL: " DeBuG " },
+ tty: true,
+ verbose: true,
+ },
+ {
+ name: "shared debug fallback",
+ args: [],
+ environment: { CODEX_SECURITY_LOG_LEVEL: " ", LOG_LEVEL: " DEBUG " },
+ tty: false,
+ verbose: true,
+ },
+ {
+ name: "dedicated level precedence",
+ args: [],
+ environment: { CODEX_SECURITY_LOG_LEVEL: "info", LOG_LEVEL: "debug" },
+ tty: false,
+ verbose: false,
+ },
+ {
+ name: "verbose flag precedence",
+ args: ["--verbose"],
+ environment: { CODEX_SECURITY_LOG_LEVEL: "error", LOG_LEVEL: "warn" },
+ tty: false,
+ verbose: true,
+ },
+ ])("keeps verbosity and redaction independent for $name", async (mode) => {
+ for (const value of [undefined, "0", "1"]) {
+ const warning = "recoverable warning: token=SYNTHETIC_WARNING_VALUE";
+ const observer = "observer failure: token=SYNTHETIC_OBSERVER_VALUE";
+ const stdout = capture();
+ const stderr = capture(mode.tty);
+ const result = fakeResult([], "complete", {
+ input_tokens: 200,
+ cached_input_tokens: 20,
+ output_tokens: 10,
+ });
+ const deps = dependencies({
+ environment: {
+ ...mode.environment,
+ NO_COLOR: "1",
+ CODEX_SECURITY_REDACT_LOGS: value,
+ },
+ });
+ deps.createSecurity = () => ({
+ run: async (_repository, options) => {
+ options?.onAuthentication?.({
+ method: "api_key",
+ source: "OPENAI_API_KEY",
+ verified: false,
+ });
+ options?.onScanStarted?.();
+ options?.onCost?.(result.cost!);
+ options?.onWarning?.(warning);
+ options?.onObserverError?.("onWorkerStatus", new Error(observer));
+ return result;
+ },
+ preflight: async () => fakePreflight(),
+ close: async () => {},
+ });
+
+ expect(
+ await main(
+ ["scan", ".", ...mode.args],
+ stdout.stream,
+ stderr.stream,
+ deps,
+ ),
+ ).toBe(0);
+ const output = stripVTControlCharacters(stderr.text()).replace(
+ /\s+/gu,
+ " ",
+ );
+ const expectedWarning = value === "0" ? warning : "[redacted]";
+ const expectedObserver = value === "0" ? observer : "[redacted]";
+ expect(output).toContain(`codex-security: warning: ${expectedWarning}`);
+ expect(output).toContain(
+ `onWorkerStatus observer failed: ${expectedObserver}`,
+ );
+ expect(output.includes("SYNTHETIC_WARNING_VALUE")).toBe(value === "0");
+ expect(output.includes("SYNTHETIC_OBSERVER_VALUE")).toBe(value === "0");
+ expect(output.includes("codex-security: debug:")).toBe(mode.verbose);
+ if (mode.verbose) {
+ expect(output).toContain(
+ `codex-security: debug: scan.warning message=${JSON.stringify(expectedWarning)}`,
+ );
+ expect(output).toContain(
+ 'authentication.selected requested="auto" method="api_key" source="OPENAI_API_KEY" verified=false',
+ );
+ expect(output).toContain("input_tokens=200 cached_input_tokens=20");
+ expect(output).toContain(
+ 'scan.observer_failed observer="onWorkerStatus" classification="unknown"',
+ );
+ }
+ }
+ });
+
+ test.each([undefined, "0", "1"])(
+ "preserves target-warning result data with redaction setting %p",
+ async (value) => {
+ const warning = "Source changed: token=SYNTHETIC_TARGET_VALUE";
+ const stdout = capture();
+ const stderr = capture();
+ const deps = dependencies({
+ environment: { CODEX_SECURITY_REDACT_LOGS: value },
+ });
+ deps.createSecurity = () => ({
+ run: async (_repository, options) => {
+ options?.onWarning?.(warning, { kind: "target_changed" });
+ return fakeResult();
+ },
+ preflight: async () => fakePreflight(),
+ close: async () => {},
+ });
+ expect(
+ await main(
+ ["scan", ".", "--json", "--verbose"],
+ stdout.stream,
+ stderr.stream,
+ deps,
+ ),
+ ).toBe(2);
+ expect(JSON.parse(stdout.text()).warnings).toEqual([warning]);
+ expect(stderr.text()).toContain(
+ `codex-security: warning: ${value === "0" ? warning : "[redacted]"}`,
+ );
+ expect(stderr.text().includes("SYNTHETIC_TARGET_VALUE")).toBe(
+ value === "0",
+ );
+ },
+ );
+
+ test.each([
+ {
+ name: "local",
+ failure: new OutputDirectoryError(
+ "Could not write results: token=SYNTHETIC_LOCAL_VALUE",
+ ),
+ },
+ {
+ name: "network",
+ failure: new CodexSecurityError(
+ "network failure ECONNRESET token=SYNTHETIC_NETWORK_VALUE",
+ ),
+ },
+ {
+ name: "timeout",
+ failure: new CodexSecurityError(
+ "request timed out token=SYNTHETIC_TIMEOUT_VALUE",
+ ),
+ },
+ ])("applies redaction to $name scan failures", async ({ failure }) => {
+ for (const value of [undefined, "0", "1"]) {
+ const stdout = capture();
+ const stderr = capture();
+ const deps = dependencies({
+ environment: { CODEX_SECURITY_REDACT_LOGS: value },
+ });
+ deps.createSecurity = () => ({
+ run: async () => {
+ throw failure;
+ },
+ preflight: async () => fakePreflight(),
+ close: async () => {},
+ });
+ expect(
+ await main(
+ ["scan", ".", "--json", "--verbose"],
+ stdout.stream,
+ stderr.stream,
+ deps,
+ ),
+ ).toBe(2);
+ const message = value === "0" ? failure.message : "[redacted]";
+ expect(JSON.parse(stdout.text()).message).toBe(message);
+ expect(stderr.text()).toContain(message);
+ expect(stderr.text().includes(failure.message)).toBe(value === "0");
+ }
+ });
+
+ test.each([
+ "401 invalid API key for synthetic-organization token=SYNTHETIC_AUTH_VALUE",
+ "403 forbidden for synthetic-organization token=SYNTHETIC_AUTH_VALUE",
+ ])(
+ "keeps authentication advice independent of redaction for %s",
+ async (message) => {
+ const outputs = [];
+ for (const value of [undefined, "0"]) {
+ const stdout = capture();
+ const stderr = capture();
+ const deps = dependencies({
+ environment: { CODEX_SECURITY_REDACT_LOGS: value },
+ });
+ deps.createSecurity = () => ({
+ run: async () => {
+ throw new CodexSecurityError(message);
+ },
+ preflight: async () => fakePreflight(),
+ close: async () => {},
+ });
+ expect(
+ await main(
+ ["scan", ".", "--json", "--verbose"],
+ stdout.stream,
+ stderr.stream,
+ deps,
+ ),
+ ).toBe(2);
+ expect(stderr.text()).not.toContain("SYNTHETIC_AUTH_VALUE");
+ expect(stderr.text()).not.toContain("synthetic-organization");
+ outputs.push({ stdout: stdout.text(), stderr: stderr.text() });
+ }
+ expect(outputs[0]).toEqual(outputs[1]);
+ },
+ );
+
+ test.each([undefined, "0"])(
+ "applies environment value %p to live activity and observer messages",
+ async (value) => {
+ const activity = "command result: token=SYNTHETIC_ACTIVITY_VALUE";
+ const observer = "observer result: token=SYNTHETIC_OBSERVER_VALUE";
+ const stdout = capture();
+ const stderr = capture(true);
+ const deps = dependencies({
+ environment: {
+ NO_COLOR: "1",
+ CODEX_SECURITY_REDACT_LOGS: value,
+ },
+ });
+ deps.createSecurity = () => ({
+ run: async (_repository, options) => {
+ options?.onScanStarted?.();
+ options?.onActivity?.({
+ id: "synthetic-command",
+ kind: "command",
+ status: "completed",
+ description: activity,
+ paths: [],
+ });
+ options?.onObserverError?.("onWorkerStatus", new Error(observer));
+ return fakeResult();
+ },
+ preflight: async () => fakePreflight(),
+ close: async () => {},
+ });
+
+ expect(
+ await main(["scan", "."], stdout.stream, stderr.stream, deps),
+ ).toBe(0);
+ const output = stripVTControlCharacters(stderr.text()).replace(
+ /\s+/gu,
+ " ",
+ );
+ if (value === "0") {
+ expect(output).toContain(activity);
+ expect(output).toContain(observer);
+ expect(output).not.toContain("[redacted]");
+ } else {
+ expect(output).toContain("[redacted]");
+ expect(output).not.toContain("SYNTHETIC_ACTIVITY_VALUE");
+ expect(output).not.toContain("SYNTHETIC_OBSERVER_VALUE");
+ }
+ expect(stderr.text()).toContain("\u001B[?1049h");
+ expect(stderr.text()).toContain("\u001B[?1049l");
+ },
+ );
+});
diff --git a/sdk/typescript/tests-ts/cli.test.ts b/sdk/typescript/tests-ts/cli.test.ts
index 239ef7109..8d9138477 100644
--- a/sdk/typescript/tests-ts/cli.test.ts
+++ b/sdk/typescript/tests-ts/cli.test.ts
@@ -3864,7 +3864,7 @@ describe("CLI", () => {
}
});
- test("preserves verbose output paths and observer diagnostics", async () => {
+ test("preserves verbose output paths while redacting observer errors", async () => {
const stdout = capture();
const stderr = capture();
const deps = dependencies();
@@ -3904,7 +3904,10 @@ describe("CLI", () => {
expect(stderr.text()).toContain(
'codex-security: debug: scan.observer_failed observer="onWorkerStatus"',
);
- expect(stderr.text()).toContain("SYNTHETIC");
+ expect(stderr.text()).toContain(
+ "onWorkerStatus observer failed: [redacted]",
+ );
+ expect(stderr.text()).not.toContain("SYNTHETIC_OPENAI_VALUE_123");
});
test("excludes observer failure context from verbose diagnostics", async () => {
@@ -4191,7 +4194,8 @@ describe("CLI", () => {
message: "[redacted]",
});
expect(stdout.text()).not.toContain("SYNTHETIC_KEY_123");
- expect(stderr.text()).toContain("SYNTHETIC_KEY_123");
+ expect(stderr.text()).toContain("[redacted]");
+ expect(stderr.text()).not.toContain("SYNTHETIC_KEY_123");
});
test("surfaces underlying scanner errors instead of inventing a model outage", async () => {
@@ -4327,7 +4331,7 @@ describe("CLI", () => {
}
});
- test("preserves underlying network errors", async () => {
+ test("redacts credentials in underlying network errors", async () => {
const stdout = capture();
const stderr = capture();
const deps = dependencies();
@@ -4349,10 +4353,8 @@ describe("CLI", () => {
code: "SCAN_FAILED",
message: "[redacted]",
});
- expect(stderr.text()).toContain(
- `network failure ECONNRESET ${SYNTHETIC_CREDENTIALS}`,
- );
- expect(stderr.text()).toContain("SYNTHETIC_KEY_123");
+ expect(stderr.text()).toContain("[redacted]");
+ expect(stderr.text()).not.toContain("SYNTHETIC_KEY_123");
expect(stderr.text()).not.toContain("model service could not be reached");
});
@@ -4376,11 +4378,10 @@ describe("CLI", () => {
});
expect(await main(["scan"], stdout.stream, stderr.stream, deps)).toBe(2);
- expect(stderr.text()).toContain("Could not save the Codex Security scan");
- expect(stderr.text()).toContain("unable to open database file");
+ expect(stderr.text()).toContain("[redacted]");
expect(stderr.text()).not.toContain("model service could not be reached");
expect(stderr.text()).not.toContain("Check your network connection");
- expect(stderr.text()).toContain("SYNTHETIC_DATABASE_SECRET");
+ expect(stderr.text()).not.toContain("SYNTHETIC_DATABASE_SECRET");
});
test("prints only the completion summary for default scans", async () => {
@@ -4564,7 +4565,7 @@ describe("CLI", () => {
}
});
- test("preserves scan warnings in verbose diagnostics", async () => {
+ test("redacts scan warnings in verbose diagnostics", async () => {
const stdout = capture();
const stderr = capture();
const deps = dependencies();
@@ -4589,12 +4590,10 @@ describe("CLI", () => {
).toBe(0);
expect(JSON.parse(stdout.text())).toEqual(fakeResult().toJSON());
expect(stderr.text()).toContain(
- 'codex-security: debug: scan.warning message="Repository HEAD changed during the scan: sk-proj-SYNTHETIC_WARNING_SECRET_123"',
- );
- expect(stderr.text()).toContain(
- "codex-security: warning: Repository HEAD changed during the scan: sk-proj-SYNTHETIC_WARNING_SECRET_123",
+ 'codex-security: debug: scan.warning message="[redacted]"',
);
- expect(stderr.text()).toContain("SYNTHETIC_WARNING_SECRET");
+ expect(stderr.text()).toContain("codex-security: warning: [redacted]");
+ expect(stderr.text()).not.toContain("SYNTHETIC_WARNING_SECRET");
});
test("prints granted trusted cyber access without warning or corrupting JSON scans", async () => {
@@ -4719,9 +4718,9 @@ describe("CLI", () => {
).toBe(0);
expect(JSON.parse(stdout.text())).toEqual(fakeResult().toJSON());
expect(stderr.text()).toContain(
- `codex-security: warning: onWorkerStatus observer failed: status observer failed ${SYNTHETIC_CREDENTIALS}`,
+ "codex-security: warning: onWorkerStatus observer failed: [redacted]",
);
- expect(stderr.text()).toContain("SYNTHETIC_OPENAI_VALUE_123");
+ expect(stderr.text()).not.toContain("SYNTHETIC_OPENAI_VALUE_123");
});
test("maps failed scan stdout writes to the runtime-error exit code", async () => {
@@ -5608,7 +5607,7 @@ describe("CLI", () => {
expect(stderr.text()).toContain(`Protected root: ${protectedRoot}`);
});
- test("preserves caught scan and interruption failures", async () => {
+ test("redacts credentials in caught scan and interruption failures", async () => {
for (const failure of [
new CodexSecurityError(`scan failed ${SYNTHETIC_CREDENTIALS}`),
new ScanInterruptedError(
@@ -5631,9 +5630,7 @@ describe("CLI", () => {
await main(["scan", "."], stdout.stream, stderr.stream, failing),
).toBe(2);
expect(stdout.text()).toBe("");
- expect(stderr.text()).toBe(
- "[00:00] Preparing scan\n" + `scan failed ${SYNTHETIC_CREDENTIALS}\n`,
- );
+ expect(stderr.text()).toBe("[00:00] Preparing scan\n[redacted]\n");
}
});
diff --git a/sdk/typescript/tests-ts/errors.test.ts b/sdk/typescript/tests-ts/errors.test.ts
index 23db1958c..a18f9cbdc 100644
--- a/sdk/typescript/tests-ts/errors.test.ts
+++ b/sdk/typescript/tests-ts/errors.test.ts
@@ -5,6 +5,7 @@ import {
ScanCostLimitExceededError,
ScanInterruptedError,
errorMessage,
+ logErrorMessage,
safeErrorMessage,
} from "../src/errors.js";
@@ -71,6 +72,29 @@ describe("error messages", () => {
expect(errorMessage(null)).toBe("null");
});
+ test.each([undefined, "1", "", "false", "unexpected"])(
+ "keeps log redaction enabled with environment value %p",
+ (value) => {
+ const environment = { CODEX_SECURITY_REDACT_LOGS: value };
+ expect(
+ logErrorMessage(new Error("token=SYNTHETIC_TOKEN"), environment),
+ ).toBe("[redacted]");
+ expect(logErrorMessage("service unavailable", environment)).toBe(
+ "service unavailable",
+ );
+ },
+ );
+
+ test("opts out of log redaction without changing persistence redaction", () => {
+ const message = "request failed: token=SYNTHETIC_TOKEN";
+ const error = new Error(message);
+ const environment = { CODEX_SECURITY_REDACT_LOGS: "0" };
+ expect(logErrorMessage(error, environment)).toBe(message);
+ expect(logErrorMessage(message, environment)).toBe(message);
+ expect(logErrorMessage(null, environment)).toBe("null");
+ expect(safeErrorMessage(error)).toBe("[redacted]");
+ });
+
test("omits credential-bearing messages at output boundaries", () => {
for (const message of [
"request failed: token=SYNTHETIC_TOKEN",