Enhance your CI/CD deployment by using Vulnerability Assessments from Microsoft Defender for ACR

Published Feb 01 2021 02:52 PM 6,103 Views

With the release of image scanning using Microsoft Defender for container registries, we received enormous interest in findings among wide audiences including traditional Microsoft Defender for Cloud admins along with repository owners and DevOps personnel.

 

One of the biggest challenges that was raised by these audiences was how to use the Defender for Container scanning capability in their integration and deployment processes to ensure only scanned and healthy images reach the production environments.

 

By embedding Microsoft Defender for container registries assessments into your CI/CD pipeline, you can address this need and have a more secure automation and deployment processes in enterprise environments.

 

This blog will take you through a few simple steps to take your CI/CD pipeline to the next security level.

How does Microsoft Defender’s container image scanning for vulnerabilities work?

When you enable Microsoft Defender for Cloud's optional Microsoft Defender for container registries advanced security plan, the images in your container registries are scanned for vulnerabilities.

There are multiple triggers for an image scan, such as On push, On import and Recently pulled.

Microsoft defender for container Registries pulls and scans the image in an isolated sandbox. It is then extracts, filters and classifies the findings, and presents them as actionable security recommendations.

Each finding Defender for container registries published for an image is represented as a Container Registry Vulnerability Sub Assessment.

 

 

defendercontainres.png

 

 

 

 

 

Extract scan summary using API:

Scan summaries are available in Microsoft Defender for Cloud dashboards. You can also access them programmatically (through our API or PowerShell) using

With the scan summary ARG query published in Microsoft Defender for Cloud container image scan community GitHub, you can fetch results for all images by simply running it via ARG REST API, PowerShell module or Explorer.

securityresources
| where type == 'microsoft.security/assessments/subassessments'
| where id matches regex '(.+?)/providers/Microsoft.Security/assessments/dbd0cb49-b563-45e7-9724-889e799fa648/'
| parse id with registryResourceId '/providers/Microsoft.Security/assessments/' *
| parse registryResourceId with * "/providers/Microsoft.ContainerRegistry/registries/" registryName
| extend imageDigest = tostring(properties.additionalData.imageDigest)
| extend repository = tostring(properties.additionalData.repositoryName)
| extend scanFindingSeverity = tostring(properties.status.severity), scanStatus = tostring(properties.status.code)
| summarize scanFindingSeverityCount = count() by scanFindingSeverity, scanStatus, registryResourceId, registryName, repository, imageDigest
| summarize severitySummary = make_bag(pack(scanFindingSeverity, scanFindingSeverityCount)) by registryResourceId, registryName, repository, imageDigest, scanStatus

You can also filter results to get summary for a specific image or registry by adding

it to the bottom of the query, for example:

| where imageDigest == '<ImageDigest>' and repository == '<ImageRepository>' 
and registryResourceId endswith '/<ImageRegistryName>'

 

 

Use scan summary as part of an image CI\CD pipeline:

In ASC container image scan GitHub community, you can also find the Image Scan Automation Enrichment Security Gate tool.

 

The security gate tool is used for enriching and acting upon image scan results as part of a CI\CD pipeline to follow a scan initiated by image push.

