
Esegue Trivy come GitHub Action per scansionare l'immagine del tuo container Docker alla ricerca di vulnerabilità.
GitHub Action per Trivy
[![GitHub Release][release-img]][release] [![GitHub Marketplace][marketplace-img]][marketplace] [![License][license-img]][license]

name: build on: push: branches: - main pull_request: jobs: build: name: Build runs-on: ubuntu-24.04 steps: - name: Checkout code uses: actions/checkout@v4 - name: Build an image from Dockerfile run: docker build -t docker.io/my-organization/my-app:${{ github.sha }} . - name: Run Trivy vulnerability scanner uses: aquasecurity/[email protected] with: image-ref: 'docker.io/my-organization/my-app:${{ github.sha }}' format: 'table' exit-code: '1' ignore-unfixed: true vuln-type: 'os,library' severity: 'CRITICAL,HIGH'
### Pipeline CI di scansione (con configurazione Trivy)```yaml
name: build
on:
push:
branches:
- main
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner in fs mode
uses: aquasecurity/[email protected]
with:
scan-type: 'fs'
scan-ref: '.'
trivy-config: trivy.yaml
In questo caso trivy.yaml è una configurazione YAML che viene inclusa come parte del repository. Informazioni dettagliate sono disponibili sul sito web di Trivy, ma un esempio è il seguente:```yaml
format: json
exit-code: 1
severity: CRITICAL
secret:
config: config/trivy/secret.yaml
È possibile definire tutte le opzioni nel file `trivy.yaml`. La specifica delle singole opzioni tramite l'azione è mantenuta per scopi di retrocompatibilità. È necessario definire quanto segue poiché non possono essere definiti tramite il file di configurazione:
- `scan-ref`: se si utilizzano scansioni `fs, repo`.
- `image-ref`: se si utilizza la scansione `image`.
- `scan-type`: per definire il tipo di scansione, ad es. `image`, `fs`, `repo`, ecc.
#### Ordine di preferenza per le opzioni
Trivy utilizza [Viper](https://github.com/spf13/viper) che ha un ordine di precedenza definito per le opzioni. L'ordine è il seguente:
- Flag dell'azione GitHub
- Variabile d'ambiente
- File di configurazione
- Predefinito
### Cache
L'azione ha una funzionalità integrata per la memorizzazione nella cache e il ripristino del [database delle vulnerabilità](https://github.com/aquasecurity/trivy-db), del [database Java](https://github.com/aquasecurity/trivy-java-db) e del [bundle dei controlli](https://github.com/aquasecurity/trivy-checks) se vengono scaricati durante la scansione.
La cache viene archiviata nella directory `$GITHUB_WORKSPACE/.cache/trivy` per impostazione predefinita.
La cache viene ripristinata prima dell'avvio della scansione e salvata dopo il termine della scansione.
Utilizza [actions/cache](https://github.com/actions/cache) internamente, ma richiede meno impostazioni di configurazione.
L'input `cache` è opzionale e la memorizzazione nella cache è attivata per impostazione predefinita.
#### Disattivazione della cache
Se si desidera disattivare la cache, impostare l'input `cache` su `false`, ma si consiglia di mantenerla attiva per evitare problemi di rate limiting.```yaml
- name: Run Trivy scanner without cache
uses: aquasecurity/[email protected]
with:
scan-type: 'fs'
scan-ref: '.'
cache: 'false'
Si noti che esistono restrizioni sull'accesso alla cache tra i rami in GitHub Actions.
Per impostazione predefinita, un flusso di lavoro può accedere e ripristinare una cache creata nel ramo corrente o nel ramo predefinito (di solito main o master).
Se è necessario condividere le cache tra i rami, potrebbe essere necessario creare una cache nel ramo predefinito e ripristinarla nel ramo corrente.
Per ottimizzare il flusso di lavoro, è possibile impostare un processo cron per aggiornare regolarmente la cache nel ramo predefinito. Ciò consente alle scansioni successive di utilizzare il database memorizzato nella cache senza doverlo scaricare nuovamente.```yaml
name: Update Trivy Cache
on: schedule: - cron: '0 0 * * *' # Run daily at midnight UTC workflow_dispatch: # Allow manual triggering
jobs: update-trivy-db: runs-on: ubuntu-latest steps: - name: Setup oras uses: oras-project/setup-oras@v1
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Download and extract the vulnerability DB
run: |
mkdir -p $GITHUB_WORKSPACE/.cache/trivy/db
oras pull ghcr.io/aquasecurity/trivy-db:2
tar -xzf db.tar.gz -C $GITHUB_WORKSPACE/.cache/trivy/db
rm db.tar.gz
- name: Download and extract the Java DB
run: |
mkdir -p $GITHUB_WORKSPACE/.cache/trivy/java-db
oras pull ghcr.io/aquasecurity/trivy-java-db:1
tar -xzf javadb.tar.gz -C $GITHUB_WORKSPACE/.cache/trivy/java-db
rm javadb.tar.gz
- name: Cache DBs
uses: actions/cache/save@v4
with:
path: ${{ github.workspace }}/.cache/trivy
key: cache-trivy-${{ steps.date.outputs.date }}
When running a scan, set the environment variables `TRIVY_SKIP_DB_UPDATE` and `TRIVY_SKIP_JAVA_DB_UPDATE` to skip the download process.```yaml
- name: Run Trivy scanner without downloading DBs
uses: aquasecurity/[email protected]
with:
scan-type: 'image'
scan-ref: 'myimage'
env:
TRIVY_SKIP_DB_UPDATE: true
TRIVY_SKIP_JAVA_DB_UPDATE: true
Per impostazione predefinita, l'azione chiama aquasecurity/setup-trivy come primo passo,
che installa la versione di trivy specificata dall'input version. Se hai già installato trivy con altri mezzi,
ad es. chiamando direttamente aquasecurity/setup-trivy, o se stai invocando questa azione più volte, puoi usare
l'input skip-setup-trivy per disabilitare questo passaggio.
name: build on: push: branches: - main pull_request: jobs: build: name: Build runs-on: ubuntu-24.04 steps: - name: Checkout code uses: actions/checkout@v4
- name: Manual Trivy Setup
uses: aquasecurity/[email protected]
with:
cache: true
version: v0.72.0
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/[email protected]
with:
scan-type: 'fs'
ignore-unfixed: true
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL'
skip-setup-trivy: true
#### Saltare il setup quando si chiama Trivy Action più volte
Un altro caso d'uso comune è quando una build chiama questa action più volte; in questo caso possiamo impostare `skip-setup-trivy` su
`true` nelle invocazioni successive, ad es.```yaml
name: build
on:
push:
branches:
- main
pull_request:
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out Git repository
uses: actions/checkout@v4
# The first call to the action will invoke setup-trivy and install trivy
- name: Generate Trivy Vulnerability Report
uses: aquasecurity/[email protected]
with:
scan-type: "fs"
output: trivy-report.json
format: json
scan-ref: .
exit-code: 0
- name: Upload Vulnerability Scan Results
uses: actions/upload-artifact@v4
with:
name: trivy-report
path: trivy-report.json
retention-days: 30
- name: Fail build on High/Criticial Vulnerabilities
uses: aquasecurity/[email protected]
with:
scan-type: "fs"
format: table
scan-ref: .
severity: HIGH,CRITICAL
ignore-unfixed: true
exit-code: 1
# On a subsequent call to the action we know trivy is already installed so can skip this
skip-setup-trivy: true
GitHub Enterprise Server (GHES) utilizza un github.token non valido per il server https://github.com.
Pertanto, non puoi installare Trivy utilizzando l'azione setup-trivy.
Per risolvere questo problema, devi sovrascrivere il token per setup-trivy usando l'input token-setup-trivy:```yaml
- name: Run Trivy scanner without cache
uses: aquasecurity/[email protected]
with:
scan-type: 'fs'
scan-ref: '.'
token-setup-trivy: ${{ secrets.GITHUB_PAT }}
GitHub ha anche [create-github-app-token](https://github.com/actions/create-github-app-token) per casi simili.
### Scansione di un Tarball```yaml
name: build
on:
push:
branches:
- main
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Generate tarball from image
run: |
docker pull <your-docker-image>
docker save -o vuln-image.tar <your-docker-image>
- name: Run Trivy vulnerability scanner in tarball mode
uses: aquasecurity/[email protected]
with:
input: /github/workspace/vuln-image.tar
severity: 'CRITICAL,HIGH'
L'azione supporta i [Trivy templates][trivy-templates].
Usa l'input template per specificare il percorso (ricorda di anteporre @ al percorso) del file di template.```yaml
name: build
on:
push:
branches:
- main
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/[email protected]
with:
scan-type: "fs"
scan-ref: .
format: 'template'
template: "@path/to/my_template.tpl"
#### Template predefiniti
Trivy ha [template predefiniti][trivy-default-templates].
Per impostazione predefinita, `setup-trivy` li installa nella directory `$HOME/.local/bin/trivy-bin/contrib`.```yaml
name: build
on:
push:
branches:
- main
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/[email protected]
with:
scan-type: "fs"
scan-ref: .
format: 'template'
template: "@$HOME/.local/bin/trivy-bin/contrib/html.tpl"
Se disponi di GitHub code scanning puoi utilizzare Trivy come strumento di scansione come segue:```yaml name: build on: push: branches: - main pull_request: jobs: build: name: Build runs-on: ubuntu-24.04 permissions: contents: read # Required to checkout and read repo files security-events: write # Required to upload SARIF files to Security tab steps: - name: Checkout code uses: actions/checkout@v4
- name: Build an image from Dockerfile
run: |
docker build -t docker.io/my-organization/my-app:${{ github.sha }} .
- name: Run Trivy vulnerability scanner
uses: aquasecurity/[email protected]
with:
image-ref: 'docker.io/my-organization/my-app:${{ github.sha }}'
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: 'trivy-results.sarif'
Puoi trovare un esempio più approfondito qui: https://github.com/aquasecurity/trivy-sarif-demo/blob/master/.github/workflows/scan.yml
Se desideri caricare i risultati SARIF su GitHub Code scanning anche quando Trivy Scan termina con un codice di uscita diverso da zero, puoi aggiungere quanto segue al tuo passaggio di upload:```yaml
name: build
on:
push:
branches:
- main
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-24.04
permissions:
contents: read # Required to checkout and read repo files
security-events: write # Required to upload SARIF files to Security tab
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build an image from Dockerfile
run: |
docker build -t docker.io/my-organization/my-app:${{ github.sha }} .
- name: Run Trivy vulnerability scanner
uses: aquasecurity/[email protected]
with:
image-ref: 'docker.io/my-organization/my-app:${{ github.sha }}'
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v4
if: always()
with:
sarif_file: 'trivy-results.sarif'
Vedi qui per maggiori dettagli: https://docs.github.com/en/actions/learn-github-actions/expressions#always
È anche possibile scansionare i tuoi repository git con la scansione del repository integrata di Trivy. Questo può essere utile se vuoi eseguire Trivy come controllo in fase di build su ogni PR che viene aperta nel tuo repository. Questo ti aiuta a identificare potenziali vulnerabilità che potrebbero essere introdotte con ogni PR.
Se disponi di GitHub code scanning, puoi utilizzare Trivy come strumento di scansione come segue:```yaml name: build on: push: branches: - main pull_request: jobs: build: name: Build runs-on: ubuntu-24.04 permissions: contents: read # Required to checkout and read repo files security-events: write # Required to upload SARIF files to Security tab steps: - name: Checkout code uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/[email protected]
with:
scan-type: 'fs'
ignore-unfixed: true
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: 'trivy-results.sarif'
### Utilizzo di Trivy per scansionare le directory rootfs
È anche possibile scansionare le directory rootfs con la scansione rootfs integrata di Trivy. Questo può essere utile se si desidera eseguire Trivy come controllo in fase di build su ogni PR aperta nel repository. Questo aiuta a identificare potenziali vulnerabilità che potrebbero essere introdotte con ogni PR.
Se disponete della [scansione del codice GitHub](https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/about-code-scanning) potete utilizzare Trivy come strumento di scansione come segue:```yaml
name: build
on:
push:
branches:
- main
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-24.04
permissions:
contents: read # Required to checkout and read repo files
security-events: write # Required to upload SARIF files to Security tab
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner with rootfs command
uses: aquasecurity/[email protected]
with:
scan-type: 'rootfs'
scan-ref: 'rootfs-example-binary'
ignore-unfixed: true
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: 'trivy-results.sarif'
È anche possibile scansionare i tuoi repository IaC con la scansione repository integrata di Trivy. Questo può essere utile se vuoi eseguire Trivy come controllo in fase di build su ogni PR che viene aperta nel tuo repository. Questo ti aiuta a identificare potenziali vulnerabilità che potrebbero essere introdotte con ogni PR.
Se hai GitHub code scanning disponibile, puoi utilizzare Trivy come strumento di scansione come segue:```yaml name: build on: push: branches: - main pull_request: jobs: build: name: Build runs-on: ubuntu-24.04 permissions: contents: read # Required to checkout and read repo files security-events: write # Required to upload SARIF files to Security tab steps: - name: Checkout code uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner in IaC mode
uses: aquasecurity/[email protected]
with:
scan-type: 'config'
hide-progress: true
format: 'sarif'
output: 'trivy-results.sarif'
exit-code: '1'
severity: 'CRITICAL,HIGH'
- name: Upload Trivy scan results to GitHub Security tab
if: always()
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: 'trivy-results.sarif'
**Nota**: se la configurazione Terraform contiene moduli privati, configura Git per autenticarsi con il repository che li ospita.
Questa operazione può essere eseguita aggiungendo un passaggio nel flusso di lavoro CI che configura l'accesso, ad esempio utilizzando un Personal Access Token (PAT) o chiavi SSH:```yaml
- name: Configure Git for private modules
run: |
git config --global url."https://$GITHUB_USER:[email protected]/".insteadOf "https://github.com/"
env:
GITHUB_USER: ${{ github.actor }}
PRIVATE_REPO_TOKEN: ${{ secrets.PRIVATE_REPO_TOKEN }}
Ciò garantisce che Trivy possa scaricare moduli privati.
È possibile che Trivy generi una SBOM delle tue dipendenze e la invii a un consumatore come GitHub Dependency Graph.
La funzionalità di invio di una SBOM a GitHub è disponibile solo se hai GitHub Dependency Graph abilitata nel tuo repository.
GITHUB_TOKEN):```yamlname: Generate SBOM on: push: branches: - main
permissions: contents: write
jobs: generate-sbom: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4
- name: Run Trivy in GitHub SBOM mode and submit results to Dependency Graph
uses: aquasecurity/[email protected]
with:
scan-type: 'fs'
format: 'github'
output: 'dependency-results.sbom.json'
scan-ref: '.'
github-pat: ${{ secrets.GITHUB_TOKEN }} # or ${{ secrets.github_pat_name }} if you're using a PAT
Quando si scansionano le immagini, potresti voler analizzare l'output JSON effettivo, poiché Github Dependency non mostra tutti i dettagli, come ad esempio il percorso di ogni dipendenza.
Puoi caricare il report come artefatto e scaricarlo, ad esempio utilizzando l'[azione upload-artifact](https://github.com/actions/upload-artifact):```yaml
---
name: Generate SBOM
on:
push:
branches:
- main
## GITHUB_TOKEN authentication, add only if you're not going to use a PAT
permissions:
contents: write
jobs:
generate-sbom:
runs-on: ubuntu-latest
steps:
- name: Scan image in a private registry
uses: aquasecurity/[email protected]
with:
image-ref: "private_image_registry/image_name:image_tag"
scan-type: image
format: 'github'
output: 'dependency-results.sbom.json'
github-pat: ${{ secrets.GITHUB_TOKEN }} # or ${{ secrets.github_pat_name }} if you're using a PAT
severity: "MEDIUM,HIGH,CRITICAL"
scanners: "vuln"
env:
TRIVY_USERNAME: "image_registry_admin_username"
TRIVY_PASSWORD: "image_registry_admin_password"
- name: Upload trivy report as a Github artifact
uses: actions/upload-artifact@v4
with:
name: trivy-sbom-report
path: '${{ github.workspace }}/dependency-results.sbom.json'
retention-days: 20 # 90 is the default
È anche possibile scansionare il tuo registry privato con la scansione immagini integrata di Trivy. Tutto quello che devi fare è impostare le variabili ENV.
Docker Hub richiede TRIVY_USERNAME e TRIVY_PASSWORD.
Non è necessario impostare le variabili ENV quando si scarica da un repository pubblico.```yaml
name: build
on:
push:
branches:
- main
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-24.04
permissions:
contents: read # Required to checkout and read repo files
security-events: write # Required to upload SARIF results to the GitHub Security tab
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/[email protected]
with:
image-ref: 'docker.io/my-organization/my-app:${{ github.sha }}'
format: 'sarif'
output: 'trivy-results.sarif'
env:
TRIVY_USERNAME: Username
TRIVY_PASSWORD: Password
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: 'trivy-results.sarif'
#### AWS ECR (Elastic Container Registry)
Trivy usa l'AWS SDK. Non è necessario installare lo strumento CLI `aws`.
Puoi usare le [variabili d'ambiente della CLI AWS][env-var].
[env-var]: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html%60%60%60yaml
name: build
on:
push:
branches:
- main
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-24.04
permissions:
contents: read # Required to checkout and read repo files
security-events: write # Required to upload SARIF files to Security tab
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/[email protected]
with:
image-ref: 'aws_account_id.dkr.ecr.region.amazonaws.com/imageName:${{ github.sha }}'
format: 'sarif'
output: 'trivy-results.sarif'
env:
AWS_ACCESS_KEY_ID: key_id
AWS_SECRET_ACCESS_KEY: access_key
AWS_DEFAULT_REGION: us-west-2
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: 'trivy-results.sarif'
Trivy usa Google Cloud SDK. Non è necessario installare il comando gcloud.
Se desideri utilizzare il repository del progetto di destinazione, puoi impostarlo tramite GOOGLE_APPLICATION_CREDENTIALS.```yaml
name: build
on:
push:
branches:
- main
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-24.04
permissions:
contents: read # Required to checkout and read repo files
security-events: write # Required to upload SARIF files to Security tab
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/[email protected]
with:
image-ref: 'docker.io/my-organization/my-app:${{ github.sha }}'
format: 'sarif'
output: 'trivy-results.sarif'
env:
GOOGLE_APPLICATION_CREDENTIALS: /path/to/credential.json
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: 'trivy-results.sarif'
#### Self-Hosted
Il server BasicAuth richiede `TRIVY_USERNAME` e `TRIVY_PASSWORD`.
se vuoi usare la porta 80, usa NonSSL `TRIVY_NON_SSL=true````yaml
name: build
on:
push:
branches:
- main
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-24.04
permissions:
contents: read # Required to checkout and read repo files
security-events: write # Required to upload SARIF files to Security tab
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/[email protected]
with:
image-ref: 'docker.io/my-organization/my-app:${{ github.sha }}'
format: 'sarif'
output: 'trivy-results.sarif'
env:
TRIVY_USERNAME: Username
TRIVY_PASSWORD: Password
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: 'trivy-results.sarif'
È anche possibile visualizzare un risultato di scansione in un riepilogo del workflow.
Questo passaggio è particolarmente utile per repository privati senza licenza GitHub Advanced Security.```yaml
name: Run Trivy scanner uses: aquasecurity/[email protected] with: scan-type: config hide-progress: true output: trivy.txt
name: Publish Trivy Output to Summary run: | if [[ -s trivy.txt ]]; then { echo "### Security Output" echo "
terraform' cat trivy.txt echo ''
echo "## Personalizzazione
Priorità di configurazione:
- [Input](#inputs)
- [Variabili d'ambiente](#environment-variables)
- [File di configurazione di Trivy](#trivy-config-file)
- Valori predefiniti
### inputs
I seguenti input possono essere usati come chiavi `step.with`:
| Nome | Tipo | Default | Descrizione |
|------------------------------|---------|------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `scan-type` | String | `image` | Tipo di scansione, es. `image` o `fs` |
| `input` | String | | Riferimento Tar, es. `alpine-latest.tar` |
| `image-ref` | String | | Riferimento immagine, es. `alpine:3.10.2` |
| `scan-ref` | String | `/github/workspace/` | Riferimento di scansione, es. `/github/workspace/` o `.` |
| `format` | String | `table` | Formato di output (`table`, `json`, `template`, `sarif`, `cyclonedx`, `spdx`, `spdx-json`, `github`, `cosign-vuln`) |
| `template` | String | | Template di output (`@$HOME/.local/bin/trivy-bin/contrib/gitlab.tpl`, `@$HOME/.local/bin/trivy-bin/contrib/junit.tpl`) |
| `tf-vars` | String | | percorso del file delle variabili Terraform |
| `output` | String | | Salva i risultati in un file |
| `exit-code` | String | `0` | Codice di uscita quando vengono rilevate le vulnerabilità specificate |
| `ignore-unfixed` | Boolean | false | Ignora le vulnerabilità non corrette/non risolte |
| `vuln-type` | String | `os,library` | Tipi di vulnerabilità (os,library) |
| `severity` | String | `UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL` | Livelli di gravità delle vulnerabilità da cercare e visualizzare |
| `skip-dirs` | String | | Elenco separato da virgole delle directory in cui l'attraversamento viene saltato |
| `skip-files` | String | | Elenco separato da virgole dei file in cui l'attraversamento viene saltato |
| `cache-dir` | String | `$GITHUB_WORKSPACE/.cache/trivy` | Directory della cache. NOTA: questo valore non può essere configurato da `trivy.yaml`. |
| `timeout` | String | `5m0s` | Durata del timeout di scansione |
| `ignore-policy` | String | | Filtra le vulnerabilità con il linguaggio OPA rego |
| `hide-progress` | String | `false` | Sopprime la barra di avanzamento e l'output dei log |
| `list-all-pkgs` | String | | Genera l'output di tutti i pacchetti indipendentemente dalla vulnerabilità |
| `scanners` | String | `vuln,secret` | elenco separato da virgole dei problemi di sicurezza da rilevare (`vuln`,`secret`,`misconfig`,`license`) |
| `trivyignores` | String | | elenco separato da virgole di percorsi relativi all'interno del repository verso uno o più file `.trivyignore`, o un singolo file `.trivyignore.yaml`. |
| `trivy-config` | String | | Percorso del file di configurazione trivy.yaml |
| `github-pat` | String | | Token di autenticazione per abilitare l'invio dei risultati della scansione SBOM al GitHub Dependency Graph. Può essere un GitHub Personal Access Token (PAT) o GITHUB_TOKEN |
| `limit-severities-for-sarif` | Boolean | false | Di default il formato *SARIF* impone l'output di tutte le vulnerabilità indipendentemente dalle severità configurate. Per sovrascrivere questo comportamento, impostare questo parametro su **true** |
| `docker-host` | String | | Di default è impostato su `unix://var/run/docker.sock`, ma può essere aggiornato per supportare infrastrutture containerizzate (è richiesto `unix:/` o un altro prefisso) |
| `version` | String | `v0.72.0` | Versione di Trivy da usare, es. `latest` o `v0.72.0` |
| `skip-setup-trivy` | Boolean | false | Salta la chiamata all'azione `setup-trivy` per installare `trivy` |
| `token-setup-trivy` | Boolean | | Sovrascrive `github.token` usato da `setup-trivy` per effettuare il checkout del repository `trivy` |
### Variabili d'ambiente
Puoi utilizzare le [variabili d'ambiente di Trivy][trivy-env] per impostare le opzioni necessarie (inclusi i flag non supportati dagli [Input](#inputs), come `--secret-config`).
**NB** In alcune versioni precedenti dell'Azione c'era un bug che causava la propagazione degli input di una chiamata all'Azione alle
chiamate successive. Questo poteva far sì che i workflow che chiamano l'Azione più volte, ad esempio per eseguire
più scansioni, o le stesse scansioni con formati di output diversi, non producessero l'output desiderato. Puoi verificare se
questo è il caso osservando le informazioni del passaggio di GitHub Actions: se la sezione `env` mostrata nell'output delle tue Actions
contiene variabili d'ambiente `TRIVY_*` che non hai impostato esplicitamente, potresti essere interessato da questo bug e dovresti
aggiornare all'ultima versione dell'Azione.
### File di configurazione di Trivy
Quando si utilizza l'[Input](#inputs) `trivy-config`, è possibile impostare le opzioni usando il [file di configurazione di Trivy][trivy-config] (inclusi i flag non supportati dagli [Input](#inputs), come `--secret-config`).
[release]: https://github.com/aquasecurity/trivy-action/releases/latest
[release-img]: https://img.shields.io/github/release/aquasecurity/trivy-action.svg?logo=github
[marketplace]: https://github.com/marketplace/actions/aqua-security-trivy
[marketplace-img]: https://img.shields.io/badge/marketplace-trivy--action-blue?logo=github
[license]: https://raw.githubusercontent.com/aquasecurity/trivy-action/master/LICENSE
[license-img]: https://img.shields.io/github/license/aquasecurity/trivy-action
[trivy-env]: https://aquasecurity.github.io/trivy/latest/docs/configuration/#environment-variables
[trivy-config]: https://aquasecurity.github.io/trivy/latest/docs/references/configuration/config-file/
[trivy-templates]: https://aquasecurity.github.io/trivy/latest/docs/configuration/reporting/#template
[trivy-default-templates]: https://aquasecurity.github.io/trivy/latest/docs/configuration/reporting/#template