Skip to content

Commit 65cd8b7

Browse files
committed
feat: add support for artifactId in execution details in security summary card
1 parent a20c89d commit 65cd8b7

File tree

4 files changed

+8
-24
lines changed

4 files changed

+8
-24
lines changed

src/components/app/details/appDetails/AppSecurity.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const useGetAppSecurityDetails = ({
2525
appId,
2626
envId,
2727
installedAppId,
28+
artifactId,
2829
imageScanDeployInfoId,
2930
isSecurityScanV2Enabled,
3031
}: UseGetAppSecurityDetailsProps): UseGetAppSecurityDetailsReturnType => {
@@ -35,7 +36,7 @@ export const useGetAppSecurityDetails = ({
3536
)
3637

3738
const [executionDetailsLoading, executionDetailsResponse, executionDetailsError, reloadExecutionDetails] = useAsync(
38-
() => getExecutionDetails({ appId, envId, imageScanDeployInfoId }),
39+
() => getExecutionDetails({ appId, artifactId, imageScanDeployInfoId }),
3940
[appId, envId, imageScanDeployInfoId],
4041
!isSecurityScanV2Enabled && !!appId,
4142
)

src/components/app/details/appDetails/SecurityVulnerabilityCard.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const SecurityVulnerabilityCard = ({
3838
appId,
3939
envId,
4040
installedAppId,
41+
artifactId,
4142
isExternalCI,
4243
}: SecurityVulnerabilityCardType) => {
4344
const [showScanDetailsModal, setShowScanDetailsModal] = useState<boolean>(false)
@@ -46,7 +47,7 @@ export const SecurityVulnerabilityCard = ({
4647
const handleModalClose = () => setShowScanDetailsModal(false)
4748

4849
const { scanDetailsLoading, scanDetailsResponse, scanDetailsError, reloadScanDetails, severityCount } =
49-
useGetAppSecurityDetails({ appId: +appId, envId: +envId, installedAppId, isSecurityScanV2Enabled })
50+
useGetAppSecurityDetails({ appId: +appId, envId: +envId, installedAppId, artifactId, isSecurityScanV2Enabled })
5051

5152
// Since we get status in v2 Api only
5253
const imageScanFailed: boolean = isSecurityScanV2Enabled && scanDetailsResponse?.result.codeScan.status === 'Failed'

src/components/app/details/appDetails/SourceInfo.tsx

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export const SourceInfo = ({
6868
filteredEnvIds,
6969
deploymentUserActionState,
7070
}: SourceInfoType) => {
71-
const [showVulnerabilitiesCard, setShowVulnerabilitiesCard] = useState<boolean>(false)
7271
const isdeploymentAppDeleting = appDetails?.deploymentAppDeleteRequest || false
7372
const isArgoCdApp = appDetails?.deploymentAppType === DeploymentAppTypes.GITOPS
7473
const status = appDetails?.resourceTree?.status || ''
@@ -92,24 +91,6 @@ export const SourceInfo = ({
9291
message = Rollout[0].health.message
9392
}
9493

95-
const getScannedStatus = async () => {
96-
const { appId, ciArtifactId } = appDetails
97-
try {
98-
const {
99-
result: { scanEnabled, scanned },
100-
} = await getLastExecutionByAppArtifactId(ciArtifactId, appId)
101-
if (scanEnabled && scanned) {
102-
// If scanEnabled and scanned is true, then show the vulnerabilities card
103-
setShowVulnerabilitiesCard(true)
104-
} else {
105-
setShowVulnerabilitiesCard(false)
106-
}
107-
} catch (error) {
108-
setShowVulnerabilitiesCard(false)
109-
showError(error)
110-
}
111-
}
112-
11394
useEffect(() => {
11495
if (appDetails?.ciArtifactId && appDetails?.appId) {
11596
getScannedStatus()
@@ -328,13 +309,12 @@ export const SourceInfo = ({
328309
filteredEnvIds={filteredEnvIds}
329310
/>
330311
)}
331-
{!appDetails?.deploymentAppDeleteRequest &&
332-
!helmMigratedAppNotTriggered &&
333-
(showVulnerabilitiesCard || window._env_.ENABLE_RESOURCE_SCAN_V2) && (
312+
{!appDetails?.deploymentAppDeleteRequest && !helmMigratedAppNotTriggered && (
334313
<SecurityVulnerabilityCard
335314
cardLoading={cardLoading}
336315
appId={params.appId}
337316
envId={params.envId}
317+
ciArtifactId={ciArtifactId}
338318
isExternalCI={isExternalCI}
339319
/>
340320
)}

src/components/app/details/appDetails/appDetails.type.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ export interface SecurityVulnerabilityCardType {
234234
appId?: string
235235
envId?: string
236236
installedAppId?: number
237+
artifactId?: number
237238
isExternalCI?: boolean
238239
}
239240

@@ -268,6 +269,7 @@ export interface UseGetAppSecurityDetailsProps {
268269
appId: number
269270
envId: number
270271
installedAppId?: number
272+
artifactId?: number
271273
imageScanDeployInfoId?: number
272274
isSecurityScanV2Enabled: boolean
273275
}

0 commit comments

Comments
 (0)