From c1f1c9d253df3518dbed0856606e3a7528a908ef Mon Sep 17 00:00:00 2001 From: milan-deepfence Date: Tue, 13 Feb 2024 20:35:43 +0530 Subject: [PATCH 01/32] use created at field instead of updated at field in scan, scan result and compare scann pages --- .../src/components/forms/CompareScanInputModal.tsx | 10 +++++----- .../dashboard/src/components/forms/ScanTimeList.tsx | 13 +++++++------ .../features/malwares/pages/MalwareScanResults.tsx | 12 ++++++------ .../src/features/malwares/pages/MalwareScans.tsx | 2 +- .../postures/pages/PostureCloudScanResults.tsx | 12 ++++++------ .../features/postures/pages/PostureScanResults.tsx | 10 +++++----- .../features/secrets/pages/SecretScanResults.tsx | 12 ++++++------ .../src/features/secrets/pages/SecretScans.tsx | 2 +- .../pages/VulnerabilityScanResults.tsx | 12 ++++++------ .../vulnerabilities/pages/VulnerabilityScans.tsx | 2 +- .../apps/dashboard/src/queries/common.ts | 2 +- 11 files changed, 45 insertions(+), 44 deletions(-) diff --git a/deepfence_frontend/apps/dashboard/src/components/forms/CompareScanInputModal.tsx b/deepfence_frontend/apps/dashboard/src/components/forms/CompareScanInputModal.tsx index 5a677b48af..505f06f90d 100644 --- a/deepfence_frontend/apps/dashboard/src/components/forms/CompareScanInputModal.tsx +++ b/deepfence_frontend/apps/dashboard/src/components/forms/CompareScanInputModal.tsx @@ -136,7 +136,7 @@ const InputForm = ({ valueKey="nodeId" onChange={(data: ISelected) => { setToScanData({ - toScanTime: data.updatedAt, + toScanTime: data.createdAt, toScanId: data.scanId, }); }} @@ -153,7 +153,7 @@ const InputForm = ({ valueKey="nodeId" onChange={(data: ISelected) => { setToScanData({ - toScanTime: data.updatedAt, + toScanTime: data.createdAt, toScanId: data.scanId, }); }} @@ -183,7 +183,7 @@ export const CompareScanInputModal = ({ showDialog: boolean; setShowDialog: React.Dispatch>; scanHistoryData: { - updatedAt: number; + createdAt: number; scanId: string; status: string; }[]; @@ -238,12 +238,12 @@ export const CompareScanInputModal = ({ disabled={!toScanData.toScanTime} onClick={() => { const baseScan = scanHistoryData.find((data) => { - return data.updatedAt === compareInput.baseScanTime; + return data.createdAt === compareInput.baseScanTime; }); setCompareInput({ baseScanId: baseScan?.scanId ?? '', toScanId: toScanData?.toScanId ?? '', - baseScanTime: baseScan?.updatedAt ?? 0, + baseScanTime: baseScan?.createdAt ?? 0, toScanTime: toScanData?.toScanTime ?? 0, showScanTimeModal: false, }); diff --git a/deepfence_frontend/apps/dashboard/src/components/forms/ScanTimeList.tsx b/deepfence_frontend/apps/dashboard/src/components/forms/ScanTimeList.tsx index 95f8422e4d..394dfe0462 100644 --- a/deepfence_frontend/apps/dashboard/src/components/forms/ScanTimeList.tsx +++ b/deepfence_frontend/apps/dashboard/src/components/forms/ScanTimeList.tsx @@ -23,7 +23,7 @@ interface TimeListProps { } export interface ISelected { - updatedAt: number; + createdAt: number; scanId: string; } @@ -91,7 +91,7 @@ const ScanTime = ({ placeholder="Scan time" value={selectedTime as unknown as ISelected} onChange={(value: ISelected) => { - setSelectedTime(value.updatedAt); + setSelectedTime(value.createdAt); onChange?.(value); }} clearAll="Clear" @@ -109,20 +109,21 @@ const ScanTime = ({ return page.data; }) .filter( - (scan) => scan.updatedAt !== skipScanTime && isScanComplete(scan.status), + (scan) => scan.createdAt !== skipScanTime && isScanComplete(scan.status), ) + .reverse() ?.map?.((scan) => { return ( - {formatMilliseconds(scan.updatedAt)} + {formatMilliseconds(scan.createdAt)} ); })} 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 f80357ddd1..6c36bb7ca3 100644 --- a/deepfence_frontend/apps/dashboard/src/features/malwares/pages/MalwareScanResults.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/malwares/pages/MalwareScanResults.tsx @@ -585,7 +585,7 @@ const HistoryControls = () => { const [isSubmitting, setIsSubmitting] = useState(false); const { data, fetchStatus } = useScanResults(); const { scanStatusResult } = data; - const { scan_id, node_id, node_type, updated_at, status } = scanStatusResult ?? {}; + const { scan_id, node_id, node_type, created_at, status } = scanStatusResult ?? {}; const { navigate, goBack } = usePageNavigation(); const { downloadScan } = useDownloadScan((state) => { setIsSubmitting(state === 'submitting'); @@ -604,7 +604,7 @@ const HistoryControls = () => { }>({ baseScanId: '', toScanId: '', - baseScanTime: updated_at ?? 0, + baseScanTime: created_at ?? 0, toScanTime: 0, showScanTimeModal: false, }); @@ -625,7 +625,7 @@ const HistoryControls = () => { if (!scan_id || !node_id || !node_type) { throw new Error('Scan Type, Node Type and Node Id are required'); } - if (!updated_at) { + if (!created_at) { return null; } @@ -680,7 +680,7 @@ const HistoryControls = () => { id: item.scanId, isCurrent: item.scanId === scan_id, status: item.status, - timestamp: item.updatedAt, + timestamp: item.createdAt, showScanCompareButton: true, onScanTimeCompareButtonClick: onCompareScanClick, onDeleteClick: (id) => { @@ -704,7 +704,7 @@ const HistoryControls = () => { ); }, }))} - currentTimeStamp={formatMilliseconds(updated_at)} + currentTimeStamp={formatMilliseconds(created_at)} /> {scanIdToDelete && ( @@ -784,7 +784,7 @@ const HistoryControls = () => { onClick={() => { setCompareInput({ ...compareInput, - baseScanTime: updated_at ?? 0, + baseScanTime: created_at ?? 0, showScanTimeModal: true, }); }} 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 91ef896070..d1bbdba754 100644 --- a/deepfence_frontend/apps/dashboard/src/features/malwares/pages/MalwareScans.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/malwares/pages/MalwareScans.tsx @@ -736,7 +736,7 @@ const ScansTable = ({ size: 240, maxSize: 250, }), - columnHelper.accessor('updated_at', { + columnHelper.accessor('created_at', { cell: (info) => , header: () => , minSize: 140, diff --git a/deepfence_frontend/apps/dashboard/src/features/postures/pages/PostureCloudScanResults.tsx b/deepfence_frontend/apps/dashboard/src/features/postures/pages/PostureCloudScanResults.tsx index a1ee35092f..133ba1839e 100644 --- a/deepfence_frontend/apps/dashboard/src/features/postures/pages/PostureCloudScanResults.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/postures/pages/PostureCloudScanResults.tsx @@ -582,7 +582,7 @@ const HistoryControls = () => { }); const [openStopScanModal, setOpenStopScanModal] = useState(false); - const { scan_id, node_id, node_type, updated_at, status } = scanStatusResult ?? {}; + const { scan_id, node_id, node_type, created_at, status } = scanStatusResult ?? {}; const [showScanCompareModal, setShowScanCompareModal] = useState(false); @@ -597,7 +597,7 @@ const HistoryControls = () => { }>({ baseScanId: '', toScanId: '', - baseScanTime: updated_at ?? 0, + baseScanTime: created_at ?? 0, toScanTime: 0, showScanTimeModal: false, }); @@ -626,7 +626,7 @@ const HistoryControls = () => { showScanTimeModal: true, }); }; - + console.log(created_at); return (
{openStopScanModal && ( @@ -670,7 +670,7 @@ const HistoryControls = () => { id: item.scanId, isCurrent: item.scanId === scan_id, status: item.status, - timestamp: item.updatedAt, + timestamp: item.createdAt, showScanCompareButton: true, onScanTimeCompareButtonClick: onCompareScanClick, onDeleteClick: (id) => { @@ -695,7 +695,7 @@ const HistoryControls = () => { ); }, }))} - currentTimeStamp={formatMilliseconds(updated_at ?? '')} + currentTimeStamp={formatMilliseconds(created_at ?? '')} /> {scanIdToDelete && ( @@ -775,7 +775,7 @@ const HistoryControls = () => { onClick={() => { setCompareInput({ ...compareInput, - baseScanTime: updated_at ?? 0, + baseScanTime: created_at ?? 0, showScanTimeModal: true, }); }} 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 e7dd3a95ab..1852195ed9 100644 --- a/deepfence_frontend/apps/dashboard/src/features/postures/pages/PostureScanResults.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/postures/pages/PostureScanResults.tsx @@ -572,7 +572,7 @@ const HistoryControls = () => { const { data, fetchStatus } = useScanResults(); const { nodeType = '' } = useParams(); const { scanStatusResult } = data; - const { scan_id, node_id, node_type, updated_at, status } = scanStatusResult ?? {}; + const { scan_id, node_id, node_type, created_at, status } = scanStatusResult ?? {}; const { navigate, goBack } = usePageNavigation(); const { downloadScan } = useDownloadScan((state) => { setIsSubmitting(state === 'submitting'); @@ -592,7 +592,7 @@ const HistoryControls = () => { }>({ baseScanId: '', toScanId: '', - baseScanTime: updated_at ?? 0, + baseScanTime: created_at ?? 0, toScanTime: 0, showScanTimeModal: false, }); @@ -665,7 +665,7 @@ const HistoryControls = () => { id: item.scanId, isCurrent: item.scanId === scan_id, status: item.status, - timestamp: item.updatedAt, + timestamp: item.createdAt, showScanCompareButton: true, onScanTimeCompareButtonClick: onCompareScanClick, onDeleteClick: (id) => { @@ -690,7 +690,7 @@ const HistoryControls = () => { ); }, }))} - currentTimeStamp={formatMilliseconds(updated_at ?? '')} + currentTimeStamp={formatMilliseconds(created_at ?? '')} /> {scanIdToDelete && ( @@ -770,7 +770,7 @@ const HistoryControls = () => { onClick={() => { setCompareInput({ ...compareInput, - baseScanTime: updated_at ?? 0, + baseScanTime: created_at ?? 0, showScanTimeModal: true, }); }} diff --git a/deepfence_frontend/apps/dashboard/src/features/secrets/pages/SecretScanResults.tsx b/deepfence_frontend/apps/dashboard/src/features/secrets/pages/SecretScanResults.tsx index 61262756b2..9ef61199bc 100644 --- a/deepfence_frontend/apps/dashboard/src/features/secrets/pages/SecretScanResults.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/secrets/pages/SecretScanResults.tsx @@ -584,7 +584,7 @@ const HistoryControls = () => { const [isSubmitting, setIsSubmitting] = useState(false); const { data, fetchStatus } = useScanResults(); const { scanStatusResult } = data; - const { scan_id, node_id, node_type, updated_at, status } = scanStatusResult ?? {}; + const { scan_id, node_id, node_type, created_at, status } = scanStatusResult ?? {}; const { navigate, goBack } = usePageNavigation(); const { downloadScan } = useDownloadScan((state) => { setIsSubmitting(state === 'submitting'); @@ -604,7 +604,7 @@ const HistoryControls = () => { }>({ baseScanId: '', toScanId: '', - baseScanTime: updated_at ?? 0, + baseScanTime: created_at ?? 0, toScanTime: 0, showScanTimeModal: false, }); @@ -625,7 +625,7 @@ const HistoryControls = () => { if (!scan_id || !node_id || !node_type) { throw new Error('Scan Type, Node Type and Node Id are required'); } - if (!updated_at) { + if (!created_at) { return null; } const onCompareScanClick = (baseScanTime: number) => { @@ -679,7 +679,7 @@ const HistoryControls = () => { id: item.scanId, isCurrent: item.scanId === scan_id, status: item.status, - timestamp: item.updatedAt, + timestamp: item.createdAt, showScanCompareButton: true, onScanTimeCompareButtonClick: onCompareScanClick, onDeleteClick: (id) => { @@ -703,7 +703,7 @@ const HistoryControls = () => { ); }, }))} - currentTimeStamp={formatMilliseconds(updated_at)} + currentTimeStamp={formatMilliseconds(created_at)} /> {scanIdToDelete && ( @@ -783,7 +783,7 @@ const HistoryControls = () => { onClick={() => { setCompareInput({ ...compareInput, - baseScanTime: updated_at ?? 0, + baseScanTime: created_at ?? 0, showScanTimeModal: true, }); }} 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 6471115baf..d683177473 100644 --- a/deepfence_frontend/apps/dashboard/src/features/secrets/pages/SecretScans.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/secrets/pages/SecretScans.tsx @@ -739,7 +739,7 @@ const ScansTable = ({ size: 240, maxSize: 250, }), - columnHelper.accessor('updated_at', { + columnHelper.accessor('created_at', { cell: (info) => , header: () => , minSize: 140, 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 e0a8bb2b79..02f731c5bf 100644 --- a/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/VulnerabilityScanResults.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/VulnerabilityScanResults.tsx @@ -546,7 +546,7 @@ const HistoryControls = () => { const [isSubmitting, setIsSubmitting] = useState(false); const { data, fetchStatus } = useScanResults(); const { scanStatusResult } = data; - const { scan_id, node_id, node_type, updated_at, status, node_name } = + const { scan_id, node_id, node_type, created_at, status, node_name } = scanStatusResult ?? {}; const { navigate, goBack } = usePageNavigation(); const { downloadScan } = useDownloadScan((state) => { @@ -567,7 +567,7 @@ const HistoryControls = () => { }>({ baseScanId: '', toScanId: '', - baseScanTime: updated_at ?? 0, + baseScanTime: created_at ?? 0, toScanTime: 0, showScanTimeModal: false, }); @@ -588,7 +588,7 @@ const HistoryControls = () => { if (!scan_id || !node_id || !node_type) { throw new Error('Scan Type, Node Type and Node Id are required'); } - if (!updated_at) { + if (!created_at) { return null; } @@ -644,7 +644,7 @@ const HistoryControls = () => { id: item.scanId, isCurrent: item.scanId === scan_id, status: item.status, - timestamp: item.updatedAt, + timestamp: item.createdAt, showScanCompareButton: true, onScanTimeCompareButtonClick: onCompareScanClick, onDeleteClick: (id) => { @@ -668,7 +668,7 @@ const HistoryControls = () => { ); }, }))} - currentTimeStamp={formatMilliseconds(updated_at)} + currentTimeStamp={formatMilliseconds(created_at)} /> {scanIdToDelete && ( @@ -751,7 +751,7 @@ const HistoryControls = () => { onClick={() => { setCompareInput({ ...compareInput, - baseScanTime: updated_at ?? 0, + baseScanTime: created_at ?? 0, showScanTimeModal: true, }); }} 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 5c22ff4320..527e567c06 100644 --- a/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/VulnerabilityScans.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/VulnerabilityScans.tsx @@ -523,7 +523,7 @@ const ScansTable = ({ size: 240, maxSize: 250, }), - columnHelper.accessor('updated_at', { + columnHelper.accessor('created_at', { cell: (info) => , header: () => , minSize: 140, diff --git a/deepfence_frontend/apps/dashboard/src/queries/common.ts b/deepfence_frontend/apps/dashboard/src/queries/common.ts index 34f911a54d..0cf0618bbd 100644 --- a/deepfence_frontend/apps/dashboard/src/queries/common.ts +++ b/deepfence_frontend/apps/dashboard/src/queries/common.ts @@ -90,7 +90,7 @@ export const commonQueries = createQueryKeys('common', { return { data: (result.value.scans_info ?? []).slice(0, size)?.map((res) => { return { - updatedAt: res.updated_at, + createdAt: res.created_at, scanId: res.scan_id, status: res.status, nodeName: res.node_name, From b3d88c97375c1bcd65d9e7f8ae6d28540556c082 Mon Sep 17 00:00:00 2001 From: milan-deepfence Date: Wed, 14 Feb 2024 15:22:36 +0530 Subject: [PATCH 02/32] remove log --- .../src/features/postures/pages/PostureCloudScanResults.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deepfence_frontend/apps/dashboard/src/features/postures/pages/PostureCloudScanResults.tsx b/deepfence_frontend/apps/dashboard/src/features/postures/pages/PostureCloudScanResults.tsx index 133ba1839e..348040f913 100644 --- a/deepfence_frontend/apps/dashboard/src/features/postures/pages/PostureCloudScanResults.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/postures/pages/PostureCloudScanResults.tsx @@ -626,7 +626,7 @@ const HistoryControls = () => { showScanTimeModal: true, }); }; - console.log(created_at); + return (
{openStopScanModal && ( From 5b5023480516266f5036913cbfa5085e336e7572 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 15 Feb 2024 00:37:14 +0000 Subject: [PATCH 03/32] Update listing with threatintel-2024-02-15_00-17-11 --- docs/vulnerability_feeds/listing.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/vulnerability_feeds/listing.json b/docs/vulnerability_feeds/listing.json index 05e4404d1b..724c47eea2 100644 --- a/docs/vulnerability_feeds/listing.json +++ b/docs/vulnerability_feeds/listing.json @@ -27,12 +27,6 @@ } ], "5": [ - { - "built": "2024-02-11T00:35:19.348292208Z", - "version": 5, - "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v5-2024-02-11_00-19-16/threatintel-vuln-v5-2024-02-11_00-19-16.tar.gz", - "checksum": "911e408adef2fb023c75ebfe7d638856a3341026b8d4ce2d416360bc89b1a06e" - }, { "built": "2024-02-12T00:34:01.26515756Z", "version": 5, @@ -50,6 +44,12 @@ "version": 5, "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v5-2024-02-14_00-17-06/threatintel-vuln-v5-2024-02-14_00-17-06.tar.gz", "checksum": "9f4a67443a52f25a59c4adac8a3157d0b6adb1b5f48bcf990774ef61525ea313" + }, + { + "built": "2024-02-15T00:36:51.706417144Z", + "version": 5, + "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v5-2024-02-15_00-17-11/threatintel-vuln-v5-2024-02-15_00-17-11.tar.gz", + "checksum": "1dde2b4af764dcf8b99456263bd034e503f617729c085efdb6568f72fb389ede" } ] } From 66677d76d9bbdfe8c19a2c8cadc132a14bba0ee8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 15 Feb 2024 00:58:46 +0000 Subject: [PATCH 04/32] Update listing with threatintel-2024-02-15_00-49-24 --- docs/vulnerability_feeds/listing.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/vulnerability_feeds/listing.json b/docs/vulnerability_feeds/listing.json index 724c47eea2..17e8bf5aff 100644 --- a/docs/vulnerability_feeds/listing.json +++ b/docs/vulnerability_feeds/listing.json @@ -1,12 +1,6 @@ { "available": { "3": [ - { - "built": "2024-02-11T01:03:50.412286353Z", - "version": 3, - "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v3-2024-02-11_00-49-49/threatintel-vuln-v3-2024-02-11_00-49-49.tar.gz", - "checksum": "89d24cfb0fcbb8c805a437d330bbcac28def62fcc45e6d50049a02033160f8cd" - }, { "built": "2024-02-12T01:06:13.372673857Z", "version": 3, @@ -24,6 +18,12 @@ "version": 3, "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v3-2024-02-14_00-49-35/threatintel-vuln-v3-2024-02-14_00-49-35.tar.gz", "checksum": "ba735935ccfbf134d5701b8581935de0f16e0e6565361e99ae21f86476fb2bd6" + }, + { + "built": "2024-02-15T00:58:27.097728831Z", + "version": 3, + "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v3-2024-02-15_00-49-24/threatintel-vuln-v3-2024-02-15_00-49-24.tar.gz", + "checksum": "1234ddbc0f30224dc9e1c46624b83f9f42f4d94f03a7cb8905d014e38069cf67" } ], "5": [ From 4450e5d71c21c961ac43356e71b99e55926418ac Mon Sep 17 00:00:00 2001 From: varunsharma0286 Date: Thu, 15 Feb 2024 09:12:42 +0530 Subject: [PATCH 05/32] ISSUE-2130: Fixing the dockerhub validation and error message (#1964) --- .../handler/container_registry.go | 24 ++++++++++++++----- .../pkg/registry/dockerhub/docker.go | 2 +- .../pkg/registry/dockerhub/types.go | 1 + 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/deepfence_server/handler/container_registry.go b/deepfence_server/handler/container_registry.go index 3197c392cc..708e30790e 100644 --- a/deepfence_server/handler/container_registry.go +++ b/deepfence_server/handler/container_registry.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "errors" + "fmt" "io" "net/http" "strconv" @@ -325,14 +326,22 @@ func (h *Handler) UpdateRegistry(w http.ResponseWriter, r *http.Request) { func (h *Handler) AddGoogleContainerRegistry(w http.ResponseWriter, r *http.Request) { defer r.Body.Close() + failureMsg := "Failed to add registry, Error: %s" if err := r.ParseMultipartForm(1024 * 1024); err != nil { - h.respondError(&BadDecoding{err}, w) + log.Error().Msgf("%v", err) + h.respondError(&BadDecoding{fmt.Errorf(failureMsg, err.Error())}, w) return } + file, fileHeader, err := r.FormFile("service_account_json") if err != nil { - h.respondError(&BadDecoding{err}, w) + log.Error().Msgf("%v", err) + if err == http.ErrMissingFile { + h.respondError(&BadDecoding{fmt.Errorf(failureMsg, "Missing file")}, w) + } else { + h.respondError(&BadDecoding{fmt.Errorf(failureMsg, err.Error())}, w) + } return } defer file.Close() @@ -347,7 +356,8 @@ func (h *Handler) AddGoogleContainerRegistry(w http.ResponseWriter, r *http.Requ fileBytes, err := io.ReadAll(file) if err != nil { - h.respondError(&BadDecoding{err}, w) + log.Error().Msgf("%v", err) + h.respondError(&BadDecoding{fmt.Errorf(failureMsg, err.Error())}, w) return } @@ -371,7 +381,8 @@ func (h *Handler) AddGoogleContainerRegistry(w http.ResponseWriter, r *http.Requ var sa gcr.ServiceAccountJSON if err := json.Unmarshal(fileBytes, &sa); err != nil { - h.respondError(&BadDecoding{err}, w) + log.Error().Msgf("%v", err) + h.respondError(&BadDecoding{fmt.Errorf(failureMsg, err.Error())}, w) return } @@ -387,14 +398,14 @@ func (h *Handler) AddGoogleContainerRegistry(w http.ResponseWriter, r *http.Requ b, err := json.Marshal(req) if err != nil { log.Error().Msgf("%v", err) - h.respondError(&BadDecoding{err}, w) + h.respondError(&BadDecoding{fmt.Errorf(failureMsg, err.Error())}, w) return } registry, err := registry.GetRegistry(constants.GCR, b) if err != nil { log.Error().Msgf("%v", err) - h.respondError(&BadDecoding{err}, w) + h.respondError(&BadDecoding{fmt.Errorf(failureMsg, err.Error())}, w) return } @@ -420,6 +431,7 @@ func (h *Handler) AddGoogleContainerRegistry(w http.ResponseWriter, r *http.Requ ctx := r.Context() pgClient, err := directory.PostgresClient(ctx) if err != nil { + log.Error().Msgf("%v", err) h.respondError(&InternalServerError{err}, w) return } diff --git a/deepfence_server/pkg/registry/dockerhub/docker.go b/deepfence_server/pkg/registry/dockerhub/docker.go index 4ed10472db..5d1edc502c 100644 --- a/deepfence_server/pkg/registry/dockerhub/docker.go +++ b/deepfence_server/pkg/registry/dockerhub/docker.go @@ -28,7 +28,7 @@ func (d *RegistryDockerHub) ValidateFields(v *validator.Validate) error { func (d *RegistryDockerHub) IsValidCredential() bool { if d.NonSecret.DockerHubUsername == "" { - return true + return d.NonSecret.IsPublic == "true" } jsonData := map[string]interface{}{"username": d.NonSecret.DockerHubUsername, "password": d.Secret.DockerHubPassword} diff --git a/deepfence_server/pkg/registry/dockerhub/types.go b/deepfence_server/pkg/registry/dockerhub/types.go index 0f7b40d912..890976f4cb 100644 --- a/deepfence_server/pkg/registry/dockerhub/types.go +++ b/deepfence_server/pkg/registry/dockerhub/types.go @@ -10,6 +10,7 @@ type RegistryDockerHub struct { } type NonSecret struct { + IsPublic string `json:"is_public" validate:"required"` DockerHubNamespace string `json:"docker_hub_namespace" validate:"required,min=2"` DockerHubUsername string `json:"docker_hub_username" validate:"omitempty,min=2"` } From f04fa5665c707028f85c15f284a2aecf0ea48408 Mon Sep 17 00:00:00 2001 From: milan-deepfence Date: Thu, 15 Feb 2024 13:35:58 +0530 Subject: [PATCH 06/32] add data test id --- .../features/registries/pages/RegistryAccounts.tsx | 4 +++- .../topology/data-components/node-details/Host.tsx | 2 +- .../vulnerabilities/pages/VulnerabilityScans.tsx | 4 +++- .../src/components/spinner/CircleSpinner.tsx | 13 +++++++++++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/deepfence_frontend/apps/dashboard/src/features/registries/pages/RegistryAccounts.tsx b/deepfence_frontend/apps/dashboard/src/features/registries/pages/RegistryAccounts.tsx index dadd7031b0..c1ccfda053 100644 --- a/deepfence_frontend/apps/dashboard/src/features/registries/pages/RegistryAccounts.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/registries/pages/RegistryAccounts.tsx @@ -308,7 +308,9 @@ const Header = () => {
- {isFetching ? : null} + {isFetching ? ( + + ) : null}
); diff --git a/deepfence_frontend/apps/dashboard/src/features/topology/data-components/node-details/Host.tsx b/deepfence_frontend/apps/dashboard/src/features/topology/data-components/node-details/Host.tsx index e5f7c4ef36..a348e6c3de 100644 --- a/deepfence_frontend/apps/dashboard/src/features/topology/data-components/node-details/Host.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/topology/data-components/node-details/Host.tsx @@ -97,7 +97,7 @@ export const Host = (props: HostModalProps) => { - +
} > 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 5c22ff4320..2e8213df08 100644 --- a/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/VulnerabilityScans.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/VulnerabilityScans.tsx @@ -1212,7 +1212,9 @@ const VulnerabilityScans = () => {
- {isFetching ? : null} + {isFetching ? ( + + ) : null}
diff --git a/deepfence_frontend/packages/ui-components/src/components/spinner/CircleSpinner.tsx b/deepfence_frontend/packages/ui-components/src/components/spinner/CircleSpinner.tsx index 7c28a05a18..2019eac3e8 100644 --- a/deepfence_frontend/packages/ui-components/src/components/spinner/CircleSpinner.tsx +++ b/deepfence_frontend/packages/ui-components/src/components/spinner/CircleSpinner.tsx @@ -18,9 +18,18 @@ const spinnerCVA = cva(['animate-spin dark:text-bg-side-panel fill-accent-accent }, }); -export const CircleSpinner = ({ size = 'md', className }: CircleSpinnerProps) => { +export const CircleSpinner = ({ + size = 'md', + className, + ...props +}: CircleSpinnerProps) => { return ( -
+
- - - - + + + + - + + {{ range $i, $v := $value.ScanResults }} - - - + + + - + + {{ end }}
No.StatusCategoryTest NumberNo.StatusCategoryTest Number DescriptionCheck TypeCheck TypeResource
{{ add1 $i }}{{ $v.Status }}{{ $v.TestCategory }}{{ add1 $i }}{{ $v.Status }}{{ $v.TestCategory }} {{ $v.TestNumber }} {{ trunc 80 $v.TestInfo }}{{ $v.ComplianceCheckType }}{{ $v.ComplianceCheckType }}{{ $v.Resource }}
diff --git a/deepfence_worker/tasks/reports/xlsx.go b/deepfence_worker/tasks/reports/xlsx.go index 826e062165..134acba86d 100644 --- a/deepfence_worker/tasks/reports/xlsx.go +++ b/deepfence_worker/tasks/reports/xlsx.go @@ -62,12 +62,13 @@ var ( "G1": "masked", "H1": "node_id", "I1": "node_name", - "J1": "node_type", - "K1": "status", - "L1": "test_category", - "M1": "test_desc", - "N1": "test_info", - "O1": "test_number", + "J1": "resource", + "K1": "node_type", + "L1": "status", + "M1": "test_category", + "N1": "test_desc", + "O1": "test_info", + "P1": "test_number", } ) @@ -303,6 +304,7 @@ func complianceXLSX(ctx context.Context, params utils.ReportParams) (string, err c.Masked, c.ComplianceNodeID, nodeScanData.ScanInfo.NodeName, + c.Resource, c.ComplianceNodeType, c.Status, c.TestCategory, @@ -354,6 +356,7 @@ func cloudComplianceXLSX(ctx context.Context, params utils.ReportParams) (string c.Masked, c.NodeID, data.ScanInfo.NodeName, + c.Resource, c.ComplianceCheckType, c.Status, c.Type, From f7121e88e3155b0d394c2d287d0ca7949b188e49 Mon Sep 17 00:00:00 2001 From: ramanan-ravi Date: Fri, 16 Feb 2024 20:54:50 +0530 Subject: [PATCH 18/32] Update version --- deepfence_agent/fargate/Dockerfile.fargate | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deepfence_agent/fargate/Dockerfile.fargate b/deepfence_agent/fargate/Dockerfile.fargate index 1a7d6d67f9..0b14fea9af 100644 --- a/deepfence_agent/fargate/Dockerfile.fargate +++ b/deepfence_agent/fargate/Dockerfile.fargate @@ -115,7 +115,7 @@ LABEL deepfence.role=system WORKDIR / -COPY fargate/deepfence-agent-bin-2.1.0 /deepfence +COPY fargate/deepfence-agent-bin-2.1.1 /deepfence COPY fargate/deepfence-entry-point-scratch.sh deepfence/usr/local/bin/deepfence-entry-point-scratch.sh COPY --from=builder /tmp/rootfs/bin/curl /deepfence/bin/curl From 4d93e2234c62a85aa2c8382f8123f36a59af10a0 Mon Sep 17 00:00:00 2001 From: milan-deepfence Date: Fri, 16 Feb 2024 20:54:59 +0530 Subject: [PATCH 19/32] logic update for modal on malware scan page --- .../features/malwares/pages/MalwareScans.tsx | 268 +++++++++++------- 1 file changed, 169 insertions(+), 99 deletions(-) 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 d1bbdba754..3c0cba5027 100644 --- a/deepfence_frontend/apps/dashboard/src/features/malwares/pages/MalwareScans.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/malwares/pages/MalwareScans.tsx @@ -78,7 +78,9 @@ export interface FocusableElement { } enum ActionEnumType { - DELETE = 'delete', + DELETE_SCAN = 'delete_scan', + CANCEL_SCAN = 'cancel_scan', + START_SCAN = 'start_scan,', } const DEFAULT_PAGE_SIZE = 10; @@ -109,7 +111,7 @@ const action = async ({ throw new Error('Invalid action'); } - if (actionType === ActionEnumType.DELETE) { + if (actionType === ActionEnumType.DELETE_SCAN) { const resultApi = apiWrapper({ fn: getScanResultsApiClient().bulkDeleteScans, }); @@ -180,7 +182,7 @@ const DeleteConfirmationModal = ({ if ( fetcher.state === 'idle' && fetcher.data?.success && - fetcher.data.action === ActionEnumType.DELETE + fetcher.data.action === ActionEnumType.DELETE_SCAN ) { onDeleteSuccess(); } @@ -219,7 +221,7 @@ const DeleteConfirmationModal = ({ disabled={fetcher.state === 'submitting'} onClick={(e) => { e.preventDefault(); - onDeleteAction(ActionEnumType.DELETE); + onDeleteAction(ActionEnumType.DELETE_SCAN); }} > Delete @@ -247,9 +249,11 @@ const DeleteConfirmationModal = ({ const ActionDropdown = ({ trigger, row, + onTableAction, }: { trigger: React.ReactNode; row: ModelScanInfo; + onTableAction: (row: ModelScanInfo, actionType: ActionEnumType) => void; }) => { const fetcher = useFetcher(); const [open, setOpen] = useState(false); @@ -257,15 +261,13 @@ const ActionDropdown = ({ const { downloadScan } = useDownloadScan((state) => { setIsSubmitting(state === 'submitting'); }); - const [openStopScanModal, setOpenStopScanModal] = useState(false); - const [showDeleteDialog, setShowDeleteDialog] = useState(false); const { scan_id: scanId, node_id: nodeId, node_type: nodeType, status: scanStatus, } = row; - const [showStartScan, setShowStartScan] = useState(false); + const onDownloadAction = useCallback(() => { downloadScan({ scanId, @@ -280,45 +282,6 @@ const ActionDropdown = ({ return ( <> - {openStopScanModal && ( - - )} - - {showDeleteDialog && ( - { - // - }} - /> - )} - {showStartScan && ( - setShowStartScan(false)} - scanOptions={ - { - showAdvancedOptions: true, - scanType: ScanTypeEnum.MalwareScan, - data: { - nodes: [ - { - nodeId, - nodeType, - }, - ], - }, - } as ConfigureScanModalProps['scanOptions'] - } - /> - )} { e.preventDefault(); if (isScanInProgress(scanStatus)) return; - setShowStartScan(true); + onTableAction(row, ActionEnumType.START_SCAN); }} disabled={isScanInProgress(scanStatus) || isScanStopping(scanStatus)} > @@ -351,7 +314,7 @@ const ActionDropdown = ({ { e.preventDefault(); - setOpenStopScanModal(true); + onTableAction(row, ActionEnumType.CANCEL_SCAN); }} disabled={!isScanInProgress(scanStatus)} > @@ -360,7 +323,7 @@ const ActionDropdown = ({ { if (!scanId || !nodeType) return; - setShowDeleteDialog(true); + onTableAction(row, ActionEnumType.DELETE_SCAN); }} > @@ -641,9 +604,11 @@ const Filters = () => { const ScansTable = ({ rowSelectionState, setRowSelectionState, + onTableAction, }: { rowSelectionState: RowSelectionState; setRowSelectionState: React.Dispatch>; + onTableAction: (row: ModelScanInfo, actionType: ActionEnumType) => void; }) => { const [searchParams, setSearchParams] = useSearchParams(); const { data } = useSuspenseQuery({ @@ -682,6 +647,7 @@ const ScansTable = ({ cell: (cell) => ( @@ -988,7 +954,7 @@ const ScansTable = ({ const BulkActions = ({ selectedRows, - setRowSelectionState, + onBulkAction, }: { selectedRows: { scanId: string; @@ -996,11 +962,18 @@ const BulkActions = ({ nodeType: string; scanStatus: string; }[]; - setRowSelectionState: React.Dispatch>; + onBulkAction: ( + data: { + scanIdsToCancelScan: string[]; + scanIdsToDeleteScan: string[]; + nodesToStartScan: { + nodeId: string; + nodeType: string; + }[]; + }, + actionType: ActionEnumType, + ) => void; }) => { - const [openStartScan, setOpenStartScan] = useState(false); - const [showDeleteDialog, setShowDeleteDialog] = useState(false); - const [showCancelScanDialog, setShowCancelScanDialog] = useState(false); const nodesToStartScan = useMemo(() => { return selectedRows .filter( @@ -1028,50 +1001,20 @@ const BulkActions = ({ return ( <> - {openStartScan && ( - setOpenStartScan(false)} - onSuccess={() => setRowSelectionState({})} - scanOptions={ - { - showAdvancedOptions: true, - scanType: ScanTypeEnum.MalwareScan, - data: { - nodes: nodesToStartScan, - }, - } as ConfigureScanModalProps['scanOptions'] - } - /> - )} - {showDeleteDialog && ( - { - setRowSelectionState({}); - }} - /> - )} - {showCancelScanDialog ? ( - { - setRowSelectionState({}); - }} - /> - ) : null} @@ -1092,7 +1044,14 @@ const BulkActions = ({ size="sm" disabled={scanIdsToDeleteScan.length === 0} onClick={() => { - setShowDeleteDialog(true); + onBulkAction( + { + scanIdsToCancelScan: [], + scanIdsToDeleteScan, + nodesToStartScan: [], + }, + ActionEnumType.DELETE_SCAN, + ); }} > Delete Scan @@ -1107,9 +1066,12 @@ const MalwareScans = () => { queryKey: queries.malware.scanList._def, }); const [filtersExpanded, setFiltersExpanded] = useState(false); - const [rowSelectionState, setRowSelectionState] = useState({}); + const [openStartScan, setOpenStartScan] = useState(false); + const [showDeleteDialog, setShowDeleteDialog] = useState(false); + const [showCancelScanDialog, setShowCancelScanDialog] = useState(false); + const selectedRows = useMemo< { scanId: string; @@ -1123,8 +1085,118 @@ const MalwareScans = () => { }); }, [rowSelectionState]); + const [rowToAction, setRowToAction] = useState<{ + scanIdsToCancelScan: string[]; + scanIdsToDeleteScan: string[]; + nodesToStartScan: { + nodeId: string; + nodeType: string; + }[]; + }>({ + scanIdsToCancelScan: [], + scanIdsToDeleteScan: [], + nodesToStartScan: [], + }); + + const onTableAction = (row: ModelScanInfo, actionType: string) => { + if (actionType === ActionEnumType.DELETE_SCAN) { + setRowToAction({ + scanIdsToCancelScan: [], + scanIdsToDeleteScan: [row.scan_id], + nodesToStartScan: [], + }); + setShowDeleteDialog(true); + } else if (actionType === ActionEnumType.CANCEL_SCAN) { + setRowToAction({ + scanIdsToCancelScan: [row.scan_id], + scanIdsToDeleteScan: [], + nodesToStartScan: [], + }); + setShowCancelScanDialog(true); + } else if (actionType === ActionEnumType.START_SCAN) { + setRowToAction({ + scanIdsToCancelScan: [], + scanIdsToDeleteScan: [], + nodesToStartScan: [ + { + nodeId: row.node_id, + nodeType: row.node_type, + }, + ], + }); + setOpenStartScan(true); + } + }; + + const onBulkAction = ( + data: { + scanIdsToCancelScan: string[]; + scanIdsToDeleteScan: string[]; + nodesToStartScan: { + nodeId: string; + nodeType: string; + }[]; + }, + actionType: string, + ) => { + setRowToAction({ + scanIdsToCancelScan: data.scanIdsToCancelScan, + scanIdsToDeleteScan: data.scanIdsToDeleteScan, + nodesToStartScan: data.nodesToStartScan, + }); + if (actionType === ActionEnumType.DELETE_SCAN) { + setShowDeleteDialog(true); + } else if (actionType === ActionEnumType.CANCEL_SCAN) { + setShowCancelScanDialog(true); + } else if (actionType === ActionEnumType.START_SCAN) { + setOpenStartScan(true); + } + }; + + console.log(rowToAction); + return (
+ <> + {openStartScan && ( + setOpenStartScan(false)} + onSuccess={() => setRowSelectionState({})} + scanOptions={ + { + showAdvancedOptions: true, + scanType: ScanTypeEnum.MalwareScan, + data: { + nodes: rowToAction?.nodesToStartScan, + }, + } as ConfigureScanModalProps['scanOptions'] + } + /> + )} + {showDeleteDialog && ( + { + setRowSelectionState({}); + }} + /> + )} + {showCancelScanDialog ? ( + { + setRowSelectionState({}); + }} + /> + ) : null} + +
} isLink> @@ -1144,10 +1216,7 @@ const MalwareScans = () => {
- +
From b03e1149c2761c681ef289180d37ed1363bec608 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 17 Feb 2024 00:39:57 +0000 Subject: [PATCH 20/32] Update listing with threatintel-2024-02-17_00-17-06 --- docs/vulnerability_feeds/listing.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/vulnerability_feeds/listing.json b/docs/vulnerability_feeds/listing.json index d51e75bdf3..1d6c249cec 100644 --- a/docs/vulnerability_feeds/listing.json +++ b/docs/vulnerability_feeds/listing.json @@ -27,12 +27,6 @@ } ], "5": [ - { - "built": "2024-02-13T00:35:23.788906872Z", - "version": 5, - "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v5-2024-02-13_00-17-44/threatintel-vuln-v5-2024-02-13_00-17-44.tar.gz", - "checksum": "434dae101930ecd7284f15a95cfcaa4ad8def1a641f7885af8ab3790bc18ccb4" - }, { "built": "2024-02-14T00:32:37.809797265Z", "version": 5, @@ -50,6 +44,12 @@ "version": 5, "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v5-2024-02-16_00-17-03/threatintel-vuln-v5-2024-02-16_00-17-03.tar.gz", "checksum": "967b975120433ae9f4f11f44cad89f4b78b87fecdc5091cb62a4c68bdde2f5df" + }, + { + "built": "2024-02-17T00:39:33.279866383Z", + "version": 5, + "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v5-2024-02-17_00-17-06/threatintel-vuln-v5-2024-02-17_00-17-06.tar.gz", + "checksum": "d6a256f177a865252ce46c300f8b574118d5fdafc4f0007c211d0ddd35cb5dc9" } ] } From b3dfb4eee9ae76cef726bc20969e7eedb8507605 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 17 Feb 2024 01:01:43 +0000 Subject: [PATCH 21/32] Update listing with threatintel-2024-02-17_00-49-16 --- docs/vulnerability_feeds/listing.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/vulnerability_feeds/listing.json b/docs/vulnerability_feeds/listing.json index 1d6c249cec..6f45833cc5 100644 --- a/docs/vulnerability_feeds/listing.json +++ b/docs/vulnerability_feeds/listing.json @@ -1,12 +1,6 @@ { "available": { "3": [ - { - "built": "2024-02-13T01:03:12.742305129Z", - "version": 3, - "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v3-2024-02-13_00-49-33/threatintel-vuln-v3-2024-02-13_00-49-33.tar.gz", - "checksum": "501e31775326b1a468d2b92bb8ffaed69093ac1e4b57675a12c6f9afe8166c40" - }, { "built": "2024-02-14T01:04:05.764394206Z", "version": 3, @@ -24,6 +18,12 @@ "version": 3, "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v3-2024-02-16_00-49-23/threatintel-vuln-v3-2024-02-16_00-49-23.tar.gz", "checksum": "c1bd46f68a6086e488eed9c12b7fae9aad25d19c2936eedf7938bf1b961eb00a" + }, + { + "built": "2024-02-17T01:01:21.489056192Z", + "version": 3, + "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v3-2024-02-17_00-49-16/threatintel-vuln-v3-2024-02-17_00-49-16.tar.gz", + "checksum": "eda499d1c3321d871d15ff221b9dafa2d1df647c0a10979a77b5a4ef3c8b22ef" } ], "5": [ From b14957bc840fa898707561e823bf29d9a64e9255 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 18 Feb 2024 00:40:26 +0000 Subject: [PATCH 22/32] Update listing with threatintel-2024-02-18_00-18-39 --- docs/vulnerability_feeds/listing.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/vulnerability_feeds/listing.json b/docs/vulnerability_feeds/listing.json index 6f45833cc5..adaba6d13e 100644 --- a/docs/vulnerability_feeds/listing.json +++ b/docs/vulnerability_feeds/listing.json @@ -27,12 +27,6 @@ } ], "5": [ - { - "built": "2024-02-14T00:32:37.809797265Z", - "version": 5, - "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v5-2024-02-14_00-17-06/threatintel-vuln-v5-2024-02-14_00-17-06.tar.gz", - "checksum": "9f4a67443a52f25a59c4adac8a3157d0b6adb1b5f48bcf990774ef61525ea313" - }, { "built": "2024-02-15T00:36:51.706417144Z", "version": 5, @@ -50,6 +44,12 @@ "version": 5, "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v5-2024-02-17_00-17-06/threatintel-vuln-v5-2024-02-17_00-17-06.tar.gz", "checksum": "d6a256f177a865252ce46c300f8b574118d5fdafc4f0007c211d0ddd35cb5dc9" + }, + { + "built": "2024-02-18T00:40:02.467254981Z", + "version": 5, + "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v5-2024-02-18_00-18-39/threatintel-vuln-v5-2024-02-18_00-18-39.tar.gz", + "checksum": "de2f693d31611b9d1b370f5b3499f2c6addbd79af6da50394d82e8fc67a88da6" } ] } From 9fe4264a0755476389e91fafc3c46e6eef87b03e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 18 Feb 2024 01:04:17 +0000 Subject: [PATCH 23/32] Update listing with threatintel-2024-02-18_00-49-33 --- docs/vulnerability_feeds/listing.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/vulnerability_feeds/listing.json b/docs/vulnerability_feeds/listing.json index adaba6d13e..52a1b6729a 100644 --- a/docs/vulnerability_feeds/listing.json +++ b/docs/vulnerability_feeds/listing.json @@ -1,12 +1,6 @@ { "available": { "3": [ - { - "built": "2024-02-14T01:04:05.764394206Z", - "version": 3, - "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v3-2024-02-14_00-49-35/threatintel-vuln-v3-2024-02-14_00-49-35.tar.gz", - "checksum": "ba735935ccfbf134d5701b8581935de0f16e0e6565361e99ae21f86476fb2bd6" - }, { "built": "2024-02-15T00:58:27.097728831Z", "version": 3, @@ -24,6 +18,12 @@ "version": 3, "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v3-2024-02-17_00-49-16/threatintel-vuln-v3-2024-02-17_00-49-16.tar.gz", "checksum": "eda499d1c3321d871d15ff221b9dafa2d1df647c0a10979a77b5a4ef3c8b22ef" + }, + { + "built": "2024-02-18T01:03:55.277960429Z", + "version": 3, + "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v3-2024-02-18_00-49-33/threatintel-vuln-v3-2024-02-18_00-49-33.tar.gz", + "checksum": "73c909c42d7287421ef952dd7420215d82f486370daf7870f2f3b5b16a81b6b5" } ], "5": [ From 6ed123d69b014014e9c778c12e62a220327c14ea Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 19 Feb 2024 00:35:22 +0000 Subject: [PATCH 24/32] Update listing with threatintel-2024-02-19_00-17-50 --- docs/vulnerability_feeds/listing.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/vulnerability_feeds/listing.json b/docs/vulnerability_feeds/listing.json index 52a1b6729a..b7891e0720 100644 --- a/docs/vulnerability_feeds/listing.json +++ b/docs/vulnerability_feeds/listing.json @@ -27,12 +27,6 @@ } ], "5": [ - { - "built": "2024-02-15T00:36:51.706417144Z", - "version": 5, - "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v5-2024-02-15_00-17-11/threatintel-vuln-v5-2024-02-15_00-17-11.tar.gz", - "checksum": "1dde2b4af764dcf8b99456263bd034e503f617729c085efdb6568f72fb389ede" - }, { "built": "2024-02-16T00:40:16.459255439Z", "version": 5, @@ -50,6 +44,12 @@ "version": 5, "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v5-2024-02-18_00-18-39/threatintel-vuln-v5-2024-02-18_00-18-39.tar.gz", "checksum": "de2f693d31611b9d1b370f5b3499f2c6addbd79af6da50394d82e8fc67a88da6" + }, + { + "built": "2024-02-19T00:35:00.853685106Z", + "version": 5, + "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v5-2024-02-19_00-17-50/threatintel-vuln-v5-2024-02-19_00-17-50.tar.gz", + "checksum": "ff17baf5f3cfa8cfdfa808007c8370e3d0287ef0a5f03d81758d73f16446bedf" } ] } From 5c7b88d38d133963611063284c91c6722a25fc00 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 19 Feb 2024 01:00:03 +0000 Subject: [PATCH 25/32] Update listing with threatintel-2024-02-19_00-49-24 --- docs/vulnerability_feeds/listing.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/vulnerability_feeds/listing.json b/docs/vulnerability_feeds/listing.json index b7891e0720..c2dd367979 100644 --- a/docs/vulnerability_feeds/listing.json +++ b/docs/vulnerability_feeds/listing.json @@ -1,12 +1,6 @@ { "available": { "3": [ - { - "built": "2024-02-15T00:58:27.097728831Z", - "version": 3, - "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v3-2024-02-15_00-49-24/threatintel-vuln-v3-2024-02-15_00-49-24.tar.gz", - "checksum": "1234ddbc0f30224dc9e1c46624b83f9f42f4d94f03a7cb8905d014e38069cf67" - }, { "built": "2024-02-16T01:03:24.253752293Z", "version": 3, @@ -24,6 +18,12 @@ "version": 3, "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v3-2024-02-18_00-49-33/threatintel-vuln-v3-2024-02-18_00-49-33.tar.gz", "checksum": "73c909c42d7287421ef952dd7420215d82f486370daf7870f2f3b5b16a81b6b5" + }, + { + "built": "2024-02-19T00:59:42.423015778Z", + "version": 3, + "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v3-2024-02-19_00-49-24/threatintel-vuln-v3-2024-02-19_00-49-24.tar.gz", + "checksum": "4b02a72fd2e67d27b92189e105e2b108870b9e45b95d13ea931c734f95247a84" } ], "5": [ From 60ebc1c5e23bfbe6dd3805846922768a575a51ed Mon Sep 17 00:00:00 2001 From: milan-deepfence Date: Mon, 19 Feb 2024 11:08:31 +0530 Subject: [PATCH 26/32] fix modal issue in secrets and vulnerability --- .../features/malwares/pages/MalwareScans.tsx | 2 - .../features/secrets/pages/SecretScans.tsx | 266 ++++++++++------- .../pages/VulnerabilityScans.tsx | 269 +++++++++++------- 3 files changed, 326 insertions(+), 211 deletions(-) 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 3c0cba5027..05a6a6246f 100644 --- a/deepfence_frontend/apps/dashboard/src/features/malwares/pages/MalwareScans.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/malwares/pages/MalwareScans.tsx @@ -1153,8 +1153,6 @@ const MalwareScans = () => { } }; - console.log(rowToAction); - return (
<> 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 d683177473..3195b9ff34 100644 --- a/deepfence_frontend/apps/dashboard/src/features/secrets/pages/SecretScans.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/secrets/pages/SecretScans.tsx @@ -78,7 +78,9 @@ export interface FocusableElement { } enum ActionEnumType { - DELETE = 'delete', + DELETE_SCAN = 'delete_scan', + CANCEL_SCAN = 'cancel_scan', + START_SCAN = 'start_scan,', } const DEFAULT_PAGE_SIZE = 10; @@ -109,7 +111,7 @@ const action = async ({ throw new Error('Invalid action'); } - if (actionType === ActionEnumType.DELETE) { + if (actionType === ActionEnumType.DELETE_SCAN) { const resultApi = apiWrapper({ fn: getScanResultsApiClient().bulkDeleteScans, }); @@ -180,7 +182,7 @@ const DeleteConfirmationModal = ({ if ( fetcher.state === 'idle' && fetcher.data?.success && - fetcher.data.action === ActionEnumType.DELETE + fetcher.data.action === ActionEnumType.DELETE_SCAN ) { onDeleteSuccess(); } @@ -219,7 +221,7 @@ const DeleteConfirmationModal = ({ disabled={fetcher.state === 'submitting'} onClick={(e) => { e.preventDefault(); - onDeleteAction(ActionEnumType.DELETE); + onDeleteAction(ActionEnumType.DELETE_SCAN); }} > Delete @@ -247,9 +249,11 @@ const DeleteConfirmationModal = ({ const ActionDropdown = ({ trigger, row, + onTableAction, }: { trigger: React.ReactNode; row: ModelScanInfo; + onTableAction: (row: ModelScanInfo, actionType: ActionEnumType) => void; }) => { const fetcher = useFetcher(); const [open, setOpen] = useState(false); @@ -257,15 +261,12 @@ const ActionDropdown = ({ const { downloadScan } = useDownloadScan((state) => { setIsSubmitting(state === 'submitting'); }); - const [openStopScanModal, setOpenStopScanModal] = useState(false); - const [showDeleteDialog, setShowDeleteDialog] = useState(false); const { scan_id: scanId, node_id: nodeId, node_type: nodeType, status: scanStatus, } = row; - const [showStartScan, setShowStartScan] = useState(false); const onDownloadAction = useCallback(() => { downloadScan({ @@ -281,47 +282,6 @@ const ActionDropdown = ({ return ( <> - {openStopScanModal && ( - - )} - - {showDeleteDialog && ( - { - // - }} - /> - )} - - {showStartScan && ( - setShowStartScan(false)} - scanOptions={ - { - showAdvancedOptions: true, - scanType: ScanTypeEnum.SecretScan, - data: { - nodes: [ - { - nodeId, - nodeType, - }, - ], - }, - } as ConfigureScanModalProps['scanOptions'] - } - /> - )} - { e.preventDefault(); if (isScanInProgress(scanStatus)) return; - setShowStartScan(true); + onTableAction(row, ActionEnumType.START_SCAN); }} disabled={isScanInProgress(scanStatus) || isScanStopping(scanStatus)} > @@ -354,7 +314,7 @@ const ActionDropdown = ({ { e.preventDefault(); - setOpenStopScanModal(true); + onTableAction(row, ActionEnumType.CANCEL_SCAN); }} disabled={!isScanInProgress(scanStatus)} > @@ -364,7 +324,7 @@ const ActionDropdown = ({ className="text-sm" onClick={() => { if (!scanId || !nodeType) return; - setShowDeleteDialog(true); + onTableAction(row, ActionEnumType.DELETE_SCAN); }} disabled={!scanId || !nodeType} > @@ -645,9 +605,11 @@ const Filters = () => { const ScansTable = ({ rowSelectionState, setRowSelectionState, + onTableAction, }: { rowSelectionState: RowSelectionState; setRowSelectionState: React.Dispatch>; + onTableAction: (row: ModelScanInfo, actionType: ActionEnumType) => void; }) => { const [searchParams, setSearchParams] = useSearchParams(); const { data } = useSuspenseQuery({ @@ -685,6 +647,7 @@ const ScansTable = ({ cell: (cell) => ( @@ -992,7 +955,7 @@ const ScansTable = ({ const BulkActions = ({ selectedRows, - setRowSelectionState, + onBulkAction, }: { selectedRows: { scanId: string; @@ -1000,11 +963,18 @@ const BulkActions = ({ nodeType: string; scanStatus: string; }[]; - setRowSelectionState: React.Dispatch>; + onBulkAction: ( + data: { + scanIdsToCancelScan: string[]; + scanIdsToDeleteScan: string[]; + nodesToStartScan: { + nodeId: string; + nodeType: string; + }[]; + }, + actionType: ActionEnumType, + ) => void; }) => { - const [openStartScan, setOpenStartScan] = useState(false); - const [showDeleteDialog, setShowDeleteDialog] = useState(false); - const [showCancelScanDialog, setShowCancelScanDialog] = useState(false); const nodesToStartScan = useMemo(() => { return selectedRows .filter( @@ -1032,52 +1002,20 @@ const BulkActions = ({ return ( <> - {openStartScan && ( - setOpenStartScan(false)} - onSuccess={() => setRowSelectionState({})} - scanOptions={ - { - showAdvancedOptions: true, - scanType: ScanTypeEnum.SecretScan, - data: { - nodes: nodesToStartScan, - }, - } as ConfigureScanModalProps['scanOptions'] - } - /> - )} - - {showDeleteDialog && ( - { - setRowSelectionState({}); - }} - /> - )} - {showCancelScanDialog ? ( - { - setRowSelectionState({}); - }} - /> - ) : null} - @@ -1098,7 +1045,14 @@ const BulkActions = ({ size="sm" disabled={scanIdsToDeleteScan.length === 0} onClick={() => { - setShowDeleteDialog(true); + onBulkAction( + { + scanIdsToCancelScan: [], + scanIdsToDeleteScan, + nodesToStartScan: [], + }, + ActionEnumType.DELETE_SCAN, + ); }} > Delete Scan @@ -1116,6 +1070,9 @@ const SecretScans = () => { }); const [rowSelectionState, setRowSelectionState] = useState({}); + const [openStartScan, setOpenStartScan] = useState(false); + const [showDeleteDialog, setShowDeleteDialog] = useState(false); + const [showCancelScanDialog, setShowCancelScanDialog] = useState(false); const selectedRows = useMemo< { @@ -1130,8 +1087,115 @@ const SecretScans = () => { }); }, [rowSelectionState]); + const [rowToAction, setRowToAction] = useState<{ + scanIdsToCancelScan: string[]; + scanIdsToDeleteScan: string[]; + nodesToStartScan: { + nodeId: string; + nodeType: string; + }[]; + }>({ + scanIdsToCancelScan: [], + scanIdsToDeleteScan: [], + nodesToStartScan: [], + }); + + const onTableAction = (row: ModelScanInfo, actionType: string) => { + if (actionType === ActionEnumType.DELETE_SCAN) { + setRowToAction({ + scanIdsToCancelScan: [], + scanIdsToDeleteScan: [row.scan_id], + nodesToStartScan: [], + }); + setShowDeleteDialog(true); + } else if (actionType === ActionEnumType.CANCEL_SCAN) { + setRowToAction({ + scanIdsToCancelScan: [row.scan_id], + scanIdsToDeleteScan: [], + nodesToStartScan: [], + }); + setShowCancelScanDialog(true); + } else if (actionType === ActionEnumType.START_SCAN) { + setRowToAction({ + scanIdsToCancelScan: [], + scanIdsToDeleteScan: [], + nodesToStartScan: [ + { + nodeId: row.node_id, + nodeType: row.node_type, + }, + ], + }); + setOpenStartScan(true); + } + }; + + const onBulkAction = ( + data: { + scanIdsToCancelScan: string[]; + scanIdsToDeleteScan: string[]; + nodesToStartScan: { + nodeId: string; + nodeType: string; + }[]; + }, + actionType: string, + ) => { + setRowToAction({ + scanIdsToCancelScan: data.scanIdsToCancelScan, + scanIdsToDeleteScan: data.scanIdsToDeleteScan, + nodesToStartScan: data.nodesToStartScan, + }); + if (actionType === ActionEnumType.DELETE_SCAN) { + setShowDeleteDialog(true); + } else if (actionType === ActionEnumType.CANCEL_SCAN) { + setShowCancelScanDialog(true); + } else if (actionType === ActionEnumType.START_SCAN) { + setOpenStartScan(true); + } + }; + return (
+ <> + {openStartScan && ( + setOpenStartScan(false)} + onSuccess={() => setRowSelectionState({})} + scanOptions={ + { + showAdvancedOptions: true, + scanType: ScanTypeEnum.SecretScan, + data: { + nodes: rowToAction?.nodesToStartScan, + }, + } as ConfigureScanModalProps['scanOptions'] + } + /> + )} + {showDeleteDialog && ( + { + setRowSelectionState({}); + }} + /> + )} + {showCancelScanDialog ? ( + { + setRowSelectionState({}); + }} + /> + ) : null} +
} isLink> @@ -1151,10 +1215,7 @@ const SecretScans = () => {
- +
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 cc343751ad..afea9544e4 100644 --- a/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/VulnerabilityScans.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/vulnerabilities/pages/VulnerabilityScans.tsx @@ -80,7 +80,9 @@ export interface FocusableElement { } enum ActionEnumType { - DELETE = 'delete', + DELETE_SCAN = 'delete_scan', + CANCEL_SCAN = 'cancel_scan', + START_SCAN = 'start_scan,', } const DEFAULT_PAGE_SIZE = 10; @@ -101,7 +103,7 @@ const action = async ({ if (!actionType || scanIds.length === 0) { throw new Error('Action type and scan id is required'); } - if (actionType === ActionEnumType.DELETE) { + if (actionType === ActionEnumType.DELETE_SCAN) { const resultApi = apiWrapper({ fn: getScanResultsApiClient().bulkDeleteScans, }); @@ -172,7 +174,7 @@ const DeleteConfirmationModal = ({ if ( fetcher.state === 'idle' && fetcher.data?.success && - fetcher.data.action === ActionEnumType.DELETE + fetcher.data.action === ActionEnumType.DELETE_SCAN ) { onDeleteSuccess(); } @@ -211,7 +213,7 @@ const DeleteConfirmationModal = ({ disabled={fetcher.state === 'submitting'} onClick={(e) => { e.preventDefault(); - onDeleteAction(ActionEnumType.DELETE); + onDeleteAction(ActionEnumType.DELETE_SCAN); }} > Delete @@ -239,15 +241,15 @@ const DeleteConfirmationModal = ({ const ActionDropdown = ({ trigger, row, + onTableAction, }: { trigger: React.ReactNode; row: ModelScanInfo; + onTableAction: (row: ModelScanInfo, actionType: ActionEnumType) => void; }) => { const fetcher = useFetcher(); const [open, setOpen] = useState(false); - const [openStopScanModal, setOpenStopScanModal] = useState(false); const [isSubmitting, setIsSubmitting] = useState(false); - const [showDeleteDialog, setShowDeleteDialog] = useState(false); const { scan_id: scanId, node_id: nodeId, @@ -256,8 +258,6 @@ const ActionDropdown = ({ status: scanStatus, } = row; - const [showStartScan, setShowStartScan] = useState(false); - const [selectedNode, setSelectedNode] = useState<{ nodeName: string; nodeType: string; @@ -295,47 +295,6 @@ const ActionDropdown = ({ return ( <> - {openStopScanModal && ( - - )} - - {showDeleteDialog && ( - { - // - }} - /> - )} - - {showStartScan && ( - setShowStartScan(false)} - scanOptions={ - { - showAdvancedOptions: true, - scanType: ScanTypeEnum.VulnerabilityScan, - data: { - nodes: [ - { - nodeId, - nodeType, - }, - ], - }, - } as ConfigureScanModalProps['scanOptions'] - } - /> - )} - {selectedNode ? ( { e.preventDefault(); if (isScanInProgress(scanStatus)) return; - setShowStartScan(true); + onTableAction(row, ActionEnumType.START_SCAN); }} disabled={isScanInProgress(scanStatus) || isScanStopping(scanStatus)} > @@ -393,7 +352,7 @@ const ActionDropdown = ({ { e.preventDefault(); - setOpenStopScanModal(true); + onTableAction(row, ActionEnumType.CANCEL_SCAN); }} disabled={!isScanInProgress(scanStatus)} > @@ -403,7 +362,7 @@ const ActionDropdown = ({ { if (!scanId || !nodeType) return; - setShowDeleteDialog(true); + onTableAction(row, ActionEnumType.DELETE_SCAN); }} disabled={!scanId || !nodeType} > @@ -427,9 +386,11 @@ const ActionDropdown = ({ const ScansTable = ({ rowSelectionState, setRowSelectionState, + onTableAction, }: { rowSelectionState: RowSelectionState; setRowSelectionState: React.Dispatch>; + onTableAction: (row: ModelScanInfo, actionType: ActionEnumType) => void; }) => { const [searchParams, setSearchParams] = useSearchParams(); const { data } = useSuspenseQuery({ @@ -469,6 +430,7 @@ const ScansTable = ({ cell: (cell) => ( @@ -1056,7 +1018,7 @@ const Filters = () => { const BulkActions = ({ selectedRows, - setRowSelectionState, + onBulkAction, }: { selectedRows: { scanId: string; @@ -1064,11 +1026,18 @@ const BulkActions = ({ nodeType: string; scanStatus: string; }[]; - setRowSelectionState: React.Dispatch>; + onBulkAction: ( + data: { + scanIdsToCancelScan: string[]; + scanIdsToDeleteScan: string[]; + nodesToStartScan: { + nodeId: string; + nodeType: string; + }[]; + }, + actionType: ActionEnumType, + ) => void; }) => { - const [openStartScan, setOpenStartScan] = useState(false); - const [showDeleteDialog, setShowDeleteDialog] = useState(false); - const [showCancelScanDialog, setShowCancelScanDialog] = useState(false); const nodesToStartScan = useMemo(() => { return selectedRows .filter( @@ -1096,56 +1065,20 @@ const BulkActions = ({ return ( <> - {openStartScan && ( - { - setOpenStartScan(false); - }} - onSuccess={() => { - setRowSelectionState({}); - }} - scanOptions={ - { - showAdvancedOptions: true, - scanType: ScanTypeEnum.VulnerabilityScan, - data: { - nodes: nodesToStartScan, - }, - } as ConfigureScanModalProps['scanOptions'] - } - /> - )} - - {showDeleteDialog && ( - { - setRowSelectionState({}); - }} - /> - )} - {showCancelScanDialog ? ( - { - setRowSelectionState({}); - }} - /> - ) : null} -
From f8f3ad0e2c4e67509dd9b7875af545980b9e3172 Mon Sep 17 00:00:00 2001 From: milan-deepfence Date: Mon, 19 Feb 2024 18:12:49 +0530 Subject: [PATCH 27/32] fix modal issue for posture account --- .../src/features/postures/pages/Accounts.tsx | 379 ++++++++++-------- 1 file changed, 211 insertions(+), 168 deletions(-) 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 3e11fdadc9..6aced65de2 100644 --- a/deepfence_frontend/apps/dashboard/src/features/postures/pages/Accounts.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/postures/pages/Accounts.tsx @@ -58,7 +58,10 @@ import { PlusIcon } from '@/components/icons/common/Plus'; import { RefreshIcon } from '@/components/icons/common/Refresh'; import { TimesIcon } from '@/components/icons/common/Times'; import { TrashLineIcon } from '@/components/icons/common/TrashLine'; -import { CLOUDS } from '@/components/scan-configure-forms/ComplianceScanConfigureForm'; +import { + CLOUDS, + ComplianceScanConfigureFormProps, +} from '@/components/scan-configure-forms/ComplianceScanConfigureForm'; import { StopScanForm } from '@/components/scan-configure-forms/StopScanForm'; import { ScanStatusBadge } from '@/components/ScanStatusBadge'; import { PostureIcon } from '@/components/sideNavigation/icons/Posture'; @@ -99,14 +102,15 @@ import { usePageNavigation } from '@/utils/usePageNavigation'; import { isUpgradeAvailable } from '@/utils/version'; enum ActionEnumType { - DELETE = 'delete', + DELETE_SCAN = 'delete_scan', REFRESH_ACCOUNT = 'refresh_account', START_SCAN = 'start_scan', + CANCEL_SCAN = 'cancel_scan', } export const getNodeTypeByProviderName = ( providerName: string, -): ComplianceScanNodeTypeEnum | undefined => { +): ComplianceScanNodeTypeEnum => { switch (providerName) { case 'linux': case 'host': @@ -124,7 +128,7 @@ export const getNodeTypeByProviderName = ( case 'kubernetes': return ComplianceScanNodeTypeEnum.kubernetes_cluster; default: - return; + throw new Error('No matching provider name found'); } }; @@ -154,7 +158,7 @@ const action = async ({ throw new Error('Invalid action'); } - if (actionType === ActionEnumType.DELETE) { + if (actionType === ActionEnumType.DELETE_SCAN) { if (scanIds.length === 0) { throw new Error('Scan ids are required for deletion'); } @@ -181,7 +185,7 @@ const action = async ({ const { message } = await getResponseErrors(result.error); return { success: false, - action: ActionEnumType.DELETE, + action: ActionEnumType.DELETE_SCAN, message, }; } else if (result.error.response.status === 403) { @@ -189,7 +193,7 @@ const action = async ({ return { success: false, message, - action: ActionEnumType.DELETE, + action: ActionEnumType.DELETE_SCAN, }; } throw result.error; @@ -533,7 +537,7 @@ const DeleteConfirmationModal = ({ if ( fetcher.state === 'idle' && fetcher.data?.success && - fetcher.data.action === ActionEnumType.DELETE + fetcher.data.action === ActionEnumType.DELETE_SCAN ) { onSuccess(); } @@ -572,7 +576,7 @@ const DeleteConfirmationModal = ({ disabled={fetcher.state === 'submitting'} onClick={(e) => { e.preventDefault(); - onDeleteAction(ActionEnumType.DELETE); + onDeleteAction(ActionEnumType.DELETE_SCAN); }} > Delete @@ -608,23 +612,15 @@ const ActionDropdown = ({ nodeType?: string; scanType: ScanTypeEnum; row: ModelCloudNodeAccountInfo; - onTableAction: (ids: string[], actionType: ActionEnumType) => void; + onTableAction: (row: ModelCloudNodeAccountInfo, actionType: ActionEnumType) => void; }) => { const fetcher = useFetcher(); - const { - last_scan_id: scanId = '', - node_id: nodeId, - last_scan_status: scanStatus = '', - active, - } = row; + const { last_scan_id: scanId = '', last_scan_status: scanStatus = '', active } = row; const [open, setOpen] = useState(false); const [isSubmitting, setIsSubmitting] = useState(false); const { downloadScan } = useDownloadScan((state) => { setIsSubmitting(state === 'submitting'); }); - const [openStopScanModal, setOpenStopScanModal] = useState(false); - - const [showDeleteDialog, setShowDeleteDialog] = useState(false); const onDownloadAction = useCallback(() => { downloadScan({ @@ -641,35 +637,12 @@ const ActionDropdown = ({ if (fetcher.state === 'idle') setOpen(false); }, [fetcher]); - if (!nodeType || !nodeId) { - throw new Error('Node type and Node id are required'); + if (!nodeType) { + throw new Error('Node type is required'); } return ( <> - {openStopScanModal && ( - - )} - {showDeleteDialog && ( - { - // - }} - /> - )} { - if (!nodeId) { - throw new Error('Node id is required to start scan'); - } - onTableAction([nodeId], ActionEnumType.START_SCAN); + onTableAction(row, ActionEnumType.START_SCAN); }} > Start scan @@ -693,7 +663,7 @@ const ActionDropdown = ({ { e.preventDefault(); - setOpenStopScanModal(true); + onTableAction(row, ActionEnumType.CANCEL_SCAN); }} disabled={!isScanInProgress(scanStatus)} > @@ -715,7 +685,7 @@ const ActionDropdown = ({ disabled={!scanId || !nodeType} onClick={() => { if (!scanId || !nodeType) return; - setShowDeleteDialog(true); + onTableAction(row, ActionEnumType.DELETE_SCAN); }} > { - if (!nodeId) { - throw new Error('Account id is required to refresh'); - } - onTableAction([nodeId], ActionEnumType.REFRESH_ACCOUNT); + onTableAction(row, ActionEnumType.REFRESH_ACCOUNT); }} > Refresh account @@ -747,27 +714,53 @@ const ActionDropdown = ({ }; const BulkActions = ({ - onClick, - onDelete, - onRefreshAccount, - onCancelScan, - disableStartScan, - disableCancelScan, - disableDeleteScan, - disableRefreshAccount, + nodeType, + selectedRows, + onBulkAction, }: { - onClick?: React.MouseEventHandler | undefined; - onCancelScan?: React.MouseEventHandler | undefined; - onDelete?: React.MouseEventHandler | undefined; - onRefreshAccount?: React.MouseEventHandler | undefined; - disableStartScan: boolean; - disableCancelScan: boolean; - disableDeleteScan: boolean; - disableRefreshAccount: boolean; + nodeType: ComplianceScanNodeTypeEnum; + selectedRows: { + scanId: string; + nodeId: string; + nodeType: string; + active: boolean; + scanStatus: string; + }[]; + onBulkAction: ( + data: { + scanIdsToCancelScan: string[]; + scanIdsToDeleteScan: string[]; + nodesToStartScan: ComplianceScanConfigureFormProps['data'] | null; + }, + actionType: ActionEnumType, + ) => void; }) => { const { navigate } = usePageNavigation(); const params = useParams(); + const scanIdsToDeleteScan = useMemo(() => { + return selectedRows + .filter((row) => !isNeverScanned(row.scanStatus)) + .map((row) => row.scanId); + }, [selectedRows]); + + const nodeIdsToScan = useMemo(() => { + return selectedRows + .filter( + (node) => + node.active && + !isScanInProgress(node.scanStatus) && + !isScanStopping(node.scanStatus), + ) + .map((node) => node.nodeId); + }, [selectedRows]); + + const scanIdsToCancelScan = useMemo(() => { + return selectedRows + .filter((row) => isScanInProgress(row.scanStatus)) + .map((row) => row.scanId); + }, [selectedRows]); + return ( <> @@ -802,8 +807,17 @@ const BulkActions = ({ color="default" variant="flat" size="sm" - disabled={disableCancelScan} - onClick={onCancelScan} + disabled={scanIdsToCancelScan.length === 0} + onClick={() => + onBulkAction( + { + scanIdsToCancelScan, + scanIdsToDeleteScan: [], + nodesToStartScan: null, + }, + ActionEnumType.CANCEL_SCAN, + ) + } > Cancel scan @@ -812,8 +826,17 @@ const BulkActions = ({ variant="flat" startIcon={} size="sm" - disabled={disableDeleteScan} - onClick={onDelete} + disabled={scanIdsToDeleteScan.length === 0} + onClick={() => + onBulkAction( + { + scanIdsToCancelScan: [], + scanIdsToDeleteScan, + nodesToStartScan: null, + }, + ActionEnumType.DELETE_SCAN, + ) + } > Delete scan @@ -821,8 +844,17 @@ const BulkActions = ({ variant="flat" startIcon={} size="sm" - disabled={disableRefreshAccount} - onClick={onRefreshAccount} + disabled={selectedRows.length === 0} + onClick={() => + onBulkAction( + { + scanIdsToCancelScan: [], + scanIdsToDeleteScan: [], + nodesToStartScan: null, + }, + ActionEnumType.REFRESH_ACCOUNT, + ) + } > Refresh account @@ -847,7 +879,7 @@ const AccountTable = ({ scanType: 'ComplianceScan' | 'CloudComplianceScan'; setRowSelectionState: React.Dispatch>; rowSelectionState: RowSelectionState; - onTableAction: (ids: string[], actionType: ActionEnumType) => void; + onTableAction: (row: ModelCloudNodeAccountInfo, actionType: ActionEnumType) => void; }) => { const [searchParams, setSearchParams] = useSearchParams(); const { data } = usePostureAccounts(); @@ -1215,10 +1247,6 @@ const Accounts = () => { const [searchParams] = useSearchParams(); const [rowSelectionState, setRowSelectionState] = useState({}); - const [selectedScanType, setSelectedScanType] = useState< - typeof ScanTypeEnum.ComplianceScan | typeof ScanTypeEnum.CloudComplianceScan - >(); - const [filtersExpanded, setFiltersExpanded] = useState(false); const fetcher = useFetcher(); const routeParams = useParams() as { @@ -1231,7 +1259,7 @@ const Accounts = () => { const [showDeleteDialog, setShowDeleteDialog] = useState(false); const [showCancelScan, setShowCancelScan] = useState(false); - const [nodeIdsToScan, setNodeIdsToScan] = useState([]); + const [openStartScan, setOpenStartScan] = useState(false); const scanType = isNonCloudProvider(routeParams.nodeType) ? ScanTypeEnum.ComplianceScan @@ -1251,50 +1279,85 @@ const Accounts = () => { }); }, [rowSelectionState]); - const nodeIdsToDeleteScan = useMemo(() => { - return selectedRows - .filter((row) => !isNeverScanned(row.scanStatus)) - .map((row) => row.scanId); - }, [selectedRows]); - - const nodeIdsToCancelScan = useMemo(() => { - return selectedRows - .filter((row) => isScanInProgress(row.scanStatus)) - .map((row) => row.scanId); - }, [selectedRows]); - - useEffect(() => { - setNodeIdsToScan( - selectedRows - .filter( - (node) => - node.active && - !isScanInProgress(node.scanStatus) && - !isScanStopping(node.scanStatus), - ) - .map((node) => node.nodeId), - ); - }, [selectedRows]); + const [rowToAction, setRowToAction] = useState<{ + scanIdsToCancelScan: string[]; + scanIdsToDeleteScan: string[]; + nodesToStartScan: ComplianceScanConfigureFormProps['data'] | null; + }>({ + scanIdsToCancelScan: [], + scanIdsToDeleteScan: [], + nodesToStartScan: null, + }); const onTableAction = useCallback( - (nodeIds: string[], actionType: ActionEnumType) => { - if (actionType === ActionEnumType.START_SCAN) { - setNodeIdsToScan(nodeIds); - setSelectedScanType(scanType); + (row: ModelCloudNodeAccountInfo, actionType: ActionEnumType) => { + if (actionType === ActionEnumType.START_SCAN && nodeType) { + setRowToAction({ + scanIdsToCancelScan: [], + scanIdsToDeleteScan: [], + nodesToStartScan: { + nodeIds: [row.node_id!], + nodeType: nodeType, + }, + }); + setOpenStartScan(true); return; } else if (actionType === ActionEnumType.REFRESH_ACCOUNT) { const formData = new FormData(); formData.append('actionType', ActionEnumType.REFRESH_ACCOUNT); - nodeIds.forEach((nodeId) => formData.append('accountId[]', nodeId)); + [row.node_id!].forEach((nodeId) => formData.append('accountId[]', nodeId)); fetcher.submit(formData, { method: 'post', }); return; + } else if (actionType === ActionEnumType.DELETE_SCAN) { + setRowToAction({ + scanIdsToCancelScan: [], + scanIdsToDeleteScan: [row.last_scan_id!], + nodesToStartScan: null, + }); + setShowDeleteDialog(true); + } else if (actionType === ActionEnumType.CANCEL_SCAN) { + setRowToAction({ + scanIdsToCancelScan: [row.last_scan_id!], + scanIdsToDeleteScan: [], + nodesToStartScan: null, + }); + setShowCancelScan(true); } }, [fetcher], ); + const onBulkAction = ( + data: { + scanIdsToCancelScan: string[]; + scanIdsToDeleteScan: string[]; + nodesToStartScan: ComplianceScanConfigureFormProps['data'] | null; + }, + actionType: string, + ) => { + setRowToAction({ + scanIdsToCancelScan: data.scanIdsToCancelScan, + scanIdsToDeleteScan: data.scanIdsToDeleteScan, + nodesToStartScan: data.nodesToStartScan, + }); + if (actionType === ActionEnumType.DELETE_SCAN) { + setShowDeleteDialog(true); + } else if (actionType === ActionEnumType.CANCEL_SCAN) { + setShowCancelScan(true); + } else if (actionType === ActionEnumType.START_SCAN) { + setOpenStartScan(true); + } else if (actionType === ActionEnumType.REFRESH_ACCOUNT) { + const formData = new FormData(); + formData.append('actionType', ActionEnumType.REFRESH_ACCOUNT); + selectedRows.forEach((row) => formData.append('accountId[]', row.nodeId)); + fetcher.submit(formData, { + method: 'post', + }); + } + }; + return (
{!hasOrgCloudAccount(nodeType ?? '') ?
: null} @@ -1302,37 +1365,50 @@ const Accounts = () => { { setRowSelectionState({}); }} /> )} + {openStartScan && ( + setOpenStartScan(false)} + onSuccess={() => setRowSelectionState({})} + scanOptions={ + nodeType && rowToAction.nodesToStartScan + ? { + showAdvancedOptions: true, + scanType, + data: rowToAction.nodesToStartScan, + } + : undefined + } + /> + )} + {showDeleteDialog && ( + { + setRowSelectionState({}); + }} + /> + )}
{ - const formData = new FormData(); - formData.append('actionType', ActionEnumType.REFRESH_ACCOUNT); - selectedRows.forEach((row) => formData.append('accountId[]', row.nodeId)); - fetcher.submit(formData, { - method: 'post', - }); - }} - onClick={() => { - setSelectedScanType(scanType); - }} - onCancelScan={() => { - setShowCancelScan(true); - }} - onDelete={() => { - setShowDeleteDialog(true); - }} + nodeType={nodeType} + onBulkAction={onBulkAction} + selectedRows={selectedRows} />
{filtersExpanded ? : null} - setSelectedScanType(undefined)} - onSuccess={() => setRowSelectionState({})} - scanOptions={ - selectedScanType && nodeType - ? { - showAdvancedOptions: true, - scanType: selectedScanType, - data: { - nodeIds: nodeIdsToScan, - nodeType: nodeType, - }, - } - : undefined - } - /> - }> { />
- {showDeleteDialog && ( - { - setRowSelectionState({}); - }} - /> - )}
); }; From 0a0c4de466d84d4e651df0609bd321c92453b25b Mon Sep 17 00:00:00 2001 From: milan-deepfence Date: Mon, 19 Feb 2024 18:52:19 +0530 Subject: [PATCH 28/32] fix edit or delete user modal --- .../settings/pages/UserManagement.tsx | 61 ++++++++++++------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/deepfence_frontend/apps/dashboard/src/features/settings/pages/UserManagement.tsx b/deepfence_frontend/apps/dashboard/src/features/settings/pages/UserManagement.tsx index 861e4fecc2..67c622e906 100644 --- a/deepfence_frontend/apps/dashboard/src/features/settings/pages/UserManagement.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/settings/pages/UserManagement.tsx @@ -68,6 +68,7 @@ enum ActionEnumType { INVITE_USER = 'inviteUser', EDIT_USER = 'editUser', RESET_API_KEY = 'resetAPIKey', + DELETE_USER = 'delete_user', } const useListUsers = () => { @@ -283,29 +284,14 @@ const action = async ({ request }: ActionFunctionArgs): Promise => { const ActionDropdown = ({ user, trigger, + onTableAction, }: { user: ModelUser; trigger: React.ReactNode; + onTableAction: (row: ModelUser, action: ActionEnumType) => void; }) => { - const [showDeleteDialog, setShowDeleteDialog] = useState(false); - const [showEditUserForm, setShowEditUserForm] = useState(false); - return ( <> - {showDeleteDialog && user.id && ( - - )} - {showEditUserForm && ( - - )} { - setShowEditUserForm(true); + onTableAction(user, ActionEnumType.EDIT_USER); }} > Edit { - setShowDeleteDialog(true); + onTableAction(user, ActionEnumType.DELETE_USER); }} className="dark:text-status-error dark:hover:text-[#C45268]" > @@ -763,7 +749,11 @@ const APITokenComponent = () => { ); }; -const UsersTable = () => { +const UsersTable = ({ + onTableAction, +}: { + onTableAction: (row: ModelUser, action: ActionEnumType) => void; +}) => { const columnHelper = createColumnHelper(); const columns = useMemo(() => { const columns = [ @@ -777,6 +767,7 @@ const UsersTable = () => { return (
@@ -892,9 +883,37 @@ const InviteButton = ({ }; const UserManagement = () => { const [openInviteUserForm, setOpenInviteUserForm] = useState(false); + const [showDeleteDialog, setShowDeleteDialog] = useState(false); + const [showEditUserForm, setShowEditUserForm] = useState(false); + + const [user, setUser] = useState(); + + const onTableAction = (row: ModelUser, action: ActionEnumType) => { + if (action === ActionEnumType.EDIT_USER) { + setUser(row); + setShowEditUserForm(true); + } else if (action === ActionEnumType.DELETE_USER) { + setUser(row); + setShowDeleteDialog(true); + } + }; return (
+ {showDeleteDialog && user?.id && ( + + )} + {showEditUserForm && ( + + )} {openInviteUserForm && ( { /> } > - +
From 08fd64f75aa456bdf9c5174e172a7d2fb0551e0b Mon Sep 17 00:00:00 2001 From: Jatin Baweja Date: Mon, 19 Feb 2024 20:41:13 +0530 Subject: [PATCH 29/32] Allow use of created_at for Scan timestamp display on UI (#1980) * Add created_at to scan listing and status APIs * Add created_at for cloud scanner scans APIs --- .../reporters/scan/scan_reporters.go | 31 ++++++++++--------- deepfence_server/reporters/search/search.go | 13 ++++---- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/deepfence_server/reporters/scan/scan_reporters.go b/deepfence_server/reporters/scan/scan_reporters.go index 04afc2cbc8..cb1dc77c57 100644 --- a/deepfence_server/reporters/scan/scan_reporters.go +++ b/deepfence_server/reporters/scan/scan_reporters.go @@ -70,7 +70,7 @@ func GetScanStatus(ctx context.Context, scanType utils.Neo4jScanType, scanIDs [] res, err := tx.Run(fmt.Sprintf(` MATCH (m:%s) -[:SCANNED]-> (n) WHERE m.node_id IN $scan_ids - RETURN m.node_id, m.status, m.status_message, n.node_id, n.node_name, labels(n) as node_type, m.updated_at`, scanType), + RETURN m.node_id, m.status, m.status_message, n.node_id, n.node_name, labels(n) as node_type, m.created_at, m.updated_at`, scanType), map[string]interface{}{"scan_ids": scanIDs}) if err != nil { return model.ScanStatusResp{}, err @@ -94,7 +94,8 @@ func extractStatuses(recs []*db.Record) map[string]model.ScanInfo { NodeID: rec.Values[3].(string), NodeName: rec.Values[4].(string), NodeType: Labels2NodeType(rec.Values[5].([]interface{})), - UpdatedAt: rec.Values[6].(int64), + CreatedAt: rec.Values[6].(int64), + UpdatedAt: rec.Values[7].(int64), } statuses[rec.Values[0].(string)] = info } @@ -125,7 +126,7 @@ func GetComplianceScanStatus(ctx context.Context, scanType utils.Neo4jScanType, query := fmt.Sprintf(` MATCH (m:%s) -[:SCANNED]-> (n:CloudNode) WHERE m.node_id IN $scan_ids - RETURN m.node_id, m.benchmark_types, m.status, m.status_message, n.node_id, m.updated_at, n.node_name`, scanType) + RETURN m.node_id, m.benchmark_types, m.status, m.status_message, n.node_id, m.created_at, m.updated_at, n.node_name`, scanType) res, err := tx.Run(query, map[string]interface{}{"scan_ids": scanIDs}) if err != nil { @@ -156,8 +157,9 @@ func extractStatusesWithBenchmarks(recs []*db.Record) []model.ComplianceScanInfo StatusMessage: rec.Values[3].(string), NodeID: rec.Values[4].(string), NodeType: controls.ResourceTypeToString(controls.CloudAccount), - UpdatedAt: rec.Values[5].(int64), - NodeName: rec.Values[6].(string), + CreatedAt: rec.Values[5].(int64), + UpdatedAt: rec.Values[6].(int64), + NodeName: rec.Values[7].(string), }, BenchmarkTypes: benchmarkTypes, } @@ -512,13 +514,13 @@ func GetScansList(ctx context.Context, scanType utils.Neo4jScanType, nodeIDs []m WHERE n.node_id IN $node_ids AND (` + strings.Join(nodeTypesStr, " OR ") + `) ` + reporters.ParseFieldFilters2CypherWhereConditions("m", mo.Some(ff), false) + ` - RETURN m.node_id, m.status, m.status_message, m.updated_at, n.node_id, n.node_name, labels(n) as node_type + RETURN m.node_id, m.status, m.status_message, m.created_at, m.updated_at, n.node_id, n.node_name, labels(n) as node_type ORDER BY m.updated_at ` + fw.FetchWindow2CypherQuery() } else { query = ` MATCH (m:` + string(scanType) + `) -[:SCANNED]-> (n) ` + reporters.ParseFieldFilters2CypherWhereConditions("m", mo.Some(ff), true) + ` - RETURN m.node_id, m.status, m.status_message, m.updated_at, n.node_id, n.node_name, labels(n) as node_type + RETURN m.node_id, m.status, m.status_message, m.created_at, m.updated_at, n.node_id, n.node_name, labels(n) as node_type ORDER BY m.updated_at ` + fw.FetchWindow2CypherQuery() } scansInfo, err = processScansListQuery(query, nodeIDsStr, tx) @@ -546,10 +548,11 @@ func processScansListQuery(query string, nodeIds []string, tx neo4j.Transaction) ScanID: rec.Values[0].(string), Status: rec.Values[1].(string), StatusMessage: rec.Values[2].(string), - UpdatedAt: rec.Values[3].(int64), - NodeID: rec.Values[4].(string), - NodeName: rec.Values[5].(string), - NodeType: Labels2NodeType(rec.Values[6].([]interface{})), + CreatedAt: rec.Values[3].(int64), + UpdatedAt: rec.Values[4].(int64), + NodeID: rec.Values[5].(string), + NodeName: rec.Values[6].(string), + NodeType: Labels2NodeType(rec.Values[7].([]interface{})), } scansInfo = append(scansInfo, tmp) } @@ -577,7 +580,7 @@ func GetCloudCompliancePendingScansList(ctx context.Context, scanType utils.Neo4 res, err := tx.Run(` MATCH (m:`+string(scanType)+`) -[:SCANNED]-> (n:CloudNode{node_id: $node_id}) WHERE m.status = $starting - RETURN m.node_id, m.benchmark_types, m.status, m.status_message, n.node_id, m.updated_at, n.node_name ORDER BY m.updated_at`, + RETURN m.node_id, m.benchmark_types, m.status, m.status_message, n.node_id, m.created_at, m.updated_at, n.node_name ORDER BY m.updated_at`, map[string]interface{}{"node_id": nodeID, "starting": utils.ScanStatusStarting}) if err != nil { return model.CloudComplianceScanListResp{}, err @@ -1149,7 +1152,7 @@ func GetBulkScans(ctx context.Context, scanType utils.Neo4jScanType, scanID stri neoRes, err := tx.Run(` MATCH (m:Bulk`+string(scanType)+`{node_id:$scan_id}) -[:BATCH]-> (d:`+string(scanType)+`) -[:SCANNED]-> (n) - RETURN d.node_id as scan_id, d.status, d.status_message, n.node_id as node_id, n.node_name, labels(n) as node_type, d.updated_at`, + RETURN d.node_id as scan_id, d.status, d.status_message, n.node_id as node_id, n.node_name, labels(n) as node_type, d.created_at, d.updated_at`, map[string]interface{}{"scan_id": scanID}) if err != nil { return scanIDs, err @@ -1212,7 +1215,7 @@ func GetComplianceBulkScans(ctx context.Context, scanType utils.Neo4jScanType, s neoRes, err := tx.Run(` MATCH (m:Bulk`+string(scanType)+`{node_id:$scan_id}) -[:BATCH]-> (d:`+string(scanType)+`) -[:SCANNED]-> (n:CloudNode) - RETURN d.node_id, d.benchmark_types, d.status, d.status_message, n.node_id, d.updated_at, n.node_name`, + RETURN d.node_id, d.benchmark_types, d.status, d.status_message, n.node_id, d.created_at, d.updated_at, n.node_name`, map[string]interface{}{"scan_id": scanID}) if err != nil { log.Error().Msgf("Compliance bulk scans status query failed: %+v", err) diff --git a/deepfence_server/reporters/search/search.go b/deepfence_server/reporters/search/search.go index ecc2d92cf4..0697b92492 100644 --- a/deepfence_server/reporters/search/search.go +++ b/deepfence_server/reporters/search/search.go @@ -169,7 +169,7 @@ func constructIndirectMatchInit( if doReturn { if extendedField != "" { - query += "\n"+`MATCH (` + name + `) -[:IS]-> (e) ` + + query += "\n" + `MATCH (` + name + `) -[:IS]-> (e) ` + reporters.ParseFieldFilters2CypherWhereConditions("e", mo.Some(extendedFilter.Filters), true) + reporters.OrderFilter2CypherCondition("e", extendedFilter.Filters.OrderFilter, []string{name}) + ` RETURN ` + reporters.FieldFilterCypher(name, filter.InFieldFilter) + `, e` + @@ -480,7 +480,7 @@ func searchGenericScanInfoReport(ctx context.Context, scanType utils.Neo4jScanTy ORDER BY n.updated_at DESC` + scanFilter.Window.FetchWindow2CypherQuery() + `}` + - ` RETURN n.node_id as scan_id, n.status as status, n.status_message as status_message, n.updated_at as updated_at, m.node_id as node_id, COALESCE(m.node_type, m.cloud_provider) as node_type, m.node_name as node_name` + + ` RETURN n.node_id as scan_id, n.status as status, n.status_message as status_message, n.created_at as created_at, n.updated_at as updated_at, m.node_id as node_id, COALESCE(m.node_type, m.cloud_provider) as node_type, m.node_name as node_name` + reporters.OrderFilter2CypherCondition("", scanFilter.Filters.OrderFilter, nil) + fw.FetchWindow2CypherQuery() log.Debug().Msgf("search query: %v", query) @@ -507,10 +507,11 @@ func searchGenericScanInfoReport(ctx context.Context, scanType utils.Neo4jScanTy ScanID: rec.Values[0].(string), Status: rec.Values[1].(string), StatusMessage: rec.Values[2].(string), - UpdatedAt: rec.Values[3].(int64), - NodeID: rec.Values[4].(string), - NodeType: rec.Values[5].(string), - NodeName: rec.Values[6].(string), + CreatedAt: rec.Values[3].(int64), + UpdatedAt: rec.Values[4].(int64), + NodeID: rec.Values[5].(string), + NodeType: rec.Values[6].(string), + NodeName: rec.Values[7].(string), SeverityCounts: counts, }) } From 0355d112e950bc7e0cfbede2c8b46127bb112ddf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 20 Feb 2024 00:35:45 +0000 Subject: [PATCH 30/32] Update listing with threatintel-2024-02-20_00-16-46 --- docs/vulnerability_feeds/listing.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/vulnerability_feeds/listing.json b/docs/vulnerability_feeds/listing.json index c2dd367979..97be7c902e 100644 --- a/docs/vulnerability_feeds/listing.json +++ b/docs/vulnerability_feeds/listing.json @@ -27,12 +27,6 @@ } ], "5": [ - { - "built": "2024-02-16T00:40:16.459255439Z", - "version": 5, - "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v5-2024-02-16_00-17-03/threatintel-vuln-v5-2024-02-16_00-17-03.tar.gz", - "checksum": "967b975120433ae9f4f11f44cad89f4b78b87fecdc5091cb62a4c68bdde2f5df" - }, { "built": "2024-02-17T00:39:33.279866383Z", "version": 5, @@ -50,6 +44,12 @@ "version": 5, "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v5-2024-02-19_00-17-50/threatintel-vuln-v5-2024-02-19_00-17-50.tar.gz", "checksum": "ff17baf5f3cfa8cfdfa808007c8370e3d0287ef0a5f03d81758d73f16446bedf" + }, + { + "built": "2024-02-20T00:35:23.842245243Z", + "version": 5, + "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v5-2024-02-20_00-16-46/threatintel-vuln-v5-2024-02-20_00-16-46.tar.gz", + "checksum": "c581cf06c2af61a76e7acd736762d0085947895ffe962aa739f3118b847fcc58" } ] } From 8e198252f8a6b214e3832a08a458f693eaf8b980 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 20 Feb 2024 00:59:45 +0000 Subject: [PATCH 31/32] Update listing with threatintel-2024-02-20_00-49-16 --- docs/vulnerability_feeds/listing.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/vulnerability_feeds/listing.json b/docs/vulnerability_feeds/listing.json index 97be7c902e..f35d619f6b 100644 --- a/docs/vulnerability_feeds/listing.json +++ b/docs/vulnerability_feeds/listing.json @@ -1,12 +1,6 @@ { "available": { "3": [ - { - "built": "2024-02-16T01:03:24.253752293Z", - "version": 3, - "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v3-2024-02-16_00-49-23/threatintel-vuln-v3-2024-02-16_00-49-23.tar.gz", - "checksum": "c1bd46f68a6086e488eed9c12b7fae9aad25d19c2936eedf7938bf1b961eb00a" - }, { "built": "2024-02-17T01:01:21.489056192Z", "version": 3, @@ -24,6 +18,12 @@ "version": 3, "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v3-2024-02-19_00-49-24/threatintel-vuln-v3-2024-02-19_00-49-24.tar.gz", "checksum": "4b02a72fd2e67d27b92189e105e2b108870b9e45b95d13ea931c734f95247a84" + }, + { + "built": "2024-02-20T00:59:24.545374821Z", + "version": 3, + "url": "https://threat-intel.deepfence.io/vulnerability-db/releases/download/threatintel-vuln-v3-2024-02-20_00-49-16/threatintel-vuln-v3-2024-02-20_00-49-16.tar.gz", + "checksum": "7449fa6b7593e2c5bef9644e28bb02277c78a25199b1d1750cb43b5e507f77d5" } ], "5": [ From 1b7af0fa6405392d4fad02223d4b0021e2ce5dc4 Mon Sep 17 00:00:00 2001 From: milan-deepfence Date: Tue, 20 Feb 2024 12:29:03 +0530 Subject: [PATCH 32/32] fix: node type for k8 posture report --- .../dashboard/src/features/postures/pages/Accounts.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 6aced65de2..8855e87584 100644 --- a/deepfence_frontend/apps/dashboard/src/features/postures/pages/Accounts.tsx +++ b/deepfence_frontend/apps/dashboard/src/features/postures/pages/Accounts.tsx @@ -108,9 +108,7 @@ enum ActionEnumType { CANCEL_SCAN = 'cancel_scan', } -export const getNodeTypeByProviderName = ( - providerName: string, -): ComplianceScanNodeTypeEnum => { +const getNodeTypeByProviderName = (providerName: string): ComplianceScanNodeTypeEnum => { switch (providerName) { case 'linux': case 'host': @@ -625,7 +623,9 @@ const ActionDropdown = ({ const onDownloadAction = useCallback(() => { downloadScan({ scanId, - nodeType: nodeType as UtilsReportFiltersNodeTypeEnum, + nodeType: (nodeType?.toString() === ComplianceScanNodeTypeEnum.kubernetes_cluster + ? 'cluster' + : nodeType) as UtilsReportFiltersNodeTypeEnum, scanType: (scanType as ScanTypeEnum) === ScanTypeEnum.CloudComplianceScan ? UtilsReportFiltersScanTypeEnum.CloudCompliance