Skip to content

Limit anonymous website scans and check for bots - #67

Merged
maaland merged 1 commit into
mainfrom
feat/website-gating-41
Oct 12, 2026
Merged

maaland merged 1 commit into
mainfrom
feat/website-gating-41

Conversation

@maaland

@maaland maaland commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Closes #41

Covers both "Done when" lines of #41: the limits and the bot check are tested (the bot check is behind a BotCheck interface, faked in tests), and reading reports is never limited.

What changes

  • requestScan allowance hook (core): allowance.check() runs just before a new scan is created and can refuse it; allowance.spend() runs once the scan exists. Returning a running or fresh scan touches neither.
  • lib/start-scan.ts: the website's scan logic, with the server action now a thin wrapper.
    1. Bot check first. A bot gets "We couldn't confirm this is a browser. Reload the page and try again." and nothing is created.
    2. Visitor allowance: 3 new scans a day per visitor (visitor:<hmac of IP>, using STACKPROBE_IP_HASH_SECRET from Let agents create and revoke their own API keys #64).
    3. At the limit: "You've started 3 new scans today, the daily limit without a key. Scans that already exist are still free to open. You can start more at midnight UTC, in N hours."
  • "Scan again" is now a small client component on the same action, so the limit message shows under the buttons instead of an error page. Form messages use --ink-2: a limit isn't a failure.
  • Vercel BotID (botid, MIT):
    • withBotId in next.config.ts; initBotId in instrumentation-client.ts protects POSTs, which is how scan forms submit.
    • checkBotId() runs in the action only on Vercel production (VERCEL_ENV=production). Previews skip it: they're behind Vercel's login already, and Drippa's review drives a headless browser there that BotID would refuse.
    • Self-hosted setups skip it too, since there's no BotID service.

Checked

  • Unit tests:
    • 3 new scans, then the message, with nothing started.
    • Existing scans are free at the limit.
    • Scan again on a finished scan counts; while the scan is still running it doesn't.
    • Visitors are counted separately.
    • Bots are refused before anything is created.
    • Bad input spends nothing.
    • The message wording.
  • Core: the allowance is checked and spent only for new scans; a refusal creates nothing.
  • Production build in a real browser (throwaway database):
    • Three new scans from home open their reports; the fourth stays on home with the message.
    • Scan again at the limit shows the message under the buttons.
    • Opening an existing report still works.
    • Screenshots at 1280 px and 390 px.
  • pnpm lint, pnpm typecheck, pnpm test (385 passing), pnpm build pass.

Notes

  • BotID's basic check is included on Vercel; nothing to turn on. It needs NEXT_PUBLIC_VERCEL_ENV, which Vercel exposes by default ("Automatically expose System Environment Variables").
  • The bot check itself only runs on production, which is still behind Vercel's login, so it gets exercised for real once we open the site.

🤖 Generated with Claude Code

Each website visitor can start 3 new scans a day (counted by a keyed
hash of their IP, through the allowance from #36). Opening a scan that
already exists, or a rescan of one still running, spends nothing. At
the limit the form says so calmly, with when more are possible; "Scan
again" now shows that message instead of failing the page.

On Vercel production, Vercel BotID checks that a scan comes from a
browser. Previews (behind Vercel's login, where Drippa's review drives
a headless browser) and self-hosted setups skip it.

requestScan gets an allowance hook: checked just before a new scan is
created, spent once it is.

Closes #41

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@drippa-ai

drippa-ai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Drippa Sign-Off: Limit anonymous website scans to 3 a day and add a bot check

✅ Delivers ticket #41 — 5 of 5 outcomes

Open in Drippa

What was promised

  • ✅ A visitor can start 3 new scans a day on the website; the 4th is refused and nothing is started.
  • ✅ Opening a scan that is still running or under a day old does not count against the allowance.
  • ✅ A friendly message explains the limit and says how many hours until it resets at midnight UTC.
  • ✅ Starting a scan is checked for bots on the live site and skipped when self-hosted; bots get a reload message and nothing is created.
  • ✅ Reading reports is never limited, and the limits and bot check are covered by automated tests.

Proof
All 6 checks passed on the preview

Steps based on ticket #41, the pull request description and the code change.

What Drippa tested (6 steps)

Page change — click through it on this pull request's preview.
Browser check: All 6 steps passed on the preview (0c6de4d)

Before you start

  • ✓ A visitor who has started no new scans today on the preview — use a fresh day or a network the preview has not seen today
  • ✓ Three domains that have never been scanned on the preview, and one more for the fourth try
  1. Passed · On the home page, enter a domain that has never been scanned and click Scan.
    → The report page for that domain opens and the scan starts.
    → Seen: After I scanned qa-probe-731942.com, the page opened at /s/qa-probe-731942.com and showed "Running" with the scan steps in progress.
    What it did: type into element 4 · wait · → /s/qa-probe-731942.com
  2. Passed · Go back to the home page and do the same for a second and then a third new domain.
    → Each one opens its own report page.
    → Seen: Scanning qa-probe-731943.com and qa-probe-731944.com from the home page each opened its own report page at /s/ .
    What it did: click "stackprobe" · → / · type into element 4 · wait · → /s/qa-probe-731943.com · go to / · type into element 4 · wait · → /s/qa-probe-731944.com
  3. Passed · Go back to the home page and enter a fourth new domain, then click Scan.
    → You stay on the home page. A message says you've started 3 new scans today, that existing scans are still free to open, and how many hours until midnight UTC.
    → Seen: Scanning a fourth new domain kept the page on the home page, which showed the limit message ending "in 5 hours."
    What it did: go to / · type into element 4 · wait
  4. Passed · On the home page, enter the first domain you scanned again and click Scan.
    → Its existing report opens and no limit message appears.
    → Seen: Rescanning qa-probe-731942.com from the home page opened its existing report at /s/qa-probe-731942.com with no limit message.
    What it did: type into element 4 · → /s/qa-probe-731942.com
  5. Passed · On a finished report from the earlier scans, click Scan again.
    → The limit message appears under the buttons on the report page instead of an error page, and the report stays visible.
    → Seen: Clicking Scan again on the finished report showed the daily-limit message under the buttons, with the report still visible and no error page.
    What it did: click "Scan again" · wait
  6. Passed · Open one of the earlier report pages directly by its address.
    → The report loads normally even though the limit has been reached.
    → Seen: Opening /s/qa-probe-731943.com directly after the daily limit was reached loaded the full report with no error or limit block.
    What it did: go to /s/qa-probe-731943.com
Details

Starting a new scan on the website now counts against a daily allowance of 3 per visitor. The visitor is identified by a keyed hash of their IP, never the IP itself. Opening an existing or recent scan is free, and so is reading a report. On the live site, a bot check runs before anything else; previews and self-hosted setups skip it. When the limit is reached, a message says when scans reset, and on a report it appears under the "Scan again" button instead of an error page.

Test coverage: ✅ Well covered — Tests cover the 3-scan limit, free reopening of existing scans, "Scan again" counting, separate visitors, bot refusal, bad input and the message wording.

🔍 Checked: ticket #41 with 3 asks and 2 done-when lines; 9 of 12 changed files read; reused allowance and freshness rules checked elsewhere in the code

🎫 Compared against drippa-ai/stackprobe#41


Updated by Drippa • 2026-10-12 19:31 UTC

Comment @drippa-ai review for a fresh review.

@maaland
maaland merged commit f9b94d1 into main Oct 12, 2026
5 checks passed
@maaland
maaland deleted the feat/website-gating-41 branch October 12, 2026 19:28
@vercel

vercel Bot commented Oct 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
stackprobe Ready Ready Preview Oct 12, 2026 7:45pm UTC

Request Review

This branch was successfully deployed

1 active deployment
Preview — 0c6de4d2 Deployed Oct 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Website gating: anonymous allowance and bot check

1 participant