From fb20c42b215f0ff34de32e4a6e5f519eff4f6b9f Mon Sep 17 00:00:00 2001 From: Ashish-devtron Date: Thu, 5 Oct 2023 17:24:58 +0530 Subject: [PATCH 1/3] image scanning plugin --- src/components/CIPipelineN/CIPipeline.tsx | 2 + .../CIPipelineN/PluginCardListContainer.tsx | 51 ++++++++++--------- src/components/CIPipelineN/PreBuild.tsx | 4 +- src/components/ciPipeline/types.ts | 1 + 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/src/components/CIPipelineN/CIPipeline.tsx b/src/components/CIPipelineN/CIPipeline.tsx index f9c3cf5687..02c57ca5d8 100644 --- a/src/components/CIPipelineN/CIPipeline.tsx +++ b/src/components/CIPipelineN/CIPipeline.tsx @@ -773,6 +773,7 @@ export default function CIPipeline({ sharedPlugins={sharedPlugins} isJobView={isJobCard} mandatoryPluginsMap={mandatoryPluginsMap} + isSecurityModuleInstalled={isSecurityModuleInstalled} /> )} @@ -782,6 +783,7 @@ export default function CIPipeline({ presetPlugins={presetPlugins} sharedPlugins={sharedPlugins} mandatoryPluginsMap={mandatoryPluginsMap} + isSecurityModuleInstalled={isSecurityModuleInstalled} /> )} diff --git a/src/components/CIPipelineN/PluginCardListContainer.tsx b/src/components/CIPipelineN/PluginCardListContainer.tsx index da74462e21..5f0d93649c 100644 --- a/src/components/CIPipelineN/PluginCardListContainer.tsx +++ b/src/components/CIPipelineN/PluginCardListContainer.tsx @@ -6,6 +6,7 @@ export function PluginCardListContainer({ pluginListTitle, pluginList, setPluginType, + isSecurityModuleInstalled }: { pluginListTitle: string pluginList: PluginDetailType[] @@ -17,6 +18,7 @@ export function PluginCardListContainer({ inputVariables: VariableType[], outputVariables: VariableType[], ) => void + isSecurityModuleInstalled: boolean }) { return ( pluginList.length > 0 && ( @@ -24,29 +26,32 @@ export function PluginCardListContainer({
{pluginListTitle}
- {pluginList.map((pluginDetails) => ( -
- setPluginType( - PluginType.PLUGIN_REF, - pluginDetails.id, - pluginDetails.name, - pluginDetails.description, - pluginDetails.inputVariables ?? [], - pluginDetails.outputVariables ?? [], - ) - } - > - -
- ))} + {pluginList.map( + (pluginDetails) => + (pluginDetails.name !== 'Image Scanning' || isSecurityModuleInstalled) && ( +
+ setPluginType( + PluginType.PLUGIN_REF, + pluginDetails.id, + pluginDetails.name, + pluginDetails.description, + pluginDetails.inputVariables ?? [], + pluginDetails.outputVariables ?? [], + ) + } + > + +
+ ), + )} ) ) diff --git a/src/components/CIPipelineN/PreBuild.tsx b/src/components/CIPipelineN/PreBuild.tsx index 26b762a996..e0be89251f 100644 --- a/src/components/CIPipelineN/PreBuild.tsx +++ b/src/components/CIPipelineN/PreBuild.tsx @@ -25,7 +25,7 @@ import { importComponentFromFELibrary } from '../common' import { pipelineContext } from '../workflowEditor/workflowEditor' const isRequired = importComponentFromFELibrary('isRequired', null, 'function') -export function PreBuild({ presetPlugins, sharedPlugins, mandatoryPluginsMap, isJobView }: PreBuildType) { +export function PreBuild({ presetPlugins, sharedPlugins, mandatoryPluginsMap, isJobView, isSecurityModuleInstalled}: PreBuildType) { const { formData, isCdPipeline, @@ -151,11 +151,13 @@ export function PreBuild({ presetPlugins, sharedPlugins, mandatoryPluginsMap, is setPluginType={setPluginType} pluginListTitle="PRESET PLUGINS" pluginList={presetPlugins} + isSecurityModuleInstalled={isSecurityModuleInstalled} /> ) diff --git a/src/components/ciPipeline/types.ts b/src/components/ciPipeline/types.ts index 57c869b2b8..42ab454a04 100644 --- a/src/components/ciPipeline/types.ts +++ b/src/components/ciPipeline/types.ts @@ -395,6 +395,7 @@ export interface PreBuildType { sharedPlugins: PluginDetailType[] mandatoryPluginsMap?: Record isJobView?: boolean + isSecurityModuleInstalled?: boolean } export enum CIPipelineBuildType { From 81df981ffc45e23e88d3eef1be255a100f59eefa Mon Sep 17 00:00:00 2001 From: Ashish-devtron Date: Thu, 5 Oct 2023 18:02:44 +0530 Subject: [PATCH 2/3] check module installed for cd --- src/components/cdPipeline/NewCDPipeline.tsx | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/components/cdPipeline/NewCDPipeline.tsx b/src/components/cdPipeline/NewCDPipeline.tsx index d8b1dec405..3ccf15e805 100644 --- a/src/components/cdPipeline/NewCDPipeline.tsx +++ b/src/components/cdPipeline/NewCDPipeline.tsx @@ -16,7 +16,7 @@ import { import React, { useEffect, useMemo, useRef, useState } from 'react' import { ReactComponent as Close } from '../../assets/icons/ic-close.svg' import { NavLink, Redirect, Route, Switch, useParams, useRouteMatch } from 'react-router-dom' -import { CDDeploymentTabText, DELETE_ACTION, SourceTypeMap, TriggerType, ViewType } from '../../config' +import { CDDeploymentTabText, DELETE_ACTION, ModuleNameMap, SourceTypeMap, TriggerType, ViewType } from '../../config' import { ButtonWithLoader, FloatingVariablesSuggestions, sortObjectArrayAlphabetically } from '../common' import BuildCD from './BuildCD' import { CD_PATCH_ACTION, Environment, GeneratedHelmPush } from './cdPipeline.types' @@ -52,6 +52,8 @@ import { calculateLastStepDetailsLogic, checkUniqueness, validateTask } from './ import { pipelineContext } from '../workflowEditor/workflowEditor' import { PipelineFormDataErrorType, PipelineFormType } from '../workflowEditor/types' import { getDockerRegistryMinAuth } from '../ciConfig/service' +import { getModuleInfo } from '../v2/devtronStackManager/DevtronStackManager.service' +import { ModuleStatus } from '../v2/devtronStackManager/DevtronStackManager.type' export enum deleteDialogType { showForceDeleteDialog = 'showForceDeleteDialog', @@ -176,6 +178,8 @@ export default function NewCDPipeline({ preBuildStage: Map[] postBuildStage: Map[] }>({ preBuildStage: [], postBuildStage: [] }) + const [isSecurityModuleInstalled, setSecurityModuleInstalled] = useState(false) + useEffect(() => { getInit() @@ -195,6 +199,7 @@ export default function NewCDPipeline({ } const getInit = () => { + getSecurityModuleStatus() Promise.all([ getDeploymentStrategyList(appId), getGlobalVariable(Number(appId), true), @@ -276,6 +281,15 @@ export default function NewCDPipeline({ }) } + const getSecurityModuleStatus = async (): Promise => { + try { + const { result } = await getModuleInfo(ModuleNameMap.SECURITY) + if (result?.status === ModuleStatus.INSTALLED) { + setSecurityModuleInstalled(true) + } + } catch (error) {} + } + const calculateLastStepDetail = ( isFromAddNewTask: boolean, _formData: PipelineFormType, @@ -1028,12 +1042,12 @@ export default function NewCDPipeline({ {isAdvanced && ( - + )} {isAdvanced && ( - + )} From d202d165e30df2f69fd7b0ac5191e772e722fb61 Mon Sep 17 00:00:00 2001 From: Ashish-devtron Date: Thu, 5 Oct 2023 18:12:39 +0530 Subject: [PATCH 3/3] change name --- src/components/CIPipelineN/PluginCardListContainer.tsx | 3 ++- src/components/CIPipelineN/ciPipeline.utils.ts | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/CIPipelineN/PluginCardListContainer.tsx b/src/components/CIPipelineN/PluginCardListContainer.tsx index 5f0d93649c..9177c2601e 100644 --- a/src/components/CIPipelineN/PluginCardListContainer.tsx +++ b/src/components/CIPipelineN/PluginCardListContainer.tsx @@ -1,6 +1,7 @@ import React from 'react' import { PluginType, PluginDetailType, VariableType } from '@devtron-labs/devtron-fe-common-lib' import { PluginCard } from './PluginCard' +import { VulnerabilityScanning } from './ciPipeline.utils' export function PluginCardListContainer({ pluginListTitle, @@ -28,7 +29,7 @@ export function PluginCardListContainer({ {pluginList.map( (pluginDetails) => - (pluginDetails.name !== 'Image Scanning' || isSecurityModuleInstalled) && ( + (pluginDetails.name !== VulnerabilityScanning || isSecurityModuleInstalled) && (
diff --git a/src/components/CIPipelineN/ciPipeline.utils.ts b/src/components/CIPipelineN/ciPipeline.utils.ts index b35f0bd8a9..63706ab1ba 100644 --- a/src/components/CIPipelineN/ciPipeline.utils.ts +++ b/src/components/CIPipelineN/ciPipeline.utils.ts @@ -261,3 +261,5 @@ export const reactSelectStyles = { } }, } + +export const VulnerabilityScanning = 'Vulnerability Scanning' \ No newline at end of file