Documentation Scan from your CI pipeline

Scan every build and stop the pipeline when something serious turns up. Scanning from CI is included from the Skipper plan.

Set it up

  1. Create an access token in your account settings.
  2. Save it in your CI system as a secret called SC_TOKEN.
  3. Add the steps below to your pipeline.

GitHub Actions

- name: Install sc
  run: curl -fsSL https://scancontainer.com/install.sh | sh

- name: Scan the image
  env:
    SC_TOKEN: ${{ secrets.SC_TOKEN }}
  run: sc image myapp:${{ github.sha }} --fail-on high

- name: Keep the report
  if: always()
  env:
    SC_TOKEN: ${{ secrets.SC_TOKEN }}
  run: sc download last --format pdf --output report.pdf

- uses: actions/upload-artifact@v4
  if: always()
  with:
    name: scan-report
    path: report.pdf

GitLab CI

scan:
  stage: test
  script:
    - curl -fsSL https://scancontainer.com/install.sh | sh
    - sc image myapp:$CI_COMMIT_SHA --fail-on high
  after_script:
    - sc download last --format pdf --output report.pdf
  artifacts:
    when: always
    paths:
      - report.pdf

In GitLab, add SC_TOKEN as a masked variable in the CI/CD settings of the project.

Azure DevOps

- script: curl -fsSL https://scancontainer.com/install.sh | sh
  displayName: Install sc

- script: sc image myapp:$(Build.BuildId) --fail-on high
  displayName: Scan
  env:
    SC_TOKEN: $(SC_TOKEN)

Other CI systems

Jenkins, CircleCI, Bitbucket Pipelines and the rest work the same way: install sc, set SC_TOKEN and run the scan command.

Decide when the pipeline stops

CommandThe pipeline stops when
sc image myapp:1.4 --fail-on criticalThere is a critical finding.
sc image myapp:1.4 --fail-on highThere is a high or critical finding.
sc image myapp:1.4Never. The scan only reports.

Start without the option, look at a few reports and then choose the level your team can keep green.

Without installing anything

A docker push from the pipeline also starts a scan. It cannot stop the pipeline, because the result arrives after the push ends.

- name: Log in to scancontainer
  run: echo "${{ secrets.SCANCONTAINER_TOKEN }}" | docker login scancontainer.com -u your-user --password-stdin
- name: Scan the image
  run: |
    docker tag myapp:${{ github.sha }} scancontainer.com/your-user/myapp:${{ github.sha }}
    docker push scancontainer.com/your-user/myapp:${{ github.sha }}

Scan yours before the next deploy.