Skip to content

Commit db172e9

Browse files
authored
Merge pull request #2065 from devtron-labs/fix/migrate-security
fix: migrate security
2 parents 721421b + 6e47f61 commit db172e9

File tree

10 files changed

+34
-47
lines changed

10 files changed

+34
-47
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"homepage": "/dashboard",
66
"dependencies": {
7-
"@devtron-labs/devtron-fe-common-lib": "0.3.14",
7+
"@devtron-labs/devtron-fe-common-lib": "0.3.15",
88
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
99
"@rjsf/core": "^5.13.3",
1010
"@rjsf/utils": "^5.13.3",

src/components/ResourceBrowser/ResourceList/ResourceBrowserActionMenu.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,12 @@ const ResourceBrowserActionMenu: React.FC<ResourceBrowserActionMenuType> = ({
9999
setShowVulnerabilityModal(false)
100100
}
101101

102-
const showResourceScanModal = getShowResourceScanModal(
103-
selectedResource?.gvk?.Kind as NodeType,
104-
installedModuleMap.current?.[ModuleNameMap.SECURITY_TRIVY],
105-
)
102+
const showResourceScanModal =
103+
getShowResourceScanModal(
104+
selectedResource?.gvk?.Kind as NodeType,
105+
installedModuleMap.current?.[ModuleNameMap.SECURITY_TRIVY],
106+
) && window._env_.ENABLE_RESOURCE_SCAN_V2
107+
106108
return (
107109
<>
108110
<PopupMenu autoClose>

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

Lines changed: 4 additions & 2 deletions
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,8 +36,9 @@ export const useGetAppSecurityDetails = ({
3536
)
3637

3738
const [executionDetailsLoading, executionDetailsResponse, executionDetailsError, reloadExecutionDetails] = useAsync(
38-
() => getExecutionDetails({ appId, envId, imageScanDeployInfoId }),
39-
[appId, envId, imageScanDeployInfoId],
39+
() =>
40+
getExecutionDetails(appId && artifactId ? { appId, artifactId } : { appId, envId, imageScanDeployInfoId }),
41+
[appId, envId, imageScanDeployInfoId, artifactId],
4042
!isSecurityScanV2Enabled && !!appId,
4143
)
4244

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 & 28 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,30 +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-
113-
useEffect(() => {
114-
if (appDetails?.ciArtifactId && appDetails?.appId) {
115-
getScannedStatus()
116-
}
117-
}, [appDetails?.ciArtifactId, appDetails?.appId])
118-
11994
const onClickShowCommitInfo = (e): void => {
12095
e.stopPropagation()
12196
showCommitInfo(true)
@@ -328,13 +303,12 @@ export const SourceInfo = ({
328303
filteredEnvIds={filteredEnvIds}
329304
/>
330305
)}
331-
{!appDetails?.deploymentAppDeleteRequest &&
332-
!helmMigratedAppNotTriggered &&
333-
(showVulnerabilitiesCard || window._env_.ENABLE_RESOURCE_SCAN_V2) && (
306+
{!appDetails?.deploymentAppDeleteRequest && !helmMigratedAppNotTriggered && (
334307
<SecurityVulnerabilityCard
335308
cardLoading={cardLoading}
336309
appId={params.appId}
337310
envId={params.envId}
311+
artifactId={ciArtifactId}
338312
isExternalCI={isExternalCI}
339313
/>
340314
)}

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
}

src/components/app/details/triggerView/cdMaterial.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1577,7 +1577,6 @@ const CDMaterial = ({
15771577
isSecurityModuleInstalled={state.isSecurityModuleInstalled}
15781578
artifactId={+mat.id}
15791579
applicationId={appId}
1580-
environmentId={envId}
15811580
changesCard={renderGitMaterialInfo(mat)}
15821581
isScanned={mat.scanned}
15831582
isScanEnabled={mat.scanEnabled}

src/components/v2/appDetails/k8Resource/nodeType/PodPopup.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ const PodPopup = ({
3131
handleShowVulnerabilityModal,
3232
}: PodPopupProps) => {
3333
const { installedModuleMap } = useMainContext()
34-
const showResourceScanModal = getShowResourceScanModal(
35-
kind as NodeType,
36-
installedModuleMap.current?.[ModuleNameMap.SECURITY_TRIVY],
37-
)
34+
const showResourceScanModal =
35+
window._env_.ENABLE_RESOURCE_SCAN_V2 &&
36+
getShowResourceScanModal(kind as NodeType, installedModuleMap.current?.[ModuleNameMap.SECURITY_TRIVY])
3837

3938
const handleDescribeEvents = () => {
4039
describeNode(NodeDetailTabs.EVENTS)

src/components/v2/appDetails/sourceInfo/environmentStatus/EnvironmentStatus.component.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import React, { useMemo, useState } from 'react'
17+
import { useMemo, useState } from 'react'
1818
import AppStatusDetailModal from './AppStatusDetailModal'
1919
import './environmentStatus.scss'
2020
import { ReactComponent as Alert } from '../../../assets/icons/ic-alert-triangle.svg'
@@ -40,6 +40,7 @@ import IssuesListingModal from '../../../../app/details/appDetails/IssuesListing
4040
import SecurityVulnerabilityCard from '../../../../app/details/appDetails/SecurityVulnerabilityCard'
4141

4242
const AppDetailsDownloadCard = importComponentFromFELibrary('AppDetailsDownloadCard')
43+
const isFELibAvailable = importComponentFromFELibrary('isFELibAvailable', null, 'function')
4344

4445
const EnvironmentStatusComponent = ({
4546
loadingDetails,
@@ -60,6 +61,7 @@ const EnvironmentStatusComponent = ({
6061
const [, notesResult] = useAsync(() => getInstalledChartNotesDetail(+params.appId, +params.envId), [])
6162
const [errorsList, setErrorsList] = useState<ErrorItem[]>([])
6263
const [showIssuesModal, toggleIssuesModal] = useState<boolean>(false)
64+
const isScanV2Enabled = window._env_.ENABLE_RESOURCE_SCAN_V2 && isFELibAvailable
6365

6466
const onClickUpgrade = () => {
6567
const _url = `${url.split('/').slice(0, -1).join('/')}/${URLS.APP_VALUES}`
@@ -200,7 +202,7 @@ const EnvironmentStatusComponent = ({
200202
{renderLastUpdatedBlock()}
201203
{renderChartUsedBlock()}
202204
{renderUpgraderChartBlock()}
203-
<SecurityVulnerabilityCard cardLoading={cardLoading} installedAppId={appDetails?.installedAppId} />
205+
{isScanV2Enabled && <SecurityVulnerabilityCard cardLoading={cardLoading} installedAppId={appDetails?.installedAppId} />}
204206
</div>
205207
)}
206208
{showAppStatusDetail && (

yarn.lock

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,13 +1346,14 @@
13461346
dependencies:
13471347
"@jridgewell/trace-mapping" "0.3.9"
13481348

1349-
"@devtron-labs/[email protected].14":
1350-
version "0.3.14"
1351-
resolved "https://registry.yarnpkg.com/@devtron-labs/devtron-fe-common-lib/-/devtron-fe-common-lib-0.3.14.tgz#cc9458ea1bd358788be920692ff956c08d8a5cbc"
1352-
integrity sha512-xvDze0tg84sufjbeeF4Ke7FRObgEyxW2et1IUrW3zeYFDDql7xBB4vYU8wGZCQdjBXCZEtorBKxd7WvFiFgOjg==
1349+
"@devtron-labs/[email protected].15":
1350+
version "0.3.15"
1351+
resolved "https://registry.yarnpkg.com/@devtron-labs/devtron-fe-common-lib/-/devtron-fe-common-lib-0.3.15.tgz#280161b85463779fb94ec59a0445144b0ad5b851"
1352+
integrity sha512-PFZOVwZ/yW4UAXki5qS3za2YRLjRczCzw3n/cFE15jGRMX6+1jO7xBAPK7Vm/TyZjPFIsXOXvUcSX3tSOKOyDA==
13531353
dependencies:
13541354
"@types/react-dates" "^21.8.6"
13551355
ansi_up "^5.2.1"
1356+
dayjs "^1.11.12"
13561357
fast-json-patch "^3.1.1"
13571358
jsonpath-plus "^9.0.0"
13581359
react-dates "^21.8.0"
@@ -4354,6 +4355,11 @@ data-view-byte-offset@^1.0.0:
43544355
es-errors "^1.3.0"
43554356
is-data-view "^1.0.1"
43564357

4358+
dayjs@^1.11.12:
4359+
version "1.11.13"
4360+
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.13.tgz#92430b0139055c3ebb60150aa13e860a4b5a366c"
4361+
integrity sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==
4362+
43574363
dayjs@^1.11.8:
43584364
version "1.11.11"
43594365
resolved "https://registry.npmjs.org/dayjs/-/dayjs-1.11.11.tgz"

0 commit comments

Comments
 (0)