Skip to content

Commit 8a453af

Browse files
committed
feat: intergrate scanning for v1 and v2 APIs
1 parent e11df26 commit 8a453af

26 files changed

+170
-358
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.3.5",
3+
"version": "1.3.5-beta-2",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/Constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export const ROUTES = {
8989
CD_MATERIAL_GET: 'app/cd-pipeline',
9090
DEPLOYMENT_TEMPLATE_LIST: 'app/template/list',
9191
INFRA_CONFIG_PROFILE: 'infra-config/profile',
92-
SECURITY_SCAN_EXECUTION_DETAILS: 'security/scan/executionDetail',
92+
SCAN_RESULT: 'scan-result',
9393
NOTIFIER: 'notification',
9494
APP_LIST: 'app/list',
9595
TELEMETRY_EVENT: 'telemetry/event',

src/Shared/Components/ImageCardAccordion/ImageCardAccordion.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ const ImageCardAccordion = ({
4949
isScanned,
5050
isScanEnabled,
5151
SecurityModalSidebar,
52-
getSecurityScan,
5352
}: ImageCardAccordionProps) => {
5453
const [isOpened, setIsOpened] = useState<boolean>(false)
5554
const [activeTab, setActiveTab] = useState<CDModalTabType>(CDModalTab.Changes)
@@ -77,7 +76,6 @@ const ImageCardAccordion = ({
7776
environmentId={environmentId}
7877
setVulnerabilityCount={setVulnerabilityCount}
7978
SecurityModalSidebar={SecurityModalSidebar}
80-
getSecurityScan={getSecurityScan}
8179
/>
8280
)
8381
}

src/Shared/Components/ImageCardAccordion/types.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
*/
1616

1717
import React, { ReactNode } from 'react'
18-
import { CDModalTabType, ResponseType, VulnerabilityType } from '../../../Common'
18+
import { CDModalTabType, VulnerabilityType } from '../../../Common'
1919
import { MaterialSecurityInfoType } from '../../types'
20-
import { ApiResponseResultType, AppDetailsPayload, SidebarPropsType } from '../Security'
20+
import { SidebarPropsType } from '../Security'
2121

2222
export interface ImageCardAccordionProps extends MaterialSecurityInfoType {
2323
isSecurityModuleInstalled: boolean
@@ -28,9 +28,6 @@ export interface ImageCardAccordionProps extends MaterialSecurityInfoType {
2828
isScanned: boolean
2929
isScanEnabled: boolean
3030
SecurityModalSidebar: React.FC<SidebarPropsType>
31-
getSecurityScan: (
32-
props: Pick<AppDetailsPayload, 'appId' | 'artifactId'>,
33-
) => Promise<ResponseType<ApiResponseResultType>>
3431
}
3532

3633
export interface SecurityDetailsType {

src/Shared/Components/Security/SecurityModal/SecurityModal.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ const SecurityModal: React.FC<SecurityModalPropsType> = ({
3939
isLoading,
4040
error,
4141
responseData,
42-
isResourceScan = false,
43-
isHelmApp = false,
44-
isSecurityScanV2Enabled = false,
45-
isExternalCI = false,
4642
hidePolicy = false,
4743
}) => {
4844
const [state, setState] = useState<SecurityModalStateType>(DEFAULT_SECURITY_MODAL_STATE)
@@ -156,12 +152,15 @@ const SecurityModal: React.FC<SecurityModalPropsType> = ({
156152
/* NOTE: the height is restricted to (viewport - header) height since we need overflow-scroll */
157153
<div className="flexbox" style={{ height: 'calc(100vh - 49px)' }}>
158154
{/* NOTE: only show sidebar in AppDetails */}
159-
{isSecurityScanV2Enabled && !isResourceScan && Sidebar && (
155+
{Sidebar && (
160156
<Sidebar
161-
isHelmApp={isHelmApp}
162157
modalState={state}
163158
setModalState={setState}
164-
isExternalCI={isExternalCI}
159+
categoriesConfig={{
160+
imageScan: !!data.imageScan,
161+
codeScan: !!data.codeScan,
162+
kubernetesManifest: !!data.kubernetesManifest,
163+
}}
165164
/>
166165
)}
167166
<div className="dc__border-right-n1 h-100" />
@@ -176,7 +175,7 @@ const SecurityModal: React.FC<SecurityModalPropsType> = ({
176175
return (
177176
<VisibleModal2 className="dc__position-rel" close={handleModalClose}>
178177
<div
179-
className={`${isResourceScan ? 'w-800' : 'w-1024'} h-100vh bcn-0 flexbox-col dc__right-0 dc__top-0 dc__position-abs`}
178+
className={`${Sidebar ? 'w-1024' : 'w-800'} h-100vh bcn-0 flexbox-col dc__right-0 dc__top-0 dc__position-abs`}
180179
onClick={stopPropagation}
181180
>
182181
{renderHeader()}

src/Shared/Components/Security/SecurityModal/config/CodeScan.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
SEVERITY_DEFAULT_SORT_ORDER,
1818
} from '../constants'
1919
import {
20-
ApiResponseResultType,
20+
ScanResultDTO,
2121
CATEGORIES,
2222
CodeScan,
2323
CodeScanExposedSecretsListType,
@@ -489,7 +489,7 @@ const getCompletedEmptyState = (
489489
}
490490

491491
export const getCodeScanEmptyState = (
492-
data: ApiResponseResultType,
492+
data: ScanResultDTO,
493493
subCategory: SecurityModalStateType['subCategory'],
494494
detailViewData: DetailViewDataType,
495495
): EmptyStateType => {

src/Shared/Components/Security/SecurityModal/config/EmptyState.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import { getCodeScanEmptyState } from './CodeScan'
66
import { getImageScanEmptyState } from './ImageScan'
77
import { getKubernetesManifestEmptyState } from './KubernetesManifest'
8-
import { ApiResponseResultType, CATEGORIES, DetailViewDataType, SecurityModalStateType } from '../types'
8+
import { ScanResultDTO, CATEGORIES, DetailViewDataType, SecurityModalStateType } from '../types'
99

1010
export const getEmptyStateValues = (
11-
data: ApiResponseResultType,
11+
data: ScanResultDTO,
1212
category: SecurityModalStateType['category'],
1313
subCategory: SecurityModalStateType['subCategory'],
1414
detailViewData: DetailViewDataType,

src/Shared/Components/Security/SecurityModal/config/ImageScan.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
InfoCardPropsType,
1919
ImageScanLicenseListType,
2020
EmptyStateType,
21-
ApiResponseResultType,
21+
ScanResultDTO,
2222
CATEGORIES,
2323
OpenDetailViewButtonProps,
2424
} from '../types'
@@ -355,14 +355,14 @@ const getCompletedEmptyState = (
355355
}
356356

357357
export const getImageScanEmptyState = (
358-
data: ApiResponseResultType,
358+
data: ScanResultDTO,
359359
subCategory: SecurityModalStateType['subCategory'],
360360
detailViewData: DetailViewDataType,
361361
): EmptyStateType => {
362362
/**
363363
* NOTE: handling for resourceScan in ResourceBrowser
364364
* TODO: handle properly */
365-
if (!data[CATEGORIES.IMAGE_SCAN][subCategory]?.list?.length) {
365+
if (!data[CATEGORIES.IMAGE_SCAN]?.[subCategory]?.list?.length) {
366366
return SCAN_IN_PROGRESS_EMPTY_STATE
367367
}
368368

src/Shared/Components/Security/SecurityModal/config/InfoCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
* Copyright (c) 2024. Devtron Inc.
33
*/
44

5-
import { InfoCardPropsType, ApiResponseResultType, CATEGORIES, SecurityModalStateType } from '../types'
5+
import { InfoCardPropsType, ScanResultDTO, CATEGORIES, SecurityModalStateType } from '../types'
66
import { getImageScanInfoCardData } from './ImageScan'
77
import { getCodeScanInfoCardData } from './CodeScan'
88
import { getKubernetesManifestInfoCardData } from './KubernetesManifest'
99

1010
export const getInfoCardData = (
11-
data: ApiResponseResultType,
11+
data: ScanResultDTO,
1212
category: SecurityModalStateType['category'],
1313
subCategory: SecurityModalStateType['subCategory'],
1414
): InfoCardPropsType => {

0 commit comments

Comments
 (0)