diff --git a/README.md b/README.md index 20c887e..9b7cfd9 100644 --- a/README.md +++ b/README.md @@ -280,6 +280,22 @@ jobs: skip-setup-trivy: true ``` +#### Use non-default token to install Trivy +GitHub Enterprise Server (GHES) uses an invalid `github.token` for `https://github.com` server. +Therefore, you can't install `Trivy` using the `setup-trivy` action. + +To fix this problem, you need to overwrite the token for `setup-trivy` using `token-setup-trivy` input: +```yaml + - name: Run Trivy scanner without cache + uses: aquasecurity/trivy-action@0.28.0 + with: + scan-type: 'fs' + scan-ref: '.' + token-setup-trivy: ${{ secrets.GITHUB_PAT }} +``` + +GitHub even has [create-github-app-token](https://github.com/actions/create-github-app-token) for similar cases. + ### Scanning a Tarball ```yaml name: build @@ -814,7 +830,7 @@ Following inputs can be used as `step.with` keys: | `image-ref` | String | | Image reference, e.g. `alpine:3.10.2` | | `scan-ref` | String | `/github/workspace/` | Scan reference, e.g. `/github/workspace/` or `.` | | `format` | String | `table` | Output format (`table`, `json`, `template`, `sarif`, `cyclonedx`, `spdx`, `spdx-json`, `github`, `cosign-vuln`) | -| `template` | String | | Output template (`@./$HOME/.local/bin/trivy-bin/contrib/gitlab.tpl`, `@./$HOME/.local/bin/trivy-bin//contrib/junit.tpl`) | +| `template` | String | | Output template (`@$HOME/.local/bin/trivy-bin/contrib/gitlab.tpl`, `@$HOME/.local/bin/trivy-bin//contrib/junit.tpl`) | | `tf-vars` | String | | path to Terraform variables file | | `output` | String | | Save results to a file | | `exit-code` | String | `0` | Exit code when specified vulnerabilities are found | @@ -834,8 +850,9 @@ Following inputs can be used as `step.with` keys: | `github-pat` | String | | Authentication token to enable sending SBOM scan results to GitHub Dependency Graph. Can be either a GitHub Personal Access Token (PAT) or GITHUB_TOKEN | | `limit-severities-for-sarif` | Boolean | false | By default *SARIF* format enforces output of all vulnerabilities regardless of configured severities. To override this behavior set this parameter to **true** | | `docker-host` | String | | By default it is set to `unix://var/run/docker.sock`, but can be updated to help with containerized infrastructure values | -| `version` | String | `v0.56.1` | Trivy version to use, e.g. `latest` or `v0.56.1` | +| `version` | String | `v0.56.2` | Trivy version to use, e.g. `latest` or `v0.56.2` | | `skip-setup-trivy` | Boolean | false | Skip calling the `setup-trivy` action to install `trivy` | +| `token-setup-trivy` | Boolean | | Overwrite `github.token` used by `setup-trivy` to checkout the `trivy` repository | ### Environment variables You can use [Trivy environment variables][trivy-env] to set the necessary options (including flags that are not supported by [Inputs](#inputs), such as `--secret-config`). diff --git a/action.yaml b/action.yaml index 060cbe2..b42ab4d 100644 --- a/action.yaml +++ b/action.yaml @@ -107,6 +107,15 @@ inputs: description: 'skip calling the setup-trivy action to install trivy' required: false default: 'false' + token-setup-trivy: + description: > + `token-setup-trivy` is required when `github.token` in invalid for `https://github.com` server. + See https://github.com/aquasecurity/setup-trivy/?tab=readme-ov-file#install-trivy-with-non-default-token for more details. + `token-setup-trivy` is only used to fetch the Trivy repository in `setup-trivy` + required: false + ## ${{ github.token }} is default value for actions/checkout + ## cf. https://github.com/actions/checkout/blob/eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871/action.yml#L24 + default: ${{ github.token }} runs: using: 'composite' @@ -117,6 +126,7 @@ runs: with: version: ${{ inputs.version }} cache: ${{ inputs.cache }} + token: ${{ inputs.token-setup-trivy }} - name: Get current date id: date