It is built by two parts:

 

  1. Scan automation gate PowerShell script:  
    An Azure CLI PowerShell script that fetches provided image scan result and assess them by configuration. 

    • Script run ends in one of the following modes:
      • Success: scan results for image extracted successfully with no significant findings, image is healthy.
      • Warning:  scan results with some low & medium findings, but not enough to pass security gate findings severity thresholds (configurable).
      •  Failure: scan result with high severity finding or  number of medium & low severity findings has passed threshold (configurable) or scan result not found after multiple retries (configurable).

    • Customize security gate script vulnerability thresholds: 
      Security gate vulnerability severity thresholds can be customized by PS script’s optional parameters: `$mediumFindingsCountFailThreshold` , `$lowFindingsCountFailThreshold`, by default they are set to 5 and 15 respectively (script optional parameters).
      In the case of a high severity vulnerability, security gate will always end up with a failure.

    • .\ImageScanSummaryAssessmentGate.ps1 -registryName tomerregistry -repository build -tag latest​
    • This PS script can be included in any of your automation pipelines as a standalone gate to enrich scan results for image.


  2. Azure DevOps pipeline template:
    An Azure DevOps pipeline that: 
    Builds image, Pushes it to Azure container registry, then Assesses scan results for image to decide whether to pass of fail pipeline.

    • By copying security gate PS script presented above to pipeline’s path, following image’s Build and Push Docker task, pipeline can now run a custom Azure CLI PowerShell task with the PS script copied.

    • Security Gate custom Task from Azure DevOps pipeline template:
          # Run Image scan gate - which extracts image scan results and assess whether 
          # to fail the pipeline based on severity threshold configuration.
          # Using the ImageScanSummaryAssessmentGate.ps1 script in same repo folder
        - job: ImageScanGate
          displayName: Image Scan security gate
          pool:
            vmImage: $(vmImageName)
          dependsOn: 
          - BuildAndPush
          - WaitForScanResults
          steps:
          # Read more here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-cli?view=azure-devops)
          - task: AzureCLI@2
            inputs:
              azureSubscription: '<Name of the Azure Resource Manager service connection>'
              scriptType: 'pscore'
              scriptLocation: 'scriptPath'
              # Security Gate powershell script in same folder
              scriptPath: '$(Build.SourcesDirectory)/ImageScanSummaryAssessmentGate.ps1'
              arguments: '-registryName $(containerRegistry) -repository $(imageRepository) -tag $(tag)'
      • Image scan gate task runs following a short delay task (configurable) from image push task to make image scan results are published in ARG.
      • Pipeline will complete successfully on image built, push, and security gate success result.

    • Customize pipeline scan results extraction timeouts:
      By default, pipeline waits 5 minutes following image push to run the scan gate task to make sure scan results are ready and published in ARG (can by customize in pipeline variable `$waitForScanResultsAfterPushInMinutes`).

 


Push only scanned and healthy images to your production registry:

You can use the security gate task above as a conditional task to push image to your production registry.

  1. Push image to your staging registry first (make sure it is also on-boarded to Microsoft Defender for Cloud).
  2. Set Azure DevOps scan gate task to run on image in stagging registry.
  3. Set security gate task result as a dependency for Pushing the image to your production registry.

 

 

 

 

You are welcome to join Microsoft Defender for Cloud container image scan community on GitHub.

Contribute, share and suggest useful tools to automate or improve work with the Microsoft Defender for Cloud image scan service and results.

 

Tomer Weinberger, Microsoft Defender for Cloud.

3 Comments
%3CLINGO-SUB%20id%3D%22lingo-sub-2110952%22%20slang%3D%22en-US%22%3ERe%3A%20Enhance%20your%20CI%2FCD%20deployment%20by%20using%20Vulnerability%20Assessments%20from%20Azure%20Defender%20for%20ACR%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2110952%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F561747%22%20target%3D%22_blank%22%3E%40tomer_weinberger%3C%2FA%3E%26nbsp%3Bfor%20sharing!%26nbsp%3B%3C%2FP%3E%0A%3CP%3EGreat%20to%20see%20MS%20providing%20tools%20and%20security%20capabilities%20in%20CI%2FCD%20(Shift-Left)%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2110806%22%20slang%3D%22en-US%22%3ERe%3A%20Enhance%20your%20CI%2FCD%20deployment%20by%20using%20Vulnerability%20Assessments%20from%20Azure%20Defender%20for%20ACR%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2110806%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F561747%22%20target%3D%22_blank%22%3E%40tomer_weinberger%3C%2FA%3E%26nbsp%3Bfor%20Sharing%20with%20the%20Community%208)%3C%2Fimg%3E%3C%2FP%3E%0A%3CP%3EAwesome%20Blogpost.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2321260%22%20slang%3D%22en-US%22%3ERe%3A%20Enhance%20your%20CI%2FCD%20deployment%20by%20using%20Vulnerability%20Assessments%20from%20Azure%20Defender%20for%20ACR%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2321260%22%20slang%3D%22en-US%22%3E%3CP%3EI've%20noticed%20the%20following%20on%20Microsoft%20docs%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CTABLE%3E%3CTBODY%3E%3CTR%3E%3CTD%3EUnsupported%20registries%20and%20images%3A%3C%2FTD%3E%3CTD%3EWindows%20images%3CBR%20%2F%3E'Private'%20registries%3CBR%20%2F%3ERegistries%20with%20access%20limited%20with%20a%20firewall%2C%20service%20endpoint%2C%20or%20private%20endpoints%20such%20as%20Azure%20Private%20Link%3CBR%20%2F%3ESuper-minimalist%20images%20such%20as%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fhub.docker.com%2F_%2Fscratch%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EDocker%20scratch%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eimages%2C%20or%20%22Distroless%22%20images%20that%20only%20contain%20an%20application%20and%20its%20runtime%20dependencies%20without%20a%20package%20manager%2C%20shell%2C%20or%20OS%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26amp%3B%20the%20following%20on%20Microsoft%20security%20baselines%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EGuidance%3C%2FSTRONG%3E%3A%20Azure%20Virtual%20Network%20provides%20secure%2C%20private%20networking%20for%20your%20Azure%20and%20on-premises%20resources.%20By%20limiting%20access%20to%20your%20private%20Azure%20container%20registry%20from%20an%20Azure%20virtual%20network%2C%20you%20ensure%20that%20only%20resources%20in%20the%20virtual%20network%20access%20the%20registry.%20For%20cross-premises%20scenarios%2C%20you%20can%20also%20configure%20firewall%20rules%20to%20allow%20registry%20access%20only%20from%20specific%20IP%20addresses.%20From%20behind%20a%20firewall%2C%20configure%20firewall%20access%20rules%20and%20service%20tags%20to%20access%20your%20container%20registry%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAre%20there%20any%20plans%20for%20Microsoft%20to%20support%20Azure%20Defender%20for%20container%20registries%20that%20do%20not%20have%20public%20access%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2102516%22%20slang%3D%22en-US%22%3EEnhance%20your%20CI%2FCD%20deployment%20by%20using%20Vulnerability%20Assessments%20from%20Microsoft%20Defender%20for%20ACR%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2102516%22%20slang%3D%22en-US%22%3E%3CP%3EWith%20the%20release%20of%20image%20scanning%20using%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fsecurity-center%2Fdefender-for-container-registries-introduction%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EMicrosoft%20Defender%20for%20container%20registries%3C%2FA%3E%2C%20we%20received%20enormous%20interest%20in%20findings%20among%20wide%20audiences%20including%20traditional%20Microsoft%20Defender%20for%20Cloud%20admins%20along%20with%20repository%20owners%20and%20DevOps%20personnel.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOne%20of%20the%20biggest%20challenges%20that%20was%20raised%20by%20these%20audiences%20was%20how%20to%20use%20the%20Defender%20for%20Container%20scanning%20capability%20in%20their%20integration%20and%20deployment%20processes%20to%20ensure%20only%20scanned%20and%20healthy%20images%20reach%20the%20production%20environments.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBy%20embedding%20Microsoft%20Defender%20for%20container%20registries%20assessments%20into%20your%20CI%2FCD%20pipeline%2C%20you%20can%20address%20this%20need%20and%20have%20a%20more%20secure%20automation%20and%20deployment%20processes%20in%20enterprise%20environments.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23333399%22%3E%3CSTRONG%3EThis%20blog%20will%20take%20you%20through%20a%20few%20simple%20steps%20to%20take%20your%20CI%2FCD%20pipeline%20to%20the%20next%20security%20level.%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1969117658%22%20id%3D%22toc-hId-1971052118%22%3E%3CSTRONG%3E%3CU%3EHow%20does%20Microsoft%20Defender%E2%80%99s%20container%20image%20scanning%20for%20vulnerabilities%20work%3F%3C%2FU%3E%3C%2FSTRONG%3E%3C%2FH3%3E%0A%3CP%3EWhen%20you%20enable%20Microsoft%20Defender%20for%20Cloud's%20optional%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fsecurity-center%2Fdefender-for-container-registries-introduction%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EMicrosoft%20Defender%20for%20container%20registries%3C%2FA%3E%20advanced%20security%20plan%2C%20the%20images%20in%20your%20container%20registries%20are%20scanned%20for%20vulnerabilities.%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsecurity-center%2Fdefender-for-container-registries-introduction%23when-are-images-scanned%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EThere%20are%20multiple%20triggers%20for%20an%20image%20scan%3C%2FA%3E%2C%20such%20as%20On%20push%2C%20On%20import%20and%20Recently%20pulled.%3C%2FP%3E%0A%3CP%3EMicrosoft%20defender%20for%20container%20Registries%20pulls%20and%20scans%20the%20image%20in%20an%20isolated%20sandbox.%20It%20is%20then%20extracts%2C%20filters%20and%20classifies%20the%20findings%2C%20and%20presents%20them%20as%20actionable%20security%20recommendations.%3C%2FP%3E%0A%3CP%3EEach%20finding%20Defender%20for%20container%20registries%20published%20for%20an%20image%20is%20represented%20as%20a%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Frest%2Fapi%2Fsecuritycenter%2Fsubassessments%2Fget%23containerregistryvulnerabilityproperties%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EContainer%20Registry%20Vulnerability%20Sub%20Assessment.%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22defendercontainres.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F323558iDBEAC1C4F0B36AB7%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22defendercontainres.png%22%20alt%3D%22defendercontainres.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3E%3CSTRONG%3E%3CU%3EExtract%20scan%20summary%20using%20API%3A%3C%2FU%3E%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EScan%20summaries%20are%20available%20in%20Microsoft%20Defender%20for%20Cloud%20dashboards.%20You%20can%20also%20access%20them%20programmatically%20(through%20our%20API%20or%20PowerShell)%20using%3C%2FP%3E%0A%3CP%3EWith%20the%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Security-Center%2Ftree%2Fmaster%2FContainer%2520Image%2520Scan%2520Vulnerability%2520Assessment%2FARG%2520queries%2FContainer%2520Registry%2520Vulnerability%2520Assessment%2520Images%2520Scan%2520Summary%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Escan%20summary%20ARG%20query%3C%2FA%3E%20published%20in%26nbsp%3BMicrosoft%20Defender%20for%20Cloud%20container%20image%20scan%20community%20GitHub%2C%20you%20can%20fetch%20results%20for%20all%20images%20by%20simply%20running%20it%20via%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Frest%2Fapi%2Fazureresourcegraph%2Fresourcegraph(2019-04-01)%2Fresources%2Fresources%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EARG%20REST%20API%2C%3C%2FA%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fgovernance%2Fresource-graph%2Ffirst-query-powershell%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EPowerShell%20module%3C%2FA%3E%20or%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fgovernance%2Fresource-graph%2Ffirst-query-portal%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EExplorer%3C%2FA%3E.%3C%2FP%3E%0A%3CPRE%3Esecurityresources%3CBR%20%2F%3E%7C%20where%20type%20%3D%3D%20'microsoft.security%2Fassessments%2Fsubassessments'%3CBR%20%2F%3E%7C%20where%20id%20matches%20regex%20'(.%2B%3F)%2Fproviders%2FMicrosoft.Security%2Fassessments%2Fdbd0cb49-b563-45e7-9724-889e799fa648%2F'%3CBR%20%2F%3E%7C%20parse%20id%20with%20registryResourceId%20'%2Fproviders%2FMicrosoft.Security%2Fassessments%2F'%20*%3CBR%20%2F%3E%7C%20parse%20registryResourceId%20with%20*%20%22%2Fproviders%2FMicrosoft.ContainerRegistry%2Fregistries%2F%22%20registryName%3CBR%20%2F%3E%7C%20extend%20imageDigest%20%3D%20tostring(properties.additionalData.imageDigest)%3CBR%20%2F%3E%7C%20extend%20repository%20%3D%20tostring(properties.additionalData.repositoryName)%3CBR%20%2F%3E%7C%20extend%20scanFindingSeverity%20%3D%20tostring(properties.status.severity)%2C%20scanStatus%20%3D%20tostring(properties.status.code)%3CBR%20%2F%3E%7C%20summarize%20scanFindingSeverityCount%20%3D%20count()%20by%20scanFindingSeverity%2C%20scanStatus%2C%20registryResourceId%2C%20registryName%2C%20repository%2C%20imageDigest%3CBR%20%2F%3E%7C%20summarize%20severitySummary%20%3D%20make_bag(pack(scanFindingSeverity%2C%20scanFindingSeverityCount))%20by%20registryResourceId%2C%20registryName%2C%20repository%2C%20imageDigest%2C%20scanStatus%3C%2FPRE%3E%0A%3CP%3EYou%20can%20also%20filter%20results%20to%20get%20summary%20for%20a%20specific%20image%20or%20registry%20by%20adding%3C%2FP%3E%0A%3CP%3Eit%20to%20the%20bottom%20of%20the%20query%2C%20for%20example%3A%3C%2FP%3E%0A%3CPRE%3E%7C%20where%20imageDigest%20%3D%3D%20'%3CIMAGEDIGEST%3E'%20and%20repository%20%3D%3D%20'%3CIMAGEREPOSITORY%3E'%20%3CBR%20%2F%3Eand%20registryResourceId%20endswith%20'%2F%26lt%3BImageRegistryName%26gt%3B'%3C%2FIMAGEREPOSITORY%3E%3C%2FIMAGEDIGEST%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-161663195%22%20id%3D%22toc-hId-163597655%22%3E%3CFONT%20size%3D%224%22%3E%3CSTRONG%3E%3CU%3EUse%20scan%20summary%20as%20part%20of%20an%20image%20CI%5CCD%20pipeline%3A%3C%2FU%3E%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FH3%3E%0A%3CP%3EIn%20ASC%20container%20image%20scan%20GitHub%20community%2C%20you%20can%20also%20find%20the%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Security-Center%2Ftree%2Fmaster%2FContainer%2520Image%2520Scan%2520Vulnerability%2520Assessment%2FImage%2520Scan%2520Automation%2520Enrichment%2520Security%2520Gate%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EImage%20Scan%20Automation%20Enrichment%20Security%20Gate%3C%2FA%3E%20tool.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20security%20gate%20tool%20is%20used%20for%20enriching%20and%20acting%20upon%20image%20scan%20results%20as%20part%20of%20a%20CI%5CCD%20pipeline%20to%20follow%20a%20scan%20initiated%20by%20image%20push.%3C%2FP%3E%0A%3CP%3EIt%20is%20built%20by%20two%20parts%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Security-Center%2Fblob%2Fmaster%2FContainer%2520Image%2520Scan%2520Vulnerability%2520Assessment%2FImage%2520Scan%2520Automation%2520Enrichment%2520Security%2520Gate%2FImageScanSummaryAssessmentGate.ps1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EScan%20automation%20gate%20PowerShell%20script%3C%2FA%3E%3C%2FSTRONG%3E%3A%20%26nbsp%3B%3CBR%20%2F%3EAn%20Azure%20CLI%20PowerShell%20script%20that%20fetches%20provided%20image%20scan%20result%20and%20assess%20them%20by%20configuration.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3CUL%3E%0A%3CLI%3E%3CU%20style%3D%22font-family%3A%20inherit%3B%22%3EScript%20run%20ends%20in%20one%20of%20the%20following%20modes%3A%3C%2FU%3E%3CUL%20class%3D%22lia-list-style-type-circle%22%3E%0A%3CLI%3E%3CFONT%20color%3D%22%23339966%22%3ESuccess%3C%2FFONT%3E%3A%20scan%20results%20for%20image%20extracted%20successfully%20with%20no%20significant%20findings%2C%20image%20is%20healthy.%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20color%3D%22%23FF9900%22%3EWarning%3C%2FFONT%3E%3A%26nbsp%3B%20scan%20results%20with%20some%20low%20%26amp%3B%20medium%20findings%2C%20but%20not%20enough%20to%20pass%20security%20gate%20findings%20severity%20thresholds%20(configurable).%3C%2FLI%3E%0A%3CLI%3E%26nbsp%3B%3CFONT%20color%3D%22%23FF0000%22%3EFailure%3C%2FFONT%3E%3A%20scan%20result%20with%20high%20severity%20finding%20%3CSTRONG%3Eor%3C%2FSTRONG%3E%26nbsp%3B%20number%20of%20medium%20%26amp%3B%20low%20severity%20findings%20has%20passed%20threshold%20(configurable)%20%3CSTRONG%3Eor%20%3C%2FSTRONG%3Escan%20result%20not%20found%20after%20multiple%20retries%20(configurable).%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CU%20style%3D%22font-family%3A%20inherit%3B%22%3ECustomize%20security%20gate%20script%20vulnerability%20thresholds%3A%26nbsp%3B%3CBR%20%2F%3E%3C%2FU%3ESecurity%20gate%20vulnerability%20severity%20thresholds%20can%20be%20customized%20by%20PS%20script%E2%80%99s%20optional%20parameters%3A%20%60%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E%24mediumFindingsCountFailThreshold%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E%60%20%2C%20%60%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E%24lowFindingsCountFailThreshold%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E%60%2C%20%3CSTRONG%3Eby%20default%20they%20are%20set%20to%205%20and%2015%20respectively%3C%2FSTRONG%3E%20(%3C%2FSPAN%3E%3CA%20style%3D%22font-family%3A%20inherit%3B%20background-color%3A%20%23ffffff%3B%22%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Security-Center%2Fblob%2Fmaster%2FContainer%2520Image%2520Scan%2520Vulnerability%2520Assessment%2FImage%2520Scan%2520Automation%2520Enrichment%2520Security%2520Gate%2FImageScanSummaryAssessmentGate.ps1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Escript%20optional%20parameters%3C%2FA%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E).%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3EIn%20the%20case%20of%20a%20high%20severity%20vulnerability%2C%20security%20gate%20will%20always%20end%20up%20with%20a%20failure.%3CBR%20%2F%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CPRE%3E.%5CImageScanSummaryAssessmentGate.ps1%20-registryName%20tomerregistry%20-repository%20build%20-tag%20latest%E2%80%8B%3C%2FPRE%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3EThis%20PS%20script%20can%20be%20included%20in%20any%20of%20your%20automation%20pipelines%20as%20a%20standalone%20gate%20to%20enrich%20scan%20results%20for%20image.%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%3CA%20style%3D%22font-family%3A%20inherit%3B%20background-color%3A%20%23ffffff%3B%22%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Security-Center%2Fblob%2Fmaster%2FContainer%2520Image%2520Scan%2520Vulnerability%2520Assessment%2FImage%2520Scan%2520Automation%2520Enrichment%2520Security%2520Gate%2FimagePushScanGate-azure-pipelines.yml%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20DevOps%20pipeline%20template%3C%2FA%3E%3C%2FSTRONG%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E%3CSTRONG%3E%3A%20%3C%2FSTRONG%3E%3CBR%20%2F%3EAn%20Azure%20DevOps%20pipeline%20that%3A%26nbsp%3B%3C%2FSPAN%3EBuilds%20image%2C%26nbsp%3BPushes%20it%20to%20Azure%20container%20registry%2C%20then%20Assesses%20scan%20results%20for%20image%20to%20decide%20whether%20to%20pass%20of%20fail%20pipeline.%3CBR%20%2F%3E%3CBR%20%2F%3E%3CUL%3E%0A%3CLI%3EBy%20copying%20security%20gate%20PS%20script%20presented%20above%20to%20pipeline%E2%80%99s%20path%2C%20following%20image%E2%80%99s%20Build%20and%20Push%20Docker%20task%2C%20pipeline%20can%20now%20run%20a%20custom%20Azure%20CLI%20PowerShell%20task%20with%20the%20PS%20script%20copied.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3CLI%3ESecurity%20Gate%20custom%20Task%20from%20%3CA%20style%3D%22font-family%3A%20inherit%3B%20background-color%3A%20%23ffffff%3B%22%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Security-Center%2Fblob%2Fmaster%2FContainer%2520Image%2520Scan%2520Vulnerability%2520Assessment%2FImage%2520Scan%2520Automation%2520Enrichment%2520Security%2520Gate%2FimagePushScanGate-azure-pipelines.yml%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20DevOps%20pipeline%20template%3C%2FA%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E%3A%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3CPRE%20class%3D%22lia-code-sample%20language-yaml%22%3E%3CCODE%3E%20%20%20%20%23%20Run%20Image%20scan%20gate%20-%20which%20extracts%20image%20scan%20results%20and%20assess%20whether%20%0A%20%20%20%20%23%20to%20fail%20the%20pipeline%20based%20on%20severity%20threshold%20configuration.%0A%20%20%20%20%23%20Using%20the%20ImageScanSummaryAssessmentGate.ps1%20script%20in%20same%20repo%20folder%0A%20%20-%20job%3A%20ImageScanGate%0A%20%20%20%20displayName%3A%20Image%20Scan%20security%20gate%0A%20%20%20%20pool%3A%0A%20%20%20%20%20%20vmImage%3A%20%24(vmImageName)%0A%20%20%20%20dependsOn%3A%20%0A%20%20%20%20-%20BuildAndPush%0A%20%20%20%20-%20WaitForScanResults%0A%20%20%20%20steps%3A%0A%20%20%20%20%23%20Read%20more%20here%3A%20https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdevops%2Fpipelines%2Ftasks%2Fdeploy%2Fazure-cli%3Fview%3Dazure-devops)%0A%20%20%20%20-%20task%3A%20AzureCLI%402%0A%20%20%20%20%20%20inputs%3A%0A%20%20%20%20%20%20%20%20azureSubscription%3A%20'%3CNAME%20of%3D%22%22%20the%3D%22%22%20azure%3D%22%22%20resource%3D%22%22%20manager%3D%22%22%20service%3D%22%22%20connection%3D%22%22%3E'%0A%20%20%20%20%20%20%20%20scriptType%3A%20'pscore'%0A%20%20%20%20%20%20%20%20scriptLocation%3A%20'scriptPath'%0A%20%20%20%20%20%20%20%20%23%20Security%20Gate%20powershell%20script%20in%20same%20folder%0A%20%20%20%20%20%20%20%20scriptPath%3A%20'%24(Build.SourcesDirectory)%2FImageScanSummaryAssessmentGate.ps1'%0A%20%20%20%20%20%20%20%20arguments%3A%20'-registryName%20%24(containerRegistry)%20-repository%20%24(imageRepository)%20-tag%20%24(tag)'%3C%2FNAME%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%20class%3D%22lia-list-style-type-circle%22%3E%0A%3CLI%3EImage%20scan%20gate%20task%20runs%20following%20a%20short%20delay%20task%20(configurable)%20from%20image%20push%20task%20to%20make%20image%20scan%20results%20are%20published%20in%20ARG.%3C%2FLI%3E%0A%3CLI%3EPipeline%20will%20complete%20successfully%20on%20image%20built%2C%20push%2C%20and%20security%20gate%20success%20result.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CU%20style%3D%22font-family%3A%20inherit%3B%22%3ECustomize%20pipeline%20scan%20results%20extraction%20timeouts%3A%3CBR%20%2F%3E%3C%2FU%3E%3CSTRONG%3EBy%20default%2C%20pipeline%20waits%205%20minutes%20following%20image%20push%3C%2FSTRONG%3E%20to%20run%20the%20scan%20gate%20task%20to%20make%20sure%20scan%20results%20are%20ready%20and%20published%20in%20ARG%20(can%20by%20customize%20in%20pipeline%20variable%20%60%24waitForScanResultsAfterPushInMinutes%60).%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CH3%20id%3D%22toc-hId--1645791268%22%20id%3D%22toc-hId--1643856808%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId-841721565%22%20id%3D%22toc-hId-843656025%22%3E%3CSTRONG%3E%3CU%3E%3CBR%20%2F%3E%3CFONT%20size%3D%224%22%3EPush%20only%20scanned%20and%20healthy%20images%20to%20your%20production%20registry%3A%3C%2FFONT%3E%3C%2FU%3E%3C%2FSTRONG%3E%3C%2FH3%3E%0A%3CP%3EYou%20can%20use%20the%20security%20gate%20task%20above%20as%20a%20conditional%20task%20to%20push%20image%20to%20your%20production%20registry.%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EPush%20image%20to%20your%20%3CSTRONG%3Estaging%3C%2FSTRONG%3E%20registry%20first%20(make%20sure%20it%20is%20also%20on-boarded%20to%20Microsoft%20Defender%20for%20Cloud).%3C%2FLI%3E%0A%3CLI%3ESet%20Azure%20DevOps%20scan%20gate%20task%20to%20run%20on%20image%20in%20stagging%20registry.%3C%2FLI%3E%0A%3CLI%3ESet%20security%20gate%20task%20result%20as%20a%20dependency%20for%20%3CSTRONG%3EPushing%20the%20image%20to%20your%20production%20registry%3C%2FSTRONG%3E.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EYou%20are%20welcome%20to%20join%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Security-Center%2Ftree%2Fmaster%2FContainer%2520Image%2520Scan%2520Vulnerability%2520Assessment%2FARG%2520queries%2FContainer%2520Registry%2520Vulnerability%2520Assessment%2520Images%2520Scan%2520Summary%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EMicrosoft%20Defender%20for%20Cloud%20container%20image%20scan%20community%20on%20GitHub%3C%2FA%3E.%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EContribute%2C%20share%20and%20suggest%20useful%20tools%20to%20automate%20or%20improve%20work%20with%20the%26nbsp%3BMicrosoft%20Defender%20for%20Cloud%20image%20scan%20service%20and%20results.%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ETomer%20Weinberger%2C%20Microsoft%20Defender%20for%20Cloud.%3C%2FSTRONG%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2102516%22%20slang%3D%22en-US%22%3E%3CP%3EBy%20embedding%20Microsoft%20Defender%20for%20container%20registries%20assessments%20into%20your%20CI%2FCD%20pipeline%2C%20you%20can%20address%20this%20need%20and%20have%20a%20more%20secure%20automation%20and%20deployment%20processes%20in%20enterprise%20environments.%3C%2FP%3E%0A%3CP%3EThis%20blog%20will%20take%20you%20through%20a%20few%20simple%20steps%20to%20take%20your%20CI%2FCD%20pipeline%20to%20the%20next%20security%20level.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2102516%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EACR%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzureDevOps%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ECICD%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EContainer%20Registry%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EContainer%20Security%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EContainers%20Vulnerability%20Scan%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDefender%20for%20Container%20Registries%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDevOps%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Edocker%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EImage%20Scan%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Defender%20for%20Cloud%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Nov 02 2021 05:25 PM
Updated by:
www.000webhost.com