Skip to content

Commit

Permalink
fix(dashboard): Fix dashboard hosts view to include host count (#680)
Browse files Browse the repository at this point in the history
* fix(dashboard): Fix dashboard hosts view to include host count

* fix(prevent): Prevent click

* fix(build): Rebuild UI
  • Loading branch information
cmp5987 authored Feb 29, 2024
1 parent 7891be1 commit 100dd7d
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 20 deletions.
12 changes: 6 additions & 6 deletions tavern/internal/www/build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"files": {
"main.css": "/static/css/main.6e32d9b6.css",
"main.js": "/static/js/main.97f41730.js",
"main.css": "/static/css/main.88b9e0a3.css",
"main.js": "/static/js/main.b1251496.js",
"react-syntax-highlighter/refractor-core-import.js": "/static/js/react-syntax-highlighter/refractor-core-import.d0cd1e85.chunk.js",
"react-syntax-highlighter_languages_refractor_abap.js": "/static/js/react-syntax-highlighter_languages_refractor_abap.a2bf84e3.chunk.js",
"react-syntax-highlighter_languages_refractor_actionscript.js": "/static/js/react-syntax-highlighter_languages_refractor_actionscript.fff5a604.chunk.js",
Expand Down Expand Up @@ -157,8 +157,8 @@
"static/js/787.4af0fb89.chunk.js": "/static/js/787.4af0fb89.chunk.js",
"static/media/eldrich.png": "/static/media/eldrich.a80c74e8249d2461e174.png",
"index.html": "/index.html",
"main.6e32d9b6.css.map": "/static/css/main.6e32d9b6.css.map",
"main.97f41730.js.map": "/static/js/main.97f41730.js.map",
"main.88b9e0a3.css.map": "/static/css/main.88b9e0a3.css.map",
"main.b1251496.js.map": "/static/js/main.b1251496.js.map",
"refractor-core-import.d0cd1e85.chunk.js.map": "/static/js/react-syntax-highlighter/refractor-core-import.d0cd1e85.chunk.js.map",
"react-syntax-highlighter_languages_refractor_abap.a2bf84e3.chunk.js.map": "/static/js/react-syntax-highlighter_languages_refractor_abap.a2bf84e3.chunk.js.map",
"react-syntax-highlighter_languages_refractor_actionscript.fff5a604.chunk.js.map": "/static/js/react-syntax-highlighter_languages_refractor_actionscript.fff5a604.chunk.js.map",
Expand Down Expand Up @@ -314,7 +314,7 @@
"787.4af0fb89.chunk.js.map": "/static/js/787.4af0fb89.chunk.js.map"
},
"entrypoints": [
"static/css/main.6e32d9b6.css",
"static/js/main.97f41730.js"
"static/css/main.88b9e0a3.css",
"static/js/main.b1251496.js"
]
}
2 changes: 1 addition & 1 deletion tavern/internal/www/build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"><link rel="manifest" href="/site.webmanifest"><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Realm - Red Team Engagement Platform</title><script defer="defer" src="/static/js/main.97f41730.js"></script><link href="/static/css/main.6e32d9b6.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"><link rel="manifest" href="/site.webmanifest"><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Realm - Red Team Engagement Platform</title><script defer="defer" src="/static/js/main.b1251496.js"></script><link href="/static/css/main.88b9e0a3.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
4 changes: 0 additions & 4 deletions tavern/internal/www/build/static/css/main.6e32d9b6.css

This file was deleted.

4 changes: 4 additions & 0 deletions tavern/internal/www/build/static/css/main.88b9e0a3.css

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const GroupHostActivityTable = ({ hostActivity }: { hostActivity: Array<any> })
const navigation = useNavigate();

const handleOnClick = (item: any) => {
if (item?.id === "undefined") {
return null;
}
navigation(`/hosts`, {
state: [{
'label': item?.original?.group,
Expand All @@ -31,7 +34,32 @@ const GroupHostActivityTable = ({ hostActivity }: { hostActivity: Array<any> })
},
{
id: "hostStatus",
header: "Online beacons",
header: "Hosts",
accessorFn: row => row,
footer: props => props.column.id,
enableSorting: true,
sortingFn: (
rowA,
rowB,
) => {
const numA = rowA?.original?.hostsOnline / (rowA?.original?.hostsTotal);
const numB = rowB?.original?.hostsOnline / (rowB?.original?.hostsTotal);

return numA < numB ? 1 : numA > numB ? -1 : 0;
},
cell: (cellData: any) => {
const rowData = cellData.getValue();
const color = rowData.hostsOnline === 0 ? "red" : "gray";
return (
<Badge px='4' colorScheme={color} fontSize="font-base">
{rowData.hostsOnline}/{rowData.hostsTotal}
</Badge>
);
}
},
{
id: "beaconStatus",
header: "Beacons",
accessorFn: row => row,
footer: props => props.column.id,
enableSorting: true,
Expand All @@ -48,7 +76,7 @@ const GroupHostActivityTable = ({ hostActivity }: { hostActivity: Array<any> })
const rowData = cellData.getValue();
const color = rowData.online === 0 ? "red" : "gray";
return (
<Badge ml='1' px='4' colorScheme={color} fontSize="font-base">
<Badge px='4' colorScheme={color} fontSize="font-base">
{rowData.online}/{rowData.total}
</Badge>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ type UniqueCountHost = {
online: number,
total: number,
lastSeenAt: string | undefined | null
hostsOnline: number,
hostsTotal: number,
}

type UniqueCountHostByGroup = {
Expand All @@ -31,7 +33,7 @@ export const useHostAcitvityData = (data: Array<HostType>) => {
let offlineCount = 0;

hosts?.forEach((host: HostType) => {
const groupTag = host?.tags && host?.tags.find((tag: TomeTag) => tag.kind === "group");
const groupTag = host?.tags ? host?.tags.find((tag: TomeTag) => tag.kind === "group") : { name: "undefined", id: "undefined" };
const beaconStatus = getOfflineOnlineStatus(host.beacons || []);

if (beaconStatus.online > 0) {
Expand All @@ -57,14 +59,23 @@ export const useHostAcitvityData = (data: Array<HostType>) => {
}
uniqueGroups[groupName].total += beaconStatus.online + beaconStatus.offline;
uniqueGroups[groupName].online += beaconStatus.online;

if (beaconStatus.online > 0) {
uniqueGroups[groupName].hostsOnline += 1;
}

uniqueGroups[groupName].hostsTotal += 1;

}
else {
uniqueGroups[groupName] = {
tagId: groupTag.id,
group: groupTag.name,
lastSeenAt: host.lastSeenAt,
online: beaconStatus.online,
total: beaconStatus.online + beaconStatus.offline
total: beaconStatus.online + beaconStatus.offline,
hostsOnline: beaconStatus.online > 0 ? 1 : 0,
hostsTotal: 1
}
}
}
Expand Down

0 comments on commit 100dd7d

Please sign in to comment.