Skip to content

Commit

Permalink
Merge pull request #569 from acornett21/conditonally_run_runasnonroot…
Browse files Browse the repository at this point in the history
…_check

adding in RootExceptionContainerPolicy check list
  • Loading branch information
acornett21 authored Apr 19, 2022
2 parents 6fb61a7 + a5e6a10 commit 0c0918d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions certification/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ var scratchContainerPolicy = map[string]certification.Check{
// runSystemContainerCheck.Name(): runSystemContainerCheck,
}

var rootExceptionContainerPolicy = map[string]certification.Check{
hasLicenseCheck.Name(): hasLicenseCheck,
hasUniqueTagCheck.Name(): hasUniqueTagCheck,
maxLayersCheck.Name(): maxLayersCheck,
hasNoProhibitedCheck.Name(): hasNoProhibitedCheck,
hasRequiredLabelsCheck.Name(): hasRequiredLabelsCheck,
basedOnUbiCheck.Name(): basedOnUbiCheck,
hasModifiedFilesCheck.Name(): hasModifiedFilesCheck,
// runnableContainerCheck.Name(): runnableContainerCheck,
// runSystemContainerCheck.Name(): runSystemContainerCheck,
}

func makeCheckList(checkMap map[string]certification.Check) []string {
checks := make([]string, 0, len(checkMap))

Expand All @@ -158,3 +170,7 @@ func ContainerPolicy() []string {
func ScratchContainerPolicy() []string {
return makeCheckList(scratchContainerPolicy)
}

func RootExceptionContainerPolicy() []string {
return makeCheckList(rootExceptionContainerPolicy)
}
1 change: 1 addition & 0 deletions certification/pyxis/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ type Container struct {
Registry string `json:"registry,omitempty"`
Repository string `json:"repository,omitempty"`
OsContentType string `json:"os_content_type,omitempty"`
Privileged bool `json:"privileged,omitempty"`
}

type Layer struct {
Expand Down
5 changes: 5 additions & 0 deletions cmd/check_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ var checkContainerCmd = &cobra.Command{
cfg.EnabledChecks = engine.ScratchContainerPolicy()
cfg.Scratch = true
}

// if a partner sets `Host Level Access` in connect to `Privileged`, enable RootExceptionContainerPolicy checks
if certProject.Container.Privileged {
cfg.EnabledChecks = engine.RootExceptionContainerPolicy()
}
}

engine, err := engine.NewForConfig(cfg)
Expand Down

0 comments on commit 0c0918d

Please sign in to comment.