diff --git a/src/components/AlertsTable.tsx b/src/components/AlertsTable.tsx index 7b74b3a..9c67595 100644 --- a/src/components/AlertsTable.tsx +++ b/src/components/AlertsTable.tsx @@ -8,6 +8,7 @@ interface AlertsTableProps { interface GroupedAlert { severity: string; title: string; + url?: string; location?: string; references?: Array<{ label: string; url: string }>; count: number; @@ -56,6 +57,7 @@ export default function AlertsTable({ alerts, className = '' }: AlertsTableProps groupedAlerts.push({ severity: alert.severity, title: alert.title, + url: alert.url, location: alert.location, references: alert.references, count: 1 @@ -70,9 +72,13 @@ export default function AlertsTable({ alerts, className = '' }: AlertsTableProps return severityOrder[alert.severity] < severityOrder[highest.severity] ? alert : highest; }).severity; + // The first alert is the representative for the group: its title, link + // and references are shown for the collapsed row. groupedAlerts.push({ severity: highestSeverity, title: alerts[0].title, + url: alerts[0].url, + references: alerts[0].references, location, count: alerts.length }); @@ -93,7 +99,18 @@ export default function AlertsTable({ alerts, className = '' }: AlertsTableProps {alert.severity} - {alert.title} + {alert.url ? ( + + {alert.title} + + ) : ( + alert.title + )} {alert.location && ( diff --git a/src/stories/components/AlertsTable.stories.tsx b/src/stories/components/AlertsTable.stories.tsx index 5745c1e..8e38591 100644 --- a/src/stories/components/AlertsTable.stories.tsx +++ b/src/stories/components/AlertsTable.stories.tsx @@ -69,3 +69,36 @@ export const Mixed: Story = { ], }, }; + +export const LinkedAlerts: Story = { + args: { + alerts: [ + { + type: 'dependabot', + severity: 'critical', + title: 'Vulnerable package: minimist@1.2.0', + url: 'https://github.com/flanksource/mission-control/security/dependabot/1', + }, + { + type: 'code-scanning', + severity: 'high', + title: 'Bad redirect check', + url: 'https://github.com/flanksource/mission-control/security/code-scanning/124', + location: 'go/bad-redirect-check', + }, + { + type: 'code-scanning', + severity: 'high', + title: 'Bad redirect check', + url: 'https://github.com/flanksource/mission-control/security/code-scanning/125', + location: 'go/bad-redirect-check', + }, + { + type: 'secret-scanning', + severity: 'high', + title: 'Exposed GitHub token', + url: 'https://github.com/flanksource/mission-control/security/secret-scanning/3', + }, + ], + }, +};