Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/lib/analyzer/checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,9 @@ export function checkPage(extract: PageExtract, deadline?: number): Finding[] {
// A mark with real text under it — a recoverable leak.
const check = leakCheckId(cover.kind, extract.hasLargeImage)
const recovered = recoverUnder(overlapping, cover.bbox)
// A REDACTED-only label is not recovered document content.
if (recovered.toLowerCase() === 'redacted') continue
// A label or repeated-X placeholder is not recovered document content.
const placeholder = recovered.replace(/^\[\s*(.*?)\s*\]$/, '$1')
if (/^(?:redacted|x(?:\s*x)+)$/i.test(placeholder)) continue
const {title, detail} = describeLeak(check, cover.kind)
findings.push({
id: `${check}-${extract.page}-${idx++}`,
Expand Down
39 changes: 26 additions & 13 deletions tests/checks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,32 @@ function pageWithCoveredText(texts: string[]): PageExtract {
}
}

describe('recovered redaction labels', () => {
it('ignores a label regardless of case and surrounding whitespace', () => {
expect(checkPage(pageWithCoveredText([' ReDaCtEd ']))).toEqual([])
describe('recovered redaction placeholders', () => {
it.each([
' ReDaCtEd ',
'[REDACTED]',
'[ redacted ]',
'XX',
'xxx',
' XxX ',
'X X X',
'[XXX]',
'[ x x x ]',
])('ignores the placeholder %j', (text) => {
expect(checkPage(pageWithCoveredText([text]))).toEqual([])
})

it('keeps a nearby leak whose text includes the word redacted', () => {
const findings = checkPage(
pageWithCoveredText(['REDACTED', 'redacted budget'])
)
expect(findings).toHaveLength(1)
expect(findings[0]).toMatchObject({
severity: 'leak',
recovered: {text: 'redacted budget'},
})
})
it.each(['redacted budget', 'XXX budget', 'Project X', 'XX-123', 'X'])(
'keeps substantive or ambiguous text %j beside placeholders',
(text) => {
const findings = checkPage(
pageWithCoveredText(['REDACTED', '[XXX]', text])
)
expect(findings).toHaveLength(1)
expect(findings[0]).toMatchObject({
severity: 'leak',
recovered: {text},
})
}
)
})
Loading