docs(09-03): complete stealth UA pool and dedup plan

- Stealth UA pool (10 browsers) + RandomUserAgent/StealthHeaders
- Stable cross-source Dedup keyed by sha256(provider|masked|source)
- Mark RECON-INFRA-06 complete
This commit is contained in:
salvacybersec
2026-04-06 00:44:37 +03:00
parent 2988fdf9b3
commit 1eb86ca308
4 changed files with 138 additions and 9 deletions

View File

@@ -205,7 +205,7 @@ Requirements for initial release. Each maps to roadmap phases.
### OSINT/Recon — Infrastructure ### OSINT/Recon — Infrastructure
- [ ] **RECON-INFRA-05**: Per-source rate limiter with configurable limits - [ ] **RECON-INFRA-05**: Per-source rate limiter with configurable limits
- [ ] **RECON-INFRA-06**: Stealth mode (--stealth) with UA rotation and increased delays - [x] **RECON-INFRA-06**: Stealth mode (--stealth) with UA rotation and increased delays
- [ ] **RECON-INFRA-07**: robots.txt respect (--respect-robots, default on) - [ ] **RECON-INFRA-07**: robots.txt respect (--respect-robots, default on)
- [ ] **RECON-INFRA-08**: Recon full command — parallel sweep across all sources with deduplication - [ ] **RECON-INFRA-08**: Recon full command — parallel sweep across all sources with deduplication

View File

@@ -200,7 +200,7 @@ Plans:
**Plans**: 6 plans **Plans**: 6 plans
- [ ] 09-01-PLAN.md — ReconSource interface + Engine skeleton + ExampleSource stub - [ ] 09-01-PLAN.md — ReconSource interface + Engine skeleton + ExampleSource stub
- [ ] 09-02-PLAN.md — LimiterRegistry per-source rate.Limiter + jitter - [ ] 09-02-PLAN.md — LimiterRegistry per-source rate.Limiter + jitter
- [ ] 09-03-PLAN.md — Stealth UA pool + cross-source dedup - [x] 09-03-PLAN.md — Stealth UA pool + cross-source dedup
- [ ] 09-04-PLAN.md — robots.txt parser with 1h per-host cache - [ ] 09-04-PLAN.md — robots.txt parser with 1h per-host cache
- [ ] 09-05-PLAN.md — cmd/recon.go CLI tree (full, list) - [ ] 09-05-PLAN.md — cmd/recon.go CLI tree (full, list)
- [ ] 09-06-PLAN.md — Integration test + phase summary - [ ] 09-06-PLAN.md — Integration test + phase summary

View File

@@ -3,14 +3,14 @@ gsd_state_version: 1.0
milestone: v1.0 milestone: v1.0
milestone_name: milestone milestone_name: milestone
status: executing status: executing
stopped_at: Completed 08-07-PLAN.md stopped_at: Completed 09-03-PLAN.md
last_updated: "2026-04-05T21:32:47.810Z" last_updated: "2026-04-05T21:44:25.836Z"
last_activity: 2026-04-05 last_activity: 2026-04-05
progress: progress:
total_phases: 18 total_phases: 18
completed_phases: 8 completed_phases: 7
total_plans: 47 total_plans: 48
completed_plans: 47 completed_plans: 48
percent: 20 percent: 20
--- ---
@@ -82,6 +82,7 @@ Progress: [██░░░░░░░░] 20%
| Phase 08-dork-engine P02 | 12min | 2 tasks | 11 files | | Phase 08-dork-engine P02 | 12min | 2 tasks | 11 files |
| Phase 08-dork-engine P03 | 10m | 2 tasks | 10 files | | Phase 08-dork-engine P03 | 10m | 2 tasks | 10 files |
| Phase 08-dork-engine P07 | 3m | 1 tasks | 1 files | | Phase 08-dork-engine P07 | 3m | 1 tasks | 1 files |
| Phase 09 P03 | 8min | 2 tasks | 4 files |
## Accumulated Context ## Accumulated Context
@@ -115,6 +116,7 @@ Recent decisions affecting current work:
- [Phase 06-output-reporting]: keys export rejects SARIF (scan-only); keys show always unmasked; keys verify updates findings inline via db.SQL().Exec - [Phase 06-output-reporting]: keys export rejects SARIF (scan-only); keys show always unmasked; keys verify updates findings inline via db.SQL().Exec
- [Phase 08-dork-engine]: pkg/dorks mirrors pkg/providers go:embed pattern; //go:embed definitions/* tolerates empty .gitkeep-only tree - [Phase 08-dork-engine]: pkg/dorks mirrors pkg/providers go:embed pattern; //go:embed definitions/* tolerates empty .gitkeep-only tree
- [Phase 08-dork-engine]: Runner + Executor interface separate from Registry so 08-05 GitHub executor registers without touching YAML loader - [Phase 08-dork-engine]: Runner + Executor interface separate from Registry so 08-05 GitHub executor registers without touching YAML loader
- [Phase 09]: Plan 09-03: Dedup uses engine.Finding directly to avoid parallel-wave alias collision with Plan 09-01
### Pending Todos ### Pending Todos
@@ -129,6 +131,6 @@ None yet.
## Session Continuity ## Session Continuity
Last session: 2026-04-05T21:25:47.469Z Last session: 2026-04-05T21:44:25.833Z
Stopped at: Completed 08-07-PLAN.md Stopped at: Completed 09-03-PLAN.md
Resume file: None Resume file: None

