Skip to content

Commit

Permalink
adding in PrivilegedContainerPolicy which is to be used to exclude Ru…
Browse files Browse the repository at this point in the history
…nAsNonRoot check for projects that have Host level access set to `Privileged` in connect project setup

Signed-off-by: Adam D. Cornett <[email protected]>
  • Loading branch information
acornett21 committed Apr 19, 2022
1 parent 6fb61a7 commit a5e6a10
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 a5e6a10

Please sign in to comment.