trivy
Trivy détecte nativement les misconfigurations dans un plan Terraform/OpenTofuexporté en JSON (`tofu show -json`). Ce module est conçu pour consommer
l'artefact produit par le module iac/terraform (PlanArtifact).
Installation
dagger install dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/security/trivy@26c90e9dec833e21f871202fd0d4648c547bcdf2Entrypoint
Return Type
Trivy ! Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/security/trivy@26c90e9dec833e21f871202fd0d4648c547bcdf2 call \
func (m *MyModule) Example() *dagger.Trivy {
return dag.
Trivy()
}@function
def example() -> dagger.Trivy:
return (
dag.trivy()
)@func()
example(): Trivy {
return dag
.trivy()
}Types
Trivy 🔗
version() 🔗
Version de l’image aquasec/trivy
Return Type
String ! Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/security/trivy@26c90e9dec833e21f871202fd0d4648c547bcdf2 call \
versionfunc (m *MyModule) Example(ctx context.Context) string {
return dag.
Trivy().
Version(ctx)
}@function
async def example() -> str:
return await (
dag.trivy()
.version()
)@func()
async example(): Promise<string> {
return dag
.trivy()
.version()
}severity() 🔗
Sévérités à signaler (ex: “HIGH,CRITICAL”)
Return Type
String ! Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/security/trivy@26c90e9dec833e21f871202fd0d4648c547bcdf2 call \
severityfunc (m *MyModule) Example(ctx context.Context) string {
return dag.
Trivy().
Severity(ctx)
}@function
async def example() -> str:
return await (
dag.trivy()
.severity()
)@func()
async example(): Promise<string> {
return dag
.trivy()
.severity()
}registryHost() 🔗
Authentification registry (pour le scan d’images privées)
Return Type
String ! Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/security/trivy@26c90e9dec833e21f871202fd0d4648c547bcdf2 call \
registry-hostfunc (m *MyModule) Example(ctx context.Context) string {
return dag.
Trivy().
RegistryHost(ctx)
}@function
async def example() -> str:
return await (
dag.trivy()
.registry_host()
)@func()
async example(): Promise<string> {
return dag
.trivy()
.registryHost()
}registryUsername() 🔗
Return Type
String ! Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/security/trivy@26c90e9dec833e21f871202fd0d4648c547bcdf2 call \
registry-usernamefunc (m *MyModule) Example(ctx context.Context) string {
return dag.
Trivy().
RegistryUsername(ctx)
}@function
async def example() -> str:
return await (
dag.trivy()
.registry_username()
)@func()
async example(): Promise<string> {
return dag
.trivy()
.registryUsername()
}registryPassword() 🔗
Return Type
Secret ! Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/security/trivy@26c90e9dec833e21f871202fd0d4648c547bcdf2 call \
registry-passwordfunc (m *MyModule) Example() *dagger.Secret {
return dag.
Trivy().
RegistryPassword()
}@function
def example() -> dagger.Secret:
return (
dag.trivy()
.registry_password()
)@func()
example(): Secret {
return dag
.trivy()
.registryPassword()
}scanBinary() 🔗
ScanBinary scanne un binaire compilé (trivy rootfs).
Pour un binaire Go, Trivy lit les métadonnées de build embarquées par
go build et détecte les CVE sur les dépendances. Le binaire produit
par languages/go (Build) peut être chaîné directement en entrée.
Limitation : ne fonctionne pas sur les binaires compressés avec UPX (les métadonnées embarquées ne sont plus lisibles).
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| binary | File ! | - | Binaire à scanner (typiquement issu de languages/go Build) |
| failOnFindings | Boolean | true | Faire échouer le scan si des findings sont détectés |
| format | String | "table" | Format de sortie: table, json, sarif |
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/security/trivy@26c90e9dec833e21f871202fd0d4648c547bcdf2 call \
scan-binary --binary file:pathfunc (m *MyModule) Example(ctx context.Context, binary *dagger.File) string {
return dag.
Trivy().
ScanBinary(ctx, binary)
}@function
async def example(binary: dagger.File) -> str:
return await (
dag.trivy()
.scan_binary(binary)
)@func()
async example(binary: File): Promise<string> {
return dag
.trivy()
.scanBinary(binary)
}scanConfig() 🔗
ScanConfig scanne du code IaC brut (HCL, Dockerfile, Kubernetes…) dans un répertoire.
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | Répertoire contenant le code à scanner |
| subpath | String | "." | Sous-chemin relatif dans source (défaut: ".") |
| failOnFindings | Boolean | true | Faire échouer le scan si des findings sont détectés |
| format | String | "table" | Format de sortie: table, json, sarif |
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/security/trivy@26c90e9dec833e21f871202fd0d4648c547bcdf2 call \
scan-config --source DIR_PATHfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory) string {
return dag.
Trivy().
ScanConfig(ctx, source)
}@function
async def example(source: dagger.Directory) -> str:
return await (
dag.trivy()
.scan_config(source)
)@func()
async example(source: Directory): Promise<string> {
return dag
.trivy()
.scanConfig(source)
}scanFs() 🔗
ScanFs scanne le filesystem d’un projet (trivy fs).
Trivy auto-détecte les lockfiles présents : go.mod/go.sum, package-lock.json,
requirements.txt, Cargo.lock, etc. Les scanners actifs sont contrôlés via
le paramètre scanners (vide => défauts Trivy: vuln,secret).
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | Répertoire à scanner |
| subpath | String | "." | Sous-chemin relatif dans source (défaut: ".") |
| scanners | String | - | Liste de scanners séparés par virgule (ex: "vuln", "vuln,secret", "vuln,secret,misconfig"). Vide => défauts de Trivy (vuln,secret). |
| failOnFindings | Boolean | true | Faire échouer le scan si des findings sont détectés |
| format | String | "table" | Format de sortie: table, json, sarif |
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/security/trivy@26c90e9dec833e21f871202fd0d4648c547bcdf2 call \
scan-fs --source DIR_PATHfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory) string {
return dag.
Trivy().
ScanFs(ctx, source)
}@function
async def example(source: dagger.Directory) -> str:
return await (
dag.trivy()
.scan_fs(source)
)@func()
async example(source: Directory): Promise<string> {
return dag
.trivy()
.scanFs(source)
}scanFsArtifact() 🔗
ScanFsArtifact scanne le filesystem (trivy fs) en un seul passage et renvoie
un répertoire contenant le rapport (report.<ext>) et un fichier findings
(“1” si findings HIGH/CRITICAL, “0” sinon).
Contrairement à ScanFs, l’appel n’échoue jamais sur findings : le rapport est
toujours produit (à exporter via export --path), et la barrière CI se décide
en lisant findings. Cela remplace le double scan (rapport + gate) par un seul.
Return Type
Directory !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | Répertoire à scanner |
| subpath | String | "." | Sous-chemin relatif dans source (défaut: ".") |
| scanners | String | - | Liste de scanners séparés par virgule (vide => défauts Trivy: vuln,secret) |
| format | String | "sarif" | Format du rapport: table, json, sarif (défaut: sarif) |
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/security/trivy@26c90e9dec833e21f871202fd0d4648c547bcdf2 call \
scan-fs-artifact --source DIR_PATHfunc (m *MyModule) Example(source *dagger.Directory) *dagger.Directory {
return dag.
Trivy().
ScanFsArtifact(source)
}@function
def example(source: dagger.Directory) -> dagger.Directory:
return (
dag.trivy()
.scan_fs_artifact(source)
)@func()
example(source: Directory): Directory {
return dag
.trivy()
.scanFsArtifact(source)
}scanImage() 🔗
ScanImage scanne les vulnérabilités d’une image Docker (trivy image).
Pour une image d’un registry privé, configurer les identifiants au préalable via WithRegistry() : Trivy pull l’image lui-même et lit TRIVY_USERNAME / TRIVY_PASSWORD pour s’authentifier.
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| image | String ! | - | Référence complète de l'image (ex: "dordogne.azurecr.io/ad-frontend:v5") |
| ignoreUnfixed | Boolean | true | Ignorer les vulnérabilités sans correctif disponible |
| failOnFindings | Boolean | true | Faire échouer le scan si des vulnérabilités sont détectées |
| format | String | "table" | Format de sortie: table, json, sarif |
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/security/trivy@26c90e9dec833e21f871202fd0d4648c547bcdf2 call \
scan-image --image stringfunc (m *MyModule) Example(ctx context.Context, image string) string {
return dag.
Trivy().
ScanImage(ctx, image)
}@function
async def example(image: str) -> str:
return await (
dag.trivy()
.scan_image(image)
)@func()
async example(image: string): Promise<string> {
return dag
.trivy()
.scanImage(image)
}scanImageArtifact() 🔗
ScanImageArtifact scanne une image (trivy image) en un seul passage et renvoie
un répertoire contenant le rapport (report.<ext>) et un fichier findings
(“1” si vulnérabilités de la sévérité configurée, “0” sinon).
Comme ScanFsArtifact, l’appel n’échoue jamais sur findings : le rapport est
toujours produit (à exporter via export --path), et la barrière CI se décide
en lisant findings. Fusionne le couple SARIF + gate en un seul scan.
Le SBOM (inventaire complet) reste une passe distincte (portée différente).
Return Type
Directory !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| image | String ! | - | Référence complète de l'image (idéalement par digest : registre/nom@sha256:...) |
| ignoreUnfixed | Boolean | true | Ignorer les vulnérabilités sans correctif disponible |
| format | String | "sarif" | Format du rapport: table, json, sarif (défaut: sarif) |
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/security/trivy@26c90e9dec833e21f871202fd0d4648c547bcdf2 call \
scan-image-artifact --image stringfunc (m *MyModule) Example(image string) *dagger.Directory {
return dag.
Trivy().
ScanImageArtifact(image)
}@function
def example(image: str) -> dagger.Directory:
return (
dag.trivy()
.scan_image_artifact(image)
)@func()
example(image: string): Directory {
return dag
.trivy()
.scanImageArtifact(image)
}scanPlan() 🔗
ScanPlan scanne un plan Terraform/OpenTofu exporté en JSON (tofu show -json).
Trivy détecte automatiquement le format « Terraform Plan JSON » via trivy config.
Avec failOnFindings=true, la commande retourne un code non nul si une misconfiguration
d’une sévérité configurée est trouvée — ce qui fait échouer le job CI.
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| plan | File ! | - | Plan au format JSON (tfplan.json) produit par iac/terraform PlanArtifact |
| failOnFindings | Boolean | true | Faire échouer le scan si des findings sont détectés |
| format | String | "table" | Format de sortie: table, json, sarif |
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/security/trivy@26c90e9dec833e21f871202fd0d4648c547bcdf2 call \
scan-plan --plan file:pathfunc (m *MyModule) Example(ctx context.Context, plan *dagger.File) string {
return dag.
Trivy().
ScanPlan(ctx, plan)
}@function
async def example(plan: dagger.File) -> str:
return await (
dag.trivy()
.scan_plan(plan)
)@func()
async example(plan: File): Promise<string> {
return dag
.trivy()
.scanPlan(plan)
}test() 🔗
Return Type
String ! Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/security/trivy@26c90e9dec833e21f871202fd0d4648c547bcdf2 call \
testfunc (m *MyModule) Example(ctx context.Context) string {
return dag.
Trivy().
Test(ctx)
}@function
async def example() -> str:
return await (
dag.trivy()
.test()
)@func()
async example(): Promise<string> {
return dag
.trivy()
.test()
}withRegistry() 🔗
WithRegistry configure l’authentification registry pour le scan d’images privées.
Trivy s’authentifie via les variables TRIVY_USERNAME / TRIVY_PASSWORD lorsqu’il pull l’image à scanner. Utiliser env:VAR_NAME pour les identifiants.
Return Type
Trivy !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| host | String ! | - | Hôte du registry (ex: "dordogne.azurecr.io") |
| username | String ! | - | Nom d'utilisateur du registry |
| password | Secret ! | - | Mot de passe / token du registry |
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/security/trivy@26c90e9dec833e21f871202fd0d4648c547bcdf2 call \
with-registry --host string --username string --password env:MYSECRETfunc (m *MyModule) Example(host string, username string, password *dagger.Secret) *dagger.Trivy {
return dag.
Trivy().
WithRegistry(host, username, password)
}@function
def example(host: str, username: str, password: dagger.Secret) -> dagger.Trivy:
return (
dag.trivy()
.with_registry(host, username, password)
)@func()
example(host: string, username: string, password: Secret): Trivy {
return dag
.trivy()
.withRegistry(host, username, password)
}withSeverity() 🔗
WithSeverity définit les sévérités à signaler, ex: “CRITICAL” ou “HIGH,CRITICAL”.
Return Type
Trivy !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| severity | String ! | - | No description provided |
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/security/trivy@26c90e9dec833e21f871202fd0d4648c547bcdf2 call \
with-severity --severity stringfunc (m *MyModule) Example(severity string) *dagger.Trivy {
return dag.
Trivy().
WithSeverity(severity)
}@function
def example(severity: str) -> dagger.Trivy:
return (
dag.trivy()
.with_severity(severity)
)@func()
example(severity: string): Trivy {
return dag
.trivy()
.withSeverity(severity)
}withVersion() 🔗
WithVersion définit la version de l’image Trivy (pattern immuable).
Return Type
Trivy !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| version | String ! | - | No description provided |
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/security/trivy@26c90e9dec833e21f871202fd0d4648c547bcdf2 call \
with-version --version stringfunc (m *MyModule) Example(version string) *dagger.Trivy {
return dag.
Trivy().
WithVersion(version)
}@function
def example(version: str) -> dagger.Trivy:
return (
dag.trivy()
.with_version(version)
)@func()
example(version: string): Trivy {
return dag
.trivy()
.withVersion(version)
}