View File

@@ -0,0 +1,127 @@
---
phase: 09-osint-infrastructure
plan: 03
subsystem: recon
tags: [stealth, user-agent, dedup, sha256, osint]
requires:
- phase: 09-osint-infrastructure
provides: "pkg/recon package namespace (Plan 09-01, parallel wave 1)"
provides:
- "pkg/recon/stealth.go: 10-entry browser UA pool with RandomUserAgent/StealthHeaders helpers"
- "pkg/recon/dedup.go: stable cross-source Finding dedup keyed by sha256(provider|masked|source)"
affects: [09-01, 09-02, 10-sources, 11-sources, 12-sources, 13-sources, 14-sources, 15-sources, 16-sources]
tech-stack:
added: []
patterns:
- "stdlib-only dedup (crypto/sha256 + encoding/hex)"
- "first-seen-wins stable dedup preserving input order"
- "cross-platform UA pool covering desktop + mobile"
key-files:
created:
- pkg/recon/stealth.go
- pkg/recon/stealth_test.go
- pkg/recon/dedup.go
- pkg/recon/dedup_test.go
modified: []
key-decisions:
- "Use engine.Finding directly in dedup.go instead of a local Finding alias to avoid duplicate type declaration with Plan 09-01's source.go in parallel wave 1"
- "Hash key = sha256(ProviderName|KeyMasked|Source) so same key found at different URLs is retained"
- "Stable dedup: first-seen metadata (DetectedAt, Confidence) wins over later duplicates"
patterns-established:
- "Stealth mode helpers: exported RandomUserAgent + StealthHeaders for recon sources to merge into requests"
- "Stable dedup primitive: Dedup([]engine.Finding) []engine.Finding, stdlib only, O(n)"
requirements-completed: [RECON-INFRA-06]
duration: 8min
completed: 2026-04-05
---
# Phase 09 Plan 03: Stealth UA Pool + Cross-Source Dedup Summary
**10-entry browser User-Agent pool with RandomUserAgent/StealthHeaders and a stable SHA256-keyed Finding Dedup primitive ready for SweepAll orchestration.**
## Performance
- **Duration:** ~8 min
- **Started:** 2026-04-05T21:35:00Z
- **Completed:** 2026-04-05T21:43:18Z
- **Tasks:** 2 (both TDD)
- **Files created:** 4
## Accomplishments
- Stealth UA pool with 10 realistic browser User-Agents covering Chrome/Firefox/Safari/Edge on Windows, macOS, Linux, iOS, and Android
- `RandomUserAgent()` + `StealthHeaders()` helpers returning rotated UA + `Accept-Language: en-US,en;q=0.9`
- Stable cross-source `Dedup([]engine.Finding) []engine.Finding` keyed by `sha256(ProviderName|KeyMasked|Source)`
- First-seen metadata preserved; different Source URLs keep the same provider+masked key as distinct findings
- `go test ./pkg/recon/` green, `go vet ./pkg/recon/...` clean
## Task Commits
TDD flow (test → feat per task):
1. **Task 1: Stealth UA pool + RandomUserAgent**
- RED: `bbbc05f` (test: add failing test for stealth UA pool)
- GREEN: `2c140e9` (feat: implement stealth UA pool and StealthHeaders)
2. **Task 2: Cross-source finding dedup**
- RED: `ecfa2bf` (test: add failing test for cross-source Dedup)
- GREEN: `2988fdf` (feat: implement stable cross-source finding Dedup)
## Files Created/Modified
- `pkg/recon/stealth.go` — 10-entry UA pool, `RandomUserAgent`, `StealthHeaders`
- `pkg/recon/stealth_test.go``TestUAPoolSize`, `TestRandomUserAgentInPool` (100 iterations), `TestStealthHeadersHasUA`
- `pkg/recon/dedup.go``Dedup([]engine.Finding) []engine.Finding` with sha256 key + stable first-seen semantics
- `pkg/recon/dedup_test.go``TestDedupEmpty`, `TestDedupNoDuplicates`, `TestDedupAllDuplicates`, `TestDedupPreservesFirstSeen`, `TestDedupDifferentSource`
## Decisions Made
- **Use `engine.Finding` directly in `dedup.go` rather than a local `recon.Finding` alias.** Plan 09-01 (same wave, parallel) will declare `type Finding = engine.Finding` in `pkg/recon/source.go`. Declaring it again here would cause a post-merge duplicate declaration. Importing `engine.Finding` explicitly is forward-compatible — when 09-01 merges, `recon.Finding` becomes available and this file continues to compile either way.
- **Dedup key = `sha256(ProviderName|KeyMasked|Source)`.** Masked key avoids hashing plaintext; including `Source` ensures a leaked key found at multiple URLs is reported at every location rather than collapsed to one.
- **Stable first-seen wins.** Iteration is single-pass with a `seen` map; output order matches input order.
## Deviations from Plan
### Auto-fixed Issues
**1. [Rule 3 - Blocking] Use `engine.Finding` instead of local `Finding` alias**
- **Found during:** Task 2 (Dedup implementation)
- **Issue:** Plan 09-03 executes in wave 1 parallel with Plan 09-01. Plan 09-01 declares `type Finding = engine.Finding` in `pkg/recon/source.go`. The original plan body for 09-03 referenced bare `Finding` in `dedup.go`, which would require either a duplicate alias (post-merge conflict/duplicate declaration) or a dependency on 09-01's file that does not yet exist on this branch.
- **Fix:** Imported `github.com/salvacybersec/keyhunter/pkg/engine` in `dedup.go` and `dedup_test.go` and used `engine.Finding` directly. Behavior and test coverage are identical; signature is `Dedup([]engine.Finding) []engine.Finding`. A doc comment in `dedup.go` records the rationale.
- **Files modified:** `pkg/recon/dedup.go`, `pkg/recon/dedup_test.go`
- **Verification:** `go test ./pkg/recon/ -count=1` passes; `go vet ./pkg/recon/...` clean.
- **Committed in:** `2988fdf` (Task 2 GREEN commit)
---
**Total deviations:** 1 auto-fixed (1 blocking / parallel-safety)
**Impact on plan:** No scope change. The public signature matches downstream expectations because `recon.Finding` is a type alias — `[]recon.Finding` and `[]engine.Finding` are interchangeable, so SweepAll (Plan 09-01) can still call `Dedup` without any adapter.
## Issues Encountered
None beyond the deviation above.
## User Setup Required
None.
## Next Phase Readiness
- Plan 09-02 (rate limiter + jitter) can import `StealthHeaders` for outbound requests when `Config.Stealth` is true.
- Plan 09-01's `Engine.SweepAll` can call `recon.Dedup(all)` before returning to satisfy RECON-INFRA-08's "deduplicates findings before persisting" criterion.
- RECON-INFRA-06 (stealth UA rotation) satisfied.
## Self-Check: PASSED
- FOUND: pkg/recon/stealth.go
- FOUND: pkg/recon/stealth_test.go
- FOUND: pkg/recon/dedup.go
- FOUND: pkg/recon/dedup_test.go
- FOUND commit: bbbc05f
- FOUND commit: 2c140e9
- FOUND commit: ecfa2bf
- FOUND commit: 2988fdf
---
*Phase: 09-osint-infrastructure*
*Plan: 03*
*Completed: 2026-04-05*