Skip to content

Commit b3f4f78

Browse files
adi6859iamayushmvikramdevtronShivam-nagar23
authored
fix: Vulnerability scanning on hibernate/unhibernate api's (#5164)
* wip * check added * renaming --------- Co-authored-by: ayushmaheshwari <ayush@devtron.ai> Co-authored-by: Vikram Singh <vikram@devtron.ai> Co-authored-by: Shivam-nagar23 <shivam@devtron.ai>
1 parent 2e664d6 commit b3f4f78

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

pkg/deployment/trigger/devtronApps/TriggerService.go

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -426,19 +426,21 @@ func (impl *TriggerServiceImpl) ManualCdTrigger(triggerContext bean.TriggerConte
426426
impl.logger.Warnw("unable to migrate deprecated DataSource", "artifactId", artifact.Id)
427427
}
428428
}
429-
vulnerabilityCheckRequest := adapter.GetVulnerabilityCheckRequest(cdPipeline, artifact.ImageDigest)
430-
isVulnerable, err := impl.imageScanService.GetArtifactVulnerabilityStatus(ctx, vulnerabilityCheckRequest)
431-
if err != nil {
432-
impl.logger.Errorw("error in getting Artifact vulnerability status, ManualCdTrigger", "err", err)
433-
return 0, err
434-
}
429+
if isNotHibernateRequest(overrideRequest.DeploymentType) {
430+
vulnerabilityCheckRequest := adapter.GetVulnerabilityCheckRequest(cdPipeline, artifact.ImageDigest)
431+
isVulnerable, err := impl.imageScanService.GetArtifactVulnerabilityStatus(ctx, vulnerabilityCheckRequest)
432+
if err != nil {
433+
impl.logger.Errorw("error in getting Artifact vulnerability status, ManualCdTrigger", "err", err)
434+
return 0, err
435+
}
435436

436-
if isVulnerable == true {
437-
// if image vulnerable, update timeline status and return
438-
if err = impl.cdWorkflowCommonService.MarkCurrentDeploymentFailed(runner, errors.New(pipelineConfig.FOUND_VULNERABILITY), overrideRequest.UserId); err != nil {
439-
impl.logger.Errorw("error while updating current runner status to failed, TriggerDeployment", "wfrId", runner.Id, "err", err)
437+
if isVulnerable == true {
438+
// if image vulnerable, update timeline status and return
439+
if err = impl.cdWorkflowCommonService.MarkCurrentDeploymentFailed(runner, errors.New(pipelineConfig.FOUND_VULNERABILITY), overrideRequest.UserId); err != nil {
440+
impl.logger.Errorw("error while updating current runner status to failed, TriggerDeployment", "wfrId", runner.Id, "err", err)
441+
}
442+
return 0, fmt.Errorf("found vulnerability for image digest %s", artifact.ImageDigest)
440443
}
441-
return 0, fmt.Errorf("found vulnerability for image digest %s", artifact.ImageDigest)
442444
}
443445

444446
// Deploy the release
@@ -537,6 +539,13 @@ func (impl *TriggerServiceImpl) ManualCdTrigger(triggerContext bean.TriggerConte
537539
return releaseId, err
538540
}
539541

542+
func isNotHibernateRequest(deploymentType models.DeploymentType) bool {
543+
if deploymentType == models.DEPLOYMENTTYPE_STOP || deploymentType == models.DEPLOYMENTTYPE_START {
544+
return false
545+
}
546+
return true
547+
}
548+
540549
// TODO: write a wrapper to handle auto and manual trigger
541550
func (impl *TriggerServiceImpl) TriggerAutomaticDeployment(request bean.TriggerRequest) error {
542551
//in case of manual trigger auth is already applied and for auto triggers there is no need for auth check here

0 commit comments

Comments
 (0)