Skip to content

Commit e53efab

Browse files
committed
add comments, sdd SbomBuild method
1 parent 3e49bdd commit e53efab

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

ci/main.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,25 @@ func (m *Ci) Test(ctx context.Context, dir *dagger.Directory) *dagger.Container
102102
WithExec([]string{"bundle", "exec", "rails", "test"})
103103
}
104104

105+
// Creates an SBOM for the container
105106
func (m *Ci) Sbom(ctx context.Context, container *dagger.Container) *dagger.File {
106-
trivy := dag.Trivy(dagger.TrivyOpts{
107-
DatabaseRepository: "public.ecr.aws/aquasecurity/trivy-db",
108-
})
107+
trivy := dag.Trivy()
109108

110109
sbom := trivy.Container(container).
111-
Report("spdx-json").
112-
WithName("spdx.json")
110+
Report("cyclonedx").
111+
WithName("cyclonedx.json")
113112

114113
return sbom
115114
}
116115

116+
// Builds the container and creates an SBOM for it
117+
func (m *Ci) SbomBuild(ctx context.Context, dir *dagger.Directory) *dagger.File {
118+
container := m.Build(ctx, dir)
119+
120+
return m.Sbom(ctx, container)
121+
}
122+
123+
// Scans the SBOM for vulnerabilities
117124
func (m *Ci) Vulnscan(ctx context.Context, sbom *dagger.File) *dagger.File {
118125
trivy := dag.Trivy(dagger.TrivyOpts{
119126
DatabaseRepository: "public.ecr.aws/aquasecurity/trivy-db",

0 commit comments

Comments
 (0)