Standalone scanner - Jenkins example

This document (000020930) is provided subject to the disclaimer at the end of this document.

Resolution

It is often necessary to scan the development build image and ensure it is free of critical vulnerabilities before pushing it to a registry for further testing.  This article will demonstrate the use of the standalone NeuVector scanner without the need for a full NeuVector deployment.

The scanner container will perform the scan and write the output to /var/neuvector/scan_result.json.  The downstream stage can process the scan_result.json and take appropriate action.

Jenkins Pipeline:

Requirements:

  • Docker

A pipeline stage to instantiate the scanner to scan the build image.  Extending this example should include a stage to parse the scan_result.json and take appropriate action.

pipeline {
  environment {
    image = "alpine"
    tag = "3.9"
    tag_scan = "$BUILD_TAG"
    }
agent any
stages {
  stage('Build Local Image') { 
    steps {
      sh "echo 'FROM $image:$tag' > Dockerfile && docker build -t $image:$tag_scan . "
      }
    }
  stage('Check Local Image') { 
    steps {
      sh "docker images"
      }
    }
  stage('Test NV Scan Images') { 
    steps {
      //nv jenkins plugin conf
      sh "docker run -i --privileged --name neuvector.scanner -e SCANNER_REPOSITORY=$image -e SCANNER_TAG=$tag_scan -e SCANNER_ON_DEMAND=true -v /var/run/docker.sock:/var/run/docker.sock -v /var/neuvector:/var/neuvector neuvector/scanner"
      sh "docker cp neuvector.scanner:/var/neuvector/scan_result.json ."
      sh "docker rm neuvector.scanner"
      }
    }
  stage('Security Report') { 
    steps {
      archiveArtifacts artifacts: 'scan_result.json'
      cleanWs()
      }
    } 
  } 
}

 

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:000020930
  • Creation Date: 17-Jan-2023
  • Modified Date:18-Jan-2023
    • SUSE NeuVector

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

Join Our Community

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.


SUSE Customer Support Quick Reference Guide SUSE Technical Support Handbook Update Advisories
Support FAQ

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.

Go to Customer Center