Skip to content

Commit

Permalink
Merge pull request #2322 from devtron-labs/fix/integrate-scans
Browse files Browse the repository at this point in the history
fix: integrate scans
  • Loading branch information
arunjaindev authored Dec 30, 2024
2 parents 7cea9ea + 2b72f6d commit 7c33b24
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 153 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"homepage": "/dashboard",
"dependencies": {
"@devtron-labs/devtron-fe-common-lib": "1.3.9-beta-2",
"@devtron-labs/devtron-fe-common-lib": "1.3.9-beta-5",
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
"@rjsf/core": "^5.13.3",
"@rjsf/utils": "^5.13.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ export const SecurityVulnerabilityCard = ({
return <LoadingCard />
}

if (scanResultResponse && !scanResultResponse.result.scanned) {
// Here for devtron app scanned, isImageScanEnabled both should be true and imageScan shouldn't be null
// where as for helm app we only check scanned true since helm app can be scanned without imageScan
if (
scanResultResponse &&
(!scanResultResponse.result.scanned ||
(appId ? !scanResultResponse.result.isImageScanEnabled || !scanResultResponse.result.imageScan : true))
) {
return null
}

Expand Down
14 changes: 8 additions & 6 deletions src/components/app/details/cIDetails/CIDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import {
} from '../../service'
import { URLS, Routes } from '../../../../config'
import { BuildDetails, CIPipeline, HistoryLogsType, SecurityTabType } from './types'
import { ScanDisabledView, ImageNotScannedView, CIRunningView } from './cIDetails.util'
import { ImageNotScannedView, CIRunningView } from './cIDetails.util'
import './ciDetails.scss'
import { getModuleInfo } from '../../../v2/devtronStackManager/DevtronStackManager.service'
import { ModuleStatus } from '../../../v2/devtronStackManager/DevtronStackManager.type'
Expand Down Expand Up @@ -671,7 +671,7 @@ const SecurityTab = ({ ciPipelineId, artifactId, status, appIdFromParent }: Secu
const computedAppId = appId ?? appIdFromParent

const { scanResultLoading, scanResultResponse, scanResultError, reloadScanResult } = useGetAppSecurityDetails({
appId: +appId,
appId: +computedAppId,
artifactId,
})

Expand Down Expand Up @@ -705,10 +705,12 @@ const SecurityTab = ({ ciPipelineId, artifactId, status, appIdFromParent }: Secu
if (scanResultError) {
return <ErrorScreenManager code={scanResultError.code} reload={reloadScanResult} />
}
if (scanResultResponse && !scanResultResponse.result.scanned) {
if (!scanResultResponse.result.isImageScanEnabled) {
return <ScanDisabledView redirectToCreate={redirectToCreate} />
}
if (
scanResultResponse &&
(!scanResultResponse.result.scanned ||
!scanResultResponse.result.isImageScanEnabled ||
!scanResultResponse.result.imageScan)
) {
return <ImageNotScannedView />
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/app/details/triggerView/cdMaterial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ const CDMaterial = ({
getPolicyConsequences ? getPolicyConsequences({ appId, envId }) : null,
])

if (getIsTriggerBlocked(response[2].cd)) {
if (getPolicyConsequences && getIsTriggerBlocked(response[2].cd)) {
return [null, null, response[2]]
}
return response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { useRouteMatch, useHistory, useParams } from 'react-router-dom'
import NotesDrawer from './NotesDrawer'
import { getInstalledChartNotesDetail } from '../../appDetails.api'
import { importComponentFromFELibrary } from '../../../../common'
import { DeploymentAppTypes, useAsync, useMainContext } from '@devtron-labs/devtron-fe-common-lib'
import { DeploymentAppTypes, useAsync } from '@devtron-labs/devtron-fe-common-lib'
import { EnvironmentStatusComponentType } from '../environment.type'
import HelmAppConfigApplyStatusCard from './HelmAppConfigApplyStatusCard'
import AppStatusCard from '../../../../app/details/appDetails/AppStatusCard'
Expand All @@ -39,6 +39,7 @@ import IssuesListingModal from '../../../../app/details/appDetails/IssuesListing
import SecurityVulnerabilityCard from '../../../../app/details/appDetails/SecurityVulnerabilityCard'

const AppDetailsDownloadCard = importComponentFromFELibrary('AppDetailsDownloadCard')
const isFELibAvailable = importComponentFromFELibrary('isFELibAvailable', false, 'function')

const EnvironmentStatusComponent = ({
loadingDetails,
Expand All @@ -47,7 +48,6 @@ const EnvironmentStatusComponent = ({
isVirtualEnvironment,
refetchDeploymentStatus,
}: EnvironmentStatusComponentType) => {
const { isManifestScanningEnabled } = useMainContext()
const [appDetails] = useSharedState(IndexStore.getAppDetails(), IndexStore.getAppDetailsObservable())
const [showAppStatusDetail, setShowAppStatusDetail] = useState(false)
const [showNotes, setShowNotes] = useState(false)
Expand Down Expand Up @@ -183,7 +183,7 @@ const EnvironmentStatusComponent = ({
{renderHelmConfigApplyStatusBlock()}
{renderLastUpdatedBlock()}
{renderChartUsedBlock()}
{isManifestScanningEnabled && appDetails?.appType === AppType.DEVTRON_HELM_CHART && (
{isFELibAvailable && appDetails?.appType === AppType.DEVTRON_HELM_CHART && (
<SecurityVulnerabilityCard
cardLoading={cardLoading}
installedAppId={appDetails?.installedAppId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
ShowMoreText,
DEPLOYMENT_STATUS,
EMPTY_STATE_STATUS,
useMainContext,
} from '@devtron-labs/devtron-fe-common-lib'
import moment from 'moment'
import Tippy from '@tippyjs/react'
Expand Down Expand Up @@ -110,14 +109,12 @@ const ChartDeploymentHistory = ({
let initTimer = null
// Checking if deployment app type is argocd only then show steps tab

const { isManifestScanningEnabled } = useMainContext()

const deploymentTabs = () => {
const tabs = [
DEPLOYMENT_HISTORY_TAB.SOURCE,
DEPLOYMENT_HISTORY_TAB.VALUES_YAML,
DEPLOYMENT_HISTORY_TAB.HELM_GENERATED_MANIFEST,
(ChartSecurityTab && isManifestScanningEnabled && !isExternal && DEPLOYMENT_HISTORY_TAB.SECURITY),
(ChartSecurityTab && !isExternal && DEPLOYMENT_HISTORY_TAB.SECURITY),
]
if (installedAppInfo?.deploymentType === DeploymentAppTypes.GITOPS) {
tabs.unshift(DEPLOYMENT_HISTORY_TAB.STEPS)
Expand Down Expand Up @@ -596,7 +593,7 @@ const ChartDeploymentHistory = ({
status={deployment.status}
/>
)}
{selectedDeploymentTabName === DEPLOYMENT_HISTORY_TAB.SECURITY && !isExternal && isManifestScanningEnabled && ChartSecurityTab && (
{selectedDeploymentTabName === DEPLOYMENT_HISTORY_TAB.SECURITY && !isExternal && ChartSecurityTab && (
<ChartSecurityTab installedAppVersionHistoryId={deploymentHistoryArr[selectedDeploymentHistoryIndex].version} />
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { DeploymentAppTypes, useMainContext } from '@devtron-labs/devtron-fe-common-lib'
import { DeploymentAppTypes } from '@devtron-labs/devtron-fe-common-lib'
import { ChartValuesType, ChartVersionType } from '../../../charts/charts.types'
import { ChartValuesViewAction, ChartValuesViewActionTypes, ChartValuesViewState } from './ChartValuesView.type'

Expand All @@ -25,8 +25,6 @@ export const initState = (
chartVersionsDataFromParent: ChartVersionType[],
deploymentAppType: DeploymentAppTypes,
): ChartValuesViewState => {
const { isManifestScanningEnabled } = useMainContext()

return {
isLoading: true,
isLodingGUIForm: false,
Expand Down Expand Up @@ -89,9 +87,7 @@ export const initState = (
chartVersionId: selectedVersionFromParent,
chartValuesId: chartValuesFromParent?.id,
},
isManifestScanEnabled: isManifestScanningEnabled
? installedConfigFromParent?.isManifestScanEnabled ?? false
: false,
isManifestScanEnabled: installedConfigFromParent?.isManifestScanEnabled ?? false,
}
}

Expand Down
17 changes: 7 additions & 10 deletions src/components/v2/values/chartValuesDiff/ChartValuesView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const ChartValuesView = ({
presetValueId: string
envId: string
}>()
const { serverMode, isManifestScanningEnabled } = useMainContext()
const { serverMode } = useMainContext()
const { handleDownload } = useDownload()
const chartValuesAbortRef = useRef<AbortController>(new AbortController())
const [chartValuesList, setChartValuesList] = useState<ChartValuesType[]>(chartValuesListFromParent || [])
Expand Down Expand Up @@ -1786,15 +1786,12 @@ const ChartValuesView = ({
/>
)}
</div>
{isManifestScanningEnabled &&
!isExternalApp &&
(isDeployChartView || isUpdateAppView) &&
ToggleSecurityScan && (
<ToggleSecurityScan
isManifestScanEnabled={commonState.isManifestScanEnabled}
handleToggleSecurityScan={handleToggleSecurityScan}
/>
)}
{!isExternalApp && (isDeployChartView || isUpdateAppView) && ToggleSecurityScan && (
<ToggleSecurityScan
isManifestScanEnabled={commonState.isManifestScanEnabled}
handleToggleSecurityScan={handleToggleSecurityScan}
/>
)}
{!isDeployChartView &&
chartValueId !== '0' &&
!(
Expand Down
Loading

0 comments on commit 7c33b24

Please sign in to comment.