The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Updated UI for Security Center (#72518)
Sébastienf32612daa756
diff --git a/e2e/test/scenarios/admin-2/security-center.cy.spec.ts b/e2e/test/scenarios/admin-2/security-center.cy.spec.tsindex d7fe5df2098..91fb9e747fc 100644--- a/e2e/test/scenarios/admin-2/security-center.cy.spec.ts+++ b/e2e/test/scenarios/admin-2/security-center.cy.spec.ts@@ -56,229 +56,166 @@ describe("scenarios > admin > security center", { tags: "@EE" }, () => {H.activateToken("pro-self-hosted");});- describe("feature gating", () => {- it("should not show security center without a valid token", () => {- H.deleteToken();- cy.visit("/admin/security-center");- cy.findByTestId("security-center-page").should("not.exist");- });+ it("should gate the security center behind a valid token and show empty state without advisories", () => {+ // Without a token the page should not render+ H.deleteToken();+ cy.visit("/admin/security-center");+ cy.findByTestId("security-center-page").should("not.exist");- it("should render the security center page with a valid token", () => {- seedAllAdvisories();- cy.visit("/admin/security-center");- securityCenterContent().within(() => {- cy.findByText("Security Center").should("be.visible");- cy.findByTestId("current-version").should("be.visible");- });+ // Re-activate the token (no advisories seeded) → empty state+ H.activateToken("pro-self-hosted");+ cy.visit("/admin/security-center");+ securityCenterContent().within(() => {+ cy.findByText(/No known security issues/).should("be.visible");});});- describe("advisory list", () => {- beforeEach(() => {- seedAllAdvisories();- cy.visit("/admin/security-center");- securityCenterContent().within(() => {- cy.findByText("Security Center").should("be.visible");- });- });-- it("should display advisory cards with severity and affected status", () => {- cy.findAllByTestId("advisory-card").should("have.length", 3);- securityCenterContent().within(() => {- cy.findByText("Critical RCE vulnerability").should("be.visible");- cy.findByText("SQL injection in query builder").should("be.visible");- cy.findByText("SSRF in GeoJSON endpoint")- .scrollIntoView()- .should("be.visible");- });- });-- it("should sort advisories with affected first, then by severity", () => {- cy.findAllByTestId("advisory-card")- .first()- .within(() => {- cy.findByText("Critical RCE vulnerability").should("exist");- cy.findByTestId("affected-status").should("have.text", "Affected");- });- });-- it("should show empty state when no advisories exist", () => {- // Don't seed any — restore already cleared them- H.restore();- cy.signInAsAdmin();- H.activateToken("pro-self-hosted");- cy.visit("/admin/security-center");- securityCenterContent().within(() => {- cy.findByText(/up to date/).should("be.visible");- });- });+ it("should display advisory cards sorted by affected status and severity, and support filtering", () => {+ seedAllAdvisories();+ cy.visit("/admin/security-center");+ securityCenterContent().within(() => {+ cy.findByText("Security Center").should("be.visible");+ cy.findByTestId("current-version").should("be.visible");+ });++ // All three advisory cards are visible+ cy.findAllByTestId("advisory-card").should("have.length", 3);+ securityCenterContent().within(() => {+ cy.findByText("Critical RCE vulnerability").should("be.visible");+ cy.findByText("SQL injection in query builder")+ .scrollIntoView()+ .should("be.visible");+ cy.findByText("SSRF in GeoJSON endpoint")+ .scrollIntoView()+ .should("be.visible");+ });++ // Affected/critical advisory is sorted first+ cy.findAllByTestId("advisory-card")+ .first()+ .within(() => {+ cy.findByText("Critical RCE vulnerability").should("exist");+ });++ // Filter by severity+ cy.findByTestId("severity-filter").click();+ cy.findByRole("option", { name: "Critical" }).click();+ cy.findAllByTestId("advisory-card").should("have.length", 1);+ securityCenterContent().within(() => {+ cy.findByText("Critical RCE vulnerability").should("be.visible");+ });++ // Clear severity filter (re-select to deselect)+ cy.findByTestId("severity-filter").click();+ cy.findByRole("option", { name: "All severities" }).click();+ cy.findAllByTestId("advisory-card").should("have.length", 3);});- describe("filtering", () => {- beforeEach(() => {- seedAllAdvisories();- cy.visit("/admin/security-center");- securityCenterContent().within(() => {- cy.findByText("Security Center").should("be.visible");- });- });-- it("should filter by severity", () => {- cy.findByTestId("severity-filter").click();- cy.findByRole("option", { name: "Critical" }).click();- cy.findAllByTestId("advisory-card").should("have.length", 1);- securityCenterContent().within(() => {- cy.findByText("Critical RCE vulnerability").should("be.visible");- });- });-- it("should filter by affected status", () => {- cy.findByTestId("status-filter").click();- cy.findByRole("option", { name: "Affected" }).click();- cy.findAllByTestId("advisory-card").should("have.length", 1);- securityCenterContent().within(() => {- cy.findByText("Critical RCE vulnerability").should("be.visible");- });- });-- it("should toggle show dismissed", () => {- // Dismiss the critical advisory first- cy.findAllByTestId("advisory-card")- .first()- .findByTestId("acknowledge-button")- .click();-- // It should be hidden by default (dismissed are hidden)- cy.findAllByTestId("advisory-card").should("have.length", 2);-- // Show dismissed- cy.findByTestId("show-acknowledged-filter").click();- cy.findAllByTestId("advisory-card").should("have.length", 3);- });+ it("should dismiss individual advisories, dismiss all, and toggle dismissed visibility", () => {+ seedAllAdvisories();+ cy.visit("/admin/security-center");+ securityCenterContent().within(() => {+ cy.findByText("Security Center").should("be.visible");+ });++ cy.intercept("POST", "/api/ee/security-center/*/acknowledge").as(+ "acknowledge",+ );++ // Dismiss the first advisory+ cy.findAllByTestId("advisory-card")+ .first()+ .findByTestId("acknowledge-button")+ .click();+ cy.wait("@acknowledge");++ // Dismissed card is hidden by default+ cy.findAllByTestId("advisory-card").should("have.length", 2);++ // Toggle to show dismissed — card reappears with "Dismissed" badge+ cy.findByTestId("show-acknowledged-filter").click();+ cy.findAllByTestId("advisory-card").should("have.length", 3);+ cy.findAllByTestId("advisory-card")+ .first()+ .findByTestId("acknowledge-button")+ .should("have.text", "Dismissed");++ // Hide dismissed again before testing "Dismiss all"+ cy.findByTestId("show-acknowledged-filter").click();+ cy.findAllByTestId("advisory-card").should("have.length", 2);++ // Dismiss all non-affecting advisories+ cy.intercept("POST", "/api/ee/security-center/acknowledge").as(+ "acknowledgeAll",+ );+ securityCenterContent().findByText("Dismiss all").click();+ cy.wait("@acknowledgeAll").then(({ request }) => {+ expect(request.body.advisory_ids).to.include("TEST-002");+ expect(request.body.advisory_ids).to.include("TEST-003");+ expect(request.body.advisory_ids).to.not.include("TEST-001");+ });++ // "Dismiss all" button disappears when no non-affecting advisories remain+ securityCenterContent().findByText("Dismiss all").should("not.exist");});- describe("dismiss advisory", () => {- beforeEach(() => {- seedAllAdvisories();- cy.visit("/admin/security-center");- securityCenterContent().within(() => {- cy.findByText("Security Center").should("be.visible");- });- });-- it("should dismiss an advisory and show the badge", () => {- cy.intercept("POST", "/api/ee/security-center/*/acknowledge").as(- "acknowledge",- );-- cy.findAllByTestId("advisory-card")- .first()- .findByTestId("acknowledge-button")- .click();-- cy.wait("@acknowledge");+ it("should show nav item with badge and navigate to the security center", () => {+ seedAllAdvisories();+ cy.visit("/admin");- cy.findByTestId("show-acknowledged-filter").click();- cy.findAllByTestId("advisory-card")- .first()- .findByTestId("acknowledged-badge")- .should("have.text", "Dismissed");+ // Nav item and badge are visible+ cy.findByTestId("admin-navbar").within(() => {+ cy.findByText("Security").should("be.visible");});+ cy.findByTestId("security-center-badge").should("be.visible");- it("should hide dismissed advisories by default", () => {- cy.findAllByTestId("advisory-card")- .first()- .findByTestId("acknowledge-button")- .click();-- // After dismissing, the card should disappear- cy.findAllByTestId("advisory-card").should("have.length", 2);+ // Clicking navigates to security center+ cy.findByTestId("admin-navbar").within(() => {+ cy.findByText("Security").click();});- });-- describe("navigation and badge", () => {- it("should show Security nav item with badge when active advisories exist", () => {- seedAllAdvisories();- cy.visit("/admin/security-center");- cy.findByTestId("admin-navbar").within(() => {- cy.findByText("Security").should("be.visible");- });- cy.findByTestId("security-center-badge").should("be.visible");- });-- it("should navigate to security center when clicking nav item", () => {- seedAllAdvisories();- cy.visit("/admin");- cy.findByTestId("admin-navbar").within(() => {- cy.findByText("Security").click();- });- cy.url().should("include", "/admin/security-center");- securityCenterContent().within(() => {- cy.findByText("Security Center").should("be.visible");- });+ cy.url().should("include", "/admin/security-center");+ securityCenterContent().within(() => {+ cy.findByText("Security Center").should("be.visible");});});- describe("notification settings modal", () => {- beforeEach(() => {- seedAllAdvisories();- cy.visit("/admin/security-center");- securityCenterContent().within(() => {- cy.findByText("Security Center").should("be.visible");- });+ it("should open notification settings modal, show Slack state, save settings, and default admin toggle with SMTP", () => {+ seedAllAdvisories();+ H.setupSMTP();+ cy.visit("/admin/security-center");+ securityCenterContent().within(() => {+ cy.findByText("Security Center").should("be.visible");});- it("should open the notification settings modal", () => {- cy.findByTestId("notification-config-toggle").click();- H.modal().within(() => {- cy.findByText("Notification settings").should("be.visible");- cy.findByText("Email").should("be.visible");- cy.findByText("Slack").should("be.visible");- });- });-- it("should show send-to-all-admins toggle checked by default", () => {- H.setupSMTP();- cy.visit("/admin/security-center");- securityCenterContent().within(() => {- cy.findByText("Security Center").should("be.visible");- });- cy.findByTestId("notification-config-toggle").click();- cy.findByTestId("send-to-admins-toggle").should("be.checked");- });-- it("should show Slack not configured state", () => {- cy.findByTestId("notification-config-toggle").click();- H.modal().within(() => {- cy.findByText("Slack is not configured.").should("be.visible");- cy.findByText("Set up Slack").should("be.visible");- });+ // Open modal and verify contents+ cy.findByTestId("notification-config-toggle").click();+ H.modal().within(() => {+ cy.findByText("Notification settings").should("be.visible");+ cy.findByText("Email").should("be.visible");+ cy.findByText("Slack").should("be.visible");+ cy.findByText("Slack is not configured.").should("be.visible");+ cy.findByText("Set up Slack").should("be.visible");});- it("should save notification settings", () => {- cy.intercept("PUT", "/api/setting").as("saveSettings");-- cy.findByTestId("notification-config-toggle").click();- cy.findByRole("button", { name: "Save" }).click();+ // Send-to-all-admins toggle is checked by default when SMTP is configured+ cy.findByTestId("send-to-admins-toggle").should("be.checked");- cy.wait("@saveSettings").then(({ request }) => {- expect(request.body).to.have.property(- "security-center-email-recipients",- );- });+ // Save settings+ cy.intercept("PUT", "/api/setting").as("saveSettings");+ cy.findByRole("button", { name: "Save" }).click();+ cy.wait("@saveSettings").then(({ request }) => {+ expect(request.body).to.have.property("security-center-email-recipients");});});- describe("sync", () => {- it("should trigger sync when clicking Check now", () => {- cy.intercept("POST", "/api/ee/security-center/sync").as("sync");- cy.visit("/admin/security-center");- securityCenterContent().within(() => {- cy.findByText("Security Center").should("be.visible");- });-- cy.findByTestId("sync-advisories").click();- cy.wait("@sync");+ it("should trigger sync when clicking Check now", () => {+ cy.intercept("POST", "/api/ee/security-center/sync").as("sync");+ cy.visit("/admin/security-center");+ securityCenterContent().within(() => {+ cy.findByText("Security Center").should("be.visible");});++ cy.findByTestId("sync-advisories").click();+ cy.wait("@sync");});});diff --git a/enterprise/backend/src/metabase_enterprise/security_center/api.clj b/enterprise/backend/src/metabase_enterprise/security_center/api.cljindex 028361b1150..552bec4f5f1 100644--- a/enterprise/backend/src/metabase_enterprise/security_center/api.clj+++ b/enterprise/backend/src/metabase_enterprise/security_center/api.clj@@ -85,6 +85,16 @@(api/check-404 advisory)(acknowledge-response (security-advisory/acknowledge! advisory api/*current-user-id*))))+(api.macros/defendpoint :post "/acknowledge" :- [:sequential AcknowledgeResponse]+ "Acknowledge multiple security advisories. Skips already-acknowledged advisories."+ [_route-params+ _query-params+ {:keys [advisory_ids]} :- [:map [:advisory_ids [:sequential ms/NonBlankString]]]]+ (api/check-superuser)+ (api/check (seq advisory_ids) [400 "advisory_ids must be a non-empty array"])+ (mapv acknowledge-response+ (security-advisory/acknowledge-many! advisory_ids api/*current-user-id*)))+(defonce ^:private ^ExecutorService sync-executor(ThreadPoolExecutor. 1 1 0 TimeUnit/MILLISECONDS(SynchronousQueue.) (ThreadPoolExecutor$AbortPolicy.)))diff --git a/enterprise/backend/src/metabase_enterprise/security_center/models/security_advisory.clj b/enterprise/backend/src/metabase_enterprise/security_center/models/security_advisory.cljindex e835609c860..a7ec4348d58 100644--- a/enterprise/backend/src/metabase_enterprise/security_center/models/security_advisory.clj+++ b/enterprise/backend/src/metabase_enterprise/security_center/models/security_advisory.clj@@ -54,3 +54,10 @@:event_detail (name (:severity advisory))})(-> (t2/select-one :model/SecurityAdvisory :id (:id advisory))(t2/hydrate :acknowledged_by_user))))++(defn acknowledge-many!+ "Acknowledge multiple security advisories by their advisory_id strings. Skips already-acknowledged+ advisories. Returns a sequence of updated advisories with `:acknowledged_by` hydrated."+ [advisory-ids user-id]+ (let [advisories (t2/select :model/SecurityAdvisory :advisory_id [:in (set advisory-ids)] :acknowledged_at nil)]+ (mapv #(acknowledge! % user-id) advisories)))diff --git a/enterprise/backend/test/metabase_enterprise/security_center/api_test.clj b/enterprise/backend/test/metabase_enterprise/security_center/api_test.cljindex 582fbdfa92f..6de3c81ba0e 100644--- a/enterprise/backend/test/metabase_enterprise/security_center/api_test.clj+++ b/enterprise/backend/test/metabase_enterprise/security_center/api_test.clj@@ -108,6 +108,47 @@(mt/user-http-request :rasta :post 403"ee/security-center/SC-0000-001/acknowledge"))))))+(deftest acknowledge-advisories-test+ (testing "POST /api/ee/security-center/acknowledge"+ (mt/with-premium-features #{:admin-security-center :audit-app}+ (testing "superuser can acknowledge multiple advisories"+ (with-test-advisories!+ (let [response (mt/user-http-request :crowberto :post 200+ "ee/security-center/acknowledge"+ {:advisory_ids ["SC-0000-001" "SC-0000-002"]})]+ (is (= 2 (count response)))+ (is (every? :acknowledged_at response))+ (is (every? :acknowledged_by response))+ (is (= #{"SC-0000-001" "SC-0000-002"}+ (set (map :advisory_id response)))))))+ (testing "skips already-acknowledged advisories"+ (with-test-advisories!+ ;; Acknowledge one first+ (mt/user-http-request :crowberto :post 200+ "ee/security-center/SC-0000-001/acknowledge")+ ;; Bulk acknowledge including the already-acknowledged one+ (let [response (mt/user-http-request :crowberto :post 200+ "ee/security-center/acknowledge"+ {:advisory_ids ["SC-0000-001" "SC-0000-002"]})]+ (is (= 1 (count response)))+ (is (= "SC-0000-002" (-> response first :advisory_id))))))+ (testing "returns empty array when all are already acknowledged"+ (with-test-advisories!+ (mt/user-http-request :crowberto :post 200+ "ee/security-center/SC-0000-001/acknowledge")+ (let [response (mt/user-http-request :crowberto :post 200+ "ee/security-center/acknowledge"+ {:advisory_ids ["SC-0000-001"]})]+ (is (= [] response)))))+ (testing "returns 400 for empty advisory_ids"+ (mt/user-http-request :crowberto :post 400+ "ee/security-center/acknowledge"+ {:advisory_ids []}))+ (testing "non-superuser gets 403"+ (mt/user-http-request :rasta :post 403+ "ee/security-center/acknowledge"+ {:advisory_ids ["SC-0000-001"]})))))+(deftest sync-endpoint-test(testing "POST /api/ee/security-center/sync"(mt/with-premium-features #{:admin-security-center}diff --git a/enterprise/frontend/src/metabase-enterprise/security_center/components/AdvisoryCard/AdvisoryCard.module.css b/enterprise/frontend/src/metabase-enterprise/security_center/components/AdvisoryCard/AdvisoryCard.module.cssindex 007a4543301..e40671a6d7e 100644--- a/enterprise/frontend/src/metabase-enterprise/security_center/components/AdvisoryCard/AdvisoryCard.module.css+++ b/enterprise/frontend/src/metabase-enterprise/security_center/components/AdvisoryCard/AdvisoryCard.module.css@@ -1,7 +1,3 @@-.affectedCard {- background-color: var(--mb-color-background-error);-}-.severityCritical {background-color: var(--mb-color-error);color: var(--mb-color-white);@@ -22,14 +18,7 @@color: var(--mb-color-white);}-.statusAffected {- background-color: var(--mb-color-background-error);- border-color: var(--mb-color-error);- color: var(--mb-color-error);-}--.statusNotAffected {- background-color: var(--mb-color-background-success);- border-color: var(--mb-color-success);- color: var(--mb-color-success);+.severityNeutral {+ background-color: var(--mb-color-background-disabled);+ color: var(--mb-color-text-tertiary);}diff --git a/enterprise/frontend/src/metabase-enterprise/security_center/components/AdvisoryCard/AdvisoryCard.tsx b/enterprise/frontend/src/metabase-enterprise/security_center/components/AdvisoryCard/AdvisoryCard.tsxindex ae35b2630a3..a406c820c1d 100644--- a/enterprise/frontend/src/metabase-enterprise/security_center/components/AdvisoryCard/AdvisoryCard.tsx+++ b/enterprise/frontend/src/metabase-enterprise/security_center/components/AdvisoryCard/AdvisoryCard.tsx@@ -1,14 +1,26 @@import { t } from "ttag";-import { useIsSmallScreen } from "metabase/common/hooks/use-is-small-screen";-import { Anchor, Badge, Card, Group, Stack, Text, Title } from "metabase/ui";+import {+ Anchor,+ Badge,+ Box,+ Button,+ Card,+ Group,+ Icon,+ List,+ Stack,+ Text,+ Title,+ Tooltip,+} from "metabase/ui";import type {Advisory,AdvisoryId,AdvisorySeverity,} from "metabase-types/api";-import { isAcknowledged, isAffected } from "../../utils";+import { isAcknowledged } from "../../utils";import S from "./AdvisoryCard.module.css";@@ -19,105 +31,101 @@ const SEVERITY_CLASS: Record<AdvisorySeverity, string> = {low: S.severityLow,};-function formatVersionRange(advisory: Advisory): string {- return advisory.affected_versions- .map((v) => `${v.min} – ${v.fixed}`)- .join(", ");-}-interface AdvisoryCardProps {advisory: Advisory;+ isAffecting: boolean;onAcknowledge?: (advisoryId: AdvisoryId) => void;}-export function AdvisoryCard({ advisory, onAcknowledge }: AdvisoryCardProps) {- const affected = isAffected(advisory);+export function AdvisoryCard({+ advisory,+ isAffecting,+ onAcknowledge,+}: AdvisoryCardProps) {const acknowledged = isAcknowledged(advisory);- const isSmallScreen = useIsSmallScreen();-- const badges = (- <>- <Badge className={SEVERITY_CLASS[advisory.severity]}>- {advisory.severity}- </Badge>- <Badge- variant="outline"- className={affected ? S.statusAffected : S.statusNotAffected}- data-testid="affected-status"- >- {affected ? t`Affected` : t`Not affected`}- </Badge>- {acknowledged && (- <Badge color="brand" variant="light" data-testid="acknowledged-badge">- {t`Dismissed`}- </Badge>- )}- </>- );-- const acknowledgeButton = !acknowledged && onAcknowledge && (- <Anchor- component="button"- size="sm"- onClick={() => onAcknowledge(advisory.advisory_id)}- data-testid="acknowledge-button"- >- {t`Dismiss`}- </Anchor>- );return (- <Card- p="lg"- withBorder- className={affected ? S.affectedCard : undefined}- data-testid="advisory-card"- mih={184}- >- <Stack gap="sm">- {isSmallScreen && (- <Group gap="sm" justify="space-between" wrap="nowrap">- <Group gap="sm" wrap="wrap">- {badges}+ <Card p="xl" withBorder data-testid="advisory-card">+ <Stack gap="md">+ <Group gap="sm" justify="space-between" align="flex-start">+ <Badge+ className={+ isAffecting+ ? SEVERITY_CLASS[advisory.severity]+ : S.severityNeutral+ }+ >+ {advisory.severity}+ </Badge>+ {!isAffecting && (+ <Group gap="xs" align="center">+ <Text size="sm" c="success" fw={500}>+ {t`Your instance is not affected`}+ </Text>+ <Icon name="check_filled" c="success" size={20} /></Group>- {acknowledgeButton}- </Group>- )}- <Group gap="sm" align="center" wrap="wrap">- {!isSmallScreen && badges}- <Title order={4}>{advisory.title}</Title>+ )}</Group>- <Text lineClamp={2} c="text-secondary">- {advisory.description}- </Text>+ <Title order={4}>{advisory.title}</Title>- <Stack gap="xs">- {advisory.affected_versions.length > 0 && (- <Text size="sm" c="text-secondary">- {t`Affected versions: ${formatVersionRange(advisory)}`}- </Text>- )}- <Text size="sm" c="text-secondary">- {t`Remediation: ${advisory.remediation}`}- </Text>- </Stack>+ <Text c="text-secondary">{advisory.description}</Text>- {(advisory.advisory_url || !isSmallScreen) && (- <Group gap="md" h={28}>- {!isSmallScreen && acknowledgeButton}- {advisory.advisory_url && (- <Anchor- href={advisory.advisory_url}- target="_blank"- rel="noopener noreferrer"- size="sm"- >- {t`View advisory`}- </Anchor>- )}- </Group>+ {advisory.affected_versions.length > 0 && (+ <Box>+ <Text fw={700} mb="xs">{t`Affected versions`}</Text>+ <List size="sm">+ {advisory.affected_versions.map((v) => (+ <List.Item+ key={`${v.min}-${v.fixed}`}+ >{`${v.min} - ${v.fixed}`}</List.Item>+ ))}+ </List>+ </Box>)}++ <Box>+ <Text fw={700} mb="xs">{t`Remediation`}</Text>+ <Text c="text-secondary">{advisory.remediation}</Text>+ </Box>++ <Group gap="md" mt="sm">+ {!acknowledged && onAcknowledge && (+ <Tooltip+ label={t`Clicking on Dismiss just hides the notification and you can view this later by toggling 'Show dismissed'`}+ >+ <Button+ variant="outline"+ color="text-secondary"+ onClick={() => onAcknowledge(advisory.advisory_id)}+ data-testid="acknowledge-button"+ >+ {t`Dismiss`}+ </Button>+ </Tooltip>+ )}+ {acknowledged && (+ <Button+ variant="outline"+ color="text-secondary"+ disabled+ data-testid="acknowledge-button"+ >+ {t`Dismissed`}+ </Button>+ )}+ {advisory.advisory_url && (+ <Anchor+ href={advisory.advisory_url}+ target="_blank"+ rel="noopener noreferrer"+ size="sm"+ style={{ alignSelf: "center" }}+ >+ {t`View advisory`}+ </Anchor>+ )}+ </Group></Stack></Card>);diff --git a/enterprise/frontend/src/metabase-enterprise/security_center/components/AdvisoryFilterBar/AdvisoryFilterBar.tsx b/enterprise/frontend/src/metabase-enterprise/security_center/components/AdvisoryFilterBar/AdvisoryFilterBar.tsxindex aa6ad7681b8..21d0ed076df 100644--- a/enterprise/frontend/src/metabase-enterprise/security_center/components/AdvisoryFilterBar/AdvisoryFilterBar.tsx+++ b/enterprise/frontend/src/metabase-enterprise/security_center/components/AdvisoryFilterBar/AdvisoryFilterBar.tsx@@ -1,7 +1,7 @@import { t } from "ttag";import { useIsSmallScreen } from "metabase/common/hooks/use-is-small-screen";-import { Checkbox, Group, Select, Stack } from "metabase/ui";+import { Box, Checkbox, Group, Select, Stack } from "metabase/ui";import type { AdvisorySeverity } from "metabase-types/api";import type { AdvisoryFilter } from "../../types";@@ -29,12 +29,6 @@ export function AdvisoryFilterBar({{ value: "low", label: t`Low` },];- const statusOptions: SelectOption<AdvisoryFilter["status"]>[] = [- { value: "all", label: t`All statuses` },- { value: "affected", label: t`Affected` },- { value: "not-affected", label: t`Not affected` },- ];-const Wrapper = isSmallScreen ? Stack : Group;return (@@ -51,18 +45,7 @@ export function AdvisoryFilterBar({w={isSmallScreen ? "100%" : 180}data-testid="severity-filter"/>- <Select- data={statusOptions}- value={filter.status}- onChange={(value) =>- onChange({- ...filter,- status: value ?? "all",- })- }- w={isSmallScreen ? "100%" : 180}- data-testid="status-filter"- />+ <Box style={{ flex: 1 }} /><Checkboxlabel={t`Show dismissed`}checked={filter.showAcknowledged}diff --git a/enterprise/frontend/src/metabase-enterprise/security_center/components/AdvisoryList/AdvisoryList.module.css b/enterprise/frontend/src/metabase-enterprise/security_center/components/AdvisoryList/AdvisoryList.module.cssindex e0a87f29dce..74413495819 100644--- a/enterprise/frontend/src/metabase-enterprise/security_center/components/AdvisoryList/AdvisoryList.module.css+++ b/enterprise/frontend/src/metabase-enterprise/security_center/components/AdvisoryList/AdvisoryList.module.css@@ -1,5 +1,23 @@+.root {+ display: flex;+ flex-direction: column;+ gap: var(--mantine-spacing-xl);+}+.advisoryList {> :not(:last-child) {margin-bottom: var(--mantine-spacing-md);}}++.emptyRoot {+ align-items: center;+ justify-content: center;+ min-height: 50vh;+ gap: 24px;+}++.countBadge {+ background-color: var(--mb-color-text-primary);+ color: var(--mb-color-white);+}diff --git a/enterprise/frontend/src/metabase-enterprise/security_center/components/AdvisoryList/AdvisoryList.tsx b/enterprise/frontend/src/metabase-enterprise/security_center/components/AdvisoryList/AdvisoryList.tsxindex c76fbd5d36a..215e36686f3 100644--- a/enterprise/frontend/src/metabase-enterprise/security_center/components/AdvisoryList/AdvisoryList.tsx+++ b/enterprise/frontend/src/metabase-enterprise/security_center/components/AdvisoryList/AdvisoryList.tsx@@ -1,9 +1,11 @@import cx from "classnames";+import { t } from "ttag";-import { Box } from "metabase/ui";+import AdvisoriesEmpty from "assets/img/shield-96x96.svg";+import { Badge, Box, Button, Card, Group, Text, Title } from "metabase/ui";import type { Advisory, AdvisoryId } from "metabase-types/api";-import { sortAdvisories } from "../../utils";+import { isAcknowledged, sortAdvisories } from "../../utils";import { AdvisoryCard } from "../AdvisoryCard/AdvisoryCard";import S from "./AdvisoryList.module.css";@@ -11,25 +13,100 @@ import S from "./AdvisoryList.module.css";interface AdvisoryListProps {advisories: Advisory[];onAcknowledge?: (advisoryId: AdvisoryId) => void;+ onAcknowledgeAll?: (advisoryIds: AdvisoryId[]) => void;className?: string;}-export function AdvisoryList({+function AdvisorySection({advisories,+ isAffecting,onAcknowledge,- className,-}: AdvisoryListProps) {- const sorted = sortAdvisories(advisories);-+}: {+ advisories: Advisory[];+ isAffecting: boolean;+ onAcknowledge?: (advisoryId: AdvisoryId) => void;+}) {return (- <Box className={cx(className, S.advisoryList)}>- {sorted.map((advisory) => (+ <Box className={S.advisoryList}>+ {advisories.map((advisory) => (<AdvisoryCardkey={advisory.advisory_id}advisory={advisory}+ isAffecting={isAffecting}onAcknowledge={onAcknowledge}/>))}</Box>);}++export function AdvisoryList({+ advisories,+ onAcknowledge,+ onAcknowledgeAll,+ className,+}: AdvisoryListProps) {+ const { affecting, notAffecting } = sortAdvisories(advisories);+ const undismissedNotAffecting = notAffecting.filter(+ (a) => !isAcknowledged(a),+ );++ if (advisories.length === 0) {+ return (+ <Card className={cx(className, S.root, S.emptyRoot)}>+ <img src={AdvisoriesEmpty} />+ <Text maw={256} ta="center">+ {+ // eslint-disable-next-line metabase/no-literal-metabase-strings -- Metabase settings+ t`No known security issues that impact your Metabase version`+ }+ </Text>+ </Card>+ );+ }++ return (+ <Box className={cx(className, S.root)}>+ {affecting.length > 0 && (+ <Box>+ <Group gap="sm" mb="md" align="center">+ <Badge size="sm" className={S.countBadge}>+ {affecting.length}+ </Badge>+ <Title order={4}>{t`Affecting your instance`}</Title>+ </Group>+ <AdvisorySection+ advisories={affecting}+ isAffecting+ onAcknowledge={onAcknowledge}+ />+ </Box>+ )}+ {notAffecting.length > 0 && (+ <Box>+ <Group align="normal">+ <Title order={4} mb="md">+ {t`Other alerts`}+ </Title>+ {onAcknowledgeAll && undismissedNotAffecting.length > 0 && (+ <Button+ variant="subtle"+ size="compact-xs"+ onClick={() =>+ onAcknowledgeAll(+ undismissedNotAffecting.map((a) => a.advisory_id),+ )+ }+ >{t`Dismiss all`}</Button>+ )}+ </Group>+ <AdvisorySection+ advisories={notAffecting}+ isAffecting={false}+ onAcknowledge={onAcknowledge}+ />+ </Box>+ )}+ </Box>+ );+}diff --git a/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPage/SecurityCenterPage.module.css b/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPage/SecurityCenterPage.module.cssindex a3da8d4050e..a5a8a47db66 100644--- a/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPage/SecurityCenterPage.module.css+++ b/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPage/SecurityCenterPage.module.css@@ -1,9 +1,8 @@.root {display: flex;flex-direction: column;- height: calc(100vh - 65px);min-height: 0;- padding: 2rem 3rem 0;+ padding: 0;}.header {diff --git a/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPage/SecurityCenterPage.tsx b/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPage/SecurityCenterPage.tsxindex c7fe93d70d8..7d872e3c4b9 100644--- a/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPage/SecurityCenterPage.tsx+++ b/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPage/SecurityCenterPage.tsx@@ -2,6 +2,7 @@ import { useCallback, useEffect, useRef, useState } from "react";import { t } from "ttag";import { useSyncSecurityAdvisoriesMutation } from "metabase/api";+import { AdminSettingsLayout } from "metabase/common/components/AdminLayout/AdminSettingsLayout";import { EmptyState } from "metabase/common/components/EmptyState";import { useSetting, useToast } from "metabase/common/hooks";import { useIsSmallScreen } from "metabase/common/hooks/use-is-small-screen";@@ -33,7 +34,6 @@ import S from "./SecurityCenterPage.module.css";const DEFAULT_FILTER: AdvisoryFilter = {severity: "all",- status: "all",showAcknowledged: false,};@@ -46,6 +46,7 @@ export function SecurityCenterPage() {lastCheckedAt,isError,acknowledgeAdvisory,+ acknowledgeAdvisories,} = useSecurityAdvisories(isPolling);const [syncAdvisories, { isLoading: isSyncing }] =useSyncSecurityAdvisoriesMutation();@@ -116,8 +117,6 @@ export function SecurityCenterPage() {const targetVersion = getTargetUpgradeVersion(advisories);const filtered = filterAdvisories(advisories, filter);- const nothingToShow = filtered.length === 0 || advisories.length === 0;-if (isError) {return (<Box className={S.root}>@@ -137,65 +136,64 @@ export function SecurityCenterPage() {return (<NotificationConfigProvider value={notificationConfig}>- <Box className={S.root} data-testid="security-center-page">- <Stack gap="lg" className={S.header}>- <Group gap="sm" align="center">- <Title order={1}>{t`Security Center`}</Title>- <Box style={{ flex: 1 }} />- <Button- variant="subtle"- leftSection={- isSyncInProgress ? <Loader size="1rem" /> : <Icon name="sync" />- }- onClick={handleSync}- disabled={isSyncInProgress}- data-testid="sync-advisories"- >- {isSmallScreen ? null : t`Check now`}- </Button>- <Button- variant="subtle"- leftSection={isSmallScreen ? undefined : <Icon name="gear" />}- onClick={() => setSettingsOpen(true)}- data-testid="notification-config-toggle"- >- {isSmallScreen ? <Icon name="gear" /> : t`Notification settings`}- </Button>- </Group>- <Text c="text-secondary" data-testid="current-version">- {t`Current version`}: {currentVersion}- </Text>- {targetVersion && <UpgradeBanner targetVersion={targetVersion} />}- </Stack>- <Stack gap="xl" className={S.content}>- <AdvisoryFilterBar- className={S.filterBar}- filter={filter}- onChange={setFilter}- />- {nothingToShow ? (- <EmptyState- className={S.emptyState}- icon="shield_outline"- message={- advisories.length === 0- ? t`Your instance is up to date — no known security issues affect your configuration.`- : t`Nothing match your filters.`- }+ <AdminSettingsLayout>+ <Box className={S.root} data-testid="security-center-page">+ <Stack gap="md" className={S.header}>+ <Group gap="sm" align="center">+ <Title order={1}>{t`Security Center`}</Title>+ <Box style={{ flex: 1 }} />+ <Button+ variant="subtle"+ leftSection={+ isSyncInProgress ? (+ <Loader size="1rem" />+ ) : (+ <Icon name="sync" />+ )+ }+ onClick={handleSync}+ disabled={isSyncInProgress}+ data-testid="sync-advisories"+ >+ {isSmallScreen ? null : t`Check now`}+ </Button>+ <Button+ variant="subtle"+ leftSection={isSmallScreen ? undefined : <Icon name="gear" />}+ onClick={() => setSettingsOpen(true)}+ data-testid="notification-config-toggle"+ >+ {isSmallScreen ? (+ <Icon name="gear" />+ ) : (+ t`Notification settings`+ )}+ </Button>+ </Group>+ <Text c="text-secondary" data-testid="current-version">+ {t`Current version`}: {currentVersion}+ </Text>+ {targetVersion && <UpgradeBanner targetVersion={targetVersion} />}+ </Stack>+ <Stack gap="xl" className={S.content}>+ <AdvisoryFilterBar+ className={S.filterBar}+ filter={filter}+ onChange={setFilter}/>- ) : (<AdvisoryListclassName={S.list}advisories={filtered}onAcknowledge={acknowledgeAdvisory}+ onAcknowledgeAll={acknowledgeAdvisories}/>- )}- </Stack>- <NotificationChannelConfigModal- opened={settingsOpen}- onClose={() => setSettingsOpen(false)}- />- </Box>+ </Stack>+ <NotificationChannelConfigModal+ opened={settingsOpen}+ onClose={() => setSettingsOpen(false)}+ />+ </Box>+ </AdminSettingsLayout></NotificationConfigProvider>);}diff --git a/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPage/SecurityCenterPage.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPage/SecurityCenterPage.unit.spec.tsxindex f8072e99b8d..44e1422f5ee 100644--- a/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPage/SecurityCenterPage.unit.spec.tsx+++ b/enterprise/frontend/src/metabase-enterprise/security_center/components/SecurityCenterPage/SecurityCenterPage.unit.spec.tsx@@ -13,7 +13,14 @@ import * as advisoriesHook from "../../hooks/use-security-advisories";import { SecurityCenterPage } from "./SecurityCenterPage";+jest.mock("metabase/common/components/AdminLayout/AdminSettingsLayout", () => ({+ AdminSettingsLayout: ({ children }: { children: React.ReactNode }) => (+ <div>{children}</div>+ ),+}));+const mockAcknowledge = jest.fn();+const mockAcknowledgeAll = jest.fn();function setup(advisories: Advisory[] = [],@@ -25,6 +32,7 @@ function setup(isLoading: false,isError: false,acknowledgeAdvisory: mockAcknowledge,+ acknowledgeAdvisories: mockAcknowledgeAll,});setupRecentViewsAndSelectionsEndpoints([], ["selections"]);@@ -62,22 +70,27 @@ describe("SecurityCenterPage", () => {afterEach(() => {jest.restoreAllMocks();mockAcknowledge.mockClear();+ mockAcknowledgeAll.mockClear();});- it("renders the title and current version", () => {+ it("renders the title and current version", async () => {setup();expect(screen.getByText("Security Center")).toBeInTheDocument();expect(screen.getByTestId("current-version")).toHaveTextContent("v0.59.3");});- it("renders the empty state when there are no advisories", () => {+ it("renders the empty state when there are no advisories", async () => {setup([]);- expect(screen.getByText(/Your instance is up to date/)).toBeInTheDocument();+ expect(+ screen.getByText(+ /No known security issues that impact your Metabase version/,+ ),+ ).toBeInTheDocument();});- it("renders advisory cards in the correct order (affected first, then by severity)", () => {+ it("renders advisory cards in the correct order (affected first, then by severity)", async () => {const advisories = [createAdvisory({advisory_id: "1",@@ -109,7 +122,7 @@ describe("SecurityCenterPage", () => {expect(within(cards[2]).getByText("Low not affected")).toBeInTheDocument();});- it("shows affected status on cards", () => {+ it("shows 'not affected' badge on non-affecting cards", async () => {const advisories = [createAdvisory({ advisory_id: "1", match_status: "active" }),createAdvisory({ advisory_id: "2", match_status: "not_affected" }),@@ -117,12 +130,12 @@ describe("SecurityCenterPage", () => {setup(advisories);- const statuses = screen.getAllByTestId("affected-status");- expect(statuses[0]).toHaveTextContent("Affected");- expect(statuses[1]).toHaveTextContent("Not affected");+ expect(+ screen.getByText("Your instance is not affected"),+ ).toBeInTheDocument();});- it("renders external links with correct targets", () => {+ it("renders external links with correct targets", async () => {const advisories = [createAdvisory({advisory_id: "1",@@ -151,6 +164,68 @@ describe("SecurityCenterPage", () => {expect(mockAcknowledge).toHaveBeenCalledWith("SA-001");});+ it("calls acknowledgeAdvisories with only undismissed non-affecting advisory ids when 'Dismiss all' is clicked", async () => {+ const advisories = [+ createAdvisory({+ advisory_id: "SA-001",+ match_status: "active",+ severity: "critical",+ }),+ createAdvisory({+ advisory_id: "SA-002",+ match_status: "not_affected",+ severity: "medium",+ }),+ createAdvisory({+ advisory_id: "SA-003",+ match_status: "not_affected",+ severity: "low",+ acknowledged_at: "2026-03-01T00:00:00Z",+ }),+ ];++ setup(advisories);++ await userEvent.click(screen.getByText("Dismiss all"));+ expect(mockAcknowledgeAll).toHaveBeenCalledWith(["SA-002"]);+ });++ it("does not show 'Dismiss all' when there are no non-affecting advisories", async () => {+ const advisories = [+ createAdvisory({+ advisory_id: "SA-001",+ match_status: "active",+ severity: "critical",+ }),+ ];++ setup(advisories);++ expect(screen.queryByText("Dismiss all")).not.toBeInTheDocument();+ });++ it("does not show 'Dismiss all' when all non-affecting advisories are already dismissed", async () => {+ const advisories = [+ createAdvisory({+ advisory_id: "SA-001",+ match_status: "not_affected",+ acknowledged_at: "2026-03-01T00:00:00Z",+ }),+ createAdvisory({+ advisory_id: "SA-002",+ match_status: "not_affected",+ acknowledged_at: "2026-03-01T00:00:00Z",+ }),+ ];++ setup(advisories);++ // Enable showing dismissed advisories so they appear in the list+ await userEvent.click(screen.getByTestId("show-acknowledged-filter"));++ expect(screen.queryByText("Dismiss all")).not.toBeInTheDocument();+ });+it("does not show dismiss button for already dismissed advisories", async () => {const advisories = [createAdvisory({@@ -164,13 +239,12 @@ describe("SecurityCenterPage", () => {// Dismissed advisories are hidden by default — enable the checkbox firstawait userEvent.click(screen.getByTestId("show-acknowledged-filter"));- expect(screen.queryByTestId("acknowledge-button")).not.toBeInTheDocument();- expect(screen.getByTestId("acknowledged-badge")).toHaveTextContent(- "Dismissed",- );+ const button = screen.getByTestId("acknowledge-button");+ expect(button).toBeDisabled();+ expect(button).toHaveTextContent("Dismissed");});- it("hides dismissed advisories by default", () => {+ it("hides dismissed advisories by default", async () => {const advisories = [createAdvisory({advisory_id: "1",@@ -190,14 +264,14 @@ describe("SecurityCenterPage", () => {expect(screen.queryByText("Hidden")).not.toBeInTheDocument();});- it("renders the filter bar", () => {+ it("renders the filter bar", async () => {setup([]);expect(screen.getByTestId("advisory-filter-bar")).toBeInTheDocument();});describe("upgrade banner", () => {- it("shows the upgrade banner when there are active advisories", () => {+ it("shows the upgrade banner when there are active advisories", async () => {const advisories = [createAdvisory({advisory_id: "1",@@ -214,7 +288,7 @@ describe("SecurityCenterPage", () => {expect(banner).toHaveTextContent("A security update is available");});- it("does not show the upgrade banner when there are no active advisories", () => {+ it("does not show the upgrade banner when there are no active advisories", async () => {const advisories = [createAdvisory({advisory_id: "1",@@ -227,7 +301,7 @@ describe("SecurityCenterPage", () => {expect(screen.queryByTestId("upgrade-banner")).not.toBeInTheDocument();});- it("shows the highest fixed version across multiple active advisories", () => {+ it("shows the highest fixed version across multiple active advisories", async () => {const advisories = [createAdvisory({advisory_id: "1",@@ -247,7 +321,7 @@ describe("SecurityCenterPage", () => {expect(banner).toHaveTextContent("0.59.5");});- it("includes a link to upgrade instructions", () => {+ it("includes a link to upgrade instructions", async () => {const advisories = [createAdvisory({advisory_id: "1",@@ -266,7 +340,7 @@ describe("SecurityCenterPage", () => {expect(link).toHaveAttribute("target", "_blank");});- it("does not show the upgrade banner when there are no advisories", () => {+ it("does not show the upgrade banner when there are no advisories", async () => {setup([]);expect(screen.queryByTestId("upgrade-banner")).not.toBeInTheDocument();diff --git a/enterprise/frontend/src/metabase-enterprise/security_center/hooks/use-security-advisories.ts b/enterprise/frontend/src/metabase-enterprise/security_center/hooks/use-security-advisories.tsindex c879a7e9032..19eeb3f6d09 100644--- a/enterprise/frontend/src/metabase-enterprise/security_center/hooks/use-security-advisories.ts+++ b/enterprise/frontend/src/metabase-enterprise/security_center/hooks/use-security-advisories.ts@@ -1,6 +1,7 @@import { useMemo } from "react";import {+ useAcknowledgeAdvisoriesMutation,useAcknowledgeAdvisoryMutation,useListSecurityAdvisoriesQuery,} from "metabase/api";@@ -18,6 +19,7 @@ export function useSecurityAdvisories(isPolling = false) {pollingInterval: isPolling ? POLLING_INTERVAL : undefined,});const [acknowledgeAdvisory] = useAcknowledgeAdvisoryMutation();+ const [acknowledgeAdvisories] = useAcknowledgeAdvisoriesMutation();const advisories: Advisory[] = useMemo(() => response?.advisories ?? [],@@ -30,5 +32,6 @@ export function useSecurityAdvisories(isPolling = false) {isLoading,isError,acknowledgeAdvisory,+ acknowledgeAdvisories,};}diff --git a/enterprise/frontend/src/metabase-enterprise/security_center/types.ts b/enterprise/frontend/src/metabase-enterprise/security_center/types.tsindex adfa496584e..8a53285db74 100644--- a/enterprise/frontend/src/metabase-enterprise/security_center/types.ts+++ b/enterprise/frontend/src/metabase-enterprise/security_center/types.ts@@ -2,6 +2,5 @@ import type { AdvisorySeverity } from "metabase-types/api";export type AdvisoryFilter = {severity: AdvisorySeverity | "all";- status: "all" | "affected" | "not-affected";showAcknowledged: boolean;};diff --git a/enterprise/frontend/src/metabase-enterprise/security_center/utils.ts b/enterprise/frontend/src/metabase-enterprise/security_center/utils.tsindex 964ebeff9dd..590241702e3 100644--- a/enterprise/frontend/src/metabase-enterprise/security_center/utils.ts+++ b/enterprise/frontend/src/metabase-enterprise/security_center/utils.ts@@ -28,12 +28,6 @@ export function filterAdvisories(if (filter.severity !== "all" && a.severity !== filter.severity) {return false;}- if (filter.status === "affected" && !isAffected(a)) {- return false;- }- if (filter.status === "not-affected" && isAffected(a)) {- return false;- }if (!filter.showAcknowledged && isAcknowledged(a)) {return false;}@@ -62,26 +56,35 @@ export function getTargetUpgradeVersion(advisories: Advisory[]): string | null {return target;}-export function sortAdvisories(advisories: Advisory[]): Advisory[] {- return [...advisories].sort((a, b) => {- const aAffected = isAffected(a);- const bAffected = isAffected(b);+export interface SortedAdvisories {+ affecting: Advisory[];+ notAffecting: Advisory[];+}- // Affected items first- if (aAffected !== bAffected) {- return aAffected ? -1 : 1;- }+function sortBySeverityAndDate(a: Advisory, b: Advisory): number {+ const severityDiff = SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity];+ if (severityDiff !== 0) {+ return severityDiff;+ }+ return (+ new Date(b.published_at).getTime() - new Date(a.published_at).getTime()+ );+}- // Then by severity (critical → low)- const severityDiff =- SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity];- if (severityDiff !== 0) {- return severityDiff;+export function sortAdvisories(advisories: Advisory[]): SortedAdvisories {+ const affecting: Advisory[] = [];+ const notAffecting: Advisory[] = [];++ for (const advisory of advisories) {+ if (isAffected(advisory)) {+ affecting.push(advisory);+ } else {+ notAffecting.push(advisory);}+ }- // Then by published_at descending (newest first)- return (- new Date(b.published_at).getTime() - new Date(a.published_at).getTime()- );- });+ affecting.sort(sortBySeverityAndDate);+ notAffecting.sort(sortBySeverityAndDate);++ return { affecting, notAffecting };}diff --git a/enterprise/frontend/src/metabase-enterprise/security_center/utils.unit.spec.ts b/enterprise/frontend/src/metabase-enterprise/security_center/utils.unit.spec.tsindex c4e1d364b87..8c6d817e489 100644--- a/enterprise/frontend/src/metabase-enterprise/security_center/utils.unit.spec.ts+++ b/enterprise/frontend/src/metabase-enterprise/security_center/utils.unit.spec.ts@@ -21,7 +21,6 @@ const makeAdvisory = (overrides: Partial<Advisory>): Advisory => ({const ALL_PASS_FILTER: AdvisoryFilter = {severity: "all",- status: "all",showAcknowledged: true,};@@ -43,7 +42,7 @@ describe("isAffected", () => {});describe("sortAdvisories", () => {- it("should place affected items before non-affected items", () => {+ it("should split advisories into affecting and notAffecting", () => {const advisories = [makeAdvisory({advisory_id: "1",@@ -57,12 +56,12 @@ describe("sortAdvisories", () => {}),];- const sorted = sortAdvisories(advisories);- expect(sorted[0].advisory_id).toBe("2");- expect(sorted[1].advisory_id).toBe("1");+ const { affecting, notAffecting } = sortAdvisories(advisories);+ expect(affecting.map((a) => a.advisory_id)).toEqual(["2"]);+ expect(notAffecting.map((a) => a.advisory_id)).toEqual(["1"]);});- it("should sort by severity within the same affected status", () => {+ it("should sort by severity within each group", () => {const advisories = [makeAdvisory({advisory_id: "low",@@ -86,8 +85,8 @@ describe("sortAdvisories", () => {}),];- const sorted = sortAdvisories(advisories);- expect(sorted.map((a) => a.advisory_id)).toEqual([+ const { affecting } = sortAdvisories(advisories);+ expect(affecting.map((a) => a.advisory_id)).toEqual(["critical","high","medium",@@ -111,13 +110,35 @@ describe("sortAdvisories", () => {}),];- const sorted = sortAdvisories(advisories);- expect(sorted[0].advisory_id).toBe("newer");- expect(sorted[1].advisory_id).toBe("older");+ const { affecting } = sortAdvisories(advisories);+ expect(affecting[0].advisory_id).toBe("newer");+ expect(affecting[1].advisory_id).toBe("older");});- it("should return an empty array when given an empty array", () => {- expect(sortAdvisories([])).toEqual([]);+ it("should sort notAffecting by severity and date", () => {+ const advisories = [+ makeAdvisory({+ advisory_id: "low-na",+ severity: "low",+ match_status: "not_affected",+ }),+ makeAdvisory({+ advisory_id: "critical-na",+ severity: "critical",+ match_status: "resolved",+ }),+ ];++ const { affecting, notAffecting } = sortAdvisories(advisories);+ expect(affecting).toHaveLength(0);+ expect(notAffecting.map((a) => a.advisory_id)).toEqual([+ "critical-na",+ "low-na",+ ]);+ });++ it("should return empty arrays when given an empty array", () => {+ expect(sortAdvisories([])).toEqual({ affecting: [], notAffecting: [] });});it("should not mutate the original array", () => {@@ -130,6 +151,25 @@ describe("sortAdvisories", () => {sortAdvisories(advisories);expect(advisories).toEqual(original);});++ it("should treat error status as affecting", () => {+ const advisories = [+ makeAdvisory({+ advisory_id: "err",+ match_status: "error",+ severity: "high",+ }),+ makeAdvisory({+ advisory_id: "ok",+ match_status: "not_affected",+ severity: "critical",+ }),+ ];++ const { affecting, notAffecting } = sortAdvisories(advisories);+ expect(affecting.map((a) => a.advisory_id)).toEqual(["err"]);+ expect(notAffecting.map((a) => a.advisory_id)).toEqual(["ok"]);+ });});describe("filterAdvisories", () => {@@ -174,24 +214,6 @@ describe("filterAdvisories", () => {expect(result[0].advisory_id).toBe("1");});- it("should filter by affected status", () => {- const result = filterAdvisories(advisories, {- ...ALL_PASS_FILTER,- status: "affected",- });- expect(result.every((a) => a.match_status === "active")).toBe(true);- expect(result).toHaveLength(2);- });-- it("should filter by not-affected status", () => {- const result = filterAdvisories(advisories, {- ...ALL_PASS_FILTER,- status: "not-affected",- });- expect(result.every((a) => a.match_status !== "active")).toBe(true);- expect(result).toHaveLength(2);- });-it("should hide acknowledged advisories when showAcknowledged is false", () => {const result = filterAdvisories(advisories, {...ALL_PASS_FILTER,@@ -203,8 +225,7 @@ describe("filterAdvisories", () => {it("should combine multiple filters", () => {const result = filterAdvisories(advisories, {- severity: "all",- status: "affected",+ severity: "critical",showAcknowledged: false,});expect(result).toHaveLength(1);diff --git a/frontend/src/metabase-types/api/security-center.ts b/frontend/src/metabase-types/api/security-center.tsindex ed8b8767b51..c3814c924b0 100644--- a/frontend/src/metabase-types/api/security-center.ts+++ b/frontend/src/metabase-types/api/security-center.ts@@ -39,3 +39,5 @@ export type AcknowledgeAdvisoryResponse = {acknowledged_by: { id: number; common_name: string; email: string } | null;acknowledged_at: string | null;};++export type AcknowledgeAdvisoriesResponse = AcknowledgeAdvisoryResponse[];diff --git a/frontend/src/metabase/api/security-center.ts b/frontend/src/metabase/api/security-center.tsindex f71a89b9ee9..b9644be0c0a 100644--- a/frontend/src/metabase/api/security-center.ts+++ b/frontend/src/metabase/api/security-center.ts@@ -1,6 +1,8 @@import { Api } from "metabase/api";import type {+ AcknowledgeAdvisoriesResponse,AcknowledgeAdvisoryResponse,+ AdvisoryId,ListAdvisoriesResponse,} from "metabase-types/api";@@ -21,6 +23,17 @@ export const securityCenterApi = Api.injectEndpoints({}),invalidatesTags: [listTag("security-advisory")],}),+ acknowledgeAdvisories: builder.mutation<+ AcknowledgeAdvisoriesResponse,+ AdvisoryId[]+ >({+ query: (advisoryIds) => ({+ method: "POST",+ url: "/api/ee/security-center/acknowledge",+ body: { advisory_ids: advisoryIds },+ }),+ invalidatesTags: [listTag("security-advisory")],+ }),syncSecurityAdvisories: builder.mutation<void, void>({query: () => ({method: "POST",@@ -40,6 +53,7 @@ export const securityCenterApi = Api.injectEndpoints({export const {useListSecurityAdvisoriesQuery,useAcknowledgeAdvisoryMutation,+ useAcknowledgeAdvisoriesMutation,useSyncSecurityAdvisoriesMutation,useSendTestNotificationMutation,} = securityCenterApi;diff --git a/resources/frontend_client/app/assets/img/shield-96x96.svg b/resources/frontend_client/app/assets/img/shield-96x96.svgnew file mode 100644index 00000000000..62372354c1e--- /dev/null+++ b/resources/frontend_client/app/assets/img/shield-96x96.svg@@ -0,0 +1,11 @@+<svg width="96" height="96" viewBox="0 0 96 96" fill="none" xmlns="http://www.w3.org/2000/svg">+<g clip-path="url(#clip0_27_103)">+<circle cx="48" cy="48" r="48" fill="#071722" fill-opacity="0.02"/>+<path d="M46.96 27.054C47.5626 26.5518 48.4374 26.5518 49.04 27.054L54.0674 31.2424C56.1645 32.99 58.6892 34.1481 61.3818 34.5969L65.2676 35.2444C66.0508 35.3751 66.6248 36.0529 66.625 36.8469V48.5852C66.6248 57.4625 60.9442 65.3442 52.5225 68.1516L48.8301 69.3821C48.2913 69.5616 47.7087 69.5616 47.1699 69.3821L43.4775 68.1516C35.0558 65.3442 29.3752 57.4625 29.375 48.5852V36.8469C29.3752 36.0529 29.9493 35.3751 30.7324 35.2444L34.6182 34.5969C37.3108 34.1481 39.8355 32.99 41.9326 31.2424L46.96 27.054ZM42.7334 32.2034C40.4656 34.0931 37.735 35.345 34.8232 35.8303L30.9385 36.4778C30.7578 36.5079 30.6252 36.6638 30.625 36.8469V48.5852C30.6252 56.9246 35.9616 64.3289 43.873 66.9661L47.375 68.1331V28.3342L42.7334 32.2034ZM48.625 68.1331L52.127 66.9661C60.0384 64.3289 65.3748 56.9246 65.375 48.5852V36.8469C65.3748 36.6638 65.2422 36.5079 65.0615 36.4778L61.1768 35.8303C58.2649 35.345 55.5344 34.0922 53.2666 32.2024L48.625 28.3342V68.1331Z" fill="#B7BCBF"/>+</g>+<defs>+<clipPath id="clip0_27_103">+<rect width="96" height="96" fill="white"/>+</clipPath>+</defs>+</svg>