Skip to content

Commit fdff45b

Browse files
author
Hephaestus
committed
test(monitor): build PAT fixture dynamically to dodge GitGuardian false positive
GitGuardian flagged 3 literal ghp_[A-Za-z0-9]{36} patterns in monitor-payload-redaction-4802.test.ts (incident 34179555), blocking PR #4803's merge despite all other 16 CI checks passing (lint, test, helm-smoke, dashboard-e2e, platform-smoke, CodeQL, Gitleaks, Trivy, sdk-drift, etc.). Apply the established #3617 convention: define fixture constants via string concatenation at module scope so the literal PAT pattern never appears in source. The 8 contract tests still pass (8/8 green) and the assertions still verify redaction (now via not.toContain('ghp_') matching the redactor's replacement marker semantics). Refs: #4802, PR #4803
1 parent 08c6c2b commit fdff45b

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/__tests__/monitor-payload-redaction-4802.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ import type { SessionManager, SessionInfo } from '../session.js';
2020
import type { ChannelManager } from '../channels/index.js';
2121
import { SYSTEM_TENANT } from '../config.js';
2222

23+
// Build credential-shaped fixtures via concatenation to avoid triggering
24+
// GitGuardian / credo false positives (same convention as #3617).
25+
const GHP_FAKE = 'ghp_' + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghij';
26+
2327
function makeSession(): SessionInfo {
2428
return {
2529
id: 'sess-redact-1',
@@ -53,9 +57,9 @@ describe('Issue #4802 (F-6): makePayload server-side redaction', () => {
5357
const session = makeSession();
5458

5559
it('redacts GitHub PAT in detail string', () => {
56-
const detail = 'Working on auth, token was ghp_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 in env';
60+
const detail = 'Working on auth, token was ' + GHP_FAKE + ' in env';
5761
const payload = monitor.makePayload('status.error', session, detail);
58-
expect(payload.detail).not.toContain('ghp_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789');
62+
expect(payload.detail).not.toContain('ghp_');
5963
expect(payload.detail).toContain('[REDACTED:github-pat]');
6064
});
6165

@@ -84,10 +88,9 @@ describe('Issue #4802 (F-6): makePayload server-side redaction', () => {
8488
// 3000-char detail with secret at position 1950 (after the 2000-char slice).
8589
// If redaction runs AFTER slice, the secret survives. Must run BEFORE slice.
8690
const padding = 'a'.repeat(1900);
87-
const secret = 'ghp_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
88-
const detail = `${padding} token=${secret} ${'b'.repeat(1000)}`;
91+
const detail = `${padding} token=${GHP_FAKE} ${'b'.repeat(1000)}`;
8992
const payload = monitor.makePayload('status.error', session, detail);
90-
expect(payload.detail).not.toContain(secret);
93+
expect(payload.detail).not.toContain('ghp_');
9194
});
9295

9396
it('still enforces the 2000-char length cap as defense-in-depth', () => {

0 commit comments

Comments
 (0)