Quality controls in Azure DevOps with Prisma Cloud

This time I want to focus on quality by implementing CVE and compliance scan tool as well as the control gate on a release stage in Azure DevOps leveraging Prisma Cloud platform by Palo Alto Networks.

All code from this article is here

├── README.md
├── binaries
│   └── twistcli
├── pipelines
│   └── azure-pipelines.yml
└── src
    └── Dockerfile

I would like to build my code using Azure DevOps pipelines and fail earlier as possible in case:

  • of (whatever severity) vulnerabilities or failed compliance checks for built image;
  • do not allow release in case of failed quality gates.

Also I’d like to get instant feedback about the issues so I can go ahead and fix it quickly.

For automated image scanning I am going to use Prisma Cloud.


I am going to use the following Dockerfile as it should bring me bunch of CVEs and highlight failed cheks againts Center for Internet Security (CIS) benchmarks and other compliance standards.

FROM vulnerables/web-dvwa

Prisma Cloud

There are several things that I need to do in Prisma Cloud:

  1. Get console’s URL and store it’s string as variable or secret in Azure Key Vault;
  2. Generate and store (i.e. in Azure Key Vault) access and secret key so I can curl or CLI endpoints of Prisma Cloud;
  3. Download binaries of twistcli (tool to do scans) and store it in Azure Artifacts as universal package in feed.

Alternatively I could use plugin for #3 and store #2’s credentials as service connection in AzDo, but the moment I wrote this article I had several issues with the plugin and looks like it does not get much attention either (also plugin is just a wrapper around twistcli).

Pipeline definition

  vmImage: ubuntu-latest  


- stage: BUILD

    - task: Bash@3
        targetType: 'inline'
        script: |
          docker build -t myapp:$(build.buildid) .
          echo "##vso[task.setvariable variable=imagesha;isOutput=true]$(docker images --no-trunc --quiet myapp)"
          echo ${{ variables.imagesha }}          

    - task: UniversalPackages@0
        command: 'download'
        downloadDirectory: '$(System.DefaultWorkingDirectory)'
        feedsToUse: 'internal'
        vstsFeed: 'e19a49e7-5eae-4186-ab59-41190cb528e2'
        vstsFeedPackage: '5eac8bc8-e21a-473a-844c-97d9a0f71e3f'
        vstsPackageVersion: '0.0.2108525'

    - task: Bash@3
        targetType: 'inline'
        script: |
          chmod +x twistcli
          ./twistcli images scan --details --address $CONSOLE -u $ACCESS_KEY -p $SECRET_KEY myapp:$(build.buildid)          

- stage: DEV
  - deployment: DEV
    environment: dev
          - script: echo push

Environments, approvals and checks

For the quality gates I am going to call Prisma Cloud’s endpoint to check my image for any issues (this is done via environment’s approvals and checks by invoking REST API). The following screenshots show both service connection for the endpoint (with it’s credentials) and the success criteria. In order to keep it simple image’s sha is being passed as plain text in URL as well as simple success criteria is being validated (either anything being returned with false boolean in pass argument). API’s references for scan results.

Azure DevOps environment checks{: .normal } Azure DevOps generic service connection{: .normal }


  • Developer submits the code and raises PR.
  • Pipeline starts to run two stages;
    • BUILD stages uses docker build command to build the image, tag it and get the SHA of the image; following by further built image is being scanned by twistcli utility (it’s binary is being downloaded from the feed as universal package to the agent); CVE and compliance alert/failure severities can be controlled via Prisma Cloud’s UI (i.e. I can fail build if any low/medium CVE are found during scan with immediate feedback in the logs of Azure DevOps Pipeline);
    • DEV stage has a references to dev environment that contains approval and checks. Check submits payload with image’s SHA and checks whether it has any CVEs and compliance issues (and if yes fails the stage).

Azure DevOps Pipeline - image scan by Prisma Cloud for CVE and compliance issues

That’s it! I have build stage with image scan task and a quality gate that automatically fails my deployment stage in case of any vulnerabilities or compliance issues.

comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy