Skip to main content

Clair scanner reference for STO

You can scan container images using Clair, an open-source project for the static analysis of vulnerabilities in application containers. Create a CI Build or Security Tests stage, add a Security step, and then add the setting:value pairs as specified below.

Important notes for running Clair scans in STO

Docker-in-Docker requirements

The following use cases require a Docker-in-Docker background step in your pipeline:

  • Container image scans on Kubernetes and Docker build infrastructures
  • Security steps (not step palettes) on Kubernetes and Docker build infrastructures
    • Required for all target types and Orchestration/DataLoad modes

The following use cases do not require Docker-in-Docker:

Set up a Docker-in-Docker background step
  1. Go to the stage where you want to run the scan.

  2. In Overview, add the shared path /var/run.

  3. In Execution, do the following:

    1. Click Add Step and then choose Background.

    2. Configure the Background step as follows:

      1. Dependency Name = dind

      2. Container Registry = The Docker connector to download the DinD image. If you don't have one defined, go to Docker connector settings reference.

      3. Image = docker:dind

      4. Under Entry Point, add the following: dockerd

        In most cases, using dockerd is a faster and more secure way to set up the background step. For more information, go to the TLS section in the Docker quick reference.

      If the DinD service doesn't start with dockerd, clear the Entry Point field and then run the pipeline again. This starts the service with the default entry point.

      1. Under Optional Configuration, select the Privileged checkbox.
Configure the background step

Root access requirements

You need to run the scan step with root access if either of the following apply:

note

You can set up your STO scan images and pipelines to run scans as non-root and establish trust for your own proxies using custom certificates. For more information, go to Configure STO to Download Images from a Private Registry.

For more information

The following topics contain useful information for setting up scanner integrations in STO:

Security step settings for Clair scans in STO

Target and variant

The following settings are required for every Security step:

  • target_name A user-defined label for the code repository, container, application, or configuration to scan.
  • variant A user-defined label for the branch, tag, or other target variant to scan.
note

Make sure that you give unique, descriptive names for the target and variant. This makes navigating your scan results in the STO UI much easier.

You can see the target name, type, and variant in the Test Targets UI:

Target name, type, and branch

For more information, go to Targets, baselines, and variants in STO.

Clair scan settings

  • product_name = docker-content-trust (clair)
  • scan_type :containerImage
  • policy_type : orchestratedScan or ingestionOnly
  • product_url
  • product_access_id
  • product_access_token
  • product_config_name : default
  • fail_on_severity - See Fail on Severity.

Container scan settings

The following settings apply to all scanners where the scan_type is containerImage.

  • container_type
    • accepted value(s): local_image, docker_v2, jfrog_artifactory, aws_ecr
      • for container_type set to local
        • None
      • for container_type set to docker_v2
        • container_access_id: Username
        • container_access_token: Password/Token
      • for container_type set to jfrog_artifactory
        • container_access_id: Username
        • container_access_token: Password/Token
      • for container_type set to aws_ecr
        • container_access_id: Username
        • container_access_token: Password/Token
        • container_region: AWS default region
  • container_domain

Ingestion file

If the policy_type is ingestionOnly:

  • ingestion_file = The path to your scan results when running an Ingestion scan, for example /shared/scan_results/myscan.latest.sarif.
  • The data file must be in a supported format for the scanner.

  • The data file must be accessible to the scan step. It's good practice to save your results files to a shared path in your stage. In the visual editor, go to the stage where you're running the scan. Then go to Overview > Shared Paths. You can also add the path to the YAML stage definition like this:

        - stage:
    spec:
    sharedPaths:
    - /shared/scan_results

Fail on Severity

Every Security step has a Fail on Severity setting. If the scan finds any vulnerability with the specified severity level or higher, the pipeline fails automatically. You can specify one of the following:

  • CRITICAL
  • HIGH
  • MEDIUM
  • LOW
  • INFO
  • NONE — Do not fail on severity

The YAML definition looks like this: fail_on_severity : critical # | high | medium | low | info | none