test(notifications): add webhook egress control regression guard #877#1112
test(notifications): add webhook egress control regression guard #877#1112NaitikVerma6776 wants to merge 2 commits into
Conversation
utksh1
left a comment
There was a problem hiding this comment.
Requesting changes. The title says this guards webhook egress control, but the tests mostly mock httpx failures rather than proving the network policy blocks private/loopback destinations before delivery. Please assert the actual egress policy path and keep the notification_history assertions focused.
eb12929 to
906b1dc
Compare
|
heyy @utksh1 .Thanks for the feedback — you're right, the previous tests mocked httpx directly and never exercised the real policy path. I dug into send_webhook and found it already implements its own SSRF protection independent of the general network policy: it resolves the hostname via DNS, then validates every resolved IP against settings.notification_blocked_ip_ranges (which blocks 127.0.0.0/8, 169.254.0.0/16, and the cloud metadata IP by default) before httpx is ever touched. Rewrote the tests to assert this real path directly, with no httpx mocking for the blocking assertions:
All 7 tests pass locally in 1.26s. |
|
heyy @utksh1, Heads up — I'm noticing the same backend-unit (cancelled) and backend-tests (skipped) pattern across multiple open PRs, not just this one. Looks like a CI infrastructure issue (runner timeout or workflow config) rather than something caused by individual branches. Wanted to flag it in case it needs attention on the workflow side rather than per-PR fixes |
Description
Reviewed
backend/secuscan/notification_service.pyand identified thatsend_webhookuses a rawhttpx.AsyncClientwithout explicit egress-policy regression coverage. Existing notification service tests validate delivery behavior but do not verify that webhook sends respect network egress controls.Added
testing/backend/integration/test_webhook_egress_policy.pywith focused integration coverage for:127.0.0.1)10.0.0.1)FAILEDinnotification_historyFAILEDinnotification_historyAll tests fully mock
httpxand make no real network requests.Related Issues
Closes #877
Type of Change
How Has This Been Tested?
Result:
Checklist