From 7e5cb3ddf2c6f815931d96515b55cf17120cd34d Mon Sep 17 00:00:00 2001 From: milan-deepfence Date: Tue, 21 Mar 2023 19:06:16 +0530 Subject: [PATCH 1/3] added breadcrumb to all remainings scan type --- .../PostureScanConfigureForm.tsx | 36 +++++++++++-------- .../malwares/pages/MalwareScanResults.tsx | 32 ++++++++--------- .../features/malwares/pages/MalwareScans.tsx | 28 +++++++-------- .../src/features/postures/pages/Accounts.tsx | 32 ++++++++++++----- .../postures/pages/PostureScanResults.tsx | 2 +- .../secrets/pages/SecretScanResults.tsx | 30 ++++++++-------- .../features/secrets/pages/SecretScans.tsx | 28 +++++++-------- .../pages/MostExploitableVulnerabilities.tsx | 29 +++++++-------- .../vulnerabilities/pages/RuntimeBom.tsx | 28 +++++++-------- .../pages/UniqueVulnerabilities.tsx | 28 +++++++-------- .../pages/VulnerabilityScanResults.tsx | 32 ++++++++--------- .../pages/VulnerabilityScans.tsx | 27 ++++++-------- 12 files changed, 163 insertions(+), 169 deletions(-) diff --git a/deepfence_frontend/apps/dashboard/src/components/scan-configure-forms/PostureScanConfigureForm.tsx b/deepfence_frontend/apps/dashboard/src/components/scan-configure-forms/PostureScanConfigureForm.tsx index aaeec6f7b0..d100ea98c4 100644 --- a/deepfence_frontend/apps/dashboard/src/components/scan-configure-forms/PostureScanConfigureForm.tsx +++ b/deepfence_frontend/apps/dashboard/src/components/scan-configure-forms/PostureScanConfigureForm.tsx @@ -241,20 +241,28 @@ export const ControlsTable = memo( {selectedTab === '' ? (

Please select at least one compliance type to start your scan.

) : ( - setSelectedTab(v)}> - {isLoading && controlsList.length === 0 ? ( - - ) : ( - - )} - + <> + {nodeIds.length === 1 ? ( + setSelectedTab(v)} + > + {isLoading && controlsList.length === 0 ? ( + + ) : ( +
+ )} + + ) : null} + )} ); diff --git a/deepfence_frontend/apps/dashboard/src/features/malwares/pages/MalwareScanResults.tsx b/deepfence_frontend/apps/dashboard/src/features/malwares/pages/MalwareScanResults.tsx index 6062451c52..ba7e59d2cb 100644 --- a/deepfence_frontend/apps/dashboard/src/features/malwares/pages/MalwareScanResults.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/malwares/pages/MalwareScanResults.tsx @@ -5,9 +5,9 @@ import { FaHistory } from 'react-icons/fa'; import { FiFilter } from 'react-icons/fi'; import { HiArchive, - HiArrowSmLeft, HiBell, HiChevronLeft, + HiChevronRight, HiDotsVertical, HiEye, HiEyeOff, @@ -29,6 +29,8 @@ import { toast } from 'sonner'; import { twMerge } from 'tailwind-merge'; import { Badge, + Breadcrumb, + BreadcrumbLink, Button, Card, Checkbox, @@ -208,7 +210,7 @@ async function getScans( low: result.severity_counts?.['low'] ?? 0, unknown: result.severity_counts?.['unknown'] ?? 0, }, - nodeName: result.host_name, + nodeName: result.node_name, nodeType: result.node_type, nodeId: result.node_id, timestamp: result.updated_at, @@ -1006,21 +1008,17 @@ const HeaderComponent = ({ const { nodeType, nodeName } = resolvedData; return ( <> - - - - - - - MALWARE SCAN RESULTS - {nodeType} / {nodeName} - + } transparent> + + MALWARE + + + {nodeType} + + + {nodeName} + + ); }} diff --git a/deepfence_frontend/apps/dashboard/src/features/malwares/pages/MalwareScans.tsx b/deepfence_frontend/apps/dashboard/src/features/malwares/pages/MalwareScans.tsx index dde00215c3..9e3fd9e8cd 100644 --- a/deepfence_frontend/apps/dashboard/src/features/malwares/pages/MalwareScans.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/malwares/pages/MalwareScans.tsx @@ -12,7 +12,7 @@ import { IconContext } from 'react-icons'; import { FiFilter } from 'react-icons/fi'; import { HiArchive, - HiArrowSmLeft, + HiChevronRight, HiClock, HiDotsVertical, HiDownload, @@ -32,6 +32,8 @@ import { import { toast } from 'sonner'; import { Badge, + Breadcrumb, + BreadcrumbLink, Button, CircleSpinner, createColumnHelper, @@ -836,21 +838,15 @@ const MalwareScans = () => { return (
- - - - - - - MALWARE SCANS - + } transparent> + + MALWARES + + + MALWARE SCANS + + + {navigation.state === 'loading' ? : null} diff --git a/deepfence_frontend/apps/dashboard/src/features/postures/pages/Accounts.tsx b/deepfence_frontend/apps/dashboard/src/features/postures/pages/Accounts.tsx index ca92c5c3bd..a78d101ccc 100644 --- a/deepfence_frontend/apps/dashboard/src/features/postures/pages/Accounts.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/postures/pages/Accounts.tsx @@ -42,12 +42,23 @@ import { DFAwait } from '@/utils/suspense'; import { getPageFromSearchParams } from '@/utils/table'; import { usePageNavigation } from '@/utils/usePageNavigation'; -enum ActionEnumType { - START_SCAN = 'start_scan', - VIEW_SCAN = 'view_scan', - VIEW_INVENTORY = 'view_inventory', - REFRESH_DATA = 'refresh_data', -} +const getNodeTypeByProviderName = (providerName: string) => { + switch (providerName) { + case 'linux': + return 'host'; + case 'aws': + return 'aws'; + case 'gcp': + return 'gcp'; + case 'azure': + return 'azure'; + + case 'kubernetes': + return 'kubernetes_cluster'; + default: + throw new Error('Invalid provider name'); + } +}; export interface AccountData { id: string; @@ -377,6 +388,11 @@ const PostureTable = () => { const accounts = resolvedData?.accounts ?? []; const totalRows = resolvedData?.totalRows ?? 0; const currentPage = resolvedData?.currentPage ?? 0; + const cloudProvider = accounts[0]?.cloud_provider ?? ''; + + if (!cloudProvider) { + throw new Error('Cloud provider is required to show table'); + } return (
{ }); }} data={{ - nodeType: 'aws', - nodeIds: Object.keys(openScanConfigure), + nodeType: getNodeTypeByProviderName(cloudProvider), + nodeIds: openScanConfigure.nodeIds, images: [], }} /> diff --git a/deepfence_frontend/apps/dashboard/src/features/postures/pages/PostureScanResults.tsx b/deepfence_frontend/apps/dashboard/src/features/postures/pages/PostureScanResults.tsx index ca0f283025..313ec41ebe 100644 --- a/deepfence_frontend/apps/dashboard/src/features/postures/pages/PostureScanResults.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/postures/pages/PostureScanResults.tsx @@ -898,7 +898,7 @@ const HeaderComponent = () => { <> } transparent> - REGISTRIES + POSTURE - - - - - - - SECRET SCAN RESULTS - {nodeType} / {nodeName} - + } transparent> + + SECRETS + + + {nodeType} + + + {nodeName} + + ); }} diff --git a/deepfence_frontend/apps/dashboard/src/features/secrets/pages/SecretScans.tsx b/deepfence_frontend/apps/dashboard/src/features/secrets/pages/SecretScans.tsx index a4dffbf1a8..69896f50bc 100644 --- a/deepfence_frontend/apps/dashboard/src/features/secrets/pages/SecretScans.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/secrets/pages/SecretScans.tsx @@ -12,7 +12,7 @@ import { IconContext } from 'react-icons'; import { FiFilter } from 'react-icons/fi'; import { HiArchive, - HiArrowSmLeft, + HiChevronRight, HiClock, HiDotsVertical, HiDownload, @@ -32,6 +32,8 @@ import { import { toast } from 'sonner'; import { Badge, + Breadcrumb, + BreadcrumbLink, Button, CircleSpinner, createColumnHelper, @@ -838,21 +840,15 @@ const SecretScans = () => { return (
- - - - - - - SECRET SCANS - + } transparent> + + SECRETS + + + SECRET SCANS + + + {navigation.state === 'loading' ? : null} diff --git a/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/MostExploitableVulnerabilities.tsx b/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/MostExploitableVulnerabilities.tsx index 8f11a5db76..36da53099e 100644 --- a/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/MostExploitableVulnerabilities.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/MostExploitableVulnerabilities.tsx @@ -2,9 +2,8 @@ import cx from 'classnames'; import { capitalize } from 'lodash-es'; import { Suspense, useMemo } from 'react'; import { IconContext } from 'react-icons'; -import { HiArrowSmLeft, HiExternalLink } from 'react-icons/hi'; +import { HiChevronRight, HiExternalLink } from 'react-icons/hi'; import { - Await, LoaderFunctionArgs, Outlet, useLoaderData, @@ -13,6 +12,8 @@ import { } from 'react-router-dom'; import { Badge, + Breadcrumb, + BreadcrumbLink, CircleSpinner, createColumnHelper, SortingState, @@ -329,21 +330,15 @@ const MostExploitableVulnerabilities = () => { return (
- - - - - - - MOST EXPLOITABLE VULNERABILITIES - + } transparent> + + VULNERABILITIES + + + MOST EXPLOITABLE VULNERABILITIES + + + {navigation.state === 'loading' ? : null} diff --git a/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/RuntimeBom.tsx b/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/RuntimeBom.tsx index 7220638e97..cacac7e5c7 100644 --- a/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/RuntimeBom.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/RuntimeBom.tsx @@ -1,7 +1,7 @@ import { toNumber } from 'lodash-es'; import { Suspense, useMemo, useState } from 'react'; import { IconContext } from 'react-icons'; -import { HiArrowSmLeft } from 'react-icons/hi'; +import { HiChevronRight } from 'react-icons/hi'; import { LoaderFunctionArgs, useLoaderData, @@ -9,6 +9,8 @@ import { useSearchParams, } from 'react-router-dom'; import { + Breadcrumb, + BreadcrumbLink, CircleSpinner, createColumnHelper, SortingState, @@ -205,21 +207,15 @@ const RuntimeBom = () => { return (
- - - - - - - Runtime BOM - + } transparent> + + VULNERABILITIES + + + Runtime BOM + + + {navigation.state === 'loading' ? : null} diff --git a/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/UniqueVulnerabilities.tsx b/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/UniqueVulnerabilities.tsx index 6515ba9c84..67596c3edf 100644 --- a/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/UniqueVulnerabilities.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/UniqueVulnerabilities.tsx @@ -2,7 +2,7 @@ import cx from 'classnames'; import { capitalize } from 'lodash-es'; import { Suspense, useMemo } from 'react'; import { IconContext } from 'react-icons'; -import { HiArrowSmLeft, HiExternalLink } from 'react-icons/hi'; +import { HiChevronRight, HiExternalLink } from 'react-icons/hi'; import { LoaderFunctionArgs, Outlet, @@ -12,6 +12,8 @@ import { } from 'react-router-dom'; import { Badge, + Breadcrumb, + BreadcrumbLink, CircleSpinner, createColumnHelper, SortingState, @@ -307,21 +309,15 @@ const UniqueVulnerabilities = () => { return (
- - - - - - - UNIQUE VULNERABILITIES - + } transparent> + + VULNERABILITIES + + + UNIQUE VULNERABILITIES + + + {navigation.state === 'loading' ? : null} diff --git a/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/VulnerabilityScanResults.tsx b/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/VulnerabilityScanResults.tsx index 9baa8997b4..c329000f78 100644 --- a/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/VulnerabilityScanResults.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/VulnerabilityScanResults.tsx @@ -5,9 +5,9 @@ import { FaHistory } from 'react-icons/fa'; import { FiFilter } from 'react-icons/fi'; import { HiArchive, - HiArrowSmLeft, HiBell, HiChevronLeft, + HiChevronRight, HiDotsVertical, HiExternalLink, HiEye, @@ -30,6 +30,8 @@ import { toast } from 'sonner'; import { twMerge } from 'tailwind-merge'; import { Badge, + Breadcrumb, + BreadcrumbLink, Button, Card, Checkbox, @@ -1012,21 +1014,19 @@ const HeaderComponent = ({ const { nodeType, nodeName } = resolvedData; return ( <> - - - - - - - VULNERABILITY SCAN RESULTS - {nodeType} / {nodeName} - + } transparent> + + VULNERABILITIES + + + + {nodeType} + + + + {nodeName} + + ); }} diff --git a/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/VulnerabilityScans.tsx b/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/VulnerabilityScans.tsx index 6cfbb717b9..3d456c9e56 100644 --- a/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/VulnerabilityScans.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/VulnerabilityScans.tsx @@ -12,7 +12,7 @@ import { IconContext } from 'react-icons'; import { FiFilter } from 'react-icons/fi'; import { HiArchive, - HiArrowSmLeft, + HiChevronRight, HiClock, HiDotsVertical, HiDownload, @@ -32,6 +32,8 @@ import { import { toast } from 'sonner'; import { Badge, + Breadcrumb, + BreadcrumbLink, Button, CircleSpinner, createColumnHelper, @@ -886,21 +888,14 @@ const VulnerabilityScans = () => { return (
- - - - - - - VULNERABILITY SCANS - + } transparent> + + VULNERABILITIES + + + VULNERABILITY SCANS + + {navigation.state === 'loading' ? : null} From 64c94bfeba6b1429e87bbe48d2d5dfbb71e18af3 Mon Sep 17 00:00:00 2001 From: milan-deepfence Date: Tue, 21 Mar 2023 19:08:56 +0530 Subject: [PATCH 2/3] add comment --- .../apps/dashboard/src/features/postures/pages/Accounts.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deepfence_frontend/apps/dashboard/src/features/postures/pages/Accounts.tsx b/deepfence_frontend/apps/dashboard/src/features/postures/pages/Accounts.tsx index a78d101ccc..e6ddb6b4f9 100644 --- a/deepfence_frontend/apps/dashboard/src/features/postures/pages/Accounts.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/postures/pages/Accounts.tsx @@ -42,6 +42,7 @@ import { DFAwait } from '@/utils/suspense'; import { getPageFromSearchParams } from '@/utils/table'; import { usePageNavigation } from '@/utils/usePageNavigation'; +// TODO: remove this once we have correct type from api const getNodeTypeByProviderName = (providerName: string) => { switch (providerName) { case 'linux': @@ -52,7 +53,6 @@ const getNodeTypeByProviderName = (providerName: string) => { return 'gcp'; case 'azure': return 'azure'; - case 'kubernetes': return 'kubernetes_cluster'; default: From 7c590cee3ff59897ed1c42faad0628eb709f2e75 Mon Sep 17 00:00:00 2001 From: milan-deepfence Date: Tue, 21 Mar 2023 19:16:55 +0530 Subject: [PATCH 3/3] added category column in posture result --- .../postures/pages/PostureScanResults.tsx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/deepfence_frontend/apps/dashboard/src/features/postures/pages/PostureScanResults.tsx b/deepfence_frontend/apps/dashboard/src/features/postures/pages/PostureScanResults.tsx index 313ec41ebe..65b1010379 100644 --- a/deepfence_frontend/apps/dashboard/src/features/postures/pages/PostureScanResults.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/postures/pages/PostureScanResults.tsx @@ -657,13 +657,22 @@ const ScanResusltTable = () => {
-
{info.getValue()}
+
{info.row.original.test_number}
), - header: () => 'ID', - minSize: 90, - size: 100, - maxSize: 110, + header: () => 'Test ID', + minSize: 50, + size: 60, + maxSize: 65, + }), + columnHelper.accessor('test_category', { + enableSorting: false, + enableResizing: false, + cell: (info) => info.getValue(), + header: () => 'Category', + minSize: 80, + size: 90, + maxSize: 95, }), columnHelper.accessor('compliance_check_type', { enableSorting: false,