@@ -40,15 +40,14 @@ func (m *Ci) Lint(ctx context.Context, dir *dagger.Directory) (string, error) {
4040
4141// Returns the Sast report as a file
4242func (m * Ci ) Sast (ctx context.Context , directory * dagger.Directory ) * dagger.File {
43- return dag .Container ().
44- From ("presidentbeef/brakeman:latest" ).
45- WithMountedDirectory ("/app" , directory ).
46- WithWorkdir ("/app" ).
47- WithExec ([]string {"/usr/src/app/bin/brakeman" , }).
48- File ("/app/brakeman-output.tabs" )
43+ return dag .Container ().
44+ From ("presidentbeef/brakeman:latest" ).
45+ WithMountedDirectory ("/app" , directory ).
46+ WithWorkdir ("/app" ).
47+ WithExec ([]string {"/usr/src/app/bin/brakeman" }).
48+ File ("/app/brakeman-output.tabs" )
4949}
5050
51-
5251// Creates a PostgreSQL service for local testing based on the official image with the provided version. If no version is provided, 'latest' will be used.
5352func (m * Ci ) Postgres (
5453 _ context.Context ,
@@ -79,19 +78,41 @@ func (m *Ci) Memcached(
7978
8079// Executes the test suite for the Rails application in the provided Directory
8180func (m * Ci ) Test (ctx context.Context , dir * dagger.Directory ) * dagger.Container {
82- return m .Build (ctx , dir ).From ("ruby:latest" ).
81+ return dag .Container ().From ("ruby:latest" ).
82+ WithMountedDirectory ("/app" , dir ).
83+ WithWorkdir ("/app" ).
8384 WithEnvVariable ("RAILS_TEST_DB_NAME" , "postgres" ).
8485 WithEnvVariable ("RAILS_TEST_DB_USERNAME" , "postgres" ).
8586 WithEnvVariable ("RAILS_TEST_DB_PASSWORD" , "postgres" ).
8687 WithEnvVariable ("RAILS_ENV" , "test" ).
8788 WithEnvVariable ("CI" , "true" ).
8889 WithEnvVariable ("PGDATESTYLE" , "German" ).
89- WithExec ([]string {"sudo" , " apt-get" , "-yqq" , "update" }).
90- WithExec ([]string {"sudo" , " apt-get" , "-yqq" , "install" , "libpq-dev" , "libvips-dev" }).
91- WithExec ([]string {"gem" , "install" , "bundler" , "--version" , "'~> 2'" }).
90+ WithExec ([]string {"apt-get" , "-yqq" , "update" }).
91+ WithExec ([]string {"apt-get" , "-yqq" , "install" , "libpq-dev" , "libvips-dev" }).
92+ WithExec ([]string {"gem" , "install" , "bundler" }).
9293 WithExec ([]string {"bundle" , "install" , "--jobs" , "4" , "--retry" , "3" }).
9394 WithExec ([]string {"bundle" , "exec" , "rails" , "db:create" }).
9495 WithExec ([]string {"bundle" , "exec" , "rails" , "db:migrate" }).
9596 WithExec ([]string {"bundle" , "exec" , "rails" , "assets:precompile" }).
9697 WithExec ([]string {"bundle" , "exec" , "rails" , "test" })
9798}
99+
100+ func (m * Ci ) Sbom (ctx context.Context , container * dagger.Container ) * dagger.File {
101+ trivy := dag .Trivy (dagger.TrivyOpts {
102+ DatabaseRepository : "public.ecr.aws/aquasecurity/trivy-db" ,
103+ })
104+
105+ sbom := trivy .Container (container ).
106+ Report ("spdx-json" ).
107+ WithName ("spdx.json" )
108+
109+ return sbom
110+ }
111+
112+ func (m * Ci ) Vulnscan (ctx context.Context , sbom * dagger.File ) * dagger.File {
113+ trivy := dag .Trivy (dagger.TrivyOpts {
114+ DatabaseRepository : "public.ecr.aws/aquasecurity/trivy-db" ,
115+ })
116+
117+ return trivy .Sbom (sbom ).Report ("json" )
118+ }
0 commit comments