Skip to content

Commit ce3f516

Browse files
Merge pull request #6294 from devtron-labs/aws-inspector-prakash-oss
misc: Aws inspector prakash oss
2 parents 1daf2c4 + f9953c1 commit ce3f516

35 files changed

+769
-123
lines changed

cmd/external-app/wire.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ import (
8080
"github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs"
8181
repository2 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository"
8282
"github.com/devtron-labs/devtron/pkg/pipeline"
83-
"github.com/devtron-labs/devtron/pkg/policyGovernance/security/imageScanning"
84-
security2 "github.com/devtron-labs/devtron/pkg/policyGovernance/security/imageScanning/repository"
83+
"github.com/devtron-labs/devtron/pkg/policyGovernance/security/scanTool"
84+
security2 "github.com/devtron-labs/devtron/pkg/policyGovernance/security/scanTool/repository"
8585
"github.com/devtron-labs/devtron/pkg/sql"
8686
util2 "github.com/devtron-labs/devtron/pkg/util"
8787
util3 "github.com/devtron-labs/devtron/util"
@@ -130,6 +130,7 @@ func InitializeApp() (*App, error) {
130130
telemetry.NewPosthogClient,
131131
delete2.NewDeleteServiceImpl,
132132
gitMaterial.GitMaterialWireSet,
133+
scanTool.ScanToolWireSet,
133134

134135
sql.NewTransactionUtilImpl,
135136

@@ -221,9 +222,6 @@ func InitializeApp() (*App, error) {
221222
kubernetesResourceAuditLogs.Newk8sResourceHistoryServiceImpl,
222223
wire.Bind(new(kubernetesResourceAuditLogs.K8sResourceHistoryService), new(*kubernetesResourceAuditLogs.K8sResourceHistoryServiceImpl)),
223224

224-
imageScanning.NewScanToolMetadataServiceImpl,
225-
wire.Bind(new(imageScanning.ScanToolMetadataService), new(*imageScanning.ScanToolMetadataServiceImpl)),
226-
227225
security2.NewScanToolMetadataRepositoryImpl,
228226
wire.Bind(new(security2.ScanToolMetadataRepository), new(*security2.ScanToolMetadataRepositoryImpl)),
229227

cmd/external-app/wire_gen.go

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

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ require gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
288288

289289
replace (
290290
github.com/argoproj/argo-workflows/v3 v3.5.10 => github.com/devtron-labs/argo-workflows/v3 v3.5.13
291-
github.com/devtron-labs/authenticator => github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250117064214-73c2e66ce2d7
292-
github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250122110043-4d939279c70a
291+
github.com/devtron-labs/authenticator => github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250124111030-ae27cdeb9349
292+
github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250124111030-ae27cdeb9349
293293
github.com/go-check/check => github.com/go-check/check v0.0.0-20180628173108-788fd7840127
294294
github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.5.5
295295
k8s.io/api => k8s.io/api v0.29.7

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -792,10 +792,10 @@ github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc h1:VRRKCwnzq
792792
github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
793793
github.com/devtron-labs/argo-workflows/v3 v3.5.13 h1:3pINq0gXOSeTw2z/vYe+j80lRpSN5Rp/8mfQORh8SmU=
794794
github.com/devtron-labs/argo-workflows/v3 v3.5.13/go.mod h1:/vqxcovDPT4zqr4DjR5v7CF8ggpY1l3TSa2CIG3jmjA=
795-
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250117064214-73c2e66ce2d7 h1:Z29616pM3W6fcDvFsiX6JTWz2lYvdZdqzIRBfBwnK1U=
796-
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250117064214-73c2e66ce2d7/go.mod h1:5lv4Wfj5ERhhvDGXe2IeES6qxjvUVCcohaRwKnWBMNo=
797-
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250122110043-4d939279c70a h1:kDemKb2wGKXaRjRqWuu7FIGcfeacoW0kH9yzpSDTWN8=
798-
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250122110043-4d939279c70a/go.mod h1:1QJJLpgJSkb5Jm9xPeKAk+kXb0QgBOOOgJj0cgYhAVA=
795+
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250124111030-ae27cdeb9349 h1:AlIhzAP8dd6FRHFV+SaYFBaPN4cbglP7C1yPR7fWgMI=
796+
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250124111030-ae27cdeb9349/go.mod h1:5lv4Wfj5ERhhvDGXe2IeES6qxjvUVCcohaRwKnWBMNo=
797+
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250124111030-ae27cdeb9349 h1:J8rZroVKZJrVB7uN9QQKCkol7OWp4DKv8RQQdUbWee8=
798+
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250124111030-ae27cdeb9349/go.mod h1:1QJJLpgJSkb5Jm9xPeKAk+kXb0QgBOOOgJj0cgYhAVA=
799799
github.com/devtron-labs/go-bitbucket v0.9.60-beta h1:VEx1jvDgdtDPS6A1uUFoaEi0l1/oLhbr+90xOwr6sDU=
800800
github.com/devtron-labs/go-bitbucket v0.9.60-beta/go.mod h1:GnuiCesvh8xyHeMCb+twm8lBR/kQzJYSKL28ZfObp1Y=
801801
github.com/devtron-labs/protos v0.0.3-0.20240802105333-92ee9bb85d80 h1:xwbTeijNTf4/j1v+tSfwVqwLVnReas/NqEKeQHvSTys=

pkg/module/ModuleService.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
clientErrors "github.com/devtron-labs/devtron/pkg/errors"
2626
moduleRepo "github.com/devtron-labs/devtron/pkg/module/repo"
2727
moduleUtil "github.com/devtron-labs/devtron/pkg/module/util"
28-
"github.com/devtron-labs/devtron/pkg/policyGovernance/security/imageScanning"
28+
"github.com/devtron-labs/devtron/pkg/policyGovernance/security/scanTool"
2929
"github.com/devtron-labs/devtron/pkg/server"
3030
serverBean "github.com/devtron-labs/devtron/pkg/server/bean"
3131
serverEnvConfig "github.com/devtron-labs/devtron/pkg/server/config"
@@ -61,13 +61,13 @@ type ModuleServiceImpl struct {
6161
moduleCronService ModuleCronService
6262
moduleServiceHelper ModuleServiceHelper
6363
moduleResourceStatusRepository moduleRepo.ModuleResourceStatusRepository
64-
scanToolMetadataService imageScanning.ScanToolMetadataService
64+
scanToolMetadataService scanTool.ScanToolMetadataService
6565
}
6666

6767
func NewModuleServiceImpl(logger *zap.SugaredLogger, serverEnvConfig *serverEnvConfig.ServerEnvConfig, moduleRepository moduleRepo.ModuleRepository,
6868
moduleActionAuditLogRepository ModuleActionAuditLogRepository, helmAppService client.HelmAppService, serverDataStore *serverDataStore.ServerDataStore, serverCacheService server.ServerCacheService, moduleCacheService ModuleCacheService, moduleCronService ModuleCronService,
6969
moduleServiceHelper ModuleServiceHelper, moduleResourceStatusRepository moduleRepo.ModuleResourceStatusRepository,
70-
scanToolMetadataService imageScanning.ScanToolMetadataService) *ModuleServiceImpl {
70+
scanToolMetadataService scanTool.ScanToolMetadataService) *ModuleServiceImpl {
7171
return &ModuleServiceImpl{
7272
logger: logger,
7373
serverEnvConfig: serverEnvConfig,

pkg/pipeline/CiService.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -824,14 +824,32 @@ func (impl *CiServiceImpl) buildWfRequestForCiPipeline(pipeline *pipelineConfig.
824824
ImageScanRetryDelay: impl.config.ImageScanRetryDelay,
825825
UseDockerApiToGetDigest: impl.config.UseDockerApiToGetDigest,
826826
}
827-
if pipeline.App.AppType == helper.Job {
828-
workflowRequest.AppName = pipeline.App.DisplayName
829-
}
827+
workflowRequest.SetAwsInspectorConfig("")
830828
//in oss, there is no pipeline level workflow cache config, so we pass inherit to get the app level config
831829
workflowCacheConfig := impl.ciCdPipelineOrchestrator.GetWorkflowCacheConfig(pipeline.App.AppType, trigger.PipelineType, common.WorkflowCacheConfigInherit)
832830
workflowRequest.IgnoreDockerCachePush = !workflowCacheConfig.Value
833831
workflowRequest.IgnoreDockerCachePull = !workflowCacheConfig.Value
834832
impl.Logger.Debugw("Ignore Cache values", "IgnoreDockerCachePush", workflowRequest.IgnoreDockerCachePush, "IgnoreDockerCachePull", workflowRequest.IgnoreDockerCachePull)
833+
if pipeline.App.AppType == helper.Job {
834+
workflowRequest.AppName = pipeline.App.DisplayName
835+
}
836+
if pipeline.ScanEnabled {
837+
scanToolMetadata, scanVia, err := impl.fetchImageScanExecutionMedium()
838+
if err != nil {
839+
impl.Logger.Errorw("error occurred getting scanned via", "err", err)
840+
return nil, err
841+
}
842+
workflowRequest.SetExecuteImageScanningVia(scanVia)
843+
if scanVia.IsScanMediumExternal() {
844+
imageScanExecutionSteps, refPlugins, err := impl.fetchImageScanExecutionStepsForWfRequest(scanToolMetadata)
845+
if err != nil {
846+
impl.Logger.Errorw("error occurred, fetchImageScanExecutionStepsForWfRequest", "scanToolMetadata", scanToolMetadata, "err", err)
847+
return nil, err
848+
}
849+
workflowRequest.SetImageScanningSteps(imageScanExecutionSteps)
850+
workflowRequest.RefPlugins = append(workflowRequest.RefPlugins, refPlugins...)
851+
}
852+
}
835853

836854
if dockerRegistry != nil {
837855
workflowRequest.DockerRegistryId = dockerRegistry.Id

pkg/pipeline/CiService_ent.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package pipeline
2+
3+
import (
4+
"github.com/devtron-labs/common-lib/imageScan/bean"
5+
bean2 "github.com/devtron-labs/devtron/pkg/pipeline/bean"
6+
"github.com/devtron-labs/devtron/pkg/pipeline/types"
7+
"github.com/devtron-labs/devtron/pkg/policyGovernance/security/scanTool/repository"
8+
)
9+
10+
func (impl *CiServiceImpl) fetchImageScanExecutionMedium() (*repository.ScanToolMetadata, bean.ScanExecutionMedium, error) {
11+
return &repository.ScanToolMetadata{}, "", nil
12+
}
13+
14+
func (impl *CiServiceImpl) fetchImageScanExecutionStepsForWfRequest(scanToolMetadata *repository.ScanToolMetadata) ([]*types.ImageScanningSteps, []*bean2.RefPluginObject, error) {
15+
return nil, nil, nil
16+
}

pkg/pipeline/types/Workflow_ent.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package types
2+
3+
import (
4+
bean2 "github.com/devtron-labs/common-lib/imageScan/bean"
5+
"github.com/devtron-labs/devtron/pkg/pipeline/bean"
6+
)
7+
8+
type ImageScanningSteps struct {
9+
Steps []*bean.StepObject `json:"steps"`
10+
ScanToolId int `json:"scanToolId"`
11+
}
12+
13+
func NewImageScanningStepsDto() *ImageScanningSteps {
14+
return &ImageScanningSteps{}
15+
}
16+
17+
func (r *ImageScanningSteps) WithSteps(steps []*bean.StepObject) *ImageScanningSteps {
18+
return r
19+
}
20+
21+
func (r *ImageScanningSteps) WithScanToolId(scanToolId int) *ImageScanningSteps {
22+
return r
23+
}
24+
25+
func (workflowRequest *WorkflowRequest) SetExecuteImageScanningVia(scanVia bean2.ScanExecutionMedium) {
26+
return
27+
}
28+
29+
func (workflowRequest *WorkflowRequest) SetImageScanningSteps(imageScanningSteps []*ImageScanningSteps) {
30+
return
31+
}
32+
33+
func (workflowRequest *WorkflowRequest) SetAwsInspectorConfig(awsInspectorConfig string) {
34+
return
35+
}

pkg/plugin/GlobalPluginService.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ type GlobalPluginService interface {
7474
PatchPlugin(pluginDto *bean2.PluginMetadataDto, userId int32) (*bean2.PluginMetadataDto, error)
7575
GetDetailedPluginInfoByPluginId(pluginId int) (*bean2.PluginMetadataDto, error)
7676
GetAllDetailedPluginInfo() ([]*bean2.PluginMetadataDto, error)
77+
GetNewPluginStepsDtoByRefPluginIdentifier(identifier string) (*bean2.PluginStepsDto, error)
7778

7879
CreatePluginOrVersions(pluginDto *bean2.PluginParentMetadataDto, userId int32) (int, error)
7980
ListAllPluginsV2(filter *bean2.PluginsListFilter) (*bean2.PluginsDto, error)
@@ -2134,7 +2135,7 @@ func (impl *GlobalPluginServiceImpl) createNewPlugin(tx *pg.Tx, pluginDto *bean2
21342135

21352136
pluginStageMapping := &repository.PluginStageMapping{
21362137
PluginId: pluginParentMetadata.Id,
2137-
StageType: repository.CI_CD,
2138+
StageType: pluginDto.GetPluginStageType(),
21382139
AuditLog: sql.NewDefaultAuditLog(userId),
21392140
}
21402141
_, err = impl.globalPluginRepository.SavePluginStageMapping(pluginStageMapping, tx)
@@ -2329,3 +2330,13 @@ func validatePluginVariable(variable *bean2.PluginVariableDto) error {
23292330
}
23302331
return nil
23312332
}
2333+
2334+
func (impl *GlobalPluginServiceImpl) GetNewPluginStepsDtoByRefPluginIdentifier(identifier string) (*bean2.PluginStepsDto, error) {
2335+
pluginMetadata, err := impl.globalPluginRepository.GetPluginMetadataByPluginIdentifier(identifier)
2336+
if err != nil {
2337+
impl.logger.Errorw("error in getting plugin steps by plugin identifier", "identifier", identifier, "err", err)
2338+
return nil, err
2339+
}
2340+
pluginStepDto := adaptor.GetNewPluginStepDtoFromRefPluginMetadata(pluginMetadata)
2341+
return pluginStepDto, nil
2342+
}

0 commit comments

Comments
 (0)