Nexus IQ for GitLab CI


Download the docker image here:  GitLab Nexus IQ docker image


CI/CD pipeline jobs in GitLab leverage custom docker images to perform desired actions in the context of the GitLab project's build workspace.  As such, the GitLab Nexus IQ docker image provides the ability to run Nexus policy evaluation against build artifacts in GitLab and produces a summary report with policy violation counts and a link to a detailed report on the IQ server.

The IQ policy evaluation will pass/fail a GitLab pipeline based on the policy action defined in IQ for the given application and stage.  See the IQ server documentation for details on setting up policies and policy actions.

In addition, Nexus IQ for GitLab can assist with remediation of identified vulnerabilities.  See Nexus IQ for SCM for more information on how to enable and use this capability.

Any project that wants to leverage GitLab's CI/CD pipeline must include a .gitlab-ci.yml pipeline definition file in the root of the project.  Documentation on the various options for pipeline and job definitions is available here.  A GitLab pipeline job that performs Nexus IQ policy evaluation consists of the following elements and would look something like this:

  stage: test
  image: sonatype/gitlab-nexus-iq-pipeline:1.2
    - /sonatype/evaluate -i WebAppX target/web-app-x.war
    name: "policy-eval-$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
      - WebAppX-policy-eval-report.html

Let's explore some of these elements in more detail:

  • iq_policy_eval - the name of the job and can be anything you like
  • stage: test  - the pipeline stage in which to run the policy evaluation;  can be any one of the built in stages or any custom stage defined earlier in the pipeline definition file
  • image: sonatype/gitlab-nexus-iq-pipeline:1.2 - the docker image that will be used during the execution of this pipeline job
  • script - the script statements that will be run in the context of the given docker image;  in this case, the following minimal elements are required:
    • /sonatype/evaluate is the shell script inside the docker container that executes the policy evaluation
    • -i WebAppX is the unique ID of the application being evaluated, as defined in IQ server
    • target/web-app-x.war is a list of one or more artifacts from the build environment to perform the evaluation against
    • See the documentation provided with the image on Docker Hub for details about other options available during policy evaluation
  • artifacts - list of directories or files that will be zipped and archived with the executed pipeline;  see the GitLab documentation for more information on how long these artifacts live and how to access them
    • name - the name to give the artifact zip file (note: pipeline variables can be used to create the name, as shown in the above example)
    • paths - references to one or more files or directories in the build environment to include in the archive
      • WebAppX-policy-eval-report.html - this is the name of the report generated by the policy evaluation and is comprised of '<app id>-policy-eval-report.html'

In order to make GitLab CI/CD pipeline job artifacts available across jobs you should add them to the pipeline cache, which could be defined a little further up in the file, as so:

    - target/
    - <submodule1>/target/
    - <submodule2>/target/

IQ Server connection information

The required connection information for the IQ server can be specified at either the group or project level using the CI/CD settings, as so:

The following three environment variables must be defined if not set explicitly in the job definition via script parameters:

Problems with the IQ server connection will show up in, and can be diagnosed from, the pipeline job output, as so:

Release Notes

Version 1.101.0-01 (Nov 2020)

  • Nexus IQ CLI no longer supports Lifecycle XC IQ Server now has native support for all languages that were supported in Lifecycle XC. 

Version 1.98.0-01 (Sep 2020)

  • Application analysis of components for:

Version 1.97.0-01 (Aug 2020)

  • Application analysis of components for:

Version 1.94.0-01 (Jun 2020)

  • Now releasing in sync with Nexus IQ Server releases (which may or may not include updates relevant to this docker image's release)
  • Application analysis of components for:
    • C/C++ Files
    • Yum
    • Alpine
    • Debian
    • Drupal
    • R (CRAN)
    • Rust (Cargo)

Version 1.88.0-02 (Mar 2020)

  • Application analysis of components for:
    • Swift/Objective-C CocoaPods
    • Conda

Version 1.87.0-02 (Mar 2020)

  • Identify components based on SHA-1 value (content hash)
  • Application analysis of components for:
    • C/C++ Conan
    • PHP Composer
    • RubyGems
    • CycloneDX application analysis extended to support submitting component vulnerabilities

Version 1.2 (Sep 2019)

  • pushed environment variables into processes for automated onboarding of applications for Nexus IQ for SCM

Version 1.1 (Apr 2019)

  • expanded coverage option (-xc) fixed
  • application ID added to the report filename
  • policy violation counts added to the html report

Version 1.0 (Apr 2019)

  • Known issues:
    • Using the expanded coverage option (-xc) will incorrectly cause the pipeline job to fail
    • Multiple evaluations in the same job will incorrectly append report information to the same policy-eval-report.html file