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
- Create an access token in your account settings.
- Save it in your CI system as a secret called SC_TOKEN.
- 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.pdfGitLab 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.pdfIn 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
| Command | The pipeline stops when |
|---|---|
sc image myapp:1.4 --fail-on critical | There is a critical finding. |
sc image myapp:1.4 --fail-on high | There is a high or critical finding. |
sc image myapp:1.4 | Never. 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 }}