feat: webhook notifications for new devices and critical risks (#78) - #84
Merged
Merged
Conversation
- Add AppSetting key-value model (app_settings table) - Add notifications.py: get/set webhook URL, send_webhook, notify_scan_complete - Scan runner: _persist_result returns new device IDs; notify after each scan - API: GET/PATCH /api/settings, POST /api/settings/webhook/test - Settings UI: webhook URL field, Save and Test buttons with inline feedback - Tests: 7 unit tests covering send_webhook and notify_scan_complete Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Closes #78
Adds webhook notification support so NetworkCrawler can push alerts to ntfy.sh, Gotify, Home Assistant, Slack, Discord, or any HTTP endpoint.
Changes
Backend
app/models/settings.py: NewAppSettingkey-value ORM model (app_settingstable)app/notifications.py:get/set_webhook_url(),send_webhook(),notify_scan_complete()app/scan_runner.py:_persist_resultreturns new device IDs;notify_scan_completecalled after each scanapp/db.py: Registersapp.models.settingsininit_db()app/api/__init__.py:GET /api/settings,PATCH /api/settings,POST /api/settings/webhook/testFrontend
SettingsPage.tsx: Webhook URL input, Save + Test buttons with inline success/error feedbackTests
tests/test_notifications.py: 7 unit tests (send_webhook success/failure, notify_scan_complete skip/fire conditions)Webhook payload
{ "event": "scan_complete", "scan_id": 42, "summary": "1 new device(s) detected", "new_devices": [{"ip": "...", "hostname": "...", "mac": "...", "vendor": "..."}], "risk_counts": {"critical": 0, "high": 2}, "title": "NetworkCrawler Alert", "message": "1 new device(s) detected" }Compatible with ntfy.sh (use topic URL directly), Gotify, and any JSON webhook endpoint.