Commit Graph

10 Commits

Author SHA1 Message Date
salvacybersec
41a9ba2a19 fix(phase-17): align bot handler signatures and resolve merge conflicts 2026-04-06 17:39:36 +03:00
salvacybersec
230dcdc98a merge: phase 17 wave 2 2026-04-06 17:36:54 +03:00
salvacybersec
52988a7059 merge: phase 17 wave 2 2026-04-06 17:36:53 +03:00
salvacybersec
202473a799 test(17-03): add unit tests for bot command handlers
- Test extractArg parsing for all command formats
- Test isPrivateChat detection (private vs group vs supergroup)
- Test commandHelp contains all 8 commands with descriptions
- Test storageToEngine conversion fidelity
- Test New constructor wires startedAt correctly
2026-04-06 17:35:23 +03:00
salvacybersec
9ad58534fc feat(17-03): implement Telegram bot command handlers
- Add telego v1.8.0 dependency for Telegram Bot API
- Create pkg/bot package with Bot struct holding engine, verifier, recon, storage, registry deps
- Implement 8 command handlers: /help, /scan, /verify, /recon, /status, /stats, /providers, /key
- /key enforced private-chat-only for security (never exposes unmasked keys in groups)
- All other commands use masked keys only
- Handler registration via telego's BotHandler with CommandEqual predicates
2026-04-06 17:34:44 +03:00
salvacybersec
2643927821 feat(17-04): implement notification dispatcher with tests
- NotifyNewFindings sends to all subscribers on scan completion with findings
- NotifyFinding sends real-time individual finding notifications (always masked)
- formatNotification/formatErrorNotification/formatFindingNotification helpers
- Zero findings = no notification; errors get separate error format
- Per-subscriber error handling: log and continue on individual send failures
- 6 tests pass: subscribe DB round-trip, no-subscriber no-op, zero-finding skip,
  message format validation, error format, masked key enforcement

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 17:33:32 +03:00
salvacybersec
f7162aa34a test(17-04): add failing tests for notification dispatcher
- TestSubscribeUnsubscribe: DB round-trip for add/remove subscriber
- TestNotifyNewFindings_NoSubscribers: zero messages with empty table
- TestNotifyNewFindings_ZeroFindings: no notification for 0 findings
- TestFormatNotification: message contains job name, count, duration
- TestFormatFindingNotification: masked key, never full key

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 17:32:58 +03:00
salvacybersec
d671695f65 feat(17-04): implement /subscribe and /unsubscribe handlers
- handleSubscribe checks IsSubscribed, calls AddSubscriber with chat ID and username
- handleUnsubscribe calls RemoveSubscriber, reports rows affected
- Both use storage layer from Plan 17-02
- Removed stub implementations from bot.go

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 17:32:18 +03:00
salvacybersec
2d51d31b8a test(17-01): add unit tests for Bot creation and auth filtering
- TestNew_EmptyToken: verify empty token returns error from telego
- TestIsAllowed_EmptyList: verify open access when no restrictions set
- TestIsAllowed_RestrictedList: verify allowlist filtering
- TestCheckRateLimit: verify cooldown enforcement and per-user isolation
2026-04-06 17:28:05 +03:00
salvacybersec
0d00215a26 feat(17-01): add telego dependency and create Bot package skeleton
- Add telego v1.8.0 as direct dependency for Telegram bot
- Create pkg/bot/bot.go with Bot struct, Config, New, Start, Stop
- Implement isAllowed chat authorization and per-user rate limiting
- Add command dispatch with handler stubs for all 10 commands
- Long polling lifecycle with context cancellation for graceful shutdown
2026-04-06 17:27:41 +03:00