Skip to content

Commit

Permalink
feature: mirror of security/trivy-checks:0 image
Browse files Browse the repository at this point in the history
Signed-off-by: Maxim Vasilenko <[email protected]>
  • Loading branch information
Maxim Vasilenko committed Oct 14, 2024
1 parent 7bad692 commit afca3a8
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/mirror/cmd/vulndb/pull/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ func pull(_ *cobra.Command, _ []string) error {
if err != nil {
return fmt.Errorf("creating java db layout: %w", err)
}
imageLayouts.TrivyChecks, err = layouts.CreateEmptyImageLayoutAtPath(filepath.Join(VulnerabilityDBPath, "trivy-checks"))
if err != nil {
return fmt.Errorf("creating java db layout: %w", err)
}

if err := layouts.PullTrivyVulnerabilityDatabasesImages(pullContext, imageLayouts); err != nil {
return fmt.Errorf("pull vulnerability databases: %w", err)
Expand Down
1 change: 1 addition & 0 deletions internal/mirror/cmd/vulndb/push/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func push(_ *cobra.Command, _ []string) error {
path.Join(RegistryRepo, "security", "trivy-db"): filepath.Join(VulnerabilityDBPath, "trivy-db"),
path.Join(RegistryRepo, "security", "trivy-bdu"): filepath.Join(VulnerabilityDBPath, "trivy-bdu"),
path.Join(RegistryRepo, "security", "trivy-java-db"): filepath.Join(VulnerabilityDBPath, "trivy-java-db"),
path.Join(RegistryRepo, "security", "trivy-checks"): filepath.Join(VulnerabilityDBPath, "trivy-checks"),
}

repoCount := 0
Expand Down
4 changes: 4 additions & 0 deletions pkg/libmirror/layouts/layouts.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ type ImageLayouts struct {
TrivyBDUImages map[string]struct{}
TrivyJavaDB layout.Path
TrivyJavaDBImages map[string]struct{}
TrivyChecks layout.Path
TrivyChecksImages map[string]struct{}

Modules map[string]ModuleImageLayout

Expand Down Expand Up @@ -90,6 +92,7 @@ func CreateOCIImageLayoutsForDeckhouse(
&layouts.TrivyDB: filepath.Join(rootFolder, "security", "trivy-db"),
&layouts.TrivyBDU: filepath.Join(rootFolder, "security", "trivy-bdu"),
&layouts.TrivyJavaDB: filepath.Join(rootFolder, "security", "trivy-java-db"),
&layouts.TrivyChecks: filepath.Join(rootFolder, "security", "trivy-checks"),
}
for layoutPtr, fsPath := range fsPaths {
*layoutPtr, err = CreateEmptyImageLayoutAtPath(fsPath)
Expand Down Expand Up @@ -183,6 +186,7 @@ func FillLayoutsWithBasicDeckhouseImages(
mirrorCtx.DeckhouseRegistryRepo + "/security/trivy-db:2": {},
mirrorCtx.DeckhouseRegistryRepo + "/security/trivy-bdu:1": {},
mirrorCtx.DeckhouseRegistryRepo + "/security/trivy-java-db:1": {},
mirrorCtx.DeckhouseRegistryRepo + "/security/trivy-checks:0": {},
}

for _, version := range deckhouseVersions {
Expand Down
1 change: 1 addition & 0 deletions pkg/libmirror/layouts/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func PullTrivyVulnerabilityDatabasesImages(
layouts.TrivyDB: path.Join(pullCtx.DeckhouseRegistryRepo, "security", "trivy-db:2"),
layouts.TrivyBDU: path.Join(pullCtx.DeckhouseRegistryRepo, "security", "trivy-bdu:1"),
layouts.TrivyJavaDB: path.Join(pullCtx.DeckhouseRegistryRepo, "security", "trivy-java-db:1"),
layouts.TrivyChecks: path.Join(pullCtx.DeckhouseRegistryRepo, "security", "trivy-checks:0"),
}

for dbImageLayout, imageRef := range dbImages {
Expand Down
1 change: 1 addition & 0 deletions pkg/libmirror/operations/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func findLayoutsToPush(mirrorCtx *contexts.PushContext) (map[string]layout.Path,
{"security", "trivy-db"},
{"security", "trivy-bdu"},
{"security", "trivy-java-db"},
{"security", "trivy-checks"},
}

for _, bundlePath := range bundlePaths {
Expand Down
1 change: 1 addition & 0 deletions testing/e2e/mirror/mirror_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ func createTrivyVulnerabilityDatabasesInRegistry(t *testing.T, repo string, inse
repo + "/security/trivy-db:2",
repo + "/security/trivy-bdu:1",
repo + "/security/trivy-java-db:1",
repo + "/security/trivy-checks:0",
}

for _, image := range images {
Expand Down

0 comments on commit afca3a8

Please sign in to comment.