-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for security policy enforcement (#1325)
Add basic positive and negative tests for security policy enforcement. Hide policy tests behind LCOWIntegrity feature flag. Add ContainerConfigOpt and builder functions for creating security policy configs. Signed-off-by: Maksim An <[email protected]>
- Loading branch information
Showing
4 changed files
with
212 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package securitypolicy | ||
|
||
type ContainerConfigOpt func(*ContainerConfig) error | ||
|
||
// WithEnvVarRules adds environment variable constraints to container policy config. | ||
func WithEnvVarRules(envs []EnvRuleConfig) ContainerConfigOpt { | ||
return func(c *ContainerConfig) error { | ||
c.EnvRules = append(c.EnvRules, envs...) | ||
return nil | ||
} | ||
} | ||
|
||
// WithExpectedMounts adds expected mounts to container policy config. | ||
func WithExpectedMounts(em []string) ContainerConfigOpt { | ||
return func(c *ContainerConfig) error { | ||
c.ExpectedMounts = append(c.ExpectedMounts, em...) | ||
return nil | ||
} | ||
} | ||
|
||
// WithWorkingDir sets working directory in container policy config. | ||
func WithWorkingDir(wd string) ContainerConfigOpt { | ||
return func(c *ContainerConfig) error { | ||
c.WorkingDir = wd | ||
return nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
test/vendor/github.com/Microsoft/hcsshim/pkg/securitypolicy/opts.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.