Fix: scarcity/countdown synonym evasion (#203)#213
Merged
Conversation
Addresses audit item #21. Adds precise synonym coverage so a malicious page can't bypass scarcity- and countdown-redaction with common verbiage swaps. Each addition is anchored on a number, a fixed retail idiom, or a definite expiry verb to keep false-positive risk flat. scarcity-redact: - "Just N left/remaining/in stock/available" (synonym of "only N") - "N items/units/pieces left/remaining" - "While supplies last" / "while stocks last" - "Selling/going quickly" - "Flying off the shelves" / "going off shelves" - "N added to cart/basket/bag/wishlist" countdown-timer-redact: - URGENCY_UNIT_PATTERN: "to claim" / "to save" alongside "left/remaining/to go/until" - New EXPIRY_LEAD_PATTERN: "ends/expires/closes in N <unit>" Candidate-only; decrement gate still required, so a static "Expires in 30 days" badge is never replaced. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses red-team audit item #21 from #203 — "Scarcity / countdown synonym evasion." Each addition is anchored on a number, a fixed retail idiom, or a definite expiry verb, so the false-positive surface stays flat while closing common verbiage-swap bypasses.
Changes
scarcity-redact— synonym additions across all three pattern groups:SCARCITY_PATTERNS:"just N left/remaining/in stock/available"— direct synonym ofonly N"N items/units/pieces left/remaining""while supplies last"/"while stocks last"— fixed retail idiomDEMAND_PATTERNS:"selling/going quickly"— adverbial swap onselling fast"flying off the shelves"/"going off shelves"— retail-only idiom; the 80-char leaf-candidate gate keeps prose mentions out of reachACTIVITY_PATTERNS:"N added to cart/basket/bag/wishlist"(with optionalpeople/shoppers/othersinfix) — covers the verb swap fromviewingtoaddedthat benchmark scrapes turn up on Target/Amazoncountdown-timer-redact— extends the candidate surface; the existing decrement gate inreconcileCandidatesstill has the final word:URGENCY_UNIT_PATTERN: addto claim/to saveto the suffix vocabulary alongsideleft/remaining/to go/untilEXPIRY_LEAD_PATTERN:(ends|expires|closes) in N <unit>— coversSale ends in 3h,Offer expires in 45 minutes,Closes in 2d. A staticExpires in 30 daysbadge is never replaced because the snapshot-and-confirm logic still requires the parsed value to decrease over the 1.5s window — there's an explicit test for that.Why these and not more
Stayed XS per the audit complexity tag. Each phrase had to either:
Skipped tempting-but-too-broad candidates like bare
running out,last chance,hot item,trending— all FP-prone in non-retail contexts and our gates aren't tight enough to make them safe on their own.Docs
No doc changes. The rule-list entries are abstract about phrasings (
"Only 3 left","Selling fast","Sale ends in 12:34:56"); broadening the regex vocabulary doesn't alter the documented contract.Test plan
node_modules/.bin/jest src/rules/__tests__/scarcity-redact.test.ts src/rules/__tests__/countdown-timer-redact.test.ts— 106/106 pass (added 14 scarcity positives, 3 scarcity negatives, 2 countdown synonym suite cases, 2 countdown integration cases including the static-badge decrement-gate guard)node_modules/.bin/jest— full extension suite (1747 tests) passesbun run check— biome + eslint cleanbun run typecheck— cleanbun run knip— clean🤖 Generated with Claude Code