Commit 4ba133c8 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

Merge branch 'feat/vex-upload' into 'main'

feat: VEX upload

See merge request to-be-continuous/dependency-track!20
parents 0caa8abe f6d01ab7
Loading
Loading
Loading
Loading
+43 −20
Original line number Diff line number Diff line
@@ -53,11 +53,12 @@ In order to operate, this template needs a Dependency Track API Key.
Here are some details about mandatory and optional permissions used by the template:

| Permission                                  | Required?     | Explaination                                                                                                                                                                                                                                                                                                          |
| ------------------------------------------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ------------------------------------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `BOM_UPLOAD`                                | **mandatory** | Required to publish SBOM files to the Dependency Track server                                                                                                                                                                                                                                                         |
| `PROJECT_CREATION_UPLOAD`                   | **optional**  | This is required if you want to automatically create the project while uploading the SBOM files when the project does not exist (**but the parent project must exist**)                                                                                                                                               |
| `VIEW_VULNERABILITY` and `VIEW_PORTFOLIO`   | **optional**  | Required if you want to display found vulnerabilities or compute a risk score after SBOM analysis.<br/>Granting those permissions without enabling [Portfolio ACLs](https://github.com/DependencyTrack/dependency-track/issues/1127) is not recommended in the general case as it gives a read access to all projects |
| `VIEW_PORTFOLIO` and `PORTFOLIO_MANAGEMENT` | **optional**  | Required if you want to automatically create one or several project ancestors prior to uploading the SBOM files.<br/>Granting those permissions is not recommended in the general case as they virtually give administration rights to the API Key owner                                                              |
| `VULNERABILITY_ANALYSIS`                    | **optional**  | Required if you want to upload (a) VEX file(s)                                                                                                                                                                                                                                                                        |

### Multiple SBOM strategy

@@ -147,6 +148,26 @@ The corresponding Dependency Track project structure **with merged SBOMs strateg
> :bulb: this default configuration handles the Dependency Track constraint that each project name has to be globally
> unique in the server.

#### Uploading VEX information

Vulnerability Exploitability eXchange (VEX) is used to provide additional information about vulnerabilities found in your project. 
For example, they can be used to indicate that a vulnerability does not affect the project or that it has been mitigated.
This information can be stored in a file, called a VEX file.
This file should to be stored in your GIT repository along with your code.
Using a VEX file is optional, but it is highly recommended to provide additional context about the vulnerabilities found in the SBOM files.
Especially if you are using Dependency Track to keep track of vulnerabilities in multiple versions of the same project.
As otherwise you will have to manually update the VEX information in Dependency Track for each project version.

To enable VEX upload, set the `upload-vex` input / `$DEPTRACK_UPLOAD_VEX` variable to `true` (see [configuration chapter](#configuration)).
Since a single repository can have multiple SBOM files, the template will look for VEX files using the `{file_prefix}` of the SBOM file and append `.vex.json` to it to find the corresponding VEX file.
For example, if the SBOM file is named `docker-sbom.cyclonedx.json`, the template will look for a VEX file named `docker-sbom.vex.json`. The VEX file needs to be stored in the same directory as the SBOM file.
VEX files need to be in the [CycloneDX format](https://cyclonedx.org).
You can either create the VEX file manually or export it from Dependency Track through the UI.

> [!tip] merging SBOMs 
> In case SBOM files are merged, you need to specify the sbom file location using the `merged-vex-file` input / `$DEPTRACK_MERGED_VEX_FILE` variable. 
> The template will then upload the VEX file to the same project as the merged SBOM file.

#### Other use cases

The default template behavior can be changed by overridding the `project-path` input / `$DEPTRACK_PROJECT_PATH` variable.
@@ -169,7 +190,7 @@ Examples:
The Dependency Track template uses the following configuration.

| Input / Variable                                                       | Description                                                                                                                       | Default value                                                                                                                                                                                                                                                             |
| ---------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| ---------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sbom-scanner-image` / `DEPTRACK_SBOM_SCANNER_IMAGE`                   | The container image with [Dependency Track SBOM Scanner](https://gitlab.com/to-be-continuous/tools/dt-sbom-scanner) tool          | `registry.gitlab.com/to-be-continuous/tools/dt-sbom-scanner:latest`         <br/>[![Trivy Badge](https://to-be-continuous.gitlab.io/doc/secu/trivy-badge-DEPTRACK_SBOM_SCANNER_IMAGE.svg)](https://to-be-continuous.gitlab.io/doc/secu/trivy-DEPTRACK_SBOM_SCANNER_IMAGE) |
| `base-api-url` / `DEPTRACK_BASE_API_URL`                               | Dependency Track server base API url (includes `/api`)                                                                            | _none_ (required)                                                                                                                                                                                                                                                         |
| :lock: `DEPTRACK_API_KEY`                                              | Dependency Track API key                                                                                                          | _none_ (required)                                                                                                                                                                                                                                                         |
@@ -179,6 +200,8 @@ The Dependency Track template uses the following configuration.
| `parent-collection-logic-tag` \ `DEPTRACK_PARENT_COLLECTION_LOGIC_TAG` | Tag for aggregation parent-collection-logic is set to TAG                                                                         | _none_                                                                                                                                                                                                                                                                    |
| `tags` / `DEPTRACK_TAGS`                                               | Tags to attach to project (comma separeted list)                                                                                  | _none_                                                                                                                                                                                                                                                                    |
| `sbom-patterns` / `DEPTRACK_SBOM_PATTERNS`                             | SBOM file patterns to publish (supports glob patterns)                                                                            | `**/*.cyclonedx.json **/*.cyclonedx.xml`                                                                                                                                                                                                                                  |
| `upload-vex` / `DEPTRACK_UPLOAD_VEX`                                   | Upload VEX file(s) connected to SBOMs to the Dependency Track server (default `false`)                                            | _none_ (disabled)                                                                                                                                                                                                                                                         |
| `merged-vex-file` / `DEPTRACK_MERGED_VEX_FILE`                                       | Location of the VEX file to upload. Only use if `upload-vex` and `merge` are enabled.                                             | _none_                                                                                                                                                                                                                                                                    |
| `merge` / `DEPTRACK_MERGE`                                             | Merge all SBOM files into one (default `false`)                                                                                   | _none_ (disabled)                                                                                                                                                                                                                                                         |
| `merge-output` / `DEPTRACK_MERGE_OUTPUT`                               | Output merged SBOM file (only used with merge enabled) - _for debugging purpose_                                                  | `reports/deptrack-merged.cyclonedx.json`                                                                                                                                                                                                                                  |
| `purl-max-len` / `DEPTRACK_PURL_MAX_LEN`                               | PURLs max length (`-1`: auto, `0`: no trim, `>0`: trim to size - default: `-1`)                                                   | `-1` (auto)                                                                                                                                                                                                                                                               |
+12 −0
Original line number Diff line number Diff line
@@ -123,6 +123,18 @@
          "advanced": true
        }
      ]
    },
    {
      "id": "vex-upload",
      "name": "Upload VEX files",
      "description": "Upload VEX file(s) connected to SBOMs to the Dependency Track server",
      "enable_with": "DEPTRACK_UPLOAD_VEX",
      "variables": [
        {
          "name": "DEPTRACK_MERGED_VEX_FILE",
          "description": "Location of the VEX file to upload. Only use if `upload-vex` and `merge` are enabled."
        }
      ]
    }
  ],
  "variants": [
+9 −0
Original line number Diff line number Diff line
@@ -50,6 +50,13 @@ spec:
    sbom-patterns:
      description: SBOM file patterns to publish (supports glob patterns)
      default: '**/*.cyclonedx.json **/*.cyclonedx.xml'
    upload-vex:
      description: Upload VEX file(s) connected to SBOMs to the Dependency Track server
      type: boolean
      default: false
    merged-vex-file:
      description: Location of the VEX file to upload. Only use if `upload-vex` and `merge` are enabled.
      default: ''
    show-findings:
      description: Wait for analysis and display found vulnerabilities in logs
      type: boolean
@@ -137,6 +144,8 @@ variables:
  DEPTRACK_MERGE_OUTPUT: $[[ inputs.merge-output ]]
  DEPTRACK_PURL_MAX_LEN: $[[ inputs.purl-max-len ]]
  DEPTRACK_SBOM_PATTERNS: $[[ inputs.sbom-patterns ]]
  DEPTRACK_UPLOAD_VEX: $[[ inputs.upload-vex ]]
  DEPTRACK_MERGED_VEX_FILE: $[[ inputs.merged-vex-file ]]
  DEPTRACK_SHOW_FINDINGS: $[[ inputs.show-findings ]]
  DEPTRACK_RISK_SCORE_THRESHOLD: $[[ inputs.risk-score-threshold ]]