mirror of
https://github.com/okieselbach/AutopilotMonitor.git
synced 2026-10-24 20:53:06 +00:00
vul report rescan bugfix
This commit is contained in:
@@ -1 +1 @@
|
||||
680
|
||||
681
|
||||
|
||||
+22
-3
@@ -80,7 +80,7 @@ namespace AutopilotMonitor.Functions.Functions.Vulnerability
|
||||
if (inventoryItems.Count == 0)
|
||||
{
|
||||
var noInventory = req.CreateResponse(HttpStatusCode.OK);
|
||||
await noInventory.WriteAsJsonAsync(new { success = true, sessionId, report = (object?)null, message = "No software inventory events found for this session" });
|
||||
await noInventory.WriteAsJsonAsync(new { success = true, sessionId, report = (object?)null, rescanned = true, message = "No software inventory events found for this session" });
|
||||
return noInventory;
|
||||
}
|
||||
|
||||
@@ -163,8 +163,27 @@ namespace AutopilotMonitor.Functions.Functions.Vulnerability
|
||||
var triggeredAt = evt.Data.ContainsKey("triggered_at") ? evt.Data["triggered_at"]?.ToString() : null;
|
||||
if (triggeredAt != "shutdown") continue;
|
||||
|
||||
// Extract inventory array
|
||||
if (evt.Data.ContainsKey("inventory") && evt.Data["inventory"] is Newtonsoft.Json.Linq.JArray inventoryArray)
|
||||
if (!evt.Data.ContainsKey("inventory")) continue;
|
||||
|
||||
var inventoryData = evt.Data["inventory"];
|
||||
|
||||
// DeserializeEventData converts JArrays to List<object> via ConvertJTokenToNative,
|
||||
// so handle both the native List<object> case and the raw JArray case.
|
||||
if (inventoryData is IList<object> nativeList)
|
||||
{
|
||||
foreach (var entry in nativeList)
|
||||
{
|
||||
if (entry is Dictionary<string, object> dict)
|
||||
{
|
||||
items.Add(dict);
|
||||
}
|
||||
else if (entry is IDictionary<string, object> idict)
|
||||
{
|
||||
items.Add(new Dictionary<string, object>(idict));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (inventoryData is Newtonsoft.Json.Linq.JArray inventoryArray)
|
||||
{
|
||||
foreach (var item in inventoryArray)
|
||||
{
|
||||
|
||||
@@ -38,23 +38,18 @@ export function useSessionAnalysis(
|
||||
}, [sessionId, sessionTenantId, getAccessToken]);
|
||||
|
||||
const fetchVulnerabilityReport = useCallback(async (rescan = false) => {
|
||||
if (!sessionTenantId || !GUID_REGEX.test(sessionTenantId)) {
|
||||
console.warn("[VulnReport] Skipped fetch: sessionTenantId missing or invalid", { sessionTenantId, rescan });
|
||||
return;
|
||||
}
|
||||
const url = api.sessions.vulnerabilityReport(sessionId, sessionTenantId, rescan || undefined);
|
||||
console.info(`[VulnReport] Fetching: rescan=${rescan}, url=${url}`);
|
||||
if (!sessionTenantId || !GUID_REGEX.test(sessionTenantId)) return;
|
||||
try {
|
||||
const response = await authenticatedFetch(url, getAccessToken);
|
||||
const response = await authenticatedFetch(
|
||||
api.sessions.vulnerabilityReport(sessionId, sessionTenantId, rescan || undefined),
|
||||
getAccessToken
|
||||
);
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
console.info(`[VulnReport] Response OK: rescan=${rescan}, hasReport=${data.report != null}, rescanned=${data.rescanned ?? false}`);
|
||||
setVulnerabilityReport(data.report ?? null);
|
||||
} else {
|
||||
console.warn(`[VulnReport] Response not OK: status=${response.status}, rescan=${rescan}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("[VulnReport] Failed to fetch vulnerability report:", error);
|
||||
console.error("Failed to fetch vulnerability report:", error);
|
||||
}
|
||||
}, [sessionId, sessionTenantId, getAccessToken]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user