From 668030f17448141d6047f5bbc0e3e13be5342f97 Mon Sep 17 00:00:00 2001 From: milan-deepfence Date: Mon, 16 Jan 2023 21:18:28 +0530 Subject: [PATCH 01/11] feat(onboard):wip added scan option and form for compliance --- .../apps/dashboard/package.json | 2 + .../onboard/layouts/InfraScanLayout.tsx | 15 + .../features/onboard/pages/AWSChooseScan.tsx | 126 +++ .../onboard/pages/AWSInfraScanConfigure.tsx | 727 ++++++++++++++++++ .../apps/dashboard/src/routes/private.tsx | 17 + .../src/components/table/Table.tsx | 20 +- .../src/components/tabs/Tabs.tsx | 4 +- deepfence_frontend/pnpm-lock.yaml | 4 + 8 files changed, 905 insertions(+), 10 deletions(-) create mode 100644 deepfence_frontend/apps/dashboard/src/features/onboard/layouts/InfraScanLayout.tsx create mode 100644 deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSChooseScan.tsx create mode 100644 deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSInfraScanConfigure.tsx diff --git a/deepfence_frontend/apps/dashboard/package.json b/deepfence_frontend/apps/dashboard/package.json index 0b421f28da..1fb7253378 100644 --- a/deepfence_frontend/apps/dashboard/package.json +++ b/deepfence_frontend/apps/dashboard/package.json @@ -20,6 +20,7 @@ "@testing-library/jest-dom": "^5.16.5", "@testing-library/user-event": "^14.4.3", "classnames": "^2.3.2", + "lodash-es": "^4.17.21", "react": "^18.2.0", "react-dom": "^18.2.0", "react-icons": "^4.7.1", @@ -32,6 +33,7 @@ "@openapitools/openapi-generator-cli": "^2.5.2", "@playwright/test": "^1.28.1", "@testing-library/react": "^13.4.0", + "@types/lodash-es": "^4.17.6", "@types/react": "^18.0.24", "@types/react-dom": "^18.0.8", "@types/testing-library__jest-dom": "^5.14.5", diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/layouts/InfraScanLayout.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/layouts/InfraScanLayout.tsx new file mode 100644 index 0000000000..15b973ee83 --- /dev/null +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/layouts/InfraScanLayout.tsx @@ -0,0 +1,15 @@ +import { Outlet } from 'react-router-dom'; + +import { ConnectorHeader } from '../components/ConnectorHeader'; + +export const ScanInfraLayout = () => { + return ( +
+ + +
+ ); +}; diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSChooseScan.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSChooseScan.tsx new file mode 100644 index 0000000000..c5b1821d7a --- /dev/null +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSChooseScan.tsx @@ -0,0 +1,126 @@ +import { Button, Card, Separator, Typography } from 'ui-components'; + +import LogoAws from '../../../assets/logo-aws.svg'; +import LogoAwsWhite from '../../../assets/logo-aws-white.svg'; +import { useTheme } from '../../../theme/ThemeContext'; +import { usePageNavigation } from '../../../utils/usePageNavigation'; + +type ScanTypeListProps = { + scanType: string; + description: string; + lastScaned: string; + buttonText: string; + redirect: string; +}; + +const scanTypeList: ScanTypeListProps[] = [ + { + scanType: 'Vulnerability Scan', + description: `A few words about the compliance scan and why you need to use it.`, + lastScaned: '3:00pm on 11/22/2022', + buttonText: 'Configure Compliance Scan', + redirect: '/onboard/scan-infrastructure/cloud/aws/configure', + }, + { + scanType: 'Compliance Scan', + description: `A few words about the compliance scan and why you need to use it.`, + lastScaned: '3:00pm on 11/22/2022', + buttonText: 'Configure Compliance Scan', + redirect: '/onboard/scan-infrastructure/cloud/aws/configure', + }, + { + scanType: 'Secrets Scan', + description: `A few words about the compliance scan and why you need to use it.`, + lastScaned: '3:00pm on 11/22/2022', + buttonText: 'Configure Compliance Scan', + redirect: 'cloud/aws/configure', + }, +]; + +const SelectedAccountCard = () => { + const { mode } = useTheme(); + return ( +
+ + logo + +
+ + Amazon Web Services (AWS) + + + Account Id: 22222 + +
+
+ +
+
+ ); +}; + +const ScanList = () => { + const { navigate } = usePageNavigation(); + const goNext = (path: string) => { + navigate(path); + }; + return ( +
+ {scanTypeList.map( + ({ + scanType, + description, + lastScaned, + buttonText, + redirect, + }: ScanTypeListProps) => { + return ( + +

+ {scanType} +

+ +

+ {description} +

+
+ Last scan: {lastScaned} +
+ +
+ ); + }, + )} +
+ ); +}; +export const AWSChooseScan = () => { + const { goBack } = usePageNavigation(); + return ( + <> + + + + + ); +}; diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSInfraScanConfigure.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSInfraScanConfigure.tsx new file mode 100644 index 0000000000..a97713fff0 --- /dev/null +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSInfraScanConfigure.tsx @@ -0,0 +1,727 @@ +import { filter, find } from 'lodash-es'; +import { useEffect, useMemo, useState } from 'react'; +import { IconContext } from 'react-icons'; +import { HiMinusCircle, HiPlusCircle } from 'react-icons/hi'; +import { + Button, + createColumnHelper, + getRowSelectionColumn, + Switch, + Table, + Tabs, + Typography, +} from 'ui-components'; + +import { usePageNavigation } from '../../../utils/usePageNavigation'; + +type ColumnType = { + id: number; + test_category: string; + test_desc: string; + status: string; + is_enabled: boolean; +}; +const complianceTableData = [ + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 1, + is_enabled: true, + test_category: 'CloudWatch', + test_desc: + '4.1 Ensure a log metric filter and alarm exist for unauthorized API calls', + test_number: 'control.cis_v140_4_1', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 2, + is_enabled: true, + test_category: 'CloudWatch', + test_desc: + '4.2 Ensure a log metric filter and alarm exist for Management Console sign-in without MFA', + test_number: 'control.cis_v140_4_2', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 3, + is_enabled: true, + test_category: 'CloudWatch', + test_desc: + "4.3 Ensure a log metric filter and alarm exist for usage of 'root' account", + test_number: 'control.cis_v140_4_3', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 4, + is_enabled: true, + test_category: 'CloudWatch', + test_desc: '4.4 Ensure a log metric filter and alarm exist for IAM policy changes', + test_number: 'control.cis_v140_4_4', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 5, + is_enabled: true, + test_category: 'CloudWatch', + test_desc: + '4.5 Ensure a log metric filter and alarm exist for CloudTrail configuration changes', + test_number: 'control.cis_v140_4_5', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 6, + is_enabled: true, + test_category: 'CloudWatch', + test_desc: + '4.6 Ensure a log metric filter and alarm exist for AWS Management Console authentication failures', + test_number: 'control.cis_v140_4_6', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 7, + is_enabled: true, + test_category: 'CloudWatch', + test_desc: + '4.7 Ensure a log metric filter and alarm exist for disabling or scheduled deletion of customer created CMKs', + test_number: 'control.cis_v140_4_7', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 8, + is_enabled: true, + test_category: 'CloudWatch', + test_desc: + '4.8 Ensure a log metric filter and alarm exist for S3 bucket policy changes', + test_number: 'control.cis_v140_4_8', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 9, + is_enabled: true, + test_category: 'CloudWatch', + test_desc: + '4.9 Ensure a log metric filter and alarm exist for AWS Config configuration changes', + test_number: 'control.cis_v140_4_9', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 10, + is_enabled: true, + test_category: 'CloudWatch', + test_desc: + '4.10 Ensure a log metric filter and alarm exist for security group changes', + test_number: 'control.cis_v140_4_10', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 11, + is_enabled: true, + test_category: 'CloudWatch', + test_desc: + '4.11 Ensure a log metric filter and alarm exist for changes to Network Access Control Lists (NACL)', + test_number: 'control.cis_v140_4_11', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 12, + is_enabled: true, + test_category: 'CloudWatch', + test_desc: + '4.12 Ensure a log metric filter and alarm exist for changes to network gateways', + test_number: 'control.cis_v140_4_12', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 13, + is_enabled: true, + test_category: 'CloudWatch', + test_desc: '4.13 Ensure a log metric filter and alarm exist for route table changes', + test_number: 'control.cis_v140_4_13', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 14, + is_enabled: true, + test_category: 'CloudWatch', + test_desc: '4.14 Ensure a log metric filter and alarm exist for VPC changes', + test_number: 'control.cis_v140_4_14', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 15, + is_enabled: true, + test_category: 'CloudWatch', + test_desc: + '4.15 Ensure a log metric filter and alarm exists for AWS Organizations changes', + test_number: 'control.cis_v140_4_15', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 16, + is_enabled: true, + test_category: 'VPC', + test_desc: + '5.1 Ensure no Network ACLs allow ingress from 0.0.0.0/0 to remote server administration ports', + test_number: 'control.cis_v140_5_1', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 17, + is_enabled: true, + test_category: 'VPC', + test_desc: + '5.2 Ensure no security groups allow ingress from 0.0.0.0/0 to remote server administration ports', + test_number: 'control.cis_v140_5_2', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 18, + is_enabled: true, + test_category: 'VPC', + test_desc: '5.3 Ensure the default security group of every VPC restricts all traffic', + test_number: 'control.cis_v140_5_3', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 19, + is_enabled: true, + test_category: 'VPC', + test_desc: '5.4 Ensure routing tables for VPC peering are \\"least access\\', + test_number: 'control.cis_v140_5_4', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 20, + is_enabled: true, + test_category: 'CloudTrail', + test_desc: '3.1 Ensure CloudTrail is enabled in all regions', + test_number: 'control.cis_v140_3_1', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 21, + is_enabled: true, + test_category: 'CloudTrail', + test_desc: '3.2 Ensure CloudTrail log file validation is enabled', + test_number: 'control.cis_v140_3_2', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 22, + is_enabled: true, + test_category: 'CloudTrail', + test_desc: + '3.3 Ensure the S3 bucket used to store CloudTrail logs is not publicly accessible', + test_number: 'control.cis_v140_3_3', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 23, + is_enabled: true, + test_category: 'CloudTrail', + test_desc: '3.4 Ensure CloudTrail trails are integrated with CloudWatch Logs', + test_number: 'control.cis_v140_3_4', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 24, + is_enabled: true, + test_category: 'Config', + test_desc: '3.5 Ensure AWS Config is enabled in all regions', + test_number: 'control.cis_v140_3_5', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 25, + is_enabled: true, + test_category: 'CloudTrail', + test_desc: + '3.6 Ensure S3 bucket access logging is enabled on the CloudTrail S3 bucket', + test_number: 'control.cis_v140_3_6', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 26, + is_enabled: true, + test_category: 'CloudTrail', + test_desc: '3.7 Ensure CloudTrail logs are encrypted at rest using KMS CMKs', + test_number: 'control.cis_v140_3_7', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 27, + is_enabled: true, + test_category: 'KMS', + test_desc: '3.8 Ensure rotation for customer created CMKs is enabled', + test_number: 'control.cis_v140_3_8', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 28, + is_enabled: true, + test_category: 'VPC', + test_desc: '3.9 Ensure VPC flow logging is enabled in all VPCs', + test_number: 'control.cis_v140_3_9', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 29, + is_enabled: true, + test_category: 'S3', + test_desc: + '3.10 Ensure that Object-level logging for write events is enabled for S3 bucket', + test_number: 'control.cis_v140_3_10', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 30, + is_enabled: true, + test_category: 'S3', + test_desc: + '3.11 Ensure that Object-level logging for read events is enabled for S3 bucket', + test_number: 'control.cis_v140_3_11', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 31, + is_enabled: true, + test_category: 'IAM', + test_desc: '1.1 Maintain current contact details', + test_number: 'control.cis_v140_1_1', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 32, + is_enabled: true, + test_category: 'IAM', + test_desc: '1.2 Ensure security contact information is registered', + test_number: 'control.cis_v140_1_2', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 33, + is_enabled: true, + test_category: 'IAM', + test_desc: '1.3 Ensure security questions are registered in the AWS account', + test_number: 'control.cis_v140_1_3', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 34, + is_enabled: true, + test_category: 'IAM', + test_desc: "1.4 Ensure no 'root' user account access key exists", + test_number: 'control.cis_v140_1_4', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 35, + is_enabled: true, + test_category: 'IAM', + test_desc: "1.5 Ensure MFA is enabled for the 'root' user account", + test_number: 'control.cis_v140_1_5', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 36, + is_enabled: true, + test_category: 'IAM', + test_desc: "1.6 Ensure hardware MFA is enabled for the 'root' user account", + test_number: 'control.cis_v140_1_6', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 37, + is_enabled: true, + test_category: 'IAM', + test_desc: "1.7 Eliminate use of the 'root' user for administrative and daily tasks", + test_number: 'control.cis_v140_1_7', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 38, + is_enabled: true, + test_category: 'IAM', + test_desc: '1.8 Ensure IAM password policy requires minimum length of 14 or greater', + test_number: 'control.cis_v140_1_8', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 39, + is_enabled: true, + test_category: 'IAM', + test_desc: '1.9 Ensure IAM password policy prevents password reuse', + test_number: 'control.cis_v140_1_9', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 40, + is_enabled: true, + test_category: 'IAM', + test_desc: + '1.10 Ensure multi-factor authentication (MFA) is enabled for all IAM users that have a console password', + test_number: 'control.cis_v140_1_10', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 41, + is_enabled: true, + test_category: 'IAM', + test_desc: + '1.11 Do not setup access keys during initial user setup for all IAM users that have a console password', + test_number: 'control.cis_v140_1_11', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 42, + is_enabled: true, + test_category: 'IAM', + test_desc: '1.12 Ensure credentials unused for 45 days or greater are disabled', + test_number: 'control.cis_v140_1_12', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 43, + is_enabled: true, + test_category: 'IAM', + test_desc: + '1.13 Ensure there is only one active access key available for any single IAM user', + test_number: 'control.cis_v140_1_13', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 44, + is_enabled: true, + test_category: 'IAM', + test_desc: '1.14 Ensure access keys are rotated every 90 days or less', + test_number: 'control.cis_v140_1_14', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 45, + is_enabled: true, + test_category: 'IAM', + test_desc: '1.15 Ensure IAM Users Receive Permissions Only Through Groups', + test_number: 'control.cis_v140_1_15', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 46, + is_enabled: true, + test_category: 'IAM', + test_desc: + '1.16 Ensure IAM policies that allow full \\"*:*\\" administrative privileges are not attached', + test_number: 'control.cis_v140_1_16', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 47, + is_enabled: true, + test_category: 'IAM', + test_desc: + '1.17 Ensure a support role has been created to manage incidents with AWS Support', + test_number: 'control.cis_v140_1_17', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 48, + is_enabled: true, + test_category: 'IAM', + test_desc: + '1.18 Ensure IAM instance roles are used for AWS resource access from instances', + test_number: 'control.cis_v140_1_18', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 49, + is_enabled: true, + test_category: 'IAM', + test_desc: + '1.19 Ensure that all the expired SSL/TLS certificates stored in AWS IAM are removed', + test_number: 'control.cis_v140_1_19', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 50, + is_enabled: true, + test_category: 'IAM', + test_desc: '1.20 Ensure that IAM Access analyzer is enabled for all regions', + test_number: 'control.cis_v140_1_20', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 51, + is_enabled: true, + test_category: 'IAM', + test_desc: + '1.21 Ensure IAM users are managed centrally via identity federation or AWS Organizations for multi-account environments', + test_number: 'control.cis_v140_1_21', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 52, + is_enabled: true, + test_category: 'S3', + test_desc: '2.1.1 Ensure all S3 buckets employ encryption-at-rest', + test_number: 'control.cis_v140_2_1_1', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 53, + is_enabled: true, + test_category: 'S3', + test_desc: '2.1.2 Ensure S3 Bucket Policy is set to deny HTTP requests', + test_number: 'control.cis_v140_2_1_2', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 54, + is_enabled: true, + test_category: 'S3', + test_desc: '2.1.3 Ensure MFA Delete is enabled on S3 buckets', + test_number: 'control.cis_v140_2_1_3', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 55, + is_enabled: true, + test_category: 'S3', + test_desc: + '2.1.4 Ensure all data in Amazon S3 has been discovered, classified and secured when required', + test_number: 'control.cis_v140_2_1_4', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 56, + is_enabled: true, + test_category: 'S3', + test_desc: + "2.1.5 Ensure that S3 Buckets are configured with 'Block public access (bucket settings)'", + test_number: 'control.cis_v140_2_1_5', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 57, + is_enabled: true, + test_category: 'EBS', + test_desc: '2.2.1 Ensure EBS volume encryption is enabled', + test_number: 'control.cis_v140_2_2_1', + }, + { + cloud_provider: 'aws', + compliance_check_type: 'cis', + id: 58, + is_enabled: true, + test_category: 'RDS', + test_desc: '2.3.1 Ensure that encryption is enabled for RDS Instances', + test_number: 'control.cis_v140_2_3_1', + }, +]; + +const ComplianceTable = () => { + const columnHelper = createColumnHelper(); + const [tableData, setTableData] = useState(complianceTableData); + + const [rowSelectionState, setRowSelectionState] = useState({}); + + const updateTableData = (rowData: any, flag: boolean) => { + console.log(flag, 'data is ', rowData); + setTableData((data) => { + data[rowData.row.index].is_enabled = flag; + + return [...data]; + }); + }; + const columns = useMemo( + () => [ + getRowSelectionColumn(columnHelper, { + maxSize: 10, + }), + columnHelper.accessor('id', { + cell: (info) => info.getValue(), + header: () => '#', + maxSize: 20, + }), + columnHelper.accessor((row) => row.test_category, { + id: 'category', + cell: (info) => info.getValue(), + header: () => Category, + maxSize: 50, + }), + columnHelper.accessor('test_desc', { + header: () => 'Description', + cell: (info) => info.renderValue(), + minSize: 500, + }), + columnHelper.accessor('status', { + header: () => 'Status', + cell: (info) => 'Active', + maxSize: 50, + }), + columnHelper.accessor('is_enabled', { + header: () => 'Enabled', + cell: (info) => ( + { + updateTableData(info, e); + }} + /> + ), + maxSize: 50, + }), + ], + [], + ); + return ( + + ); +}; + +const scanType = ['CIS', 'GDPR', 'HIPPA', 'PIC', 'SOC2', 'NIST']; + +type TabsType = { + label: string; + value: string; +}; + +const hasTypeSelected = (prevTabs: TabsType[], value: string) => { + return find(prevTabs, ['value', value]); +}; + +export const AWSInfraScanConfigure = () => { + const { goBack } = usePageNavigation(); + const [selectedTab, setSelectedTab] = useState(''); + const [tabs, setTabs] = useState([]); + + const onScanTypeSelection = (name: string) => { + setTabs((prevTabs) => { + const found = hasTypeSelected(prevTabs, name); + if (found) { + return [...filter(prevTabs, (tab) => tab.value !== found.value)]; + } else { + return [ + ...prevTabs, + { + label: name, + value: name, + }, + ]; + } + }); + }; + + useEffect(() => { + // set selected tab by last compliance type + if (tabs.length > 0) { + setSelectedTab(tabs[tabs.length - 1].value); + } else { + setSelectedTab(''); + } + }, [tabs]); + + return ( + <> +
+ {scanType.map((type) => ( + + ))} +
+
+ {selectedTab === '' ? ( +

Please select at least one compliance type.

+ ) : ( + setSelectedTab(v)}> +
+ +
+
+ )} +
+ + + ); +}; diff --git a/deepfence_frontend/apps/dashboard/src/routes/private.tsx b/deepfence_frontend/apps/dashboard/src/routes/private.tsx index 632379d1e9..64ccde485c 100644 --- a/deepfence_frontend/apps/dashboard/src/routes/private.tsx +++ b/deepfence_frontend/apps/dashboard/src/routes/private.tsx @@ -1,11 +1,14 @@ import { Outlet, RouteObject } from 'react-router-dom'; +import { ScanInfraLayout } from '../features/onboard/layouts/InfraScanLayout'; import { OnboardLayout, rootOnboardLoader, } from '../features/onboard/layouts/OnboardLayout'; import { AmazonECRConnector } from '../features/onboard/pages/AmazonECRConnector'; +import { AWSChooseScan } from '../features/onboard/pages/AWSChooseScan'; import { AWSConnector } from '../features/onboard/pages/AWSConnector'; +import { AWSInfraScanConfigure } from '../features/onboard/pages/AWSInfraScanConfigure'; import { AzureConnector } from '../features/onboard/pages/AzureConnector'; import { Connector } from '../features/onboard/pages/Connector'; import { GCPConnector } from '../features/onboard/pages/GCPConnector'; @@ -57,6 +60,20 @@ export const privateRoutes: RouteObject[] = [ }, ], }, + { + path: 'scan-infrastructure', + element: , + children: [ + { + path: 'cloud/aws', + element: , + }, + { + path: 'cloud/aws/configure', + element: , + }, + ], + }, ], }, ]; diff --git a/deepfence_frontend/packages/ui-components/src/components/table/Table.tsx b/deepfence_frontend/packages/ui-components/src/components/table/Table.tsx index 9bfaa4f97b..5f2d382587 100644 --- a/deepfence_frontend/packages/ui-components/src/components/table/Table.tsx +++ b/deepfence_frontend/packages/ui-components/src/components/table/Table.tsx @@ -251,8 +251,8 @@ function Th({ onClick={header.column.getToggleSortingHandler()} >
@@ -360,12 +360,16 @@ function Td({
diff --git a/deepfence_frontend/packages/ui-components/src/components/tabs/Tabs.tsx b/deepfence_frontend/packages/ui-components/src/components/tabs/Tabs.tsx index 4bff2b4ce6..eb9ec8c5aa 100644 --- a/deepfence_frontend/packages/ui-components/src/components/tabs/Tabs.tsx +++ b/deepfence_frontend/packages/ui-components/src/components/tabs/Tabs.tsx @@ -30,9 +30,9 @@ const classes = { }; const Tabs = (props: TabProps) => { - const { tabs, value, defaultValue, size = 'sm', children, ...rest } = props; + const { tabs, value, size = 'sm', children, ...rest } = props; return ( - + Date: Tue, 17 Jan 2023 14:24:56 +0530 Subject: [PATCH 02/11] wip: add actions --- .../onboard/pages/AWSInfraScanConfigure.tsx | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSInfraScanConfigure.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSInfraScanConfigure.tsx index a97713fff0..c5ea72f3ea 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSInfraScanConfigure.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSInfraScanConfigure.tsx @@ -1,4 +1,4 @@ -import { filter, find } from 'lodash-es'; +import { filter, find, isEmpty } from 'lodash-es'; import { useEffect, useMemo, useState } from 'react'; import { IconContext } from 'react-icons'; import { HiMinusCircle, HiPlusCircle } from 'react-icons/hi'; @@ -630,14 +630,19 @@ const ComplianceTable = () => { [], ); return ( -
{flexRender(cell.column.columnDef.cell, cell.getContext())}
+
+
+ {isEmpty(rowSelectionState) ? 'No rows selected' :
} +
+
+ ); }; @@ -689,6 +694,7 @@ export const AWSInfraScanConfigure = () => { {scanType.map((type) => (
{ return find(prevTabs, ['value', value]); }; -export const AWSInfraScanConfigure = () => { +export const ComplianceScanConfigure = () => { const { goBack } = usePageNavigation(); const [selectedTab, setSelectedTab] = useState(''); const [tabs, setTabs] = useState([]); @@ -690,6 +703,14 @@ export const AWSInfraScanConfigure = () => { return ( <> +
{scanType.map((type) => (
- diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/SecretScanConfigure.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/SecretScanConfigure.tsx new file mode 100644 index 0000000000..4f52d302d4 --- /dev/null +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/SecretScanConfigure.tsx @@ -0,0 +1,61 @@ +import { Button, Checkbox, Switch, Typography } from 'ui-components'; + +import { usePageNavigation } from '../../../utils/usePageNavigation'; +import { ConnectorHeader } from '../components/ConnectorHeader'; + +const packages = [ + { + name: 'OS Packages', + }, + { + name: 'Java', + }, + { + name: 'Javascript', + }, + { + name: 'Rust', + }, + { + name: 'GoLang', + }, + { + name: 'Ruby', + }, + { + name: 'Python', + }, + { + name: 'PHP', + }, + { + name: 'Dotnet', + }, +]; + +export const SecretScanConfigure = () => { + const { goBack } = usePageNavigation(); + return ( + <> + +
+
+ Packages +
+
+ + + + ); +}; diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/VulnerabilityScanConfigure.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/VulnerabilityScanConfigure.tsx new file mode 100644 index 0000000000..151949a466 --- /dev/null +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/VulnerabilityScanConfigure.tsx @@ -0,0 +1,87 @@ +import { Button, Checkbox, Switch, Typography } from 'ui-components'; + +import { usePageNavigation } from '../../../utils/usePageNavigation'; +import { ConnectorHeader } from '../components/ConnectorHeader'; +import { ScanInfraLayout } from '../layouts/InfraScanLayout'; + +const packages = [ + { + name: 'OS Packages', + }, + { + name: 'Java', + }, + { + name: 'Javascript', + }, + { + name: 'Rust', + }, + { + name: 'GoLang', + }, + { + name: 'Ruby', + }, + { + name: 'Python', + }, + { + name: 'PHP', + }, + { + name: 'Dotnet', + }, +]; + +export const VulnerabilityScanConfigure = () => { + const { goBack } = usePageNavigation(); + return ( + <> + +
+
+ Packages +
+
+ +
+ +
+ {packages.map((pkg) => { + return ; + })} +
+
+ +
+
+ Advanced Options +
+ +
+ + +
+
+ + + ); +}; diff --git a/deepfence_frontend/apps/dashboard/src/routes/private.tsx b/deepfence_frontend/apps/dashboard/src/routes/private.tsx index 64ccde485c..41eec860d2 100644 --- a/deepfence_frontend/apps/dashboard/src/routes/private.tsx +++ b/deepfence_frontend/apps/dashboard/src/routes/private.tsx @@ -8,11 +8,13 @@ import { import { AmazonECRConnector } from '../features/onboard/pages/AmazonECRConnector'; import { AWSChooseScan } from '../features/onboard/pages/AWSChooseScan'; import { AWSConnector } from '../features/onboard/pages/AWSConnector'; -import { AWSInfraScanConfigure } from '../features/onboard/pages/AWSInfraScanConfigure'; import { AzureConnector } from '../features/onboard/pages/AzureConnector'; +import { ComplianceScanConfigure } from '../features/onboard/pages/ComplianceScanConfigure'; import { Connector } from '../features/onboard/pages/Connector'; import { GCPConnector } from '../features/onboard/pages/GCPConnector'; import { K8sConnector } from '../features/onboard/pages/K8sConnector'; +import { SecretScanConfigure } from '../features/onboard/pages/SecretScanConfigure'; +import { VulnerabilityScanConfigure } from '../features/onboard/pages/VulnerabilityScanConfigure'; export const privateRoutes: RouteObject[] = [ { @@ -62,7 +64,7 @@ export const privateRoutes: RouteObject[] = [ }, { path: 'scan-infrastructure', - element: , + element: , children: [ { path: 'cloud/aws', @@ -70,7 +72,15 @@ export const privateRoutes: RouteObject[] = [ }, { path: 'cloud/aws/configure', - element: , + element: , + }, + { + path: 'host/configure/vulnerability', + element: , + }, + { + path: 'host/configure/secret', + element: , }, ], }, From f9db55da33265b7c89761d16fbe179e8c18cd868 Mon Sep 17 00:00:00 2001 From: milan-deepfence Date: Wed, 18 Jan 2023 12:57:23 +0530 Subject: [PATCH 04/11] update to use root base import, rename button --- .../registries/AmazonECRConnectionForm.tsx | 4 +- .../features/onboard/pages/AWSChooseScan.tsx | 32 +++++++------- .../onboard/pages/AmazonECRConnector.tsx | 2 +- .../features/onboard/pages/AzureConnector.tsx | 2 +- .../onboard/pages/ComplianceScanConfigure.tsx | 7 ++-- .../onboard/pages/DockerConnector.tsx | 2 +- .../features/onboard/pages/GCPConnector.tsx | 2 +- .../features/onboard/pages/K8sConnector.tsx | 2 +- .../features/onboard/pages/LinuxConnector.tsx | 2 +- .../onboard/pages/SecretScanConfigure.tsx | 42 +++---------------- .../pages/VulnerabilityScanConfigure.tsx | 7 ++-- .../pages/connectors/AddConnectors.tsx | 4 +- .../apps/dashboard/src/routes/private.tsx | 29 ++++++++++++- 13 files changed, 66 insertions(+), 71 deletions(-) diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/components/connectors/registries/AmazonECRConnectionForm.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/components/connectors/registries/AmazonECRConnectionForm.tsx index 027da86397..92f5fa4c5b 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/components/connectors/registries/AmazonECRConnectionForm.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/components/connectors/registries/AmazonECRConnectionForm.tsx @@ -66,8 +66,8 @@ export const AmazonECRConnectorForm = () => { placeholder="AWS Region" /> - diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSChooseScan.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSChooseScan.tsx index e1d55e8ab7..7ffddd58cd 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSChooseScan.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSChooseScan.tsx @@ -1,10 +1,11 @@ +import { useLocation } from 'react-router-dom'; import { Button, Card, Separator, Typography } from 'ui-components'; -import LogoAws from '../../../assets/logo-aws.svg'; -import LogoAwsWhite from '../../../assets/logo-aws-white.svg'; -import { useTheme } from '../../../theme/ThemeContext'; -import { usePageNavigation } from '../../../utils/usePageNavigation'; -import { ConnectorHeader } from '../components/ConnectorHeader'; +import LogoAws from '@/assets/logo-aws.svg'; +import LogoAwsWhite from '@/assets/logo-aws-white.svg'; +import { ConnectorHeader } from '@/features/onboard/components/ConnectorHeader'; +import { useTheme } from '@/theme/ThemeContext'; +import { usePageNavigation } from '@/utils/usePageNavigation'; type ScanTypeListProps = { scanType: string; @@ -14,27 +15,27 @@ type ScanTypeListProps = { redirect: string; }; -const scanTypeList: ScanTypeListProps[] = [ +const scanTypes: ScanTypeListProps[] = [ { scanType: 'Vulnerability Scan', description: `A few words about the compliance scan and why you need to use it.`, lastScaned: '3:00pm on 11/22/2022', buttonText: 'Configure Vulnerability Scan', - redirect: '/onboard/scan-infrastructure/host/configure/vulnerability', + redirect: '/vulnerability', }, { scanType: 'Compliance Scan', description: `A few words about the compliance scan and why you need to use it.`, lastScaned: '3:00pm on 11/22/2022', buttonText: 'Configure Compliance Scan', - redirect: '/onboard/scan-infrastructure/cloud/aws/configure', + redirect: '/compliance', }, { scanType: 'Secrets Scan', description: `A few words about the compliance scan and why you need to use it.`, lastScaned: '3:00pm on 11/22/2022', buttonText: 'Configure Secret Scan', - redirect: '/onboard/scan-infrastructure/host/configure/secret', + redirect: '/secret', }, ]; @@ -66,14 +67,16 @@ const SelectedAccountCard = () => { ); }; -const ScanList = () => { +const ScanType = () => { + const location = useLocation(); const { navigate } = usePageNavigation(); const goNext = (path: string) => { navigate(path); }; + return (
- {scanTypeList.map( + {scanTypes.map( ({ scanType, description, @@ -101,7 +104,8 @@ const ScanList = () => { size="xs" color="primary" onClick={() => { - goNext(redirect); + // redirect: '/onboard/scan/configure/secret', + goNext(`${location.pathname}${redirect}`); }} > {buttonText} @@ -122,9 +126,9 @@ export const AWSChooseScan = () => { description="Choose from the below options to perform your first scan." /> - + ); diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AmazonECRConnector.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AmazonECRConnector.tsx index cabd5f067b..66d84a78c1 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AmazonECRConnector.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AmazonECRConnector.tsx @@ -15,7 +15,7 @@ export const AmazonECRConnector = () => {
diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AzureConnector.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AzureConnector.tsx index 6cc84c68fe..b1c56e82ac 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AzureConnector.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AzureConnector.tsx @@ -15,7 +15,7 @@ export const AzureConnector = () => { /> ); diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ComplianceScanConfigure.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ComplianceScanConfigure.tsx index a01fcad2ea..dcc7e46fdb 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ComplianceScanConfigure.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ComplianceScanConfigure.tsx @@ -12,9 +12,8 @@ import { Typography, } from 'ui-components'; -import { usePageNavigation } from '../../../utils/usePageNavigation'; -import { ConnectorHeader } from '../components/ConnectorHeader'; -import { ScanInfraLayout } from '../layouts/InfraScanLayout'; +import { ConnectorHeader } from '@/features/onboard/components/ConnectorHeader'; +import { usePageNavigation } from '@/utils/usePageNavigation'; type ColumnType = { id: number; @@ -747,7 +746,7 @@ export const ComplianceScanConfigure = () => { )} ); diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/DockerConnector.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/DockerConnector.tsx index 2f145325f5..8fc1eeec7b 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/DockerConnector.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/DockerConnector.tsx @@ -16,7 +16,7 @@ export const DockerConnector = () => { ); diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/GCPConnector.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/GCPConnector.tsx index a51361ada7..5fe16bbd40 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/GCPConnector.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/GCPConnector.tsx @@ -16,7 +16,7 @@ export const GCPConnector = () => { ); diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/K8sConnector.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/K8sConnector.tsx index aed78fc391..de7a3c5f99 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/K8sConnector.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/K8sConnector.tsx @@ -18,7 +18,7 @@ export const K8sConnector = () => {
diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/LinuxConnector.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/LinuxConnector.tsx index d6a2fa0310..88383be4f1 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/LinuxConnector.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/LinuxConnector.tsx @@ -16,7 +16,7 @@ export const LinuxConnector = () => { ); diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/SecretScanConfigure.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/SecretScanConfigure.tsx index 4f52d302d4..dcb389ad59 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/SecretScanConfigure.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/SecretScanConfigure.tsx @@ -1,37 +1,7 @@ -import { Button, Checkbox, Switch, Typography } from 'ui-components'; +import { Button, Typography } from 'ui-components'; -import { usePageNavigation } from '../../../utils/usePageNavigation'; -import { ConnectorHeader } from '../components/ConnectorHeader'; - -const packages = [ - { - name: 'OS Packages', - }, - { - name: 'Java', - }, - { - name: 'Javascript', - }, - { - name: 'Rust', - }, - { - name: 'GoLang', - }, - { - name: 'Ruby', - }, - { - name: 'Python', - }, - { - name: 'PHP', - }, - { - name: 'Dotnet', - }, -]; +import { ConnectorHeader } from '@/features/onboard/components/ConnectorHeader'; +import { usePageNavigation } from '@/utils/usePageNavigation'; export const SecretScanConfigure = () => { const { goBack } = usePageNavigation(); @@ -48,13 +18,11 @@ export const SecretScanConfigure = () => {
- Packages -
+ >
); diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/VulnerabilityScanConfigure.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/VulnerabilityScanConfigure.tsx index 151949a466..f69bbb4e1b 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/VulnerabilityScanConfigure.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/VulnerabilityScanConfigure.tsx @@ -1,8 +1,7 @@ import { Button, Checkbox, Switch, Typography } from 'ui-components'; -import { usePageNavigation } from '../../../utils/usePageNavigation'; -import { ConnectorHeader } from '../components/ConnectorHeader'; -import { ScanInfraLayout } from '../layouts/InfraScanLayout'; +import { ConnectorHeader } from '@/features/onboard/components/ConnectorHeader'; +import { usePageNavigation } from '@/utils/usePageNavigation'; const packages = [ { @@ -80,7 +79,7 @@ export const VulnerabilityScanConfigure = () => { ); diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/connectors/AddConnectors.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/connectors/AddConnectors.tsx index 45285cdd8c..e7fd27a2f8 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/connectors/AddConnectors.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/connectors/AddConnectors.tsx @@ -126,12 +126,12 @@ const Host = () => { { icon: LogoDocker, label: 'Docker Container', - path: 'docker', + path: 'host/docker', }, { icon: LogoLinux, label: 'Linux Bare-Metal/VM', - path: 'host-linux', + path: 'host/linux', }, ]; diff --git a/deepfence_frontend/apps/dashboard/src/routes/private.tsx b/deepfence_frontend/apps/dashboard/src/routes/private.tsx index 7286907e65..e36447d1a9 100644 --- a/deepfence_frontend/apps/dashboard/src/routes/private.tsx +++ b/deepfence_frontend/apps/dashboard/src/routes/private.tsx @@ -9,14 +9,18 @@ import { rootOnboardLoader, } from '@/features/onboard/layouts/OnboardLayout'; import { AmazonECRConnector } from '@/features/onboard/pages/AmazonECRConnector'; +import { AWSChooseScan } from '@/features/onboard/pages/AWSChooseScan'; import { AWSConnector } from '@/features/onboard/pages/AWSConnector'; import { AzureConnector } from '@/features/onboard/pages/AzureConnector'; +import { ComplianceScanConfigure } from '@/features/onboard/pages/ComplianceScanConfigure'; import { AddConnector } from '@/features/onboard/pages/connectors/AddConnectors'; import { MyConnectors } from '@/features/onboard/pages/connectors/MyConnectors'; import { DockerConnector } from '@/features/onboard/pages/DockerConnector'; import { GCPConnector } from '@/features/onboard/pages/GCPConnector'; import { K8sConnector } from '@/features/onboard/pages/K8sConnector'; import { LinuxConnector } from '@/features/onboard/pages/LinuxConnector'; +import { SecretScanConfigure } from '@/features/onboard/pages/SecretScanConfigure'; +import { VulnerabilityScanConfigure } from '@/features/onboard/pages/VulnerabilityScanConfigure'; export const privateRoutes: RouteObject[] = [ { @@ -60,11 +64,11 @@ export const privateRoutes: RouteObject[] = [ element: , }, { - path: 'docker', + path: 'host/docker', element: , }, { - path: 'host-linux', + path: 'host/linux', element: , }, { @@ -73,6 +77,27 @@ export const privateRoutes: RouteObject[] = [ }, ], }, + { + path: 'scan', + children: [ + { + path: 'configure', + element: , + }, + { + path: 'configure/compliance', + element: , + }, + { + path: 'configure/vulnerability', + element: , + }, + { + path: 'configure/secret', + element: , + }, + ], + }, ], }, ]; From d35f7899bd52f358d43125529fdf613dfb289140 Mon Sep 17 00:00:00 2001 From: milan-deepfence Date: Wed, 18 Jan 2023 15:02:12 +0530 Subject: [PATCH 05/11] update switch connector button, remove component --- .../features/onboard/layouts/InfraScanLayout.tsx | 15 --------------- .../src/features/onboard/pages/AWSChooseScan.tsx | 14 +++++++++++--- 2 files changed, 11 insertions(+), 18 deletions(-) delete mode 100644 deepfence_frontend/apps/dashboard/src/features/onboard/layouts/InfraScanLayout.tsx diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/layouts/InfraScanLayout.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/layouts/InfraScanLayout.tsx deleted file mode 100644 index 15b973ee83..0000000000 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/layouts/InfraScanLayout.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { Outlet } from 'react-router-dom'; - -import { ConnectorHeader } from '../components/ConnectorHeader'; - -export const ScanInfraLayout = () => { - return ( -
- - -
- ); -}; diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSChooseScan.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSChooseScan.tsx index 7ffddd58cd..c1c844481b 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSChooseScan.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSChooseScan.tsx @@ -1,3 +1,4 @@ +import { HiSwitchHorizontal } from 'react-icons/hi'; import { useLocation } from 'react-router-dom'; import { Button, Card, Separator, Typography } from 'ui-components'; @@ -41,6 +42,7 @@ const scanTypes: ScanTypeListProps[] = [ const SelectedAccountCard = () => { const { mode } = useTheme(); + const { navigate } = usePageNavigation(); return (
@@ -59,8 +61,15 @@ const SelectedAccountCard = () => {
-
@@ -104,7 +113,6 @@ const ScanType = () => { size="xs" color="primary" onClick={() => { - // redirect: '/onboard/scan/configure/secret', goNext(`${location.pathname}${redirect}`); }} > From dbf3ecbe257fe3242e107d555af5cb8aaede0fb5 Mon Sep 17 00:00:00 2001 From: milan-deepfence Date: Wed, 18 Jan 2023 16:45:20 +0530 Subject: [PATCH 06/11] rename component --- .../pages/{AWSChooseScan.tsx => ChooseScan.tsx} | 2 +- .../src/features/onboard/pages/SecretScanConfigure.tsx | 10 +++++----- .../apps/dashboard/src/routes/private.tsx | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) rename deepfence_frontend/apps/dashboard/src/features/onboard/pages/{AWSChooseScan.tsx => ChooseScan.tsx} (99%) diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSChooseScan.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ChooseScan.tsx similarity index 99% rename from deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSChooseScan.tsx rename to deepfence_frontend/apps/dashboard/src/features/onboard/pages/ChooseScan.tsx index c1c844481b..584c88a45e 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/AWSChooseScan.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ChooseScan.tsx @@ -125,7 +125,7 @@ const ScanType = () => { ); }; -export const AWSChooseScan = () => { +export const ChooseScan = () => { const { goBack } = usePageNavigation(); return ( <> diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/SecretScanConfigure.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/SecretScanConfigure.tsx index dcb389ad59..b863134745 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/SecretScanConfigure.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/SecretScanConfigure.tsx @@ -1,4 +1,4 @@ -import { Button, Typography } from 'ui-components'; +import { Button } from 'ui-components'; import { ConnectorHeader } from '@/features/onboard/components/ConnectorHeader'; import { usePageNavigation } from '@/utils/usePageNavigation'; @@ -9,16 +9,16 @@ export const SecretScanConfigure = () => { <>
-
+
+ )} @@ -678,7 +678,7 @@ export const ComplianceScanConfigure = () => { setTabs((prevTabs) => { const found = hasTypeSelected(prevTabs, name); if (found) { - return [...filter(prevTabs, (tab) => tab.value !== found.value)]; + return [...filter(prevTabs, (tab: TabsType) => tab.value !== found.value)]; } else { return [ ...prevTabs, @@ -703,14 +703,14 @@ export const ComplianceScanConfigure = () => { return ( <> -
+
{scanType.map((type) => ( ))} +
{selectedTab === '' ? ( -

Please select at least one compliance type.

+

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

) : ( setSelectedTab(v)}>
diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/SecretScanConfigure.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/SecretScanConfigure.tsx index b863134745..0714705ad9 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/SecretScanConfigure.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/SecretScanConfigure.tsx @@ -8,15 +8,16 @@ export const SecretScanConfigure = () => { return ( <> -
-
diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/VulnerabilityScanConfigure.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/VulnerabilityScanConfigure.tsx index f69bbb4e1b..0a88027b70 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/VulnerabilityScanConfigure.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/VulnerabilityScanConfigure.tsx @@ -38,7 +38,7 @@ export const VulnerabilityScanConfigure = () => { return ( <> { }} />
-
- Packages -
+
+
+ Packages +
+ +
diff --git a/deepfence_frontend/apps/dashboard/src/routes/private.tsx b/deepfence_frontend/apps/dashboard/src/routes/private.tsx index 64a739ae8d..df32bbd196 100644 --- a/deepfence_frontend/apps/dashboard/src/routes/private.tsx +++ b/deepfence_frontend/apps/dashboard/src/routes/private.tsx @@ -81,7 +81,7 @@ export const privateRoutes: RouteObject[] = [ path: 'scan', children: [ { - path: 'configure', + path: 'choose', element: , }, { From fb048914eea72a5412011a094c5c4b173728e79b Mon Sep 17 00:00:00 2001 From: milan-deepfence Date: Thu, 19 Jan 2023 10:00:46 +0530 Subject: [PATCH 08/11] added select all functionality --- .../src/features/onboard/pages/ChooseScan.tsx | 4 +- .../pages/VulnerabilityScanConfigure.tsx | 83 ++++++++++++++++++- 2 files changed, 82 insertions(+), 5 deletions(-) diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ChooseScan.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ChooseScan.tsx index 1a537f0889..8e07014360 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ChooseScan.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ChooseScan.tsx @@ -40,7 +40,7 @@ const scanTypes: ScanTypeListProps[] = [ }, ]; -const SelectedAccountCard = () => { +const SelectedAccount = () => { const { mode } = useTheme(); const { navigate } = usePageNavigation(); return ( @@ -133,7 +133,7 @@ export const ChooseScan = () => { title="Choose your scan type" description="Choose from the below options to perform your first scan." /> - +
- +
- {packages.map((pkg) => { - return ; + {pkgs.map((pkg) => { + return ( + { + onPackageCheckedChange(pkg, checked); + }} + /> + ); })}
From 1bf7ac394cbdf8ec99572be2636080164838464b Mon Sep 17 00:00:00 2001 From: milan-deepfence Date: Thu, 19 Jan 2023 10:18:06 +0530 Subject: [PATCH 09/11] remove unused import --- .../src/features/onboard/pages/ComplianceScanConfigure.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ComplianceScanConfigure.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ComplianceScanConfigure.tsx index 71bd2dad79..5e095dca20 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ComplianceScanConfigure.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ComplianceScanConfigure.tsx @@ -1,6 +1,5 @@ import { filter, find, isEmpty } from 'lodash-es'; import { useEffect, useMemo, useState } from 'react'; -import { IconContext } from 'react-icons'; import { HiBan, HiLightBulb, HiMinusCircle, HiPlusCircle } from 'react-icons/hi'; import { Button, From 2265bc354a61e49560783a7e285ecc0dc9dc4a31 Mon Sep 17 00:00:00 2001 From: milan-deepfence Date: Thu, 19 Jan 2023 10:28:33 +0530 Subject: [PATCH 10/11] fix build failed --- .../onboard/pages/ComplianceScanConfigure.tsx | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ComplianceScanConfigure.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ComplianceScanConfigure.tsx index 5e095dca20..4ae3b0b71b 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ComplianceScanConfigure.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ComplianceScanConfigure.tsx @@ -31,6 +31,7 @@ const complianceTableData = [ test_desc: '4.1 Ensure a log metric filter and alarm exist for unauthorized API calls', test_number: 'control.cis_v140_4_1', + status: 'Active', }, { cloud_provider: 'aws', @@ -41,6 +42,7 @@ const complianceTableData = [ test_desc: '4.2 Ensure a log metric filter and alarm exist for Management Console sign-in without MFA', test_number: 'control.cis_v140_4_2', + status: 'Active', }, { cloud_provider: 'aws', @@ -51,6 +53,7 @@ const complianceTableData = [ test_desc: "4.3 Ensure a log metric filter and alarm exist for usage of 'root' account", test_number: 'control.cis_v140_4_3', + status: 'Active', }, { cloud_provider: 'aws', @@ -60,6 +63,7 @@ const complianceTableData = [ test_category: 'CloudWatch', test_desc: '4.4 Ensure a log metric filter and alarm exist for IAM policy changes', test_number: 'control.cis_v140_4_4', + status: 'Active', }, { cloud_provider: 'aws', @@ -70,6 +74,7 @@ const complianceTableData = [ test_desc: '4.5 Ensure a log metric filter and alarm exist for CloudTrail configuration changes', test_number: 'control.cis_v140_4_5', + status: 'Active', }, { cloud_provider: 'aws', @@ -80,6 +85,7 @@ const complianceTableData = [ test_desc: '4.6 Ensure a log metric filter and alarm exist for AWS Management Console authentication failures', test_number: 'control.cis_v140_4_6', + status: 'Active', }, { cloud_provider: 'aws', @@ -90,6 +96,7 @@ const complianceTableData = [ test_desc: '4.7 Ensure a log metric filter and alarm exist for disabling or scheduled deletion of customer created CMKs', test_number: 'control.cis_v140_4_7', + status: 'Active', }, { cloud_provider: 'aws', @@ -100,6 +107,7 @@ const complianceTableData = [ test_desc: '4.8 Ensure a log metric filter and alarm exist for S3 bucket policy changes', test_number: 'control.cis_v140_4_8', + status: 'Active', }, { cloud_provider: 'aws', @@ -110,6 +118,7 @@ const complianceTableData = [ test_desc: '4.9 Ensure a log metric filter and alarm exist for AWS Config configuration changes', test_number: 'control.cis_v140_4_9', + status: 'Active', }, { cloud_provider: 'aws', @@ -120,6 +129,7 @@ const complianceTableData = [ test_desc: '4.10 Ensure a log metric filter and alarm exist for security group changes', test_number: 'control.cis_v140_4_10', + status: 'Active', }, { cloud_provider: 'aws', @@ -130,6 +140,7 @@ const complianceTableData = [ test_desc: '4.11 Ensure a log metric filter and alarm exist for changes to Network Access Control Lists (NACL)', test_number: 'control.cis_v140_4_11', + status: 'Active', }, { cloud_provider: 'aws', @@ -140,6 +151,7 @@ const complianceTableData = [ test_desc: '4.12 Ensure a log metric filter and alarm exist for changes to network gateways', test_number: 'control.cis_v140_4_12', + status: 'Active', }, { cloud_provider: 'aws', @@ -149,6 +161,7 @@ const complianceTableData = [ test_category: 'CloudWatch', test_desc: '4.13 Ensure a log metric filter and alarm exist for route table changes', test_number: 'control.cis_v140_4_13', + status: 'Active', }, { cloud_provider: 'aws', @@ -158,6 +171,7 @@ const complianceTableData = [ test_category: 'CloudWatch', test_desc: '4.14 Ensure a log metric filter and alarm exist for VPC changes', test_number: 'control.cis_v140_4_14', + status: 'Active', }, { cloud_provider: 'aws', @@ -168,6 +182,7 @@ const complianceTableData = [ test_desc: '4.15 Ensure a log metric filter and alarm exists for AWS Organizations changes', test_number: 'control.cis_v140_4_15', + status: 'Active', }, { cloud_provider: 'aws', @@ -178,6 +193,7 @@ const complianceTableData = [ test_desc: '5.1 Ensure no Network ACLs allow ingress from 0.0.0.0/0 to remote server administration ports', test_number: 'control.cis_v140_5_1', + status: 'Active', }, { cloud_provider: 'aws', @@ -188,6 +204,7 @@ const complianceTableData = [ test_desc: '5.2 Ensure no security groups allow ingress from 0.0.0.0/0 to remote server administration ports', test_number: 'control.cis_v140_5_2', + status: 'Active', }, { cloud_provider: 'aws', @@ -197,6 +214,7 @@ const complianceTableData = [ test_category: 'VPC', test_desc: '5.3 Ensure the default security group of every VPC restricts all traffic', test_number: 'control.cis_v140_5_3', + status: 'Active', }, { cloud_provider: 'aws', @@ -206,6 +224,7 @@ const complianceTableData = [ test_category: 'VPC', test_desc: '5.4 Ensure routing tables for VPC peering are \\"least access\\', test_number: 'control.cis_v140_5_4', + status: 'Active', }, { cloud_provider: 'aws', @@ -215,6 +234,7 @@ const complianceTableData = [ test_category: 'CloudTrail', test_desc: '3.1 Ensure CloudTrail is enabled in all regions', test_number: 'control.cis_v140_3_1', + status: 'Active', }, { cloud_provider: 'aws', @@ -224,6 +244,7 @@ const complianceTableData = [ test_category: 'CloudTrail', test_desc: '3.2 Ensure CloudTrail log file validation is enabled', test_number: 'control.cis_v140_3_2', + status: 'Active', }, { cloud_provider: 'aws', @@ -234,6 +255,7 @@ const complianceTableData = [ test_desc: '3.3 Ensure the S3 bucket used to store CloudTrail logs is not publicly accessible', test_number: 'control.cis_v140_3_3', + status: 'Active', }, { cloud_provider: 'aws', @@ -243,6 +265,7 @@ const complianceTableData = [ test_category: 'CloudTrail', test_desc: '3.4 Ensure CloudTrail trails are integrated with CloudWatch Logs', test_number: 'control.cis_v140_3_4', + status: 'Active', }, { cloud_provider: 'aws', @@ -252,6 +275,7 @@ const complianceTableData = [ test_category: 'Config', test_desc: '3.5 Ensure AWS Config is enabled in all regions', test_number: 'control.cis_v140_3_5', + status: 'Active', }, { cloud_provider: 'aws', @@ -262,6 +286,7 @@ const complianceTableData = [ test_desc: '3.6 Ensure S3 bucket access logging is enabled on the CloudTrail S3 bucket', test_number: 'control.cis_v140_3_6', + status: 'Active', }, { cloud_provider: 'aws', @@ -271,6 +296,7 @@ const complianceTableData = [ test_category: 'CloudTrail', test_desc: '3.7 Ensure CloudTrail logs are encrypted at rest using KMS CMKs', test_number: 'control.cis_v140_3_7', + status: 'Active', }, { cloud_provider: 'aws', @@ -280,6 +306,7 @@ const complianceTableData = [ test_category: 'KMS', test_desc: '3.8 Ensure rotation for customer created CMKs is enabled', test_number: 'control.cis_v140_3_8', + status: 'Active', }, { cloud_provider: 'aws', @@ -289,6 +316,7 @@ const complianceTableData = [ test_category: 'VPC', test_desc: '3.9 Ensure VPC flow logging is enabled in all VPCs', test_number: 'control.cis_v140_3_9', + status: 'Active', }, { cloud_provider: 'aws', @@ -299,6 +327,7 @@ const complianceTableData = [ test_desc: '3.10 Ensure that Object-level logging for write events is enabled for S3 bucket', test_number: 'control.cis_v140_3_10', + status: 'Active', }, { cloud_provider: 'aws', @@ -309,6 +338,7 @@ const complianceTableData = [ test_desc: '3.11 Ensure that Object-level logging for read events is enabled for S3 bucket', test_number: 'control.cis_v140_3_11', + status: 'Active', }, { cloud_provider: 'aws', @@ -318,6 +348,7 @@ const complianceTableData = [ test_category: 'IAM', test_desc: '1.1 Maintain current contact details', test_number: 'control.cis_v140_1_1', + status: 'Active', }, { cloud_provider: 'aws', @@ -327,6 +358,7 @@ const complianceTableData = [ test_category: 'IAM', test_desc: '1.2 Ensure security contact information is registered', test_number: 'control.cis_v140_1_2', + status: 'Active', }, { cloud_provider: 'aws', @@ -336,6 +368,7 @@ const complianceTableData = [ test_category: 'IAM', test_desc: '1.3 Ensure security questions are registered in the AWS account', test_number: 'control.cis_v140_1_3', + status: 'Active', }, { cloud_provider: 'aws', @@ -345,6 +378,7 @@ const complianceTableData = [ test_category: 'IAM', test_desc: "1.4 Ensure no 'root' user account access key exists", test_number: 'control.cis_v140_1_4', + status: 'Active', }, { cloud_provider: 'aws', @@ -354,6 +388,7 @@ const complianceTableData = [ test_category: 'IAM', test_desc: "1.5 Ensure MFA is enabled for the 'root' user account", test_number: 'control.cis_v140_1_5', + status: 'Active', }, { cloud_provider: 'aws', @@ -363,6 +398,7 @@ const complianceTableData = [ test_category: 'IAM', test_desc: "1.6 Ensure hardware MFA is enabled for the 'root' user account", test_number: 'control.cis_v140_1_6', + status: 'Active', }, { cloud_provider: 'aws', @@ -372,6 +408,7 @@ const complianceTableData = [ test_category: 'IAM', test_desc: "1.7 Eliminate use of the 'root' user for administrative and daily tasks", test_number: 'control.cis_v140_1_7', + status: 'Active', }, { cloud_provider: 'aws', @@ -381,6 +418,7 @@ const complianceTableData = [ test_category: 'IAM', test_desc: '1.8 Ensure IAM password policy requires minimum length of 14 or greater', test_number: 'control.cis_v140_1_8', + status: 'Active', }, { cloud_provider: 'aws', @@ -390,6 +428,7 @@ const complianceTableData = [ test_category: 'IAM', test_desc: '1.9 Ensure IAM password policy prevents password reuse', test_number: 'control.cis_v140_1_9', + status: 'Active', }, { cloud_provider: 'aws', @@ -400,6 +439,7 @@ const complianceTableData = [ test_desc: '1.10 Ensure multi-factor authentication (MFA) is enabled for all IAM users that have a console password', test_number: 'control.cis_v140_1_10', + status: 'Active', }, { cloud_provider: 'aws', @@ -410,6 +450,7 @@ const complianceTableData = [ test_desc: '1.11 Do not setup access keys during initial user setup for all IAM users that have a console password', test_number: 'control.cis_v140_1_11', + status: 'Active', }, { cloud_provider: 'aws', @@ -419,6 +460,7 @@ const complianceTableData = [ test_category: 'IAM', test_desc: '1.12 Ensure credentials unused for 45 days or greater are disabled', test_number: 'control.cis_v140_1_12', + status: 'Active', }, { cloud_provider: 'aws', @@ -429,6 +471,7 @@ const complianceTableData = [ test_desc: '1.13 Ensure there is only one active access key available for any single IAM user', test_number: 'control.cis_v140_1_13', + status: 'Active', }, { cloud_provider: 'aws', @@ -438,6 +481,7 @@ const complianceTableData = [ test_category: 'IAM', test_desc: '1.14 Ensure access keys are rotated every 90 days or less', test_number: 'control.cis_v140_1_14', + status: 'Active', }, { cloud_provider: 'aws', @@ -447,6 +491,7 @@ const complianceTableData = [ test_category: 'IAM', test_desc: '1.15 Ensure IAM Users Receive Permissions Only Through Groups', test_number: 'control.cis_v140_1_15', + status: 'Active', }, { cloud_provider: 'aws', @@ -457,6 +502,7 @@ const complianceTableData = [ test_desc: '1.16 Ensure IAM policies that allow full \\"*:*\\" administrative privileges are not attached', test_number: 'control.cis_v140_1_16', + status: 'Active', }, { cloud_provider: 'aws', @@ -467,6 +513,7 @@ const complianceTableData = [ test_desc: '1.17 Ensure a support role has been created to manage incidents with AWS Support', test_number: 'control.cis_v140_1_17', + status: 'Active', }, { cloud_provider: 'aws', @@ -477,6 +524,7 @@ const complianceTableData = [ test_desc: '1.18 Ensure IAM instance roles are used for AWS resource access from instances', test_number: 'control.cis_v140_1_18', + status: 'Active', }, { cloud_provider: 'aws', @@ -487,6 +535,7 @@ const complianceTableData = [ test_desc: '1.19 Ensure that all the expired SSL/TLS certificates stored in AWS IAM are removed', test_number: 'control.cis_v140_1_19', + status: 'Active', }, { cloud_provider: 'aws', @@ -496,6 +545,7 @@ const complianceTableData = [ test_category: 'IAM', test_desc: '1.20 Ensure that IAM Access analyzer is enabled for all regions', test_number: 'control.cis_v140_1_20', + status: 'Active', }, { cloud_provider: 'aws', @@ -506,6 +556,7 @@ const complianceTableData = [ test_desc: '1.21 Ensure IAM users are managed centrally via identity federation or AWS Organizations for multi-account environments', test_number: 'control.cis_v140_1_21', + status: 'Active', }, { cloud_provider: 'aws', @@ -515,6 +566,7 @@ const complianceTableData = [ test_category: 'S3', test_desc: '2.1.1 Ensure all S3 buckets employ encryption-at-rest', test_number: 'control.cis_v140_2_1_1', + status: 'Active', }, { cloud_provider: 'aws', @@ -524,6 +576,7 @@ const complianceTableData = [ test_category: 'S3', test_desc: '2.1.2 Ensure S3 Bucket Policy is set to deny HTTP requests', test_number: 'control.cis_v140_2_1_2', + status: 'Active', }, { cloud_provider: 'aws', @@ -533,6 +586,7 @@ const complianceTableData = [ test_category: 'S3', test_desc: '2.1.3 Ensure MFA Delete is enabled on S3 buckets', test_number: 'control.cis_v140_2_1_3', + status: 'Active', }, { cloud_provider: 'aws', @@ -543,6 +597,7 @@ const complianceTableData = [ test_desc: '2.1.4 Ensure all data in Amazon S3 has been discovered, classified and secured when required', test_number: 'control.cis_v140_2_1_4', + status: 'Active', }, { cloud_provider: 'aws', @@ -553,6 +608,7 @@ const complianceTableData = [ test_desc: "2.1.5 Ensure that S3 Buckets are configured with 'Block public access (bucket settings)'", test_number: 'control.cis_v140_2_1_5', + status: 'Active', }, { cloud_provider: 'aws', @@ -562,6 +618,7 @@ const complianceTableData = [ test_category: 'EBS', test_desc: '2.2.1 Ensure EBS volume encryption is enabled', test_number: 'control.cis_v140_2_2_1', + status: 'Non Active', }, { cloud_provider: 'aws', @@ -571,6 +628,7 @@ const complianceTableData = [ test_category: 'RDS', test_desc: '2.3.1 Ensure that encryption is enabled for RDS Instances', test_number: 'control.cis_v140_2_3_1', + status: 'Non Active', }, ]; From decb76a17755631d3f01361bf449b9c24a08c015 Mon Sep 17 00:00:00 2001 From: milan-deepfence Date: Thu, 19 Jan 2023 15:10:50 +0530 Subject: [PATCH 11/11] pass component to connector header to display selected accounts --- .../onboard/components/ConnectorHeader.tsx | 41 +- .../src/features/onboard/pages/ChooseScan.tsx | 2 - .../onboard/pages/ComplianceScanConfigure.tsx | 541 ++---------------- .../onboard/pages/SecretScanConfigure.tsx | 4 - .../pages/VulnerabilityScanConfigure.tsx | 4 - 5 files changed, 63 insertions(+), 529 deletions(-) diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/components/ConnectorHeader.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/components/ConnectorHeader.tsx index 3d5a858764..ecb3d507a5 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/components/ConnectorHeader.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/components/ConnectorHeader.tsx @@ -6,25 +6,23 @@ import { Breadcrumb, BreadcrumbLink, Typography } from 'ui-components'; type ConnectorHeaderProps = { title: string; description: string; - metadata?: { - [key: string]: string; - }; + endComponent?: JSX.Element; }; const canRoute = (pathname: string) => { const path = { addConnector: '/onboard/connectors/add-connectors', - scanResult: '', + configureScan: '', viewResult: '', }; - if (pathname.includes('view-scan-results')) { - path.viewResult = '/onboard/view-scan-results'; - path.scanResult = '/onboard/scan-infrastructure'; - } else if (pathname.includes('scan-infrastructure')) { - path.scanResult = '/onboard/scan-infrastructure'; + if (pathname.includes('view-summary')) { + path.viewResult = '/onboard/scan/view-summary'; + path.configureScan = '#'; + } else if (pathname.includes('scan/configure')) { + path.configureScan = '#'; path.viewResult = '#'; } else if (pathname.includes('connectors')) { - path.scanResult = '#'; + path.configureScan = '#'; path.viewResult = '#'; } return path; @@ -33,7 +31,7 @@ const canRoute = (pathname: string) => { export const ConnectorHeader = ({ title, description, - metadata = {}, + endComponent, }: ConnectorHeaderProps) => { const location = useLocation(); @@ -45,11 +43,14 @@ export const ConnectorHeader = ({ }; const isScanRoutePath = () => { - return location.pathname.includes('scan-infrastructure'); + return ( + location.pathname.startsWith('/onboard/scan/choose') || + location.pathname.startsWith('/onboard/scan/configure') + ); }; - const isViewResultsRoutePath = () => { - return location.pathname.includes('view-scan-results'); + const isViewScanSummaryRoutePath = () => { + return location.pathname.includes('scan/view-summary'); }; return ( @@ -68,7 +69,7 @@ export const ConnectorHeader = ({ View Scan Results @@ -97,13 +98,7 @@ export const ConnectorHeader = ({ {description}

-
- - {metadata.accountId - ? `Account: ${metadata.type} / ${metadata.accountId}` - : null} - -
+ {endComponent ?
{endComponent}
: null}
); diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ChooseScan.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ChooseScan.tsx index 8e07014360..5376da1744 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ChooseScan.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ChooseScan.tsx @@ -1,5 +1,4 @@ import { HiSwitchHorizontal } from 'react-icons/hi'; -import { useLocation } from 'react-router-dom'; import { Button, Card, Separator, Typography } from 'ui-components'; import LogoAws from '@/assets/logo-aws.svg'; @@ -77,7 +76,6 @@ const SelectedAccount = () => { }; const ScanType = () => { - const location = useLocation(); const { navigate } = usePageNavigation(); const goNext = (path: string) => { navigate(path); diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ComplianceScanConfigure.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ComplianceScanConfigure.tsx index 4ae3b0b71b..70ae264f6b 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ComplianceScanConfigure.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/ComplianceScanConfigure.tsx @@ -8,6 +8,7 @@ import { Switch, Table, Tabs, + Tooltip, Typography, } from 'ui-components'; @@ -142,494 +143,6 @@ const complianceTableData = [ test_number: 'control.cis_v140_4_11', status: 'Active', }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 12, - is_enabled: true, - test_category: 'CloudWatch', - test_desc: - '4.12 Ensure a log metric filter and alarm exist for changes to network gateways', - test_number: 'control.cis_v140_4_12', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 13, - is_enabled: true, - test_category: 'CloudWatch', - test_desc: '4.13 Ensure a log metric filter and alarm exist for route table changes', - test_number: 'control.cis_v140_4_13', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 14, - is_enabled: true, - test_category: 'CloudWatch', - test_desc: '4.14 Ensure a log metric filter and alarm exist for VPC changes', - test_number: 'control.cis_v140_4_14', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 15, - is_enabled: true, - test_category: 'CloudWatch', - test_desc: - '4.15 Ensure a log metric filter and alarm exists for AWS Organizations changes', - test_number: 'control.cis_v140_4_15', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 16, - is_enabled: true, - test_category: 'VPC', - test_desc: - '5.1 Ensure no Network ACLs allow ingress from 0.0.0.0/0 to remote server administration ports', - test_number: 'control.cis_v140_5_1', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 17, - is_enabled: true, - test_category: 'VPC', - test_desc: - '5.2 Ensure no security groups allow ingress from 0.0.0.0/0 to remote server administration ports', - test_number: 'control.cis_v140_5_2', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 18, - is_enabled: true, - test_category: 'VPC', - test_desc: '5.3 Ensure the default security group of every VPC restricts all traffic', - test_number: 'control.cis_v140_5_3', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 19, - is_enabled: true, - test_category: 'VPC', - test_desc: '5.4 Ensure routing tables for VPC peering are \\"least access\\', - test_number: 'control.cis_v140_5_4', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 20, - is_enabled: true, - test_category: 'CloudTrail', - test_desc: '3.1 Ensure CloudTrail is enabled in all regions', - test_number: 'control.cis_v140_3_1', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 21, - is_enabled: true, - test_category: 'CloudTrail', - test_desc: '3.2 Ensure CloudTrail log file validation is enabled', - test_number: 'control.cis_v140_3_2', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 22, - is_enabled: true, - test_category: 'CloudTrail', - test_desc: - '3.3 Ensure the S3 bucket used to store CloudTrail logs is not publicly accessible', - test_number: 'control.cis_v140_3_3', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 23, - is_enabled: true, - test_category: 'CloudTrail', - test_desc: '3.4 Ensure CloudTrail trails are integrated with CloudWatch Logs', - test_number: 'control.cis_v140_3_4', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 24, - is_enabled: true, - test_category: 'Config', - test_desc: '3.5 Ensure AWS Config is enabled in all regions', - test_number: 'control.cis_v140_3_5', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 25, - is_enabled: true, - test_category: 'CloudTrail', - test_desc: - '3.6 Ensure S3 bucket access logging is enabled on the CloudTrail S3 bucket', - test_number: 'control.cis_v140_3_6', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 26, - is_enabled: true, - test_category: 'CloudTrail', - test_desc: '3.7 Ensure CloudTrail logs are encrypted at rest using KMS CMKs', - test_number: 'control.cis_v140_3_7', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 27, - is_enabled: true, - test_category: 'KMS', - test_desc: '3.8 Ensure rotation for customer created CMKs is enabled', - test_number: 'control.cis_v140_3_8', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 28, - is_enabled: true, - test_category: 'VPC', - test_desc: '3.9 Ensure VPC flow logging is enabled in all VPCs', - test_number: 'control.cis_v140_3_9', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 29, - is_enabled: true, - test_category: 'S3', - test_desc: - '3.10 Ensure that Object-level logging for write events is enabled for S3 bucket', - test_number: 'control.cis_v140_3_10', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 30, - is_enabled: true, - test_category: 'S3', - test_desc: - '3.11 Ensure that Object-level logging for read events is enabled for S3 bucket', - test_number: 'control.cis_v140_3_11', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 31, - is_enabled: true, - test_category: 'IAM', - test_desc: '1.1 Maintain current contact details', - test_number: 'control.cis_v140_1_1', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 32, - is_enabled: true, - test_category: 'IAM', - test_desc: '1.2 Ensure security contact information is registered', - test_number: 'control.cis_v140_1_2', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 33, - is_enabled: true, - test_category: 'IAM', - test_desc: '1.3 Ensure security questions are registered in the AWS account', - test_number: 'control.cis_v140_1_3', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 34, - is_enabled: true, - test_category: 'IAM', - test_desc: "1.4 Ensure no 'root' user account access key exists", - test_number: 'control.cis_v140_1_4', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 35, - is_enabled: true, - test_category: 'IAM', - test_desc: "1.5 Ensure MFA is enabled for the 'root' user account", - test_number: 'control.cis_v140_1_5', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 36, - is_enabled: true, - test_category: 'IAM', - test_desc: "1.6 Ensure hardware MFA is enabled for the 'root' user account", - test_number: 'control.cis_v140_1_6', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 37, - is_enabled: true, - test_category: 'IAM', - test_desc: "1.7 Eliminate use of the 'root' user for administrative and daily tasks", - test_number: 'control.cis_v140_1_7', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 38, - is_enabled: true, - test_category: 'IAM', - test_desc: '1.8 Ensure IAM password policy requires minimum length of 14 or greater', - test_number: 'control.cis_v140_1_8', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 39, - is_enabled: true, - test_category: 'IAM', - test_desc: '1.9 Ensure IAM password policy prevents password reuse', - test_number: 'control.cis_v140_1_9', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 40, - is_enabled: true, - test_category: 'IAM', - test_desc: - '1.10 Ensure multi-factor authentication (MFA) is enabled for all IAM users that have a console password', - test_number: 'control.cis_v140_1_10', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 41, - is_enabled: true, - test_category: 'IAM', - test_desc: - '1.11 Do not setup access keys during initial user setup for all IAM users that have a console password', - test_number: 'control.cis_v140_1_11', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 42, - is_enabled: true, - test_category: 'IAM', - test_desc: '1.12 Ensure credentials unused for 45 days or greater are disabled', - test_number: 'control.cis_v140_1_12', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 43, - is_enabled: true, - test_category: 'IAM', - test_desc: - '1.13 Ensure there is only one active access key available for any single IAM user', - test_number: 'control.cis_v140_1_13', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 44, - is_enabled: true, - test_category: 'IAM', - test_desc: '1.14 Ensure access keys are rotated every 90 days or less', - test_number: 'control.cis_v140_1_14', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 45, - is_enabled: true, - test_category: 'IAM', - test_desc: '1.15 Ensure IAM Users Receive Permissions Only Through Groups', - test_number: 'control.cis_v140_1_15', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 46, - is_enabled: true, - test_category: 'IAM', - test_desc: - '1.16 Ensure IAM policies that allow full \\"*:*\\" administrative privileges are not attached', - test_number: 'control.cis_v140_1_16', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 47, - is_enabled: true, - test_category: 'IAM', - test_desc: - '1.17 Ensure a support role has been created to manage incidents with AWS Support', - test_number: 'control.cis_v140_1_17', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 48, - is_enabled: true, - test_category: 'IAM', - test_desc: - '1.18 Ensure IAM instance roles are used for AWS resource access from instances', - test_number: 'control.cis_v140_1_18', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 49, - is_enabled: true, - test_category: 'IAM', - test_desc: - '1.19 Ensure that all the expired SSL/TLS certificates stored in AWS IAM are removed', - test_number: 'control.cis_v140_1_19', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 50, - is_enabled: true, - test_category: 'IAM', - test_desc: '1.20 Ensure that IAM Access analyzer is enabled for all regions', - test_number: 'control.cis_v140_1_20', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 51, - is_enabled: true, - test_category: 'IAM', - test_desc: - '1.21 Ensure IAM users are managed centrally via identity federation or AWS Organizations for multi-account environments', - test_number: 'control.cis_v140_1_21', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 52, - is_enabled: true, - test_category: 'S3', - test_desc: '2.1.1 Ensure all S3 buckets employ encryption-at-rest', - test_number: 'control.cis_v140_2_1_1', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 53, - is_enabled: true, - test_category: 'S3', - test_desc: '2.1.2 Ensure S3 Bucket Policy is set to deny HTTP requests', - test_number: 'control.cis_v140_2_1_2', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 54, - is_enabled: true, - test_category: 'S3', - test_desc: '2.1.3 Ensure MFA Delete is enabled on S3 buckets', - test_number: 'control.cis_v140_2_1_3', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 55, - is_enabled: true, - test_category: 'S3', - test_desc: - '2.1.4 Ensure all data in Amazon S3 has been discovered, classified and secured when required', - test_number: 'control.cis_v140_2_1_4', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 56, - is_enabled: true, - test_category: 'S3', - test_desc: - "2.1.5 Ensure that S3 Buckets are configured with 'Block public access (bucket settings)'", - test_number: 'control.cis_v140_2_1_5', - status: 'Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 57, - is_enabled: true, - test_category: 'EBS', - test_desc: '2.2.1 Ensure EBS volume encryption is enabled', - test_number: 'control.cis_v140_2_2_1', - status: 'Non Active', - }, - { - cloud_provider: 'aws', - compliance_check_type: 'cis', - id: 58, - is_enabled: true, - test_category: 'RDS', - test_desc: '2.3.1 Ensure that encryption is enabled for RDS Instances', - test_number: 'control.cis_v140_2_3_1', - status: 'Non Active', - }, ]; const ComplianceTable = () => { @@ -638,8 +151,7 @@ const ComplianceTable = () => { const [rowSelectionState, setRowSelectionState] = useState({}); - const updateTableData = (rowData: any, flag: boolean) => { - console.log(flag, 'data is ', rowData); + const onToggleChange = (rowData: any, flag: boolean) => { setTableData((data) => { data[rowData.row.index].is_enabled = flag; @@ -669,7 +181,7 @@ const ComplianceTable = () => { }), columnHelper.accessor('status', { header: () => 'Status', - cell: (info) => 'Active', + cell: (info) => info.renderValue(), maxSize: 50, }), columnHelper.accessor('is_enabled', { @@ -678,7 +190,7 @@ const ComplianceTable = () => { { - updateTableData(info, e); + onToggleChange(info, e); }} /> ), @@ -726,10 +238,33 @@ const hasTypeSelected = (prevTabs: TabsType[], value: string) => { return find(prevTabs, ['value', value]); }; +const SelectedAccountComponent = ({ + type, + accounts, +}: { + type: string; + accounts: string[]; +}) => { + return ( + + {accounts.length > 0 ? `Account: ${type} / ${accounts[0]}` : null} +   + {accounts.length > 1 && ( + + + +{accounts.length - 1} more + + + )} + + ); +}; + export const ComplianceScanConfigure = () => { const { goBack } = usePageNavigation(); const [selectedTab, setSelectedTab] = useState(''); const [tabs, setTabs] = useState([]); + const { navigate } = usePageNavigation(); const onScanTypeSelection = (name: string) => { setTabs((prevTabs) => { @@ -762,10 +297,22 @@ export const ComplianceScanConfigure = () => { + } />
{scanType.map((type) => ( @@ -778,6 +325,7 @@ export const ComplianceScanConfigure = () => { onScanTypeSelection(type); }} endIcon={hasTypeSelected(tabs, type) ? : } + className="self-start" > {type} @@ -787,6 +335,7 @@ export const ComplianceScanConfigure = () => { color="primary" className="ml-auto" disabled={tabs.length === 0} + onClick={() => navigate('/onboard/scan/view-summary')} > Start Scan diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/SecretScanConfigure.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/SecretScanConfigure.tsx index 0714705ad9..da8f34abb2 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/SecretScanConfigure.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/SecretScanConfigure.tsx @@ -10,10 +10,6 @@ export const SecretScanConfigure = () => {
diff --git a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/VulnerabilityScanConfigure.tsx b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/VulnerabilityScanConfigure.tsx index 212b246c2a..f773dfe42d 100644 --- a/deepfence_frontend/apps/dashboard/src/features/onboard/pages/VulnerabilityScanConfigure.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/onboard/pages/VulnerabilityScanConfigure.tsx @@ -103,10 +103,6 @@ export const VulnerabilityScanConfigure = () => {