|
| 1 | +# ScanCode.io Azure Pipeline Template |
| 2 | + |
| 3 | +Run [ScanCode.io](https://github.com/aboutcode-org/scancode.io) pipelines from your Azure DevOps Pipelines. |
| 4 | + |
| 5 | +- [Usage](#usage) |
| 6 | + - [Basic](#basic) |
| 7 | + - [Parameters](#parameters) |
| 8 | +- [Examples](#examples) |
| 9 | + - [Scan repo codebase](#scan-repo-codebase) |
| 10 | + - [Run a specific pipeline](#run-a-specific-pipeline) |
| 11 | + - [Run multiple pipelines](#run-multiple-pipelines) |
| 12 | + - [Choose the output formats](#choose-the-output-formats) |
| 13 | + - [Provide download URLs inputs](#provide-download-urls-inputs) |
| 14 | + - [Fetch pipelines inputs](#fetch-pipelines-inputs) |
| 15 | + - [Check for compliance issues](#check-for-compliance-issues) |
| 16 | + - [Define a custom project name](#define-a-custom-project-name) |
| 17 | + - [Install ScanCode.io from a repository branch](#install-scancodeio-from-a-repository-branch) |
| 18 | +- [Where does the scan results go?](#where-does-the-scan-results-go) |
| 19 | + |
| 20 | +## Usage |
| 21 | + |
| 22 | +### Basic |
| 23 | + |
| 24 | +```yaml |
| 25 | +stages: |
| 26 | + - stage: ScanCode |
| 27 | + jobs: |
| 28 | + - job: RunScanCode |
| 29 | + steps: |
| 30 | + - template: azure-pipelines/templates/scancode-template.yml@scancode-action |
| 31 | + parameters: |
| 32 | + pipelines: "scan_codebase" |
| 33 | + outputFormats: "json xlsx spdx cyclonedx" |
| 34 | +``` |
| 35 | +
|
| 36 | +### Parameters |
| 37 | +
|
| 38 | +```yaml |
| 39 | +- template: azure-pipelines/templates/scancode-template.yml@scancode-action |
| 40 | + parameters: |
| 41 | + # Names of the pipelines (comma-separated) and in order. |
| 42 | + # Default is 'scan_codebase' |
| 43 | + pipelines: |
| 44 | + |
| 45 | + # The list of output formats to generate. |
| 46 | + # Default is 'json xlsx spdx cyclonedx' |
| 47 | + outputFormats: |
| 48 | + |
| 49 | + # Relative path within the $(Build.SourcesDirectory) for pipeline inputs. |
| 50 | + # Default is '$(Build.SourcesDirectory)/scancode-inputs' |
| 51 | + inputsPath: |
| 52 | + |
| 53 | + # Provide one or more URLs to download for the pipeline run execution |
| 54 | + inputUrls: |
| 55 | + |
| 56 | + # Name of the project. |
| 57 | + # Default is 'scancode-devops' |
| 58 | + projectName: |
| 59 | + |
| 60 | + # Name of the outputs archive. |
| 61 | + # Default is 'scancode-outputs' |
| 62 | + outputsArchiveName: |
| 63 | + |
| 64 | + # Check for compliance issues in the project. |
| 65 | + # Exits with a non-zero status if compliance issues are detected. |
| 66 | + # Default is false |
| 67 | + checkCompliance: |
| 68 | + |
| 69 | + # Failure level for compliance check. Options: ERROR, WARNING, MISSING. |
| 70 | + # Default is 'ERROR' |
| 71 | + complianceFailLevel: |
| 72 | + |
| 73 | + # Exit with a non-zero status if known vulnerabilities are detected in discovered |
| 74 | + # packages and dependencies. |
| 75 | + # Default is false |
| 76 | + complianceFailOnVulnerabilities: |
| 77 | + |
| 78 | + # Python version that will be installed to run ScanCode.io |
| 79 | + # Default is '3.12' |
| 80 | + pythonVersion: |
| 81 | + |
| 82 | + # Install ScanCode.io from a specific GitHub branch (optional) |
| 83 | + # Default is empty (uses latest PyPI release) |
| 84 | + scancodeioRepoBranch: |
| 85 | +``` |
| 86 | +
|
| 87 | +## Examples |
| 88 | +
|
| 89 | +### Scan repo codebase |
| 90 | +
|
| 91 | +```yaml |
| 92 | +stages: |
| 93 | + - stage: ScanCode |
| 94 | + jobs: |
| 95 | + - job: RunScanCode |
| 96 | + steps: |
| 97 | + - template: azure-pipelines/templates/scancode-template.yml@scancode-action |
| 98 | +``` |
| 99 | +
|
| 100 | +### Run a specific pipeline |
| 101 | +
|
| 102 | +[Built-in pipelines list](https://scancodeio.readthedocs.io/en/latest/built-in-pipelines.html) |
| 103 | +
|
| 104 | +```yaml |
| 105 | +- template: azure-pipelines/templates/scancode-template.yml@scancode-action |
| 106 | + parameters: |
| 107 | + pipelines: "scan_codebase" |
| 108 | +``` |
| 109 | +
|
| 110 | +### Run multiple pipelines |
| 111 | +
|
| 112 | +```yaml |
| 113 | +- template: azure-pipelines/templates/scancode-template.yml@scancode-action |
| 114 | + parameters: |
| 115 | + pipelines: "scan_codebase,find_vulnerabilities" |
| 116 | + env: |
| 117 | + VULNERABLECODE_URL: https://public.vulnerablecode.io/ |
| 118 | +``` |
| 119 | +
|
| 120 | +#### Configuring find_vulnerabilities Pipeline |
| 121 | +
|
| 122 | +The find_vulnerabilities pipeline requires access to a VulnerableCode instance, |
| 123 | +which can be defined using the VULNERABLECODE_URL environment variable. |
| 124 | +
|
| 125 | +In the example provided, a public instance is referenced. |
| 126 | +However, you also have the option to run your own VulnerableCode instance. |
| 127 | +For details on setting up and configuring your own instance, please refer to the |
| 128 | +[VulnerableCode documentation](https://vulnerablecode.readthedocs.io/en/latest/index.html). |
| 129 | +
|
| 130 | +#### Fail on known vulnerabilities |
| 131 | +
|
| 132 | +When enabled, the pipeline will fail if any known vulnerabilities are found in the |
| 133 | +project's discovered packages or dependencies. |
| 134 | +Activate this behavior by enabling checkCompliance and setting |
| 135 | +complianceFailOnVulnerabilities to true. |
| 136 | +
|
| 137 | +```yaml |
| 138 | +- template: azure-pipelines/templates/scancode-template.yml@scancode-action |
| 139 | + parameters: |
| 140 | + pipelines: "scan_codebase,find_vulnerabilities" |
| 141 | + checkCompliance: true |
| 142 | + complianceFailOnVulnerabilities: true |
| 143 | + env: |
| 144 | + VULNERABLECODE_URL: https://public.vulnerablecode.io/ |
| 145 | +``` |
| 146 | +
|
| 147 | +### Choose the output formats |
| 148 | +
|
| 149 | +```yaml |
| 150 | +- template: azure-pipelines/templates/scancode-template.yml@scancode-action |
| 151 | + parameters: |
| 152 | + outputFormats: "json xlsx spdx cyclonedx" |
| 153 | +``` |
| 154 | +
|
| 155 | +> [!NOTE] |
| 156 | +> To specify a CycloneDX spec version (default to latest), use the syntax |
| 157 | + `cyclonedx:VERSION` as format value. For example: `cyclonedx:1.5`. |
| 158 | + |
| 159 | +### Provide download URLs inputs |
| 160 | + |
| 161 | +```yaml |
| 162 | +- template: azure-pipelines/templates/scancode-template.yml@scancode-action |
| 163 | + parameters: |
| 164 | + pipelines: "map_deploy_to_develop" |
| 165 | + inputUrls: "https://domain.url/source.zip#from https://domain.url/binaries.zip#to" |
| 166 | +``` |
| 167 | + |
| 168 | +### Fetch pipelines inputs |
| 169 | + |
| 170 | +```yaml |
| 171 | +stages: |
| 172 | + - stage: ScanCode |
| 173 | + jobs: |
| 174 | + - job: RunScanCode |
| 175 | + steps: |
| 176 | + - script: | |
| 177 | + mkdir -p $(Build.SourcesDirectory)/scancode-inputs |
| 178 | + wget --directory-prefix=$(Build.SourcesDirectory)/scancode-inputs https://github.com/$(Build.Repository.Name)/archive/$(Build.SourceBranch).zip |
| 179 | + displayName: 'Download repository archive to scancode-inputs/ directory' |
| 180 | + - template: azure-pipelines/templates/scancode-template.yml@scancode-action |
| 181 | + parameters: |
| 182 | + pipelines: "scan_single_package" |
| 183 | +``` |
| 184 | + |
| 185 | +### Check for compliance issues |
| 186 | + |
| 187 | +```yaml |
| 188 | +- template: azure-pipelines/templates/scancode-template.yml@scancode-action |
| 189 | + parameters: |
| 190 | + checkCompliance: true |
| 191 | + complianceFailLevel: "WARNING" |
| 192 | +``` |
| 193 | + |
| 194 | +> [!NOTE] |
| 195 | +> This feature requires to provide Project policies. |
| 196 | +> For details on setting up and configuring your own instance, please refer to the |
| 197 | +> [ScanCode.io Policies documentation](https://scancodeio.readthedocs.io/en/latest/policies.html). |
| 198 | + |
| 199 | +### Define a custom project name |
| 200 | + |
| 201 | +```yaml |
| 202 | +- template: azure-pipelines/templates/scancode-template.yml@scancode-action |
| 203 | + parameters: |
| 204 | + projectName: "my-project-name" |
| 205 | +``` |
| 206 | + |
| 207 | +### Install ScanCode.io from a repository branch |
| 208 | + |
| 209 | +```yaml |
| 210 | +- template: azure-pipelines/templates/scancode-template.yml@scancode-action |
| 211 | + parameters: |
| 212 | + scancodeioRepoBranch: "main" |
| 213 | +``` |
| 214 | + |
| 215 | +## Where are the Scan Results? |
| 216 | + |
| 217 | +Upon completion of the pipeline, you can **find the scan results** in the dedicated |
| 218 | +**pipeline artifacts section**. Navigate to your pipeline run summary page and look |
| 219 | +for the **Artifacts** tab. The scan results will be available as a published artifact |
| 220 | +named `scancode-outputs` (or your custom `outputsArchiveName` if specified). |
| 221 | +This artifact contains all the outputs generated by the ScanCode.io pipelines in the |
| 222 | +formats you specified. |
0 commit comments