@wallarm-org/design-system 4.9.0 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/components/Badge/generateBadgeVariants.js +9 -28
- package/dist/components/CodeSnippet/internal/FoldToggle.js +1 -1
- package/dist/components/SimpleCharts/Chart/classes.js +1 -1
- package/dist/components/SimpleCharts/HorizontalBarStack/classes.js +1 -1
- package/dist/components/SimpleCharts/Metric/classes.d.ts +2 -2
- package/dist/components/SimpleCharts/Metric/classes.js +2 -2
- package/dist/components/Table/TableBody/TableBodyCell.js +4 -1
- package/dist/guidelines/patterns/complex-drawer.md +1084 -0
- package/dist/guidelines/patterns/confirmation-dialogs.md +3 -11
- package/dist/guidelines/patterns/detail-drawer.md +31 -13
- package/dist/guidelines/patterns/empty-states.md +6 -5
- package/dist/guidelines/patterns/entity-table.md +25 -29
- package/dist/guidelines/patterns/feedback-toasts.md +3 -11
- package/dist/guidelines/patterns/resource-list-page.md +14 -16
- package/dist/guidelines/rules.md +6 -5
- package/dist/guidelines/templates/ai-assistant.md +1133 -0
- package/dist/guidelines/templates/api-inventory.md +905 -0
- package/dist/guidelines/templates/attack-events.md +2722 -0
- package/dist/guidelines/templates/incident-detail.md +2085 -0
- package/dist/guidelines/templates/integrations-settings.md +836 -0
- package/dist/guidelines/templates/page-states.md +798 -0
- package/dist/guidelines/templates/rule-editor.md +886 -0
- package/dist/guidelines/templates/security-dashboard.md +681 -0
- package/dist/metadata/components.json +10 -10
- package/dist/metadata/guidelines.json +1204 -37
- package/dist/theme/tokens.test.ts +52 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1084 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Complex drawer
|
|
3
|
+
description: Use when a row click opens a wide drawer about one event — an attack, an incident, a session — with a summary header, tabs, an attribute card, chart cards and a list-and-detail split.
|
|
4
|
+
components: [Drawer, DrawerContent, DrawerHeader, DrawerBody, DrawerResizeHandle, Heading, Text, Badge, Tabs, TabsList, TabsTrigger, Tooltip, TooltipTrigger, TooltipContent, Button, Attribute, AttributeLabel, AttributeValue, FormatDateTime, Ip, IpCountry, IpAddress, Chart, ChartHeader, ChartTitle, LineChart, LineChartBody, LineChartGrid, LineChartXAxis, LineChartYAxis, LineChartLine, LineChartTooltip, LineChartEmpty, BarList, BarListItem, BarListBar, BarListLabel, BarListValue, BarListPercent, BarListSkeleton, PieChart, PieChartDonut, PieChartCenter, PieChartCenterValue, PieChartCenterLabel, PieChartLegend, PieChartLegendItem, PieChartLegendValue, PieChartLegendPercent, LegendDot, PieChartSkeleton, FilterInput, ScrollArea, ScrollAreaViewport, ScrollAreaContent, ScrollAreaScrollbar, HttpMethod, ResponseCode, InlineCodeSnippet, CodeSnippetRoot, CodeSnippetContent, CodeSnippetLineNumbers, CodeSnippetCode, Separator, DropdownMenu, Table, HStack, VStack]
|
|
5
|
+
keywords: [complex drawer, event drawer, attack drawer, incident drawer, session drawer, analytics drawer, overview tab, requests tab, list and detail, split view, two panes, columns in drawer, timeline, top 5, status codes, charts in drawer, summary header, blocked count, copy link, wide drawer, 1064, request card, full request]
|
|
6
|
+
order: 55
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Complex drawer
|
|
10
|
+
|
|
11
|
+
A complex drawer is a wide [Detail drawer](./detail-drawer.md) for something that happened many times: an attack, an incident, an API session. The header summarises it, Overview shows attributes and charts, and a records tab splits into a list and a detail.
|
|
12
|
+
|
|
13
|
+
## When to use
|
|
14
|
+
|
|
15
|
+
| Need | Use | Not |
|
|
16
|
+
| --- | --- | --- |
|
|
17
|
+
| One configured entity (a provider, a rule) | [Detail drawer](./detail-drawer.md), 640px | This pattern |
|
|
18
|
+
| One event with counts over time and many records | This pattern, 1064px | A new page, a `Dialog` |
|
|
19
|
+
| How the event ended | Status `Badge variant='dotted'` on the summary line | A status row only in the body |
|
|
20
|
+
| Counts ("0/55 blocked", "2 IPs across 1 country") | Secondary `Text` on the summary line, split by `·` | `Metric` cards |
|
|
21
|
+
| Copy or share a link | Icon `Button` in a `Tooltip`, before the close X | An "Actions" menu with one item |
|
|
22
|
+
| Volume over time | `LineChart` in a full-width `Chart` | A table of hours |
|
|
23
|
+
| Top N of something | `BarList` in a `Chart` | A nested `Table` |
|
|
24
|
+
| Share by class (status codes) | `PieChart` donut in a `Chart` | `BarList` |
|
|
25
|
+
| The event's own records (requests, hits) | A tab with a list on the left and the selected record on the right | A `Table` under the charts, a nested drawer |
|
|
26
|
+
|
|
27
|
+
## Rules
|
|
28
|
+
|
|
29
|
+
This page is about layout. Values inside it (dates, IPs, codes, badges) follow [Entity table](./entity-table.md) and [Detail drawer](./detail-drawer.md).
|
|
30
|
+
|
|
31
|
+
**Drawer**
|
|
32
|
+
|
|
33
|
+
- Everything in [Detail drawer](./detail-drawer.md) still applies: one controlled non-modal `Drawer`, opened from `onMasterCellClick`, `activeRowId`, no footer.
|
|
34
|
+
- Pass `width={1064}`; put `DrawerResizeHandle` first and persist `onResizeEnd`.
|
|
35
|
+
- Reset the tab to Overview and clear the selected record when another row opens the drawer.
|
|
36
|
+
|
|
37
|
+
**Header**
|
|
38
|
+
|
|
39
|
+
- `DrawerHeader` › `HStack align='start' justify='between' gap={16} fullWidth className='min-w-0'`: the title block, then icon buttons. `min-w-0` lets a long title truncate instead of pushing out the close X.
|
|
40
|
+
- Title block: `VStack gap={4} className='min-w-0'` › `Heading as='h2' size='xl' weight='medium' truncate` › summary `HStack gap={4} align='center'`.
|
|
41
|
+
- Summary: `Badge variant='dotted' type='secondary' size='medium'`, then `Text size='xs' color='secondary'` parts split by a `·` `Text`. Wrap every string in `Text`: `HStack` drops bare text.
|
|
42
|
+
- Tabs follow `DrawerHeader` as their own strip: `Tabs` › `TabsList`, outside `DrawerBody`. The records tab shows its count as `Badge type='secondary' color='slate' size='medium' className='ml-4'`.
|
|
43
|
+
- Render the active tab yourself (`tab === 'overview' && …`); there is no `TabsContent` here.
|
|
44
|
+
|
|
45
|
+
**Overview tab**
|
|
46
|
+
|
|
47
|
+
- `DrawerBody` › `VStack gap={12} className='py-16'`.
|
|
48
|
+
- Attributes go in one bordered card: `grid grid-cols-2 gap-x-8 gap-y-16 rounded-8 border border-border-primary-light p-16`, default (vertical) `Attribute`. A long list (IPs) spans both columns: `className='col-span-2'`.
|
|
49
|
+
- Then one full-width `Chart` with the `LineChart` timeline, then cards two per row: `grid grid-cols-2 gap-12`. The grid row gives neighbours one height; `Chart` has no minimum of its own.
|
|
50
|
+
|
|
51
|
+
**Records tab: list and detail**
|
|
52
|
+
|
|
53
|
+
- This tab replaces `DrawerBody`: `<div className='flex min-h-0 flex-1 flex-col'>`. Each pane brings its own `ScrollArea`, so the list and the detail scroll apart. **Never** nest the panes in `DrawerBody` or reach into its `data-slot`s.
|
|
54
|
+
- Filter bar across both panes: `HStack gap={8} className='shrink-0 border-b border-border-primary-light px-16 py-8'` › `FilterInput` in `min-w-0 flex-1`, then the sort `Button variant='ghost' size='small'`.
|
|
55
|
+
- Panes: `flex min-h-0 flex-1` › list `w-320 shrink-0 border-r border-border-primary-light` › detail `min-w-0 flex-1`.
|
|
56
|
+
- List item: a `button` with `value={id}` and `aria-pressed`, `w-full rounded-8 p-8 text-left`; selected `bg-states-primary-default-alt`, else `hover:bg-states-primary-hover`. Inside, `VStack gap={2}`: time and `ResponseCode` (`ml-auto`), attack type `Badge`s, `HttpMethod` + path, host.
|
|
57
|
+
- Detail attributes: `grid grid-cols-2 gap-x-8 gap-y-6`, horizontal `Attribute`; a long value spans both columns.
|
|
58
|
+
- Detail: sections, each a header row (`HStack justify='between' className='px-24 py-8'`, `Text size='md'`, optional "Actions" menu) and a body with `px-24`. Split sections with `<div className='px-24 py-4'><Separator /></div>`.
|
|
59
|
+
- Nothing selected: centred `Text size='sm' color='secondary'` "Select a request to view details".
|
|
60
|
+
|
|
61
|
+
**Does not exist:** `DrawerStatus`, `DrawerSubtitle`, a split-pane or resizable-panel component, a `size` prop on `Chart`, `BarList` `limit`.
|
|
62
|
+
|
|
63
|
+
## Examples
|
|
64
|
+
|
|
65
|
+
The list opens one shared drawer; switch to Requests for the split.
|
|
66
|
+
|
|
67
|
+
Click an attack: one shared, non-modal drawer opens. Its header carries the summary and the
|
|
68
|
+
tabs; Overview scrolls in `DrawerBody`, Requests splits into a list and a detail that scroll on
|
|
69
|
+
their own.
|
|
70
|
+
|
|
71
|
+
```tsx story=Default
|
|
72
|
+
import { type MouseEvent, useState } from 'react';
|
|
73
|
+
import { Attribute, AttributeLabel, AttributeValue } from '@wallarm-org/design-system/Attribute';
|
|
74
|
+
import { Badge } from '@wallarm-org/design-system/Badge';
|
|
75
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
76
|
+
import { CodeSnippetCode, CodeSnippetContent, CodeSnippetLineNumbers, CodeSnippetRoot, InlineCodeSnippet } from '@wallarm-org/design-system/CodeSnippet';
|
|
77
|
+
import { Drawer, DrawerBody, DrawerContent, DrawerHeader, DrawerResizeHandle } from '@wallarm-org/design-system/Drawer';
|
|
78
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuItemText, DropdownMenuSeparator, DropdownMenuTrigger } from '@wallarm-org/design-system/DropdownMenu';
|
|
79
|
+
import { FilterInput } from '@wallarm-org/design-system/FilterInput';
|
|
80
|
+
import { FormatDateTime } from '@wallarm-org/design-system/FormatDateTime';
|
|
81
|
+
import { Heading } from '@wallarm-org/design-system/Heading';
|
|
82
|
+
import { HttpMethod } from '@wallarm-org/design-system/HttpMethod';
|
|
83
|
+
import { ArrowDown, Link } from '@wallarm-org/design-system/icons';
|
|
84
|
+
import { Ip, IpAddress, IpCountry } from '@wallarm-org/design-system/Ip';
|
|
85
|
+
import { Page, PageContent, PageHeader, PageHeaderGroup, PageTitle } from '@wallarm-org/design-system/Page';
|
|
86
|
+
import { ResponseCode } from '@wallarm-org/design-system/ResponseCode';
|
|
87
|
+
import { ScrollArea, ScrollAreaContent, ScrollAreaScrollbar, ScrollAreaViewport } from '@wallarm-org/design-system/ScrollArea';
|
|
88
|
+
import { Separator } from '@wallarm-org/design-system/Separator';
|
|
89
|
+
import { BarList, BarListBar, BarListItem, BarListLabel, BarListPercent, BarListValue, Chart, ChartHeader, ChartTitle, LineChart, LineChartBody, LineChartGrid, LineChartLine, LineChartTooltip, LineChartXAxis, LineChartYAxis, useChartTimeFormatters } from '@wallarm-org/design-system/SimpleCharts';
|
|
90
|
+
import { HStack, VStack } from '@wallarm-org/design-system/Stack';
|
|
91
|
+
import { type TableColumnDef, Table } from '@wallarm-org/design-system/Table';
|
|
92
|
+
import { Tabs, TabsList, TabsTrigger } from '@wallarm-org/design-system/Tabs';
|
|
93
|
+
import { Text } from '@wallarm-org/design-system/Text';
|
|
94
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '@wallarm-org/design-system/Tooltip';
|
|
95
|
+
|
|
96
|
+
export const Default = () => {
|
|
97
|
+
const [selectedId, setSelectedId] = useState<string | null>(null);
|
|
98
|
+
const [open, setOpen] = useState(false);
|
|
99
|
+
const [tab, setTab] = useState('overview');
|
|
100
|
+
const [requestId, setRequestId] = useState<string | null>(null);
|
|
101
|
+
const { formatHour, formatHourWithTimezone } = useChartTimeFormatters();
|
|
102
|
+
|
|
103
|
+
const attack = ATTACKS.find(item => item.id === selectedId) ?? null;
|
|
104
|
+
const request = attack?.requests.find(item => item.id === requestId) ?? null;
|
|
105
|
+
|
|
106
|
+
const columns: TableColumnDef<Attack>[] = [
|
|
107
|
+
{ accessorKey: 'name', header: 'Attack', size: 520 },
|
|
108
|
+
{ accessorKey: 'type', header: 'Type', size: 160 },
|
|
109
|
+
{ accessorKey: 'status', header: 'Status', size: 140 },
|
|
110
|
+
{ accessorKey: 'total', header: 'Requests', size: 120 },
|
|
111
|
+
];
|
|
112
|
+
|
|
113
|
+
const handleMasterCellClick = (id: string) => {
|
|
114
|
+
setSelectedId(id);
|
|
115
|
+
setTab('overview');
|
|
116
|
+
setRequestId(null);
|
|
117
|
+
setOpen(true);
|
|
118
|
+
};
|
|
119
|
+
const handleCopyLink = () => onCopyLink(attack);
|
|
120
|
+
const handleSelectRequest = (event: MouseEvent<HTMLButtonElement>) =>
|
|
121
|
+
setRequestId(event.currentTarget.value);
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<Page name='events-attacks' fullSize fixedHeight data-testid='attacks-page'>
|
|
125
|
+
<PageHeader>
|
|
126
|
+
<PageHeaderGroup>
|
|
127
|
+
<PageTitle>Attacks</PageTitle>
|
|
128
|
+
</PageHeaderGroup>
|
|
129
|
+
</PageHeader>
|
|
130
|
+
|
|
131
|
+
<PageContent>
|
|
132
|
+
<Table
|
|
133
|
+
aria-label='Attacks'
|
|
134
|
+
data={ATTACKS}
|
|
135
|
+
columns={columns}
|
|
136
|
+
getRowId={getAttackId}
|
|
137
|
+
activeRowId={open ? selectedId : null}
|
|
138
|
+
onMasterCellClick={handleMasterCellClick}
|
|
139
|
+
data-testid='attacks-table'
|
|
140
|
+
/>
|
|
141
|
+
</PageContent>
|
|
142
|
+
|
|
143
|
+
<Drawer
|
|
144
|
+
open={open}
|
|
145
|
+
onOpenChange={setOpen}
|
|
146
|
+
modal={false}
|
|
147
|
+
overlay={false}
|
|
148
|
+
closeOnOutsideClick={false}
|
|
149
|
+
width={1064}
|
|
150
|
+
data-testid='attack-drawer'
|
|
151
|
+
>
|
|
152
|
+
<DrawerContent>
|
|
153
|
+
<DrawerResizeHandle onResizeEnd={onSaveDrawerWidth} />
|
|
154
|
+
<DrawerHeader>
|
|
155
|
+
<HStack align='start' justify='between' gap={16} fullWidth className='min-w-0'>
|
|
156
|
+
<VStack gap={4} className='min-w-0'>
|
|
157
|
+
<Heading as='h2' size='xl' weight='medium' truncate>
|
|
158
|
+
{attack?.name}
|
|
159
|
+
</Heading>
|
|
160
|
+
<HStack gap={4} align='center'>
|
|
161
|
+
<Badge
|
|
162
|
+
variant='dotted'
|
|
163
|
+
type='secondary'
|
|
164
|
+
size='medium'
|
|
165
|
+
color={attack?.status === 'Blocked' ? 'red' : 'amber'}
|
|
166
|
+
>
|
|
167
|
+
{attack?.status}
|
|
168
|
+
</Badge>
|
|
169
|
+
<Text size='xs' color='secondary'>
|
|
170
|
+
·
|
|
171
|
+
</Text>
|
|
172
|
+
<Text size='xs' color='secondary'>
|
|
173
|
+
{attack?.blocked}/{attack?.total} blocked
|
|
174
|
+
</Text>
|
|
175
|
+
<Text size='xs' color='secondary'>
|
|
176
|
+
·
|
|
177
|
+
</Text>
|
|
178
|
+
<Text size='xs' color='secondary'>
|
|
179
|
+
{attack?.ips.length} IPs across 1 country
|
|
180
|
+
</Text>
|
|
181
|
+
</HStack>
|
|
182
|
+
</VStack>
|
|
183
|
+
<Tooltip>
|
|
184
|
+
<TooltipTrigger asChild>
|
|
185
|
+
<Button
|
|
186
|
+
variant='ghost'
|
|
187
|
+
color='neutral'
|
|
188
|
+
size='small'
|
|
189
|
+
aria-label='Copy link'
|
|
190
|
+
onClick={handleCopyLink}
|
|
191
|
+
>
|
|
192
|
+
<Link />
|
|
193
|
+
</Button>
|
|
194
|
+
</TooltipTrigger>
|
|
195
|
+
<TooltipContent>Copy link</TooltipContent>
|
|
196
|
+
</Tooltip>
|
|
197
|
+
</HStack>
|
|
198
|
+
</DrawerHeader>
|
|
199
|
+
<Tabs value={tab} onChange={setTab} data-testid='attack-tabs'>
|
|
200
|
+
<TabsList>
|
|
201
|
+
<TabsTrigger value='overview'>Overview</TabsTrigger>
|
|
202
|
+
<TabsTrigger value='requests'>
|
|
203
|
+
Requests
|
|
204
|
+
<Badge type='secondary' color='slate' size='medium' className='ml-4'>
|
|
205
|
+
{attack?.total}
|
|
206
|
+
</Badge>
|
|
207
|
+
</TabsTrigger>
|
|
208
|
+
</TabsList>
|
|
209
|
+
</Tabs>
|
|
210
|
+
|
|
211
|
+
{tab === 'overview' && (
|
|
212
|
+
<DrawerBody>
|
|
213
|
+
<VStack gap={12} className='py-16'>
|
|
214
|
+
<div
|
|
215
|
+
className='grid grid-cols-2 gap-x-8 gap-y-16 rounded-8 border border-border-primary-light p-16'
|
|
216
|
+
data-testid='attack-info-card'
|
|
217
|
+
>
|
|
218
|
+
<Attribute>
|
|
219
|
+
<AttributeLabel>Status</AttributeLabel>
|
|
220
|
+
<AttributeValue>
|
|
221
|
+
<Badge variant='dotted' type='secondary' size='medium' color='amber'>
|
|
222
|
+
{attack?.status}
|
|
223
|
+
</Badge>
|
|
224
|
+
</AttributeValue>
|
|
225
|
+
</Attribute>
|
|
226
|
+
<Attribute>
|
|
227
|
+
<AttributeLabel>First seen</AttributeLabel>
|
|
228
|
+
<AttributeValue>
|
|
229
|
+
<FormatDateTime
|
|
230
|
+
value={attack?.firstSeen ?? ''}
|
|
231
|
+
format='datetime'
|
|
232
|
+
layout='inline'
|
|
233
|
+
/>
|
|
234
|
+
</AttributeValue>
|
|
235
|
+
</Attribute>
|
|
236
|
+
<Attribute>
|
|
237
|
+
<AttributeLabel>Attack type</AttributeLabel>
|
|
238
|
+
<AttributeValue>
|
|
239
|
+
<Badge type='secondary' color='slate' size='medium'>
|
|
240
|
+
{attack?.type}
|
|
241
|
+
</Badge>
|
|
242
|
+
</AttributeValue>
|
|
243
|
+
</Attribute>
|
|
244
|
+
<Attribute>
|
|
245
|
+
<AttributeLabel>Last seen</AttributeLabel>
|
|
246
|
+
<AttributeValue>
|
|
247
|
+
<FormatDateTime
|
|
248
|
+
value={attack?.lastSeen ?? ''}
|
|
249
|
+
format='datetime'
|
|
250
|
+
layout='inline'
|
|
251
|
+
/>
|
|
252
|
+
</AttributeValue>
|
|
253
|
+
</Attribute>
|
|
254
|
+
<Attribute>
|
|
255
|
+
<AttributeLabel>Sessions</AttributeLabel>
|
|
256
|
+
<AttributeValue>{formatCount(attack?.sessions ?? 0)} sessions</AttributeValue>
|
|
257
|
+
</Attribute>
|
|
258
|
+
<Attribute>
|
|
259
|
+
<AttributeLabel>Users</AttributeLabel>
|
|
260
|
+
<AttributeValue>{attack?.users[0]?.name}</AttributeValue>
|
|
261
|
+
</Attribute>
|
|
262
|
+
<Attribute className='col-span-2'>
|
|
263
|
+
<AttributeLabel>IPs</AttributeLabel>
|
|
264
|
+
<AttributeValue>
|
|
265
|
+
<HStack gap={8}>
|
|
266
|
+
{attack?.ips.map(ip => (
|
|
267
|
+
<Ip key={ip.name}>
|
|
268
|
+
<IpCountry code={attack.country} />
|
|
269
|
+
<IpAddress>{ip.name}</IpAddress>
|
|
270
|
+
</Ip>
|
|
271
|
+
))}
|
|
272
|
+
</HStack>
|
|
273
|
+
</AttributeValue>
|
|
274
|
+
</Attribute>
|
|
275
|
+
</div>
|
|
276
|
+
<Chart>
|
|
277
|
+
<ChartHeader>
|
|
278
|
+
<ChartTitle>Timeline</ChartTitle>
|
|
279
|
+
</ChartHeader>
|
|
280
|
+
<LineChart data={TIMELINE} series={TIMELINE_SERIES} xKey='timestamp'>
|
|
281
|
+
<LineChartBody>
|
|
282
|
+
<LineChartGrid />
|
|
283
|
+
<LineChartXAxis tickFormatter={formatHour} minTickGap={48} />
|
|
284
|
+
<LineChartYAxis />
|
|
285
|
+
<LineChartLine seriesKey='requests' curve='linear' />
|
|
286
|
+
<LineChartTooltip xTickFormatter={formatHourWithTimezone} />
|
|
287
|
+
</LineChartBody>
|
|
288
|
+
</LineChart>
|
|
289
|
+
</Chart>
|
|
290
|
+
<div className='grid grid-cols-2 gap-12'>
|
|
291
|
+
<Chart>
|
|
292
|
+
<ChartHeader>
|
|
293
|
+
<ChartTitle>Top 5 hosts</ChartTitle>
|
|
294
|
+
</ChartHeader>
|
|
295
|
+
<BarList max={sumValues(attack?.hosts ?? [])}>
|
|
296
|
+
{attack?.hosts.map(row => (
|
|
297
|
+
<BarListItem key={row.name} value={row.value}>
|
|
298
|
+
<BarListBar />
|
|
299
|
+
<BarListLabel>{row.name}</BarListLabel>
|
|
300
|
+
<BarListValue>
|
|
301
|
+
<BarListPercent />
|
|
302
|
+
</BarListValue>
|
|
303
|
+
</BarListItem>
|
|
304
|
+
))}
|
|
305
|
+
</BarList>
|
|
306
|
+
</Chart>
|
|
307
|
+
<Chart>
|
|
308
|
+
<ChartHeader>
|
|
309
|
+
<ChartTitle>Top 5 IPs</ChartTitle>
|
|
310
|
+
</ChartHeader>
|
|
311
|
+
<BarList max={sumValues(attack?.ips ?? [])}>
|
|
312
|
+
{attack?.ips.map(row => (
|
|
313
|
+
<BarListItem key={row.name} value={row.value}>
|
|
314
|
+
<BarListBar />
|
|
315
|
+
<BarListLabel>{row.name}</BarListLabel>
|
|
316
|
+
<BarListValue>
|
|
317
|
+
<BarListPercent />
|
|
318
|
+
</BarListValue>
|
|
319
|
+
</BarListItem>
|
|
320
|
+
))}
|
|
321
|
+
</BarList>
|
|
322
|
+
</Chart>
|
|
323
|
+
</div>
|
|
324
|
+
</VStack>
|
|
325
|
+
</DrawerBody>
|
|
326
|
+
)}
|
|
327
|
+
|
|
328
|
+
{tab === 'requests' && (
|
|
329
|
+
<div className='flex min-h-0 flex-1 flex-col' data-testid='attack-requests'>
|
|
330
|
+
<HStack gap={8} className='shrink-0 border-b border-border-primary-light px-16 py-8'>
|
|
331
|
+
<div className='min-w-0 flex-1'>
|
|
332
|
+
<FilterInput placeholder='Filter requests...' />
|
|
333
|
+
</div>
|
|
334
|
+
<Button variant='ghost' color='neutral' size='small'>
|
|
335
|
+
<ArrowDown /> Date
|
|
336
|
+
</Button>
|
|
337
|
+
</HStack>
|
|
338
|
+
<div className='flex min-h-0 flex-1'>
|
|
339
|
+
<div className='w-320 shrink-0 border-r border-border-primary-light'>
|
|
340
|
+
<ScrollArea>
|
|
341
|
+
<ScrollAreaViewport>
|
|
342
|
+
<ScrollAreaContent>
|
|
343
|
+
<VStack gap={2} className='p-8' data-testid='attack-request-list'>
|
|
344
|
+
{attack?.requests.map(item => (
|
|
345
|
+
<button
|
|
346
|
+
key={item.id}
|
|
347
|
+
type='button'
|
|
348
|
+
value={item.id}
|
|
349
|
+
aria-pressed={item.id === requestId}
|
|
350
|
+
onClick={handleSelectRequest}
|
|
351
|
+
className={
|
|
352
|
+
item.id === requestId
|
|
353
|
+
? 'w-full rounded-8 bg-states-primary-default-alt p-8 text-left'
|
|
354
|
+
: 'w-full rounded-8 p-8 text-left hover:bg-states-primary-hover'
|
|
355
|
+
}
|
|
356
|
+
>
|
|
357
|
+
<VStack gap={2}>
|
|
358
|
+
<HStack gap={4}>
|
|
359
|
+
<FormatDateTime
|
|
360
|
+
value={item.time}
|
|
361
|
+
format='datetime'
|
|
362
|
+
layout='inline'
|
|
363
|
+
/>
|
|
364
|
+
<div className='ml-auto'>
|
|
365
|
+
<ResponseCode code={item.status} />
|
|
366
|
+
</div>
|
|
367
|
+
</HStack>
|
|
368
|
+
<HStack gap={4}>
|
|
369
|
+
{item.attackTypes.map(type => (
|
|
370
|
+
<Badge key={type} type='secondary' color='slate' size='medium'>
|
|
371
|
+
{type}
|
|
372
|
+
</Badge>
|
|
373
|
+
))}
|
|
374
|
+
</HStack>
|
|
375
|
+
<HStack gap={4}>
|
|
376
|
+
<HttpMethod method={item.method} />
|
|
377
|
+
<Text size='xs' truncate>
|
|
378
|
+
{item.path}
|
|
379
|
+
</Text>
|
|
380
|
+
</HStack>
|
|
381
|
+
<Text size='xs' color='secondary' truncate>
|
|
382
|
+
{item.host}
|
|
383
|
+
</Text>
|
|
384
|
+
</VStack>
|
|
385
|
+
</button>
|
|
386
|
+
))}
|
|
387
|
+
</VStack>
|
|
388
|
+
</ScrollAreaContent>
|
|
389
|
+
</ScrollAreaViewport>
|
|
390
|
+
<ScrollAreaScrollbar />
|
|
391
|
+
</ScrollArea>
|
|
392
|
+
</div>
|
|
393
|
+
<div className='min-w-0 flex-1' data-testid='attack-request'>
|
|
394
|
+
{request ? (
|
|
395
|
+
<ScrollArea>
|
|
396
|
+
<ScrollAreaViewport>
|
|
397
|
+
<ScrollAreaContent>
|
|
398
|
+
<HStack justify='between' className='px-24 py-8'>
|
|
399
|
+
<Text size='md'>Request details</Text>
|
|
400
|
+
<DropdownMenu>
|
|
401
|
+
<DropdownMenuTrigger asChild>
|
|
402
|
+
<Button variant='outline' color='neutral' size='small'>
|
|
403
|
+
Actions
|
|
404
|
+
</Button>
|
|
405
|
+
</DropdownMenuTrigger>
|
|
406
|
+
<DropdownMenuContent>
|
|
407
|
+
<DropdownMenuItem onSelect={onMarkFalsePositive}>
|
|
408
|
+
<DropdownMenuItemText>
|
|
409
|
+
Mark as false positive
|
|
410
|
+
</DropdownMenuItemText>
|
|
411
|
+
</DropdownMenuItem>
|
|
412
|
+
<DropdownMenuSeparator />
|
|
413
|
+
<DropdownMenuItem
|
|
414
|
+
variant='destructive'
|
|
415
|
+
onSelect={onAddIpToDenylist}
|
|
416
|
+
>
|
|
417
|
+
<DropdownMenuItemText>Add IP to denylist</DropdownMenuItemText>
|
|
418
|
+
</DropdownMenuItem>
|
|
419
|
+
</DropdownMenuContent>
|
|
420
|
+
</DropdownMenu>
|
|
421
|
+
</HStack>
|
|
422
|
+
<div className='grid grid-cols-2 gap-x-8 gap-y-6 px-24 pb-8'>
|
|
423
|
+
<Attribute orientation='horizontal'>
|
|
424
|
+
<AttributeLabel>Source IP</AttributeLabel>
|
|
425
|
+
<AttributeValue>
|
|
426
|
+
<Ip>
|
|
427
|
+
<IpCountry code={attack?.country ?? 'US'} />
|
|
428
|
+
<IpAddress>{request.ip}</IpAddress>
|
|
429
|
+
</Ip>
|
|
430
|
+
</AttributeValue>
|
|
431
|
+
</Attribute>
|
|
432
|
+
<Attribute orientation='horizontal'>
|
|
433
|
+
<AttributeLabel>Request ID</AttributeLabel>
|
|
434
|
+
<AttributeValue>
|
|
435
|
+
<InlineCodeSnippet code={request.id} size='sm' />
|
|
436
|
+
</AttributeValue>
|
|
437
|
+
</Attribute>
|
|
438
|
+
<Attribute orientation='horizontal'>
|
|
439
|
+
<AttributeLabel>User</AttributeLabel>
|
|
440
|
+
<AttributeValue>{request.user}</AttributeValue>
|
|
441
|
+
</Attribute>
|
|
442
|
+
<Attribute orientation='horizontal'>
|
|
443
|
+
<AttributeLabel>Session ID</AttributeLabel>
|
|
444
|
+
<AttributeValue>
|
|
445
|
+
<InlineCodeSnippet code={request.sessionId} size='sm' />
|
|
446
|
+
</AttributeValue>
|
|
447
|
+
</Attribute>
|
|
448
|
+
<Attribute orientation='horizontal' className='col-span-2'>
|
|
449
|
+
<AttributeLabel>URI</AttributeLabel>
|
|
450
|
+
<AttributeValue>
|
|
451
|
+
<HStack gap={6}>
|
|
452
|
+
<HttpMethod method={request.method} />
|
|
453
|
+
<Text size='sm' truncate>
|
|
454
|
+
{request.path}
|
|
455
|
+
</Text>
|
|
456
|
+
</HStack>
|
|
457
|
+
</AttributeValue>
|
|
458
|
+
</Attribute>
|
|
459
|
+
</div>
|
|
460
|
+
<div className='px-24 py-4'>
|
|
461
|
+
<Separator />
|
|
462
|
+
</div>
|
|
463
|
+
<div className='px-24 py-8'>
|
|
464
|
+
<Text size='md'>Full request</Text>
|
|
465
|
+
</div>
|
|
466
|
+
<div className='px-24 pb-16'>
|
|
467
|
+
<CodeSnippetRoot
|
|
468
|
+
code={request.raw}
|
|
469
|
+
language='text'
|
|
470
|
+
maxLines={15}
|
|
471
|
+
wrapLines
|
|
472
|
+
>
|
|
473
|
+
<CodeSnippetContent>
|
|
474
|
+
<CodeSnippetLineNumbers />
|
|
475
|
+
<CodeSnippetCode />
|
|
476
|
+
</CodeSnippetContent>
|
|
477
|
+
</CodeSnippetRoot>
|
|
478
|
+
</div>
|
|
479
|
+
</ScrollAreaContent>
|
|
480
|
+
</ScrollAreaViewport>
|
|
481
|
+
<ScrollAreaScrollbar />
|
|
482
|
+
</ScrollArea>
|
|
483
|
+
) : (
|
|
484
|
+
<div className='flex h-full items-center justify-center'>
|
|
485
|
+
<Text size='sm' color='secondary'>
|
|
486
|
+
Select a request to view details
|
|
487
|
+
</Text>
|
|
488
|
+
</div>
|
|
489
|
+
)}
|
|
490
|
+
</div>
|
|
491
|
+
</div>
|
|
492
|
+
</div>
|
|
493
|
+
)}
|
|
494
|
+
</DrawerContent>
|
|
495
|
+
</Drawer>
|
|
496
|
+
</Page>
|
|
497
|
+
);
|
|
498
|
+
};
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
The header: title, summary line, copy link, tabs.
|
|
502
|
+
|
|
503
|
+
The header is two lines: a truncated `Heading` with the event name, then the summary — status
|
|
504
|
+
`Badge`, then counts in secondary text split by middle dots. One icon button sits before the
|
|
505
|
+
built-in close X. The tabs follow the header as their own strip, with a count `Badge`.
|
|
506
|
+
|
|
507
|
+
```tsx story=Header
|
|
508
|
+
import { useState } from 'react';
|
|
509
|
+
import { Badge } from '@wallarm-org/design-system/Badge';
|
|
510
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
511
|
+
import { Drawer, DrawerContent, DrawerHeader, DrawerTrigger } from '@wallarm-org/design-system/Drawer';
|
|
512
|
+
import { Heading } from '@wallarm-org/design-system/Heading';
|
|
513
|
+
import { Link } from '@wallarm-org/design-system/icons';
|
|
514
|
+
import { HStack, VStack } from '@wallarm-org/design-system/Stack';
|
|
515
|
+
import { Tabs, TabsList, TabsTrigger } from '@wallarm-org/design-system/Tabs';
|
|
516
|
+
import { Text } from '@wallarm-org/design-system/Text';
|
|
517
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '@wallarm-org/design-system/Tooltip';
|
|
518
|
+
|
|
519
|
+
export const Header = () => {
|
|
520
|
+
const [tab, setTab] = useState('overview');
|
|
521
|
+
|
|
522
|
+
const handleCopyLink = () => onCopyLink(RCE);
|
|
523
|
+
|
|
524
|
+
return (
|
|
525
|
+
<Drawer width={1064} data-testid='attack-drawer'>
|
|
526
|
+
<DrawerTrigger asChild>
|
|
527
|
+
<Button variant='outline' color='neutral'>
|
|
528
|
+
View attack
|
|
529
|
+
</Button>
|
|
530
|
+
</DrawerTrigger>
|
|
531
|
+
<DrawerContent>
|
|
532
|
+
<DrawerHeader>
|
|
533
|
+
<HStack align='start' justify='between' gap={16} fullWidth className='min-w-0'>
|
|
534
|
+
<VStack gap={4} className='min-w-0' data-testid='attack-summary'>
|
|
535
|
+
<Heading as='h2' size='xl' weight='medium' truncate>
|
|
536
|
+
{RCE.name}
|
|
537
|
+
</Heading>
|
|
538
|
+
<HStack gap={4} align='center'>
|
|
539
|
+
<Badge variant='dotted' type='secondary' size='medium' color='amber'>
|
|
540
|
+
{RCE.status}
|
|
541
|
+
</Badge>
|
|
542
|
+
<Text size='xs' color='secondary'>
|
|
543
|
+
·
|
|
544
|
+
</Text>
|
|
545
|
+
<Text size='xs' color='secondary'>
|
|
546
|
+
{RCE.blocked}/{RCE.total} blocked
|
|
547
|
+
</Text>
|
|
548
|
+
<Text size='xs' color='secondary'>
|
|
549
|
+
·
|
|
550
|
+
</Text>
|
|
551
|
+
<Text size='xs' color='secondary'>
|
|
552
|
+
{RCE.ips.length} IPs across 1 country
|
|
553
|
+
</Text>
|
|
554
|
+
</HStack>
|
|
555
|
+
</VStack>
|
|
556
|
+
<Tooltip>
|
|
557
|
+
<TooltipTrigger asChild>
|
|
558
|
+
<Button
|
|
559
|
+
variant='ghost'
|
|
560
|
+
color='neutral'
|
|
561
|
+
size='small'
|
|
562
|
+
aria-label='Copy link'
|
|
563
|
+
onClick={handleCopyLink}
|
|
564
|
+
>
|
|
565
|
+
<Link />
|
|
566
|
+
</Button>
|
|
567
|
+
</TooltipTrigger>
|
|
568
|
+
<TooltipContent>Copy link</TooltipContent>
|
|
569
|
+
</Tooltip>
|
|
570
|
+
</HStack>
|
|
571
|
+
</DrawerHeader>
|
|
572
|
+
<Tabs value={tab} onChange={setTab}>
|
|
573
|
+
<TabsList>
|
|
574
|
+
<TabsTrigger value='overview'>Overview</TabsTrigger>
|
|
575
|
+
<TabsTrigger value='requests'>
|
|
576
|
+
Requests
|
|
577
|
+
<Badge type='secondary' color='slate' size='medium' className='ml-4'>
|
|
578
|
+
{RCE.total}
|
|
579
|
+
</Badge>
|
|
580
|
+
</TabsTrigger>
|
|
581
|
+
</TabsList>
|
|
582
|
+
</Tabs>
|
|
583
|
+
</DrawerContent>
|
|
584
|
+
</Drawer>
|
|
585
|
+
);
|
|
586
|
+
};
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
Overview: the attribute card, the timeline and chart cards.
|
|
590
|
+
|
|
591
|
+
Overview: the attributes sit in one bordered card, two columns, with the long list (IPs) across
|
|
592
|
+
both. Then the full-width timeline, then chart cards two per row.
|
|
593
|
+
|
|
594
|
+
```tsx story=OverviewTab
|
|
595
|
+
import { Attribute, AttributeLabel, AttributeValue } from '@wallarm-org/design-system/Attribute';
|
|
596
|
+
import { Badge } from '@wallarm-org/design-system/Badge';
|
|
597
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
598
|
+
import { Drawer, DrawerBody, DrawerContent, DrawerHeader, DrawerTrigger } from '@wallarm-org/design-system/Drawer';
|
|
599
|
+
import { FormatDateTime } from '@wallarm-org/design-system/FormatDateTime';
|
|
600
|
+
import { Heading } from '@wallarm-org/design-system/Heading';
|
|
601
|
+
import { Ip, IpAddress, IpCountry } from '@wallarm-org/design-system/Ip';
|
|
602
|
+
import { BarList, BarListBar, BarListItem, BarListLabel, BarListPercent, BarListValue, Chart, ChartHeader, ChartTitle, LegendDot, LineChart, LineChartBody, LineChartGrid, LineChartLine, LineChartTooltip, LineChartXAxis, LineChartYAxis, PieChart, PieChartCenter, PieChartCenterLabel, PieChartCenterValue, PieChartDonut, PieChartLegend, PieChartLegendItem, PieChartLegendPercent, PieChartLegendValue, useChartTimeFormatters } from '@wallarm-org/design-system/SimpleCharts';
|
|
603
|
+
import { HStack, VStack } from '@wallarm-org/design-system/Stack';
|
|
604
|
+
|
|
605
|
+
export const OverviewTab = () => {
|
|
606
|
+
const { formatHour, formatHourWithTimezone } = useChartTimeFormatters();
|
|
607
|
+
|
|
608
|
+
return (
|
|
609
|
+
<Drawer width={1064} data-testid='attack-drawer'>
|
|
610
|
+
<DrawerTrigger asChild>
|
|
611
|
+
<Button variant='outline' color='neutral'>
|
|
612
|
+
View attack
|
|
613
|
+
</Button>
|
|
614
|
+
</DrawerTrigger>
|
|
615
|
+
<DrawerContent>
|
|
616
|
+
<DrawerHeader>
|
|
617
|
+
<Heading as='h2' size='xl' weight='medium' truncate>
|
|
618
|
+
{RCE.name}
|
|
619
|
+
</Heading>
|
|
620
|
+
</DrawerHeader>
|
|
621
|
+
<DrawerBody>
|
|
622
|
+
<VStack gap={12} className='py-16' data-testid='attack-overview'>
|
|
623
|
+
<div className='grid grid-cols-2 gap-x-8 gap-y-16 rounded-8 border border-border-primary-light p-16'>
|
|
624
|
+
<Attribute>
|
|
625
|
+
<AttributeLabel>Status</AttributeLabel>
|
|
626
|
+
<AttributeValue>
|
|
627
|
+
<Badge variant='dotted' type='secondary' size='medium' color='amber'>
|
|
628
|
+
{RCE.status}
|
|
629
|
+
</Badge>
|
|
630
|
+
</AttributeValue>
|
|
631
|
+
</Attribute>
|
|
632
|
+
<Attribute>
|
|
633
|
+
<AttributeLabel>First seen</AttributeLabel>
|
|
634
|
+
<AttributeValue>
|
|
635
|
+
<FormatDateTime value={RCE.firstSeen} format='datetime' layout='inline' />
|
|
636
|
+
</AttributeValue>
|
|
637
|
+
</Attribute>
|
|
638
|
+
<Attribute>
|
|
639
|
+
<AttributeLabel>Attack type</AttributeLabel>
|
|
640
|
+
<AttributeValue>
|
|
641
|
+
<Badge type='secondary' color='slate' size='medium'>
|
|
642
|
+
{RCE.type}
|
|
643
|
+
</Badge>
|
|
644
|
+
</AttributeValue>
|
|
645
|
+
</Attribute>
|
|
646
|
+
<Attribute>
|
|
647
|
+
<AttributeLabel>Last seen</AttributeLabel>
|
|
648
|
+
<AttributeValue>
|
|
649
|
+
<FormatDateTime value={RCE.lastSeen} format='datetime' layout='inline' />
|
|
650
|
+
</AttributeValue>
|
|
651
|
+
</Attribute>
|
|
652
|
+
<Attribute>
|
|
653
|
+
<AttributeLabel>Sessions</AttributeLabel>
|
|
654
|
+
<AttributeValue>{formatCount(RCE.sessions)} sessions</AttributeValue>
|
|
655
|
+
</Attribute>
|
|
656
|
+
<Attribute>
|
|
657
|
+
<AttributeLabel>Users</AttributeLabel>
|
|
658
|
+
<AttributeValue>{RCE.users[0]?.name}</AttributeValue>
|
|
659
|
+
</Attribute>
|
|
660
|
+
<Attribute className='col-span-2'>
|
|
661
|
+
<AttributeLabel>IPs</AttributeLabel>
|
|
662
|
+
<AttributeValue>
|
|
663
|
+
<HStack gap={8}>
|
|
664
|
+
{RCE.ips.map(ip => (
|
|
665
|
+
<Ip key={ip.name}>
|
|
666
|
+
<IpCountry code={RCE.country} />
|
|
667
|
+
<IpAddress>{ip.name}</IpAddress>
|
|
668
|
+
</Ip>
|
|
669
|
+
))}
|
|
670
|
+
</HStack>
|
|
671
|
+
</AttributeValue>
|
|
672
|
+
</Attribute>
|
|
673
|
+
</div>
|
|
674
|
+
<Chart>
|
|
675
|
+
<ChartHeader>
|
|
676
|
+
<ChartTitle>Timeline</ChartTitle>
|
|
677
|
+
</ChartHeader>
|
|
678
|
+
<LineChart data={TIMELINE} series={TIMELINE_SERIES} xKey='timestamp'>
|
|
679
|
+
<LineChartBody>
|
|
680
|
+
<LineChartGrid />
|
|
681
|
+
<LineChartXAxis tickFormatter={formatHour} minTickGap={48} />
|
|
682
|
+
<LineChartYAxis />
|
|
683
|
+
<LineChartLine seriesKey='requests' curve='linear' />
|
|
684
|
+
<LineChartTooltip xTickFormatter={formatHourWithTimezone} />
|
|
685
|
+
</LineChartBody>
|
|
686
|
+
</LineChart>
|
|
687
|
+
</Chart>
|
|
688
|
+
<div className='grid grid-cols-2 gap-12'>
|
|
689
|
+
<Chart>
|
|
690
|
+
<ChartHeader>
|
|
691
|
+
<ChartTitle>Top 5 hosts</ChartTitle>
|
|
692
|
+
</ChartHeader>
|
|
693
|
+
<BarList max={sumValues(RCE.hosts)}>
|
|
694
|
+
{RCE.hosts.map(row => (
|
|
695
|
+
<BarListItem key={row.name} value={row.value}>
|
|
696
|
+
<BarListBar />
|
|
697
|
+
<BarListLabel>{row.name}</BarListLabel>
|
|
698
|
+
<BarListValue>
|
|
699
|
+
<BarListPercent />
|
|
700
|
+
</BarListValue>
|
|
701
|
+
</BarListItem>
|
|
702
|
+
))}
|
|
703
|
+
</BarList>
|
|
704
|
+
</Chart>
|
|
705
|
+
<Chart>
|
|
706
|
+
<ChartHeader>
|
|
707
|
+
<ChartTitle>Status codes</ChartTitle>
|
|
708
|
+
</ChartHeader>
|
|
709
|
+
<PieChart data={RCE_STATUS_CODES} total={sumValues(RCE_STATUS_CODES)}>
|
|
710
|
+
<PieChartDonut>
|
|
711
|
+
<PieChartCenter>
|
|
712
|
+
<PieChartCenterValue>{formatCount(RCE.total)}</PieChartCenterValue>
|
|
713
|
+
<PieChartCenterLabel pluralize={{ one: 'request', other: 'requests' }} />
|
|
714
|
+
</PieChartCenter>
|
|
715
|
+
</PieChartDonut>
|
|
716
|
+
<PieChartLegend>
|
|
717
|
+
{RCE_STATUS_CODES.map(row => (
|
|
718
|
+
<PieChartLegendItem key={row.name} name={row.name}>
|
|
719
|
+
<Badge color={row.color} type='secondary' textVariant='code'>
|
|
720
|
+
{row.name}
|
|
721
|
+
</Badge>
|
|
722
|
+
<PieChartLegendValue>
|
|
723
|
+
{formatCount(row.value)}
|
|
724
|
+
<LegendDot />
|
|
725
|
+
<PieChartLegendPercent />
|
|
726
|
+
</PieChartLegendValue>
|
|
727
|
+
</PieChartLegendItem>
|
|
728
|
+
))}
|
|
729
|
+
</PieChartLegend>
|
|
730
|
+
</PieChart>
|
|
731
|
+
</Chart>
|
|
732
|
+
<Chart>
|
|
733
|
+
<ChartHeader>
|
|
734
|
+
<ChartTitle>Top 5 IPs</ChartTitle>
|
|
735
|
+
</ChartHeader>
|
|
736
|
+
<BarList max={sumValues(RCE.ips)}>
|
|
737
|
+
{RCE.ips.map(row => (
|
|
738
|
+
<BarListItem key={row.name} value={row.value}>
|
|
739
|
+
<BarListBar />
|
|
740
|
+
<BarListLabel>{row.name}</BarListLabel>
|
|
741
|
+
<BarListValue>
|
|
742
|
+
<BarListPercent />
|
|
743
|
+
</BarListValue>
|
|
744
|
+
</BarListItem>
|
|
745
|
+
))}
|
|
746
|
+
</BarList>
|
|
747
|
+
</Chart>
|
|
748
|
+
<Chart>
|
|
749
|
+
<ChartHeader>
|
|
750
|
+
<ChartTitle>Top 5 users</ChartTitle>
|
|
751
|
+
</ChartHeader>
|
|
752
|
+
<BarList max={sumValues(RCE.users)}>
|
|
753
|
+
{RCE.users.map(row => (
|
|
754
|
+
<BarListItem key={row.name} value={row.value}>
|
|
755
|
+
<BarListBar />
|
|
756
|
+
<BarListLabel>{row.name}</BarListLabel>
|
|
757
|
+
<BarListValue>
|
|
758
|
+
<BarListPercent />
|
|
759
|
+
</BarListValue>
|
|
760
|
+
</BarListItem>
|
|
761
|
+
))}
|
|
762
|
+
</BarList>
|
|
763
|
+
</Chart>
|
|
764
|
+
</div>
|
|
765
|
+
</VStack>
|
|
766
|
+
</DrawerBody>
|
|
767
|
+
</DrawerContent>
|
|
768
|
+
</Drawer>
|
|
769
|
+
);
|
|
770
|
+
};
|
|
771
|
+
```
|
|
772
|
+
|
|
773
|
+
Requests: filter bar, list and detail.
|
|
774
|
+
|
|
775
|
+
Requests: a list and a detail side by side, each scrolling on its own, so this tab takes the
|
|
776
|
+
place of `DrawerBody` instead of sitting in it. A filter bar spans both; each request is a card
|
|
777
|
+
of time and response code, attack types, method and path, host.
|
|
778
|
+
|
|
779
|
+
```tsx story=RequestsTab
|
|
780
|
+
import { type MouseEvent, useState } from 'react';
|
|
781
|
+
import { Attribute, AttributeLabel, AttributeValue } from '@wallarm-org/design-system/Attribute';
|
|
782
|
+
import { Badge } from '@wallarm-org/design-system/Badge';
|
|
783
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
784
|
+
import { CodeSnippetCode, CodeSnippetContent, CodeSnippetLineNumbers, CodeSnippetRoot, InlineCodeSnippet } from '@wallarm-org/design-system/CodeSnippet';
|
|
785
|
+
import { Drawer, DrawerContent, DrawerHeader, DrawerTrigger } from '@wallarm-org/design-system/Drawer';
|
|
786
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuItemText, DropdownMenuSeparator, DropdownMenuTrigger } from '@wallarm-org/design-system/DropdownMenu';
|
|
787
|
+
import { FilterInput } from '@wallarm-org/design-system/FilterInput';
|
|
788
|
+
import { FormatDateTime } from '@wallarm-org/design-system/FormatDateTime';
|
|
789
|
+
import { Heading } from '@wallarm-org/design-system/Heading';
|
|
790
|
+
import { HttpMethod } from '@wallarm-org/design-system/HttpMethod';
|
|
791
|
+
import { ArrowDown } from '@wallarm-org/design-system/icons';
|
|
792
|
+
import { Ip, IpAddress, IpCountry } from '@wallarm-org/design-system/Ip';
|
|
793
|
+
import { ResponseCode } from '@wallarm-org/design-system/ResponseCode';
|
|
794
|
+
import { ScrollArea, ScrollAreaContent, ScrollAreaScrollbar, ScrollAreaViewport } from '@wallarm-org/design-system/ScrollArea';
|
|
795
|
+
import { Separator } from '@wallarm-org/design-system/Separator';
|
|
796
|
+
import { HStack, VStack } from '@wallarm-org/design-system/Stack';
|
|
797
|
+
import { Text } from '@wallarm-org/design-system/Text';
|
|
798
|
+
|
|
799
|
+
export const RequestsTab = () => {
|
|
800
|
+
const [requestId, setRequestId] = useState<string | null>('req-1');
|
|
801
|
+
|
|
802
|
+
const request = REQUESTS.find(item => item.id === requestId) ?? null;
|
|
803
|
+
|
|
804
|
+
const handleSelectRequest = (event: MouseEvent<HTMLButtonElement>) =>
|
|
805
|
+
setRequestId(event.currentTarget.value);
|
|
806
|
+
|
|
807
|
+
return (
|
|
808
|
+
<Drawer width={1064} data-testid='attack-drawer'>
|
|
809
|
+
<DrawerTrigger asChild>
|
|
810
|
+
<Button variant='outline' color='neutral'>
|
|
811
|
+
View requests
|
|
812
|
+
</Button>
|
|
813
|
+
</DrawerTrigger>
|
|
814
|
+
<DrawerContent>
|
|
815
|
+
<DrawerHeader>
|
|
816
|
+
<Heading as='h2' size='xl' weight='medium' truncate>
|
|
817
|
+
{RCE.name}
|
|
818
|
+
</Heading>
|
|
819
|
+
</DrawerHeader>
|
|
820
|
+
<div className='flex min-h-0 flex-1 flex-col' data-testid='attack-requests'>
|
|
821
|
+
<HStack gap={8} className='shrink-0 border-b border-border-primary-light px-16 py-8'>
|
|
822
|
+
<div className='min-w-0 flex-1'>
|
|
823
|
+
<FilterInput placeholder='Filter requests...' />
|
|
824
|
+
</div>
|
|
825
|
+
<Button variant='ghost' color='neutral' size='small'>
|
|
826
|
+
<ArrowDown /> Date
|
|
827
|
+
</Button>
|
|
828
|
+
</HStack>
|
|
829
|
+
<div className='flex min-h-0 flex-1'>
|
|
830
|
+
<div className='w-320 shrink-0 border-r border-border-primary-light'>
|
|
831
|
+
<ScrollArea>
|
|
832
|
+
<ScrollAreaViewport>
|
|
833
|
+
<ScrollAreaContent>
|
|
834
|
+
<VStack gap={2} className='p-8' data-testid='attack-request-list'>
|
|
835
|
+
{REQUESTS.map(item => (
|
|
836
|
+
<button
|
|
837
|
+
key={item.id}
|
|
838
|
+
type='button'
|
|
839
|
+
value={item.id}
|
|
840
|
+
aria-pressed={item.id === requestId}
|
|
841
|
+
onClick={handleSelectRequest}
|
|
842
|
+
className={
|
|
843
|
+
item.id === requestId
|
|
844
|
+
? 'w-full rounded-8 bg-states-primary-default-alt p-8 text-left'
|
|
845
|
+
: 'w-full rounded-8 p-8 text-left hover:bg-states-primary-hover'
|
|
846
|
+
}
|
|
847
|
+
>
|
|
848
|
+
<VStack gap={2}>
|
|
849
|
+
<HStack gap={4}>
|
|
850
|
+
<FormatDateTime value={item.time} format='datetime' layout='inline' />
|
|
851
|
+
<div className='ml-auto'>
|
|
852
|
+
<ResponseCode code={item.status} />
|
|
853
|
+
</div>
|
|
854
|
+
</HStack>
|
|
855
|
+
<HStack gap={4}>
|
|
856
|
+
{item.attackTypes.map(type => (
|
|
857
|
+
<Badge key={type} type='secondary' color='slate' size='medium'>
|
|
858
|
+
{type}
|
|
859
|
+
</Badge>
|
|
860
|
+
))}
|
|
861
|
+
</HStack>
|
|
862
|
+
<HStack gap={4}>
|
|
863
|
+
<HttpMethod method={item.method} />
|
|
864
|
+
<Text size='xs' truncate>
|
|
865
|
+
{item.path}
|
|
866
|
+
</Text>
|
|
867
|
+
</HStack>
|
|
868
|
+
<Text size='xs' color='secondary' truncate>
|
|
869
|
+
{item.host}
|
|
870
|
+
</Text>
|
|
871
|
+
</VStack>
|
|
872
|
+
</button>
|
|
873
|
+
))}
|
|
874
|
+
</VStack>
|
|
875
|
+
</ScrollAreaContent>
|
|
876
|
+
</ScrollAreaViewport>
|
|
877
|
+
<ScrollAreaScrollbar />
|
|
878
|
+
</ScrollArea>
|
|
879
|
+
</div>
|
|
880
|
+
<div className='min-w-0 flex-1' data-testid='attack-request'>
|
|
881
|
+
{request && (
|
|
882
|
+
<ScrollArea>
|
|
883
|
+
<ScrollAreaViewport>
|
|
884
|
+
<ScrollAreaContent>
|
|
885
|
+
<HStack justify='between' className='px-24 py-8'>
|
|
886
|
+
<Text size='md'>Request details</Text>
|
|
887
|
+
<DropdownMenu>
|
|
888
|
+
<DropdownMenuTrigger asChild>
|
|
889
|
+
<Button variant='outline' color='neutral' size='small'>
|
|
890
|
+
Actions
|
|
891
|
+
</Button>
|
|
892
|
+
</DropdownMenuTrigger>
|
|
893
|
+
<DropdownMenuContent>
|
|
894
|
+
<DropdownMenuItem onSelect={onMarkFalsePositive}>
|
|
895
|
+
<DropdownMenuItemText>Mark as false positive</DropdownMenuItemText>
|
|
896
|
+
</DropdownMenuItem>
|
|
897
|
+
<DropdownMenuSeparator />
|
|
898
|
+
<DropdownMenuItem variant='destructive' onSelect={onAddIpToDenylist}>
|
|
899
|
+
<DropdownMenuItemText>Add IP to denylist</DropdownMenuItemText>
|
|
900
|
+
</DropdownMenuItem>
|
|
901
|
+
</DropdownMenuContent>
|
|
902
|
+
</DropdownMenu>
|
|
903
|
+
</HStack>
|
|
904
|
+
<div className='grid grid-cols-2 gap-x-8 gap-y-6 px-24 pb-8'>
|
|
905
|
+
<Attribute orientation='horizontal'>
|
|
906
|
+
<AttributeLabel>Source IP</AttributeLabel>
|
|
907
|
+
<AttributeValue>
|
|
908
|
+
<Ip>
|
|
909
|
+
<IpCountry code={RCE.country} />
|
|
910
|
+
<IpAddress>{request.ip}</IpAddress>
|
|
911
|
+
</Ip>
|
|
912
|
+
</AttributeValue>
|
|
913
|
+
</Attribute>
|
|
914
|
+
<Attribute orientation='horizontal'>
|
|
915
|
+
<AttributeLabel>Request ID</AttributeLabel>
|
|
916
|
+
<AttributeValue>
|
|
917
|
+
<InlineCodeSnippet code={request.id} size='sm' />
|
|
918
|
+
</AttributeValue>
|
|
919
|
+
</Attribute>
|
|
920
|
+
<Attribute orientation='horizontal'>
|
|
921
|
+
<AttributeLabel>User</AttributeLabel>
|
|
922
|
+
<AttributeValue>{request.user}</AttributeValue>
|
|
923
|
+
</Attribute>
|
|
924
|
+
<Attribute orientation='horizontal'>
|
|
925
|
+
<AttributeLabel>Session ID</AttributeLabel>
|
|
926
|
+
<AttributeValue>
|
|
927
|
+
<InlineCodeSnippet code={request.sessionId} size='sm' />
|
|
928
|
+
</AttributeValue>
|
|
929
|
+
</Attribute>
|
|
930
|
+
<Attribute orientation='horizontal' className='col-span-2'>
|
|
931
|
+
<AttributeLabel>URI</AttributeLabel>
|
|
932
|
+
<AttributeValue>
|
|
933
|
+
<HStack gap={6}>
|
|
934
|
+
<HttpMethod method={request.method} />
|
|
935
|
+
<Text size='sm' truncate>
|
|
936
|
+
{request.path}
|
|
937
|
+
</Text>
|
|
938
|
+
</HStack>
|
|
939
|
+
</AttributeValue>
|
|
940
|
+
</Attribute>
|
|
941
|
+
</div>
|
|
942
|
+
<div className='px-24 py-4'>
|
|
943
|
+
<Separator />
|
|
944
|
+
</div>
|
|
945
|
+
<div className='px-24 py-8'>
|
|
946
|
+
<Text size='md'>Attack</Text>
|
|
947
|
+
</div>
|
|
948
|
+
<div className='grid grid-cols-1 gap-y-6 px-24 pb-8'>
|
|
949
|
+
<Attribute orientation='horizontal'>
|
|
950
|
+
<AttributeLabel>Parameter</AttributeLabel>
|
|
951
|
+
<AttributeValue>
|
|
952
|
+
<InlineCodeSnippet code={request.parameter} size='sm' />
|
|
953
|
+
</AttributeValue>
|
|
954
|
+
</Attribute>
|
|
955
|
+
<Attribute orientation='horizontal'>
|
|
956
|
+
<AttributeLabel>Payload</AttributeLabel>
|
|
957
|
+
<AttributeValue>
|
|
958
|
+
<InlineCodeSnippet code={request.payload} size='sm' />
|
|
959
|
+
</AttributeValue>
|
|
960
|
+
</Attribute>
|
|
961
|
+
</div>
|
|
962
|
+
<div className='px-24 py-4'>
|
|
963
|
+
<Separator />
|
|
964
|
+
</div>
|
|
965
|
+
<div className='px-24 py-8'>
|
|
966
|
+
<Text size='md'>Full request</Text>
|
|
967
|
+
</div>
|
|
968
|
+
<div className='px-24 pb-16'>
|
|
969
|
+
<CodeSnippetRoot code={request.raw} language='text' maxLines={15} wrapLines>
|
|
970
|
+
<CodeSnippetContent>
|
|
971
|
+
<CodeSnippetLineNumbers />
|
|
972
|
+
<CodeSnippetCode />
|
|
973
|
+
</CodeSnippetContent>
|
|
974
|
+
</CodeSnippetRoot>
|
|
975
|
+
</div>
|
|
976
|
+
</ScrollAreaContent>
|
|
977
|
+
</ScrollAreaViewport>
|
|
978
|
+
<ScrollAreaScrollbar />
|
|
979
|
+
</ScrollArea>
|
|
980
|
+
)}
|
|
981
|
+
</div>
|
|
982
|
+
</div>
|
|
983
|
+
</div>
|
|
984
|
+
</DrawerContent>
|
|
985
|
+
</Drawer>
|
|
986
|
+
);
|
|
987
|
+
};
|
|
988
|
+
```
|
|
989
|
+
|
|
990
|
+
## States
|
|
991
|
+
|
|
992
|
+
| State | Show | Example component |
|
|
993
|
+
| --- | --- | --- |
|
|
994
|
+
| Event loading | `loading` on each `Attribute`; `LineChartEmpty` with no text; `BarListSkeleton`, `PieChartSkeleton`. Card titles stay | `Chart` |
|
|
995
|
+
| No data for a card | `ChartEmpty` inside the card | `Chart` |
|
|
996
|
+
| Nothing selected | Secondary text centred in the detail pane | `Text` |
|
|
997
|
+
| A list failed to load | `EmptyState` in place of the list, with "Try again" | `EmptyState` |
|
|
998
|
+
|
|
999
|
+
Loading.
|
|
1000
|
+
|
|
1001
|
+
Still loading: attributes show their skeletons and every card keeps its title over a skeleton of
|
|
1002
|
+
its own shape. No `Loader` over the body.
|
|
1003
|
+
|
|
1004
|
+
```tsx story=Loading
|
|
1005
|
+
import { Attribute, AttributeLabel, AttributeValue } from '@wallarm-org/design-system/Attribute';
|
|
1006
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
1007
|
+
import { Drawer, DrawerBody, DrawerContent, DrawerHeader, DrawerTrigger } from '@wallarm-org/design-system/Drawer';
|
|
1008
|
+
import { Heading } from '@wallarm-org/design-system/Heading';
|
|
1009
|
+
import { BarListSkeleton, Chart, ChartHeader, ChartTitle, LineChartEmpty, PieChartSkeleton } from '@wallarm-org/design-system/SimpleCharts';
|
|
1010
|
+
import { VStack } from '@wallarm-org/design-system/Stack';
|
|
1011
|
+
|
|
1012
|
+
export const Loading = () => (
|
|
1013
|
+
<Drawer width={1064} data-testid='attack-drawer'>
|
|
1014
|
+
<DrawerTrigger asChild>
|
|
1015
|
+
<Button variant='outline' color='neutral'>
|
|
1016
|
+
View attack
|
|
1017
|
+
</Button>
|
|
1018
|
+
</DrawerTrigger>
|
|
1019
|
+
<DrawerContent>
|
|
1020
|
+
<DrawerHeader>
|
|
1021
|
+
<Heading as='h2' size='xl' weight='medium' truncate>
|
|
1022
|
+
{RCE.name}
|
|
1023
|
+
</Heading>
|
|
1024
|
+
</DrawerHeader>
|
|
1025
|
+
<DrawerBody>
|
|
1026
|
+
<VStack gap={12} className='py-16' data-testid='attack-loading'>
|
|
1027
|
+
<div className='grid grid-cols-2 gap-x-8 gap-y-16 rounded-8 border border-border-primary-light p-16'>
|
|
1028
|
+
<Attribute loading>
|
|
1029
|
+
<AttributeLabel>Status</AttributeLabel>
|
|
1030
|
+
<AttributeValue />
|
|
1031
|
+
</Attribute>
|
|
1032
|
+
<Attribute loading>
|
|
1033
|
+
<AttributeLabel>First seen</AttributeLabel>
|
|
1034
|
+
<AttributeValue />
|
|
1035
|
+
</Attribute>
|
|
1036
|
+
<Attribute loading>
|
|
1037
|
+
<AttributeLabel>Attack type</AttributeLabel>
|
|
1038
|
+
<AttributeValue />
|
|
1039
|
+
</Attribute>
|
|
1040
|
+
<Attribute loading>
|
|
1041
|
+
<AttributeLabel>Last seen</AttributeLabel>
|
|
1042
|
+
<AttributeValue />
|
|
1043
|
+
</Attribute>
|
|
1044
|
+
</div>
|
|
1045
|
+
<Chart>
|
|
1046
|
+
<ChartHeader>
|
|
1047
|
+
<ChartTitle>Timeline</ChartTitle>
|
|
1048
|
+
</ChartHeader>
|
|
1049
|
+
<LineChartEmpty />
|
|
1050
|
+
</Chart>
|
|
1051
|
+
<div className='grid grid-cols-2 gap-12'>
|
|
1052
|
+
<Chart>
|
|
1053
|
+
<ChartHeader>
|
|
1054
|
+
<ChartTitle>Top 5 hosts</ChartTitle>
|
|
1055
|
+
</ChartHeader>
|
|
1056
|
+
<BarListSkeleton rows={3} />
|
|
1057
|
+
</Chart>
|
|
1058
|
+
<Chart>
|
|
1059
|
+
<ChartHeader>
|
|
1060
|
+
<ChartTitle>Status codes</ChartTitle>
|
|
1061
|
+
</ChartHeader>
|
|
1062
|
+
<PieChartSkeleton rows={3} />
|
|
1063
|
+
</Chart>
|
|
1064
|
+
</div>
|
|
1065
|
+
</VStack>
|
|
1066
|
+
</DrawerBody>
|
|
1067
|
+
</DrawerContent>
|
|
1068
|
+
</Drawer>
|
|
1069
|
+
);
|
|
1070
|
+
```
|
|
1071
|
+
|
|
1072
|
+
## What your app owns
|
|
1073
|
+
|
|
1074
|
+
| You own | The DS owns |
|
|
1075
|
+
| --- | --- |
|
|
1076
|
+
| Fetching the event, series, top N and records | Card frame, chart drawing, tooltips |
|
|
1077
|
+
| Tab state, the selected record, resets | Tabs strip, scroll areas |
|
|
1078
|
+
| List virtualisation and paging | Item styles via tokens |
|
|
1079
|
+
| The link being copied, the toast | Tooltip, button states |
|
|
1080
|
+
|
|
1081
|
+
## Related
|
|
1082
|
+
|
|
1083
|
+
- [Detail drawer](./detail-drawer.md), [Entity table](./entity-table.md)
|
|
1084
|
+
- [Filtering](./filtering.md), [Empty states](./empty-states.md)
|