Documentation Scan from your CI pipeline
Scan every change 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
- uses: actions/checkout@v4
- name: Install sc
run: curl -fsSL https://scancodebase.com/install.sh | sh
- name: Scan the code
env:
SC_TOKEN: ${{ secrets.SC_TOKEN }}
run: sc code . --fail-on high --format sarif --output scan.sarif
- name: Show the findings in GitHub
if: always()
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: scan.sarifGitLab CI
scan:
stage: test
script:
- curl -fsSL https://scancodebase.com/install.sh | sh
- sc code . --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://scancodebase.com/install.sh | sh
displayName: Install sc
- script: sc code . --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 code . --fail-on critical | There is a critical finding. |
sc code . --fail-on high | There is a high or critical finding. |
sc code . | 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 git push from the pipeline also starts a scan. It cannot stop the pipeline, because the result arrives after the push ends.
- name: Scan with scancodebase
run: |
git remote add scancodebase https://your-user:${{ secrets.SCANCODEBASE_TOKEN }}@scancodebase.com/your-user/myapp.git
git push scancodebase HEAD:main