Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test(#7483): name the dummy header marker so gitleaks does not read it as a key; ignore the history-only fingerprint

garrytanda9d0c8552b1
diff --git a/.gitleaksignore b/.gitleaksignore
index 742f664b2f..3247dee3a7 100644
--- a/.gitleaksignore
+++ b/.gitleaksignore
@@ -49,3 +49,6 @@ a3140831d22a944947ef9cbd72ff7129a3541951:test/large-pages/credential-reseal-segm
# generic-api-key; the tree now builds them at runtime. These history-only fingerprints are not secrets.
fb1cee45c18357eb43d537715b2a8dc43fafc70f:test/google-api-access-cmd-7073.serial.test.ts:generic-api-key:37
fb1cee45c18357eb43d537715b2a8dc43fafc70f:test/google-api-access-cmd-7073.serial.test.ts:generic-api-key:55
+# #7483 (GBRA-190): the dummy header marker in test/connectors-header-redaction-7483.test.ts (commit e670a328) read as
+# generic-api-key; the tree now names it MARKER. This history-only fingerprint is not a secret.
+e670a32809a7038c9a63d9dfbf4480f8ab545db2:test/connectors-header-redaction-7483.test.ts:generic-api-key:25
diff --git a/test/connectors-header-redaction-7483.test.ts b/test/connectors-header-redaction-7483.test.ts
index 14d5ed5815..bb62a4dbd1 100644
--- a/test/connectors-header-redaction-7483.test.ts
+++ b/test/connectors-header-redaction-7483.test.ts
@@ -22,18 +22,18 @@ import { runConnectorSync } from '../src/core/connectors/sync.ts';
import { saveCredential } from '../src/core/connectors/credentials.ts';
import { authErrorAtKey } from '../src/core/connectors/config-keys.ts';
-const SECRET = 'DUMMY-SECRET-7483';
+const MARKER = 'dummy-marker-7483';
const MALFORMED: Record<string, string> = {
- lf: `sessionKey=${SECRET}\nX`,
- crlf: `sessionKey=${SECRET}\r\nX`,
- nul: `sessionKey=${SECRET}\u0000X`,
- non_ascii: `sessionKey=${SECRET}\u20acX`,
+ lf: `sessionKey=${MARKER}\nX`,
+ crlf: `sessionKey=${MARKER}\r\nX`,
+ nul: `sessionKey=${MARKER}\u0000X`,
+ non_ascii: `sessionKey=${MARKER}\u20acX`,
};
/** The undici shape: a header-validation TypeError whose message quotes the value. */
const echoingFetch = (calls: { n: number }): ConnectorFetch => async (_url, init) => {
calls.n++;
- const value = Object.values(init.headers as Record<string, string>).find(v => v.includes(SECRET)) ?? '';
+ const value = Object.values(init.headers as Record<string, string>).find(v => v.includes(MARKER)) ?? '';
throw new TypeError(`Headers.append: "${value}" is an invalid header value.`);
};
@@ -73,19 +73,19 @@ describe('#7483 malformed header values are refused before any request', () => {
});
const r = await provider.probe(client);
expect(r).toMatchObject({ ok: false, kind: 'invalid_credential' });
- expect(JSON.stringify(r)).not.toContain(SECRET);
+ expect(JSON.stringify(r)).not.toContain(MARKER);
expect(calls.n).toBe(0);
});
}
}
test('the real runtime fetch is never reached with the value (the client throws its own fixed error)', async () => {
- const client = new ConnectorClient({ baseUrl: 'http://127.0.0.1:9', headers: async () => ({ authorization: `Bearer ${SECRET}\nX` }), sleep: () => Promise.resolve() });
+ const client = new ConnectorClient({ baseUrl: 'http://127.0.0.1:9', headers: async () => ({ authorization: `Bearer ${MARKER}\nX` }), sleep: () => Promise.resolve() });
const e = await client.fetchJSON('/x').then(() => null, (err: unknown) => err);
expect(e).toBeInstanceOf(ConnectorCredentialFormatError);
expect((e as ConnectorCredentialFormatError).code).toBe('invalid_header_value');
expect((e as Error).message).toContain('authorization');
- expect((e as Error).message).not.toContain(SECRET);
+ expect((e as Error).message).not.toContain(MARKER);
});
test('sync with a stored malformed cookie: auth_required, auth_error_at stamped, hint and log free of the value', async () => {
@@ -99,8 +99,8 @@ describe('#7483 malformed header values are refused before any request', () => {
});
expect(r.status).toBe('auth_required');
expect(r.hint).toContain('cannot carry');
- expect(JSON.stringify(r)).not.toContain(SECRET);
- expect(logs.join('\n')).not.toContain(SECRET);
+ expect(JSON.stringify(r)).not.toContain(MARKER);
+ expect(logs.join('\n')).not.toContain(MARKER);
expect(calls.n).toBe(0);
expect(await engine.getConfig(authErrorAtKey('chatgpt'))).toBeTruthy();
});
@@ -112,20 +112,20 @@ describe('#7483 a fetch error that echoes a header value is never copied out', (
const calls = { n: 0 };
const client = new ConnectorClient({
baseUrl: CHATGPT_BASE_URL,
- headers: async () => ({ cookie: `sessionKey=${SECRET}` }),
+ headers: async () => ({ cookie: `sessionKey=${MARKER}` }),
fetchImpl: echoingFetch(calls),
sleep: () => Promise.resolve(),
});
const r = await chatgptProvider.probe(client);
expect(r).toMatchObject({ ok: false, kind: 'network' });
- expect(JSON.stringify(r)).not.toContain(SECRET);
+ expect(JSON.stringify(r)).not.toContain(MARKER);
expect(JSON.stringify(r)).toContain('TypeError');
expect(calls.n).toBe(1);
});
test('sync: the probe hint (printed by --json, stored by a background job) is free of the value', async () => {
await env(async () => {
- saveCredential({ provider: 'claude', strategy: 'browser-session', cookie: `sessionKey=${SECRET}`, savedAt: new Date(0).toISOString() });
+ saveCredential({ provider: 'claude', strategy: 'browser-session', cookie: `sessionKey=${MARKER}`, savedAt: new Date(0).toISOString() });
const logs: string[] = [];
const r = await runConnectorSync(engine, {
provider: 'claude',
@@ -133,8 +133,8 @@ describe('#7483 a fetch error that echoes a header value is never copied out', (
});
expect(r.status).toBe('partial');
expect(r.hint).toContain('probe failed');
- expect(JSON.stringify(r)).not.toContain(SECRET);
- expect(logs.join('\n')).not.toContain(SECRET);
+ expect(JSON.stringify(r)).not.toContain(MARKER);
+ expect(logs.join('\n')).not.toContain(MARKER);
});
});
});