trivy
Find vulnerabilities, misconfigurations, secrets, SBOM in containers, Kubernetes, code repositories, clouds and more.
Example (Init)
no available example in current languagefunc (m *Examples) Trivy_Init() {
dag.Trivy(dagger.TrivyOpts{
// Persist cache between runs
Cache: dag.CacheVolume("trivy"),
}).
// Preheat vulnerability database cache
DownloadDb()
}no available example in current languageno available example in current languageExample (Container)
no available example in current languagefunc (m *Examples) Trivy_Container(ctx context.Context) error {
// Initialize Trivy module
trivy := m.trivy()
// Grab or build a container
container := dag.Container().From("alpine:latest")
// Scan the container
report := trivy.Container(container)
// Grab the the report output
{
output, err := report.Output(ctx)
if err != nil {
return err
}
_ = output
}
// Grab the report as a file
{
output, err := report.Report(dagger.TrivyScanReportOpts{
Format: "json",
}).Sync(ctx)
if err != nil {
return err
}
_ = output
}
return nil
}no available example in current languageno available example in current languageInstallation
dagger install github.com/sagikazarmark/daggerverse/trivy@v0.1.0Entrypoint
Return Type
Trivy !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| version | String | - | Version (image tag) to use from the official image repository as a base container. |
| container | Container | - | Custom container to use as a base container. Takes precedence over version. |
| config | File | - | Trivy configuration file. |
| cache | CacheVolume | - | Persist Trivy cache between runs. |
Example
dagger -m github.com/sagikazarmark/daggerverse/trivy@d7b73b82451aac826822879a451de57e20238d8f 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 🔗
downloadDb() 🔗
Download vulnerability database.
This is done automatically when scanning, but can be called manually to warm the cache. This is useful when a cache volume is used.
Return Type
Trivy !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| repository | String | - | Override the default Trivy database URL. |
Example
dagger -m github.com/sagikazarmark/daggerverse/trivy@d7b73b82451aac826822879a451de57e20238d8f call \
download-dbfunc (m *MyModule) Example() *dagger.Trivy {
return dag.
Trivy().
DownloadDb()
}@function
def example() -> dagger.Trivy:
return (
dag.trivy()
.download_db()
)@func()
example(): Trivy {
return dag
.trivy()
.downloadDb()
}container() 🔗
Scan a container.
Return Type
Scan !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| container | Container ! | - | Image container to scan. |
| config | File | - | Trivy configuration file. |
Example
dagger -m github.com/sagikazarmark/daggerverse/trivy@d7b73b82451aac826822879a451de57e20238d8f call \
container --container IMAGE:TAGfunc (m *MyModule) Example(container *dagger.Container) *dagger.TrivyScan {
return dag.
Trivy().
Container(container)
}@function
def example(container: dagger.Container) -> dagger.TrivyScan:
return (
dag.trivy()
.container(container)
)@func()
example(container: Container): TrivyScan {
return dag
.trivy()
.container(container)
}Scan 🔗
output() 🔗
Get the scan results.
Return Type
String ! Example
dagger -m github.com/sagikazarmark/daggerverse/trivy@d7b73b82451aac826822879a451de57e20238d8f call \
container --container IMAGE:TAG \
outputfunc (m *MyModule) Example(ctx context.Context, container *dagger.Container) string {
return dag.
Trivy().
Container(container).
Output(ctx)
}@function
async def example(container: dagger.Container) -> str:
return await (
dag.trivy()
.container(container)
.output()
)@func()
async example(container: Container): Promise<string> {
return dag
.trivy()
.container(container)
.output()
}report() 🔗
Get the scan report as a file.
Return Type
File !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| format | String | - | Trivy report format. |
Example
dagger -m github.com/sagikazarmark/daggerverse/trivy@d7b73b82451aac826822879a451de57e20238d8f call \
container --container IMAGE:TAG \
reportfunc (m *MyModule) Example(container *dagger.Container) *dagger.File {
return dag.
Trivy().
Container(container).
Report()
}@function
def example(container: dagger.Container) -> dagger.File:
return (
dag.trivy()
.container(container)
.report()
)@func()
example(container: Container): File {
return dag
.trivy()
.container(container)
.report()
}