mirror of
https://github.com/okieselbach/AutopilotMonitor.git
synced 2026-10-24 04:32:32 +00:00
fix CVE data sync and signalr join
This commit is contained in:
+1
-1
Submodule .claude/commands updated: 93d356afd4...4d307c96dc
@@ -1 +1 @@
|
|||||||
623
|
627
|
||||||
|
|||||||
+7
-4
@@ -200,11 +200,14 @@ namespace AutopilotMonitor.Functions.Functions.Vulnerability
|
|||||||
|
|
||||||
var cveDataJson = System.Text.Json.JsonSerializer.Serialize(cves);
|
var cveDataJson = System.Text.Json.JsonSerializer.Serialize(cves);
|
||||||
|
|
||||||
// Guard 64KB limit
|
// Guard 64KB limit — iteratively halve until it fits
|
||||||
if (cveDataJson.Length > 60_000)
|
var cacheCves = cves;
|
||||||
|
while (cveDataJson.Length > 60_000 && cacheCves.Count > 10)
|
||||||
{
|
{
|
||||||
var reduced = cves.Take(cves.Count / 2).ToList();
|
cacheCves = cacheCves.Take(cacheCves.Count / 2).ToList();
|
||||||
cveDataJson = System.Text.Json.JsonSerializer.Serialize(reduced);
|
cveDataJson = System.Text.Json.JsonSerializer.Serialize(cacheCves);
|
||||||
|
_logger.LogInformation("[VulnSync] Reduced CVE cache for {CpeUri} to {Count} entries ({Bytes} chars)",
|
||||||
|
cpeUri, cacheCves.Count, cveDataJson.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
var data = new Dictionary<string, object>
|
var data = new Dictionary<string, object>
|
||||||
|
|||||||
@@ -92,8 +92,8 @@ public static class EndpointAccessPolicyCatalog
|
|||||||
new("GET", "auth/me", EndpointPolicy.AuthenticatedUser),
|
new("GET", "auth/me", EndpointPolicy.AuthenticatedUser),
|
||||||
new("GET", "auth/is-global-admin", EndpointPolicy.AuthenticatedUser),
|
new("GET", "auth/is-global-admin", EndpointPolicy.AuthenticatedUser),
|
||||||
new("POST", "realtime/negotiate", EndpointPolicy.AuthenticatedUser),
|
new("POST", "realtime/negotiate", EndpointPolicy.AuthenticatedUser),
|
||||||
new("POST", "realtime/groups/join", EndpointPolicy.AuthenticatedUser),
|
new("POST", "realtime/groups/join", EndpointPolicy.MemberRead),
|
||||||
new("POST", "realtime/groups/leave", EndpointPolicy.AuthenticatedUser),
|
new("POST", "realtime/groups/leave", EndpointPolicy.MemberRead),
|
||||||
new("GET", "progress/sessions", EndpointPolicy.AuthenticatedUser),
|
new("GET", "progress/sessions", EndpointPolicy.AuthenticatedUser),
|
||||||
new("GET", "progress/sessions/{sessionId}/events", EndpointPolicy.AuthenticatedUser),
|
new("GET", "progress/sessions/{sessionId}/events", EndpointPolicy.AuthenticatedUser),
|
||||||
new("PUT", "preview/notification-email", EndpointPolicy.AuthenticatedUser),
|
new("PUT", "preview/notification-email", EndpointPolicy.AuthenticatedUser),
|
||||||
|
|||||||
+21
-10
@@ -474,20 +474,31 @@ namespace AutopilotMonitor.Functions.Services.Vulnerability
|
|||||||
// Persist to repository (best-effort, don't fail the request)
|
// Persist to repository (best-effort, don't fail the request)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var cveDataJson = JsonSerializer.Serialize(cves, JsonOptions);
|
var cacheCves = cves
|
||||||
|
.OrderByDescending(c => c.CvssScore)
|
||||||
|
.ThenByDescending(c => c.PublishedDate)
|
||||||
|
.ToList();
|
||||||
|
var cveDataJson = JsonSerializer.Serialize(cacheCves, JsonOptions);
|
||||||
|
|
||||||
// Guard against exceeding Table Storage 64KB single-property limit
|
// Guard against exceeding Table Storage 64KB single-property limit
|
||||||
|
// Iteratively halve until it fits (floor: 10 CVEs)
|
||||||
|
while (cveDataJson.Length > 60_000 && cacheCves.Count > 10)
|
||||||
|
{
|
||||||
|
cacheCves = cacheCves.Take(cacheCves.Count / 2).ToList();
|
||||||
|
cveDataJson = JsonSerializer.Serialize(cacheCves, JsonOptions);
|
||||||
|
_logger.LogInformation("Reduced CVE cache for {CpeUri} to {Count} entries ({Bytes} chars) to fit 64KB limit",
|
||||||
|
cpeUri, cacheCves.Count, cveDataJson.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Last resort: strip Criteria strings (biggest space consumer) and retry
|
||||||
if (cveDataJson.Length > 60_000)
|
if (cveDataJson.Length > 60_000)
|
||||||
{
|
{
|
||||||
// Further reduce until it fits
|
foreach (var c in cacheCves)
|
||||||
var reduced = cves
|
foreach (var v in c.AffectedVersions)
|
||||||
.OrderByDescending(c => c.CvssScore)
|
v.Criteria = null;
|
||||||
.ThenByDescending(c => c.PublishedDate)
|
cveDataJson = JsonSerializer.Serialize(cacheCves, JsonOptions);
|
||||||
.Take(cves.Count / 2)
|
_logger.LogWarning("Stripped Criteria from CVE cache for {CpeUri} to fit 64KB limit ({Bytes} chars)",
|
||||||
.ToList();
|
cpeUri, cveDataJson.Length);
|
||||||
cveDataJson = JsonSerializer.Serialize(reduced, JsonOptions);
|
|
||||||
_logger.LogInformation("Further reduced CVE cache for {CpeUri} to {Count} entries to fit 64KB limit",
|
|
||||||
cpeUri, reduced.Count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var data = new Dictionary<string, object>
|
var data = new Dictionary<string, object>
|
||||||
|
|||||||
Reference in New Issue
Block a user