Skip to content

Commit 16fb862

Browse files
Backlog/v12 adversary view (#2402)
* fix[frontend](adversary): fixed filter select colors * fix[frontend](adversary): added sankey auto dimension handler to avoud extremelly grouped data * fix[backend](adversary): reduced retrievered fields on adversary alerts request to avoid data overhead
1 parent 056f245 commit 16fb862

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

backend/modules/alerts/usecase/adversary.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ import (
1616
// adversaryIndexPattern is the OpenSearch index the adversary aggregation reads.
1717
const adversaryIndexPattern = "v11-alert-*"
1818

19+
// alertSourceIncludes trims top_hits _source to only fields the frontend renders
20+
// plus `id` (needed by parseAdversaryAggs to correlate children to parents).
21+
// Cuts per-doc payload from full alerts (KBs) to ~4 scalar fields, keeping the
22+
// circuit-breaking parent breaker from tripping on wide time ranges.
23+
var alertSourceIncludes = []string{"id", "name", "target", "severity"}
24+
1925
// adversaryBucketAggs is the set of sub-aggregations run under each adversary
2026
// bucket (by host or by IP) — shared so both grouping strategies fetch the
2127
// same shape of data.
@@ -49,6 +55,9 @@ func adversaryBucketAggs() map[string]any {
4955
"sort": []map[string]any{
5056
{"@timestamp": map[string]any{"order": "desc"}},
5157
},
58+
"_source": map[string]any{
59+
"includes": alertSourceIncludes,
60+
},
5261
},
5362
},
5463
},
@@ -66,6 +75,9 @@ func adversaryBucketAggs() map[string]any {
6675
"sort": []map[string]any{
6776
{"@timestamp": map[string]any{"order": "desc"}},
6877
},
78+
"_source": map[string]any{
79+
"includes": alertSourceIncludes,
80+
},
6981
},
7082
},
7183
},
@@ -93,8 +105,9 @@ func (u *adversaryUsecase) FetchAdversaryAlerts(
93105
}
94106

95107
body := map[string]any{
96-
"size": 0,
97-
"query": common_models.FiltersToQuery(filters),
108+
"size": 0,
109+
"timeout": "30s",
110+
"query": common_models.FiltersToQuery(filters),
98111
"aggs": map[string]any{
99112
// Group by adversary.host when present — internally-identified
100113
// attackers (compromised hosts, agents) carry a hostname.

frontend/src/features/adversaries/components/adversaries-sankey.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,13 @@ export function AdversariesSankey({ data }: { data: AdversaryResponse[] }) {
167167
{ key: 'adversaries.col.victims', color: COLUMN_COLOR.victim },
168168
]
169169

170+
170171
return (
171-
<div className="flex h-full w-full flex-col rounded-xl border border-border bg-card p-3">
172+
<div
173+
style={{
174+
height:`${Math.min(Math.max(data.length,50)*1.7,300)}%`
175+
}}
176+
className={`flex w-full flex-col rounded-xl border border-border bg-card p-3`}>
172177
<div className="grid grid-cols-3 gap-2 pb-2 text-xs font-medium">
173178
{headers.map((h, i) => (
174179
<div

frontend/src/features/alerts/lib/alert-meta.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const TS = '@timestamp'
7373
export const PAGE_SIZE_DEFAULT = 20
7474

7575
export const SELECT_CLS =
76-
'h-9 cursor-pointer rounded-md border border-input bg-background/40 px-2 text-sm transition-colors focus-visible:border-ring focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring'
76+
'h-9 cursor-pointer rounded-md border border-input bg-popover px-2 text-sm text-popover-foreground transition-colors focus-visible:border-ring focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring'
7777

7878
export function relativeTime(iso?: string) {
7979
if (!iso) return '—'

0 commit comments

Comments
 (0)