Skip to content

Fix scope-deleting polls, migration lockout, and cancellation gaps - #51

Merged
cozyGarage merged 5 commits into
mainfrom
fix/local-ci-green
Oct 2, 2026
Merged

cozyGarage merged 5 commits into
mainfrom
fix/local-ci-green

Conversation

@cozyGarage

Copy link
Copy Markdown
Owner

Summary

Bug hunt fixes, each with a regression test (most verified to fail on the old code against Postgres 16).

Data loss

  • poll --db with --category/--bbp-only/--private-only stored a filtered subset as full scope and deleted the rest → now merge-only, program sync skipped.
  • Any poll --db without --ai deleted all stored AI variants → stored variants are reattached on every poll.
  • Export/import flipped a target's base in_scope when it had an AI variant override → new base_in_scope field (JSON + CSV); old backups import as before.

Availability

  • Migrations ignored unique violations inside the transaction; Postgres aborted it, so storage.Open failed on every start for legacy duplicates → savepoint.
  • One platform's auth failure aborted bbscope poll → remaining platforms are polled, exit code stays non-zero.
  • A custom program owning a platform URL failed that platform's sync forever → per-program warning.
  • YesWeHack listing could end early (and let sync disable programs) when a later page lacked pagination.

Cancellation / retries

  • whttp requests now take a context; passed by all pollers, Bugcrowd's rate limiter, and Bugcrowd/YesWeHack login.
  • Immunefi: fail fast on 4xx, cancelable backoff, outer retries 20 → 3 (whttp already retries 10×; was up to ~220 requests per URL).

Other

  • NormalizeTarget is now idempotent (example.com./, //host:443, port-only authorities); fuzz test asserts it.
  • Tests mock the OS keyring so they no longer hang on a desktop Secret Service prompt.
  • Removed unused bugcrowd.NewPollerWithLogin; Bugcrowd fetch functions take ctx.

Test plan

  • go build ./... && go vet ./..., golangci-lint run (0 issues)
  • go test -race ./... with TEST_DB_URL against Postgres 16
  • FuzzNormalizeTarget 3 min clean
  • bbscope poll dev --db end to end (repeat poll: no changes; --category keeps scope)

🤖 Generated with Claude Code

cozyGarage and others added 5 commits October 3, 2026 00:45
On a desktop, credentials tests reached the real keyring and hung on the
unlock prompt (10 min timeout) or read stored credentials.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- --category/--bbp-only/--private-only with --db merged a filtered subset
  as full scope, deleting filtered-out targets; now merge-only, no sync.
- Plain --db polls deleted every stored AI variant; stored variants are
  now reattached on every poll.
- One platform's auth failure aborted 'bbscope poll'; the platforms that
  authenticated are polled and the exit code stays non-zero.
- A program URL owned by a custom entry failed the platform and blocked
  its sync on every run; it is now a per-program warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- whttp requests take a context, passed by every poller including
  Bugcrowd's rate limiter and Bugcrowd/YesWeHack login (TOTP wait too).
- Immunefi fails fast on 4xx, backs off on 5xx, sleeps cancelably, and
  caps outer retries at 3 (whttp already retries each call 10 times).
- YesWeHack reads nb_pages from page 1 only, so a later page without
  pagination can no longer end the listing early.
- Remove unused bugcrowd.NewPollerWithLogin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Optional migration rewrites ignored unique violations inside the
  transaction, which Postgres then aborted, so Open failed forever on
  legacy duplicates. They now run in a savepoint.
- NormalizeTarget was not idempotent (example.com./, //host:443, port-only
  authorities). The fuzzer now asserts idempotency.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AI rows exported the variant's effective in_scope only, and import used
it for the base target, flipping in-scope targets with an out-of-scope
variant. Export base_in_scope (JSON and CSV) and use it on import.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cozyGarage
cozyGarage merged commit 3216f12 into main Oct 2, 2026
9 checks passed
@cozyGarage
cozyGarage deleted the fix/local-ci-green branch October 2, 2026 22:47
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.

1 participant