Dagger
Search

trivy

Find vulnerabilities, misconfigurations, secrets, SBOM in containers, Kubernetes, code repositories, clouds and more.

Example (Init)
no available example in current language
func (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 language
no available example in current language
Example (Container)
no available example in current language
func (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 language
no available example in current language

Installation

dagger install github.com/sagikazarmark/daggerverse/trivy@v0.1.0

Entrypoint

Return Type
Trivy !
Arguments
NameTypeDescription
versionString Version (image tag) to use from the official image repository as a base container.
containerContainer Custom container to use as a base container. Takes precedence over version.
configFile Trivy configuration file.
cacheCacheVolume Persist Trivy cache between runs.
Example
dagger -m github.com/sagikazarmark/daggerverse/trivy@d7b73b82451aac826822879a451de57e20238d8f call \
func (m *myModule) example() *Trivy  {
	return dag.
			Trivy()
}
@function
def example() -> dag.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
NameTypeDefault ValueDescription
repositoryString -Override the default Trivy database URL.
Example
dagger -m github.com/sagikazarmark/daggerverse/trivy@d7b73b82451aac826822879a451de57e20238d8f call \
 download-db
func (m *myModule) example() *Trivy  {
	return dag.
			Trivy().
			DownloadDb()
}
@function
def example() -> dag.Trivy:
	return (
		dag.trivy()
		.download_db()
	)
@func()
example(): Trivy {
	return dag
		.trivy()
		.downloadDb()
}

container() 🔗

Scan a container.

Return Type
Scan !
Arguments
NameTypeDefault ValueDescription
containerContainer !-Image container to scan.
configFile -Trivy configuration file.
Example
dagger -m github.com/sagikazarmark/daggerverse/trivy@d7b73b82451aac826822879a451de57e20238d8f call \
 container --container IMAGE:TAG
func (m *myModule) example(container *Container) *TrivyScan  {
	return dag.
			Trivy().
			Container(container)
}
@function
def example(container: dagger.Container) -> dag.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 \
 output
func (m *myModule) example(ctx context.Context, container *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
NameTypeDefault ValueDescription
formatString -Trivy report format.
Example
dagger -m github.com/sagikazarmark/daggerverse/trivy@d7b73b82451aac826822879a451de57e20238d8f call \
 container --container IMAGE:TAG \
 report
func (m *myModule) example(container *Container) *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()
}