mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-10-26 20:01:57 -06:00
Merge pull request #71 from bunny-lab-io:codex/fix-missing-agent_hashes-in-device-table-ol68er
Include agent hash in audit payload and surface in device list
This commit is contained in:
@@ -912,6 +912,12 @@ def _build_details_fallback() -> dict:
|
|||||||
'storage': collect_storage(),
|
'storage': collect_storage(),
|
||||||
'network': network,
|
'network': network,
|
||||||
}
|
}
|
||||||
|
try:
|
||||||
|
agent_hash_value = _read_agent_hash()
|
||||||
|
if agent_hash_value:
|
||||||
|
details.setdefault('summary', {})['agent_hash'] = agent_hash_value
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
return details
|
return details
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ export default function DeviceList({ onSelectDevice }) {
|
|||||||
const arr = Object.entries(data || {}).map(([id, a]) => {
|
const arr = Object.entries(data || {}).map(([id, a]) => {
|
||||||
const hostname = a.hostname || id || "unknown";
|
const hostname = a.hostname || id || "unknown";
|
||||||
const details = detailsByHost[hostname] || {};
|
const details = detailsByHost[hostname] || {};
|
||||||
const agentHash = (a.agent_hash || "").trim();
|
const agentHash = (a.agent_hash || details.agentHash || "").trim();
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
hostname,
|
hostname,
|
||||||
@@ -230,43 +230,47 @@ export default function DeviceList({ onSelectDevice }) {
|
|||||||
const externalIp = summary.external_ip || "";
|
const externalIp = summary.external_ip || "";
|
||||||
const lastReboot = summary.last_reboot || "";
|
const lastReboot = summary.last_reboot || "";
|
||||||
const description = summary.description || "";
|
const description = summary.description || "";
|
||||||
|
const agentHashValue = (summary.agent_hash || "").trim();
|
||||||
|
const enriched = {
|
||||||
|
lastUser,
|
||||||
|
created: createdRaw,
|
||||||
|
createdTs,
|
||||||
|
type: deviceType,
|
||||||
|
internalIp,
|
||||||
|
externalIp,
|
||||||
|
lastReboot,
|
||||||
|
description,
|
||||||
|
agentHash: agentHashValue,
|
||||||
|
};
|
||||||
setDetailsByHost((prev) => ({
|
setDetailsByHost((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
[h]: {
|
[h]: enriched,
|
||||||
lastUser,
|
|
||||||
created: createdRaw,
|
|
||||||
createdTs,
|
|
||||||
type: deviceType,
|
|
||||||
internalIp,
|
|
||||||
externalIp,
|
|
||||||
lastReboot,
|
|
||||||
description,
|
|
||||||
},
|
|
||||||
}));
|
}));
|
||||||
|
setRows((prev) =>
|
||||||
|
prev.map((r) => {
|
||||||
|
if (r.hostname !== h) return r;
|
||||||
|
const nextHash = agentHashValue || r.agentHash;
|
||||||
|
return {
|
||||||
|
...r,
|
||||||
|
lastUser: enriched.lastUser || r.lastUser,
|
||||||
|
type: enriched.type || r.type,
|
||||||
|
created: enriched.created || r.created,
|
||||||
|
createdTs: enriched.createdTs || r.createdTs,
|
||||||
|
internalIp: enriched.internalIp || r.internalIp,
|
||||||
|
externalIp: enriched.externalIp || r.externalIp,
|
||||||
|
lastReboot: enriched.lastReboot || r.lastReboot,
|
||||||
|
description: enriched.description || r.description,
|
||||||
|
agentHash: nextHash,
|
||||||
|
agentVersion: computeAgentVersion(nextHash, repoSha),
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
} catch {
|
} catch {
|
||||||
// ignore per-host failure
|
// ignore per-host failure
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// After caching, refresh rows to apply newly available details
|
|
||||||
setRows((prev) =>
|
|
||||||
prev.map((r) => {
|
|
||||||
const det = detailsByHost[r.hostname];
|
|
||||||
if (!det) return r;
|
|
||||||
return {
|
|
||||||
...r,
|
|
||||||
lastUser: det.lastUser || r.lastUser,
|
|
||||||
type: det.type || r.type,
|
|
||||||
created: det.created || r.created,
|
|
||||||
createdTs: det.createdTs || r.createdTs,
|
|
||||||
internalIp: det.internalIp || r.internalIp,
|
|
||||||
externalIp: det.externalIp || r.externalIp,
|
|
||||||
lastReboot: det.lastReboot || r.lastReboot,
|
|
||||||
description: det.description || r.description,
|
|
||||||
};
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn("Failed to load agents:", e);
|
console.warn("Failed to load agents:", e);
|
||||||
|
|||||||
Reference in New Issue
Block a user