fix(ida): separate explicit secrets from HTTP credentials

This commit is contained in:
morluto
2026-10-24 07:10:44 +08:00
parent 46a5f55f74
commit 455f816d0b
2 changed files with 20 additions and 1 deletions
+15
View File
@@ -62,6 +62,21 @@ describe("IDA diagnostic credential redaction", () => {
const message = "Failed at /caller/input \t with ordinary whitespace";
expect(redact(message)).toBe(message);
});
it.each(["X-Caller-Value", "Authorization"])(
"redacts explicitly marked whitespace in %s independently of HTTP authentication",
(name) => {
const redact = createIdaDiagnosticRedactor({
url: "http://127.0.0.1:12345/mcp",
headers: { [name]: "\t" },
sensitive: { headers: [name.toLowerCase()], env: [] },
mode: "attached",
timeoutMs: 1000,
}).text;
expect(redact("input\tvalue")).toBe(
"input[redacted transport credential]value",
);
},
);
it("does not reprocess the replacement marker as another credential", () => {
const redact = createIdaDiagnosticRedactor({
url: "http://127.0.0.1:12345/mcp",
+5 -1
View File
@@ -21,7 +21,11 @@ export const idaExplicitSensitiveValues = (
if (config === undefined) return [];
return "headers" in config
? Object.entries(config.headers)
.filter(([name]) => isSensitiveHeader(config, name))
.filter(([name]) =>
config.sensitive?.headers.some(
(selected) => selected.toLowerCase() === name.toLowerCase(),
),
)
.map(([, value]) => value)
: Object.entries(config.env)
.filter(([name]) => config.sensitive?.env.includes(name))