fix: corriger les issues mineures du review
🟡 SnapshotUrl: validation sécurité SSRF (scheme + loopback) 🟡 Integration tests: skip graceful sans PostgreSQL (TestContainers)
This commit is contained in:
1 parent
fba29b3eb4
commit
a6b2a21ebc
3 files changed
+54
-2
No files matched your search
@@ -54,6 +54,26 @@ public class NotificationService : INotificationService
|
||||
}
|
||||
}
|
||||
|
||||
// Validate snapshot URL — prevent SSRF and internal URL exposure
|
||||
if (!string.IsNullOrEmpty(snapshotUrl))
|
||||
{
|
||||
if (!Uri.TryCreate(snapshotUrl, UriKind.Absolute, out var uri))
|
||||
{
|
||||
_logger.LogWarning("Invalid snapshot URL format: {Url}", snapshotUrl);
|
||||
snapshotUrl = null;
|
||||
}
|
||||
else if (uri.Scheme is not ("http" or "https"))
|
||||
{
|
||||
_logger.LogWarning("Blocked snapshot URL with disallowed scheme: {Scheme}", uri.Scheme);
|
||||
snapshotUrl = null;
|
||||
}
|
||||
else if (uri.IsLoopback)
|
||||
{
|
||||
_logger.LogWarning("Blocked snapshot URL pointing to loopback: {Url}", snapshotUrl);
|
||||
snapshotUrl = null;
|
||||
}
|
||||
}
|
||||
|
||||
var notification = new Notification(
|
||||
userId, title, message, type, eventType, cameraId, siteId, snapshotUrl, link);
|
||||
|
||||
|
||||
Reference in new issue
Block a user