Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultCRIMounts() []oci.Mount
- func DefaultCRIPrivilegedMounts() []oci.Mount
- func DefaultPrivilegedCapabilities() []string
- func DefaultUnprivilegedCapabilities() []string
- func EmptyCapabiltiesSet() []string
- func ExtendPolicyWithNetworkingMounts(sandboxRoot string, enforcer SecurityPolicyEnforcer, spec *oci.Spec) error
- func ExtractPolicyDecision(errorMessage string) (string, error)
- func GetAllUserInfo(process *oci.Process, rootPath string) (userIDName IDName, groupIDNames []IDName, umask string, err error)
- func HugePagesMountsDir(sandboxID string) string
- func MarshalFragment(namespace string, svn string, containers []*Container, ...) (string, error)
- func MarshalPolicy(marshaller string, allowAll bool, containers []*Container, ...) (string, error)
- func MarshalWindowsFragment(namespace string, svn string, containers []*WindowsContainer, ...) (string, error)
- func MarshalWindowsPolicy(marshaller string, allowAll bool, containers []*WindowsContainer, ...) (string, error)
- func MeasureSeccompProfile(seccomp *specs.LinuxSeccomp) (string, error)
- func NewSecurityPolicyDigest(base64policy string) ([]byte, error)
- func SandboxMountsDir(sandboxID string) string
- type AuthConfig
- type CapabilitiesConfig
- type ClosedDoorSecurityPolicyEnforcer
- func (ClosedDoorSecurityPolicyEnforcer) EncodedSecurityPolicy() string
- func (ClosedDoorSecurityPolicyEnforcer) EnforceCreateContainerPolicy(context.Context, string, string, []string, []string, string, []oci.Mount, bool, ...) (EnvList, *oci.LinuxCapabilities, bool, error)
- func (ClosedDoorSecurityPolicyEnforcer) EnforceCreateContainerPolicyV2(ctx context.Context, containerID string, argList []string, envList []string, ...) (EnvList, *oci.LinuxCapabilities, bool, error)
- func (ClosedDoorSecurityPolicyEnforcer) EnforceDeviceMountPolicy(context.Context, string, string) error
- func (ClosedDoorSecurityPolicyEnforcer) EnforceDeviceUnmountPolicy(context.Context, string) error
- func (ClosedDoorSecurityPolicyEnforcer) EnforceDumpStacksPolicy(context.Context) error
- func (ClosedDoorSecurityPolicyEnforcer) EnforceExecExternalProcessPolicy(context.Context, []string, []string, string) (EnvList, bool, error)
- func (ClosedDoorSecurityPolicyEnforcer) EnforceExecInContainerPolicy(context.Context, string, []string, []string, string, bool, IDName, []IDName, ...) (EnvList, *oci.LinuxCapabilities, bool, error)
- func (ClosedDoorSecurityPolicyEnforcer) EnforceExecInContainerPolicyV2(ctx context.Context, containerID string, argList []string, envList []string, ...) (EnvList, *oci.LinuxCapabilities, bool, error)
- func (ClosedDoorSecurityPolicyEnforcer) EnforceGetPropertiesPolicy(context.Context) error
- func (ClosedDoorSecurityPolicyEnforcer) EnforceHostNetworkPolicy(context.Context) error
- func (ClosedDoorSecurityPolicyEnforcer) EnforceLogProviderPolicy(context.Context, []string) ([]string, error)
- func (ClosedDoorSecurityPolicyEnforcer) EnforceMountBlockDevicePolicy(context.Context, string) error
- func (ClosedDoorSecurityPolicyEnforcer) EnforceOverlayMountPolicy(context.Context, string, []string, string) error
- func (ClosedDoorSecurityPolicyEnforcer) EnforceOverlayUnmountPolicy(context.Context, string) error
- func (*ClosedDoorSecurityPolicyEnforcer) EnforcePlan9MountPolicy(context.Context, string) error
- func (*ClosedDoorSecurityPolicyEnforcer) EnforcePlan9UnmountPolicy(context.Context, string) error
- func (ClosedDoorSecurityPolicyEnforcer) EnforceRWDeviceMountPolicy(context.Context, string, bool, bool, string) error
- func (ClosedDoorSecurityPolicyEnforcer) EnforceRWDeviceUnmountPolicy(context.Context, string) error
- func (ClosedDoorSecurityPolicyEnforcer) EnforceRegistryChangesPolicy(ctx context.Context, containerID string, registryValues interface{}) error
- func (ClosedDoorSecurityPolicyEnforcer) EnforceRuntimeLoggingPolicy(context.Context) error
- func (ClosedDoorSecurityPolicyEnforcer) EnforceScratchMountPolicy(context.Context, string, bool) error
- func (ClosedDoorSecurityPolicyEnforcer) EnforceScratchUnmountPolicy(context.Context, string) error
- func (*ClosedDoorSecurityPolicyEnforcer) EnforceShutdownContainerPolicy(context.Context, string) error
- func (*ClosedDoorSecurityPolicyEnforcer) EnforceSignalContainerProcessPolicy(context.Context, string, syscall.Signal, bool, []string) error
- func (*ClosedDoorSecurityPolicyEnforcer) EnforceSignalContainerProcessPolicyV2(ctx context.Context, containerID string, opts *SignalContainerOptions) error
- func (ClosedDoorSecurityPolicyEnforcer) EnforceUnmountBlockDevicePolicy(context.Context, string) error
- func (ClosedDoorSecurityPolicyEnforcer) EnforceVerifiedCIMsPolicy(ctx context.Context, containerID string, layerHashes []string, ...) error
- func (ClosedDoorSecurityPolicyEnforcer) ExtendDefaultMounts(_ []oci.Mount) error
- func (ClosedDoorSecurityPolicyEnforcer) GetUserInfo(spec *oci.Process, rootPath string) (IDName, []IDName, string, error)
- func (ClosedDoorSecurityPolicyEnforcer) LoadFragment(context.Context, LoadFragmentOptions) error
- func (ClosedDoorSecurityPolicyEnforcer) LoadTransparencyTrustList(context.Context, LoadTransparencyTrustListOptions) error
- func (ClosedDoorSecurityPolicyEnforcer) WithMetadataRollback(fn func() error) error
- type CommandArgs
- type Container
- type ContainerConfig
- type ContainerConfigOpt
- func WithAllowElevated(elevated bool) ContainerConfigOpt
- func WithAllowPrivilegeEscalation(allow bool) ContainerConfigOpt
- func WithAllowStdioAccess(stdio bool) ContainerConfigOpt
- func WithCapabilities(capabilities *CapabilitiesConfig) ContainerConfigOpt
- func WithCommand(cmd []string) ContainerConfigOpt
- func WithEnvVarRules(envs []EnvRuleConfig) ContainerConfigOpt
- func WithExecProcesses(execs []ExecProcessConfig) ContainerConfigOpt
- func WithMountConstraints(mc []MountConfig) ContainerConfigOpt
- func WithSeccompProfilePath(path string) ContainerConfigOpt
- func WithUser(user UserConfig) ContainerConfigOpt
- func WithWorkingDir(wd string) ContainerConfigOpt
- type ContainerInterface
- type Containers
- type CreateContainerOptions
- type EncodedSecurityPolicy
- type EnvList
- type EnvRuleConfig
- type EnvRules
- type EnvVarRule
- type ExecOptions
- type ExecProcessConfig
- type ExternalProcessConfig
- type FragmentConfig
- type IDName
- type IDNameConfig
- type IDNameStrategy
- type Layers
- type LoadFragmentOptions
- type LoadTransparencyTrustListOptions
- type Mount
- type MountConfig
- type Mounts
- type OSAwareMarshalFunc
- type OpenDoorSecurityPolicyEnforcer
- func (oe *OpenDoorSecurityPolicyEnforcer) EncodedSecurityPolicy() string
- func (OpenDoorSecurityPolicyEnforcer) EnforceCreateContainerPolicy(_ context.Context, _, _ string, _ []string, envList []string, _ string, ...) (EnvList, *oci.LinuxCapabilities, bool, error)
- func (OpenDoorSecurityPolicyEnforcer) EnforceCreateContainerPolicyV2(ctx context.Context, containerID string, argList []string, envList []string, ...) (EnvList, *oci.LinuxCapabilities, bool, error)
- func (OpenDoorSecurityPolicyEnforcer) EnforceDeviceMountPolicy(context.Context, string, string) error
- func (OpenDoorSecurityPolicyEnforcer) EnforceDeviceUnmountPolicy(context.Context, string) error
- func (OpenDoorSecurityPolicyEnforcer) EnforceDumpStacksPolicy(context.Context) error
- func (OpenDoorSecurityPolicyEnforcer) EnforceExecExternalProcessPolicy(_ context.Context, _ []string, envList []string, _ string) (EnvList, bool, error)
- func (OpenDoorSecurityPolicyEnforcer) EnforceExecInContainerPolicy(_ context.Context, _ string, _ []string, envList []string, _ string, _ bool, ...) (EnvList, *oci.LinuxCapabilities, bool, error)
- func (OpenDoorSecurityPolicyEnforcer) EnforceExecInContainerPolicyV2(ctx context.Context, containerID string, argList []string, envList []string, ...) (EnvList, *oci.LinuxCapabilities, bool, error)
- func (OpenDoorSecurityPolicyEnforcer) EnforceGetPropertiesPolicy(context.Context) error
- func (OpenDoorSecurityPolicyEnforcer) EnforceHostNetworkPolicy(context.Context) error
- func (OpenDoorSecurityPolicyEnforcer) EnforceLogProviderPolicy(_ context.Context, providerNames []string) ([]string, error)
- func (OpenDoorSecurityPolicyEnforcer) EnforceMountBlockDevicePolicy(context.Context, string) error
- func (OpenDoorSecurityPolicyEnforcer) EnforceOverlayMountPolicy(context.Context, string, []string, string) error
- func (OpenDoorSecurityPolicyEnforcer) EnforceOverlayUnmountPolicy(context.Context, string) error
- func (*OpenDoorSecurityPolicyEnforcer) EnforcePlan9MountPolicy(context.Context, string) error
- func (*OpenDoorSecurityPolicyEnforcer) EnforcePlan9UnmountPolicy(context.Context, string) error
- func (OpenDoorSecurityPolicyEnforcer) EnforceRWDeviceMountPolicy(context.Context, string, bool, bool, string) error
- func (OpenDoorSecurityPolicyEnforcer) EnforceRWDeviceUnmountPolicy(context.Context, string) error
- func (OpenDoorSecurityPolicyEnforcer) EnforceRegistryChangesPolicy(ctx context.Context, containerID string, registryValues interface{}) error
- func (OpenDoorSecurityPolicyEnforcer) EnforceRuntimeLoggingPolicy(context.Context) error
- func (OpenDoorSecurityPolicyEnforcer) EnforceScratchMountPolicy(context.Context, string, bool) error
- func (OpenDoorSecurityPolicyEnforcer) EnforceScratchUnmountPolicy(context.Context, string) error
- func (*OpenDoorSecurityPolicyEnforcer) EnforceShutdownContainerPolicy(context.Context, string) error
- func (*OpenDoorSecurityPolicyEnforcer) EnforceSignalContainerProcessPolicy(context.Context, string, syscall.Signal, bool, []string) error
- func (*OpenDoorSecurityPolicyEnforcer) EnforceSignalContainerProcessPolicyV2(ctx context.Context, containerID string, opts *SignalContainerOptions) error
- func (OpenDoorSecurityPolicyEnforcer) EnforceUnmountBlockDevicePolicy(context.Context, string) error
- func (OpenDoorSecurityPolicyEnforcer) EnforceVerifiedCIMsPolicy(ctx context.Context, containerID string, layerHashes []string, ...) error
- func (OpenDoorSecurityPolicyEnforcer) ExtendDefaultMounts([]oci.Mount) error
- func (OpenDoorSecurityPolicyEnforcer) GetUserInfo(spec *oci.Process, rootPath string) (IDName, []IDName, string, error)
- func (OpenDoorSecurityPolicyEnforcer) LoadFragment(context.Context, LoadFragmentOptions) error
- func (OpenDoorSecurityPolicyEnforcer) LoadTransparencyTrustList(context.Context, LoadTransparencyTrustListOptions) error
- func (OpenDoorSecurityPolicyEnforcer) WithMetadataRollback(fn func() error) error
- type Options
- type PolicyConfig
- type PolicyConfigOpt
- func WithAllowCapabilityDropping(allow bool) PolicyConfigOpt
- func WithAllowDumpStacks(allow bool) PolicyConfigOpt
- func WithAllowEnvVarDropping(allow bool) PolicyConfigOpt
- func WithAllowHostNetwork(allow bool) PolicyConfigOpt
- func WithAllowLogProviderDropping(allow bool) PolicyConfigOpt
- func WithAllowPropertiesAccess(allow bool) PolicyConfigOpt
- func WithAllowRuntimeLogging(allow bool) PolicyConfigOpt
- func WithAllowUnencryptedScratch(allow bool) PolicyConfigOpt
- func WithContainers(containers []ContainerConfig) PolicyConfigOpt
- func WithExternalProcesses(processes []ExternalProcessConfig) PolicyConfigOpt
- func WithWindowsContainers(containers []WindowsContainerConfig) PolicyConfigOpt
- type SecurityOptions
- func (s *SecurityOptions) InjectFragment(ctx context.Context, fragment *guestresource.SecurityPolicyFragment) (err error)
- func (s *SecurityOptions) SetConfidentialOptions(ctx context.Context, enforcerType string, encodedSecurityPolicy string, ...) error
- func (s *SecurityOptions) WriteSecurityContextDir(spec *specs.Spec) (string, error)
- type SecurityPolicy
- type SecurityPolicyEnforcer
- type SignalContainerOptions
- type StringArrayMap
- type UserConfig
- type WindowsContainer
- type WindowsContainerConfig
- type WindowsContainerConfigOpt
- func WithWindowsAllowStdioAccess(allow bool) WindowsContainerConfigOpt
- func WithWindowsCommand(command []string) WindowsContainerConfigOpt
- func WithWindowsEnvVarRules(envs []EnvRuleConfig) WindowsContainerConfigOpt
- func WithWindowsExecProcesses(processes []WindowsExecProcessConfig) WindowsContainerConfigOpt
- func WithWindowsImageName(imageName string) WindowsContainerConfigOpt
- func WithWindowsSignals(signals []guestrequest.SignalValueWCOW) WindowsContainerConfigOpt
- func WithWindowsUser(user string) WindowsContainerConfigOpt
- func WithWindowsWorkingDir(workingDir string) WindowsContainerConfigOpt
- type WindowsContainers
- type WindowsExecProcessConfig
Constants ¶
const ( SecurityContextDirTemplate = "security-context-*" PolicyFilename = "security-policy-base64" HostAMDCertFilename = "host-amd-cert-base64" ReferenceInfoFilename = "reference-info-base64" HashEnvelopeReferenceInfoFilename = "transparent-reference-info-base64" TCBReferenceInfoFilename = "tcb-reference-info-base64" PlatformReferenceInfoFilename = "platform-reference-info-base64" )
Variables ¶
var APICode = strings.Replace(apiCodeTemplate, "@@API_VERSION@@", apiVersion, 1)
var ErrInvalidOpenDoorPolicy = errors.New("Invalid policy for open-door enforcer")
var FrameworkCode = strings.Replace(frameworkCodeTemplate, "@@FRAMEWORK_VERSION@@", frameworkVersion, 1)
Functions ¶
func DefaultCRIMounts ¶
func DefaultCRIPrivilegedMounts ¶
DefaultCRIPrivilegedMounts returns a slice of mounts which are added to the linux container spec when a container runs in a privileged mode.
func DefaultPrivilegedCapabilities ¶ added in v0.10.0
func DefaultPrivilegedCapabilities() []string
func DefaultUnprivilegedCapabilities ¶ added in v0.10.0
func DefaultUnprivilegedCapabilities() []string
func EmptyCapabiltiesSet ¶ added in v0.10.0
func EmptyCapabiltiesSet() []string
func ExtendPolicyWithNetworkingMounts ¶
func ExtendPolicyWithNetworkingMounts(sandboxRoot string, enforcer SecurityPolicyEnforcer, spec *oci.Spec) error
func ExtractPolicyDecision ¶ added in v0.10.0
func GetAllUserInfo ¶
func HugePagesMountsDir ¶ added in v0.14.0
HugePagesMountsDir returns hugepages mounts directory inside UVM.
func MarshalFragment ¶ added in v0.10.0
func MarshalFragment( namespace string, svn string, containers []*Container, externalProcesses []ExternalProcessConfig, fragments []FragmentConfig) (string, error)
func MarshalPolicy ¶ added in v0.10.0
func MarshalPolicy( marshaller string, allowAll bool, containers []*Container, externalProcesses []ExternalProcessConfig, fragments []FragmentConfig, allowPropertiesAccess bool, allowDumpStacks bool, allowRuntimeLogging bool, allowHostNetwork bool, allowEnvironmentVariableDropping bool, allowUnencryptedScratch bool, allowCapbilitiesDropping bool, allowLogProviderDropping bool, ) (string, error)
func MarshalWindowsFragment ¶
func MarshalWindowsFragment( namespace string, svn string, containers []*WindowsContainer, externalProcesses []ExternalProcessConfig, fragments []FragmentConfig) (string, error)
MarshalWindowsFragment encodes a Rego policy fragment for Windows containers.
func MarshalWindowsPolicy ¶
func MarshalWindowsPolicy( marshaller string, allowAll bool, containers []*WindowsContainer, externalProcesses []ExternalProcessConfig, fragments []FragmentConfig, allowPropertiesAccess bool, allowDumpStacks bool, allowRuntimeLogging bool, allowHostNetwork bool, allowEnvironmentVariableDropping bool, allowUnencryptedScratch bool, allowCapabilitiesDropping bool, allowLogProviderDropping bool, ) (string, error)
MarshalWindowsPolicy encodes a security policy for Windows containers.
func MeasureSeccompProfile ¶ added in v0.10.0
func MeasureSeccompProfile(seccomp *specs.LinuxSeccomp) (string, error)
func NewSecurityPolicyDigest ¶ added in v0.10.0
NewSecurityPolicyDigest decodes base64 encoded policy string, computes and returns sha256 digest
func SandboxMountsDir ¶ added in v0.14.0
SandboxMountsDir returns sandbox mounts directory inside UVM/host.
Types ¶
type AuthConfig ¶ added in v0.10.0
type AuthConfig struct {
Username string `json:"username" toml:"username"`
Password string `json:"password" toml:"password"`
}
AuthConfig contains toml or JSON config for registry authentication.
type CapabilitiesConfig ¶ added in v0.10.0
type CapabilitiesConfig struct {
Bounding []string `json:"bounding" toml:"bounding"`
Effective []string `json:"effective" toml:"effective"`
Inheritable []string `json:"inheritable" toml:"inheritable"`
Permitted []string `json:"permitted" toml:"permitted"`
Ambient []string `json:"ambient" toml:"ambient"`
}
CapabilitiesConfig contains the toml or JSON config for capabilies security polict constraint description
type ClosedDoorSecurityPolicyEnforcer ¶
type ClosedDoorSecurityPolicyEnforcer struct{}
func (ClosedDoorSecurityPolicyEnforcer) EncodedSecurityPolicy ¶ added in v0.10.0
func (ClosedDoorSecurityPolicyEnforcer) EncodedSecurityPolicy() string
func (ClosedDoorSecurityPolicyEnforcer) EnforceCreateContainerPolicy ¶
func (ClosedDoorSecurityPolicyEnforcer) EnforceCreateContainerPolicyV2 ¶
func (ClosedDoorSecurityPolicyEnforcer) EnforceDeviceMountPolicy ¶
func (ClosedDoorSecurityPolicyEnforcer) EnforceDeviceUnmountPolicy ¶
func (ClosedDoorSecurityPolicyEnforcer) EnforceDeviceUnmountPolicy(context.Context, string) error
func (ClosedDoorSecurityPolicyEnforcer) EnforceDumpStacksPolicy ¶ added in v0.10.0
func (ClosedDoorSecurityPolicyEnforcer) EnforceDumpStacksPolicy(context.Context) error
func (ClosedDoorSecurityPolicyEnforcer) EnforceExecExternalProcessPolicy ¶ added in v0.10.0
func (ClosedDoorSecurityPolicyEnforcer) EnforceExecInContainerPolicy ¶ added in v0.10.0
func (ClosedDoorSecurityPolicyEnforcer) EnforceExecInContainerPolicyV2 ¶
func (ClosedDoorSecurityPolicyEnforcer) EnforceExecInContainerPolicyV2( ctx context.Context, containerID string, argList []string, envList []string, workingDir string, user IDName, opts *ExecOptions, ) (EnvList, *oci.LinuxCapabilities, bool, error)
func (ClosedDoorSecurityPolicyEnforcer) EnforceGetPropertiesPolicy ¶ added in v0.10.0
func (ClosedDoorSecurityPolicyEnforcer) EnforceGetPropertiesPolicy(context.Context) error
func (ClosedDoorSecurityPolicyEnforcer) EnforceHostNetworkPolicy ¶
func (ClosedDoorSecurityPolicyEnforcer) EnforceHostNetworkPolicy(context.Context) error
func (ClosedDoorSecurityPolicyEnforcer) EnforceLogProviderPolicy ¶
func (ClosedDoorSecurityPolicyEnforcer) EnforceMountBlockDevicePolicy ¶
func (ClosedDoorSecurityPolicyEnforcer) EnforceMountBlockDevicePolicy(context.Context, string) error
func (ClosedDoorSecurityPolicyEnforcer) EnforceOverlayMountPolicy ¶
func (ClosedDoorSecurityPolicyEnforcer) EnforceOverlayUnmountPolicy ¶ added in v0.10.0
func (ClosedDoorSecurityPolicyEnforcer) EnforceOverlayUnmountPolicy(context.Context, string) error
func (*ClosedDoorSecurityPolicyEnforcer) EnforcePlan9MountPolicy ¶ added in v0.10.0
func (*ClosedDoorSecurityPolicyEnforcer) EnforcePlan9MountPolicy(context.Context, string) error
func (*ClosedDoorSecurityPolicyEnforcer) EnforcePlan9UnmountPolicy ¶ added in v0.10.0
func (*ClosedDoorSecurityPolicyEnforcer) EnforcePlan9UnmountPolicy(context.Context, string) error
func (ClosedDoorSecurityPolicyEnforcer) EnforceRWDeviceMountPolicy ¶
func (ClosedDoorSecurityPolicyEnforcer) EnforceRWDeviceUnmountPolicy ¶
func (ClosedDoorSecurityPolicyEnforcer) EnforceRWDeviceUnmountPolicy(context.Context, string) error
func (ClosedDoorSecurityPolicyEnforcer) EnforceRegistryChangesPolicy ¶
func (ClosedDoorSecurityPolicyEnforcer) EnforceRegistryChangesPolicy(ctx context.Context, containerID string, registryValues interface{}) error
func (ClosedDoorSecurityPolicyEnforcer) EnforceRuntimeLoggingPolicy ¶ added in v0.10.0
func (ClosedDoorSecurityPolicyEnforcer) EnforceRuntimeLoggingPolicy(context.Context) error
func (ClosedDoorSecurityPolicyEnforcer) EnforceScratchMountPolicy ¶ added in v0.10.0
func (ClosedDoorSecurityPolicyEnforcer) EnforceScratchUnmountPolicy ¶ added in v0.10.0
func (ClosedDoorSecurityPolicyEnforcer) EnforceScratchUnmountPolicy(context.Context, string) error
func (*ClosedDoorSecurityPolicyEnforcer) EnforceShutdownContainerPolicy ¶ added in v0.10.0
func (*ClosedDoorSecurityPolicyEnforcer) EnforceShutdownContainerPolicy(context.Context, string) error
func (*ClosedDoorSecurityPolicyEnforcer) EnforceSignalContainerProcessPolicy ¶ added in v0.10.0
func (*ClosedDoorSecurityPolicyEnforcer) EnforceSignalContainerProcessPolicyV2 ¶
func (*ClosedDoorSecurityPolicyEnforcer) EnforceSignalContainerProcessPolicyV2(ctx context.Context, containerID string, opts *SignalContainerOptions) error
func (ClosedDoorSecurityPolicyEnforcer) EnforceUnmountBlockDevicePolicy ¶
func (ClosedDoorSecurityPolicyEnforcer) EnforceUnmountBlockDevicePolicy(context.Context, string) error
func (ClosedDoorSecurityPolicyEnforcer) EnforceVerifiedCIMsPolicy ¶
func (ClosedDoorSecurityPolicyEnforcer) ExtendDefaultMounts ¶ added in v0.10.0
func (ClosedDoorSecurityPolicyEnforcer) ExtendDefaultMounts(_ []oci.Mount) error
func (ClosedDoorSecurityPolicyEnforcer) GetUserInfo ¶ added in v0.10.0
func (ClosedDoorSecurityPolicyEnforcer) LoadFragment ¶ added in v0.10.0
func (ClosedDoorSecurityPolicyEnforcer) LoadFragment(context.Context, LoadFragmentOptions) error
func (ClosedDoorSecurityPolicyEnforcer) LoadTransparencyTrustList ¶
func (ClosedDoorSecurityPolicyEnforcer) LoadTransparencyTrustList(context.Context, LoadTransparencyTrustListOptions) error
func (ClosedDoorSecurityPolicyEnforcer) WithMetadataRollback ¶
func (ClosedDoorSecurityPolicyEnforcer) WithMetadataRollback(fn func() error) error
type CommandArgs ¶
type CommandArgs StringArrayMap
func (CommandArgs) MarshalJSON ¶
func (c CommandArgs) MarshalJSON() ([]byte, error)
type Container ¶
type Container struct {
Command CommandArgs `json:"command"`
EnvRules EnvRules `json:"env_rules"`
Layers Layers `json:"layers"`
WorkingDir string `json:"working_dir"`
Mounts Mounts `json:"mounts"`
AllowElevated bool `json:"allow_elevated"`
ExecProcesses []ExecProcessConfig `json:"-"`
Signals []syscall.Signal `json:"-"`
AllowStdioAccess bool `json:"-"`
NoNewPrivileges bool `json:"-"`
User UserConfig `json:"-"`
Capabilities *CapabilitiesConfig `json:"-"`
SeccompProfileSHA256 string `json:"-"`
}
func CreateContainerPolicy ¶ added in v0.10.0
func CreateContainerPolicy( command, layers []string, envRules []EnvRuleConfig, workingDir string, mounts []MountConfig, allowElevated bool, execProcesses []ExecProcessConfig, signals []syscall.Signal, allowStdioAccess bool, noNewPrivileges bool, user UserConfig, capabilities *CapabilitiesConfig, seccompProfileSHA256 string, ) (*Container, error)
CreateContainerPolicy creates a new Container policy instance from the provided constraints or an error if parameter validation fails.
func (*Container) ToInternalContainer ¶
Implement ContainerInterface for Container
type ContainerConfig ¶ added in v0.10.0
type ContainerConfig struct {
ImageName string `json:"image_name" toml:"image_name"`
Command []string `json:"command" toml:"command"`
Auth AuthConfig `json:"auth" toml:"auth"`
EnvRules []EnvRuleConfig `json:"env_rules" toml:"env_rule"`
WorkingDir string `json:"working_dir" toml:"working_dir"`
Mounts []MountConfig `json:"mounts" toml:"mount"`
AllowElevated bool `json:"allow_elevated" toml:"allow_elevated"`
ExecProcesses []ExecProcessConfig `json:"exec_processes" toml:"exec_process"`
Signals []syscall.Signal `json:"signals" toml:"signals"`
AllowStdioAccess bool `json:"allow_stdio_access" toml:"allow_stdio_access"`
AllowPrivilegeEscalation bool `json:"allow_privilege_escalation" toml:"allow_privilege_escalation"`
User *UserConfig `json:"user" toml:"user"`
Capabilities *CapabilitiesConfig `json:"capabilities" toml:"capabilities"`
SeccompProfilePath string `json:"seccomp_profile_path" toml:"seccomp_profile_path"`
}
ContainerConfig contains toml or JSON config for container described in security policy.
type ContainerConfigOpt ¶ added in v0.10.0
type ContainerConfigOpt func(config *ContainerConfig) error
func WithAllowElevated ¶ added in v0.10.0
func WithAllowElevated(elevated bool) ContainerConfigOpt
WithAllowElevated allows container to run in an elevated/privileged mode.
func WithAllowPrivilegeEscalation ¶ added in v0.10.0
func WithAllowPrivilegeEscalation(allow bool) ContainerConfigOpt
WithAllowPrivilegeEscalation allows escalating of privileges by clearing the NoNewPrivileges flag
func WithAllowStdioAccess ¶ added in v0.10.0
func WithAllowStdioAccess(stdio bool) ContainerConfigOpt
WithAllowStdioAccess enables or disables container init process stdio.
func WithCapabilities ¶ added in v0.10.0
func WithCapabilities(capabilities *CapabilitiesConfig) ContainerConfigOpt
WithCapabilities sets capabilities in container policy config.
func WithCommand ¶ added in v0.10.0
func WithCommand(cmd []string) ContainerConfigOpt
WithCommand sets ContainerConfig.Command in container policy config.
func WithEnvVarRules ¶ added in v0.10.0
func WithEnvVarRules(envs []EnvRuleConfig) ContainerConfigOpt
WithEnvVarRules adds environment variable constraints to container policy config.
func WithExecProcesses ¶ added in v0.10.0
func WithExecProcesses(execs []ExecProcessConfig) ContainerConfigOpt
WithExecProcesses allows specified exec processes.
func WithMountConstraints ¶ added in v0.10.0
func WithMountConstraints(mc []MountConfig) ContainerConfigOpt
WithMountConstraints extends ContainerConfig.Mounts with provided mount constraints.
func WithSeccompProfilePath ¶ added in v0.10.0
func WithSeccompProfilePath(path string) ContainerConfigOpt
WithSeccompProfilePath sets seccomp profile path in container policy config.
func WithUser ¶ added in v0.10.0
func WithUser(user UserConfig) ContainerConfigOpt
WithUser sets user in container policy config.
func WithWorkingDir ¶ added in v0.10.0
func WithWorkingDir(wd string) ContainerConfigOpt
WithWorkingDir sets working directory in container policy config.
type ContainerInterface ¶
type ContainerInterface interface {
ToInternalContainer() (interface{}, error)
}
ContainerInterface represents either Container or WindowsContainer
type Containers ¶
type Containers struct {
Length int `json:"length"`
Elements map[string]Container `json:"elements"`
}
func (Containers) MarshalJSON ¶
func (c Containers) MarshalJSON() ([]byte, error)
type CreateContainerOptions ¶
type CreateContainerOptions struct {
SandboxID string
Privileged *bool
NoNewPrivileges *bool
Groups []IDName
Umask string
Capabilities *oci.LinuxCapabilities
SeccompProfileSHA256 string
// IsSandboxContainer is true when the container being created is the cri
// pod sandbox container (usually it is the "pause" image).
IsSandboxContainer bool
LinuxDevices []oci.LinuxDevice
}
type EncodedSecurityPolicy ¶
type EncodedSecurityPolicy struct {
SecurityPolicy string `json:"SecurityPolicy,omitempty"`
}
EncodedSecurityPolicy is a JSON representation of SecurityPolicy that has been base64 encoded for storage in an annotation embedded within another JSON configuration
type EnvRuleConfig ¶ added in v0.10.0
type EnvRuleConfig struct {
Strategy EnvVarRule `json:"strategy" toml:"strategy"`
Rule string `json:"rule" toml:"rule"`
Required bool `json:"required" toml:"required"`
// If UseNameValue is true, the marshalled Rego will use rules with name and
// value separately, and ignore .Rule and .Strategy.
UseNameValue bool
Name string
NameStrategy EnvVarRule
Value string
ValueStrategy EnvVarRule
}
EnvRuleConfig contains toml or JSON config for environment variable security policy enforcement.
func NewEnvVarRules ¶ added in v0.10.0
func NewEnvVarRules(envVars []string, required bool) []EnvRuleConfig
NewEnvVarRules creates slice of EnvRuleConfig's from environment variables strings slice.
type EnvRules ¶
type EnvRules struct {
Length int `json:"length"`
Elements map[string]EnvRuleConfig `json:"elements"`
}
func (EnvRules) MarshalJSON ¶
type EnvVarRule ¶
type EnvVarRule string
const ( EnvVarRuleString EnvVarRule = "string" EnvVarRuleRegex EnvVarRule = "re2" )
type ExecOptions ¶
type ExecOptions struct {
Groups []IDName // optional: empty slice or nil
Umask string // optional: "" means unspecified
Capabilities *oci.LinuxCapabilities // optional: nil means "none"
NoNewPrivileges *bool // optional: nil means "not set"
}
type ExecProcessConfig ¶ added in v0.10.0
type ExecProcessConfig struct {
Command []string `json:"command" toml:"command"`
Signals []syscall.Signal `json:"signals" toml:"signals"`
}
ExecProcessConfig contains toml or JSON config for exec process security policy constraint description
type ExternalProcessConfig ¶ added in v0.10.0
type ExternalProcessConfig struct {
Command []string `json:"command" toml:"command"`
WorkingDir string `json:"working_dir" toml:"working_dir"`
AllowStdioAccess bool `json:"allow_stdio_access" toml:"allow_stdio_access"`
}
ExternalProcessConfig contains toml or JSON config for running external processes in the UVM.
type FragmentConfig ¶ added in v0.10.0
type FragmentConfig struct {
Issuer string `json:"issuer" toml:"issuer"`
Feed string `json:"feed" toml:"feed"`
MinimumSVN string `json:"minimum_svn" toml:"minimum_svn"`
Includes []string `json:"includes" toml:"include"`
}
FragmentConfig contains toml or JSON config for including elements from fragments.
type IDNameConfig ¶ added in v0.10.0
type IDNameConfig struct {
Strategy IDNameStrategy `json:"strategy" toml:"strategy"`
Rule string `json:"rule" toml:"rule"`
}
type IDNameStrategy ¶ added in v0.10.0
type IDNameStrategy string
const ( IDNameStrategyName IDNameStrategy = "name" IDNameStrategyID IDNameStrategy = "id" IDNameStrategyRegex IDNameStrategy = "re2" IDNameStrategyAny IDNameStrategy = "any" )
type LoadFragmentOptions ¶
type LoadFragmentOptions struct {
Issuer string
Feed string
// If the fragment's COSE envelope contains a CWT Claims with a SVN, pass it
// in HeaderSVN.
HeaderSVN *int64
// Rego is the fragment's Rego payload.
Rego string
// Receipts are the COSE transparency receipts attached to the fragment's
// COSE envelope, if any. Validation is handled by the enforcer, caller
// does not have to validate them.
Receipts []cosesign1.ParsedCOSEReceipt
}
type LoadTransparencyTrustListOptions ¶
type LoadTransparencyTrustListOptions struct {
// Issuer of the signed Transparency Trust List (TTL).
Issuer string
// Subject of the TTL.
Subject string
// SVN carried in the TTL's COSE header.
SVN int64
// ParsedTTL maps each ledger name (receipt issuer) to that ledger's kid ->
// public key map. This is the return value of cosesign1.ParseTTLPayload.
ParsedTTL map[string]map[string]crypto.PublicKey
}
type MountConfig ¶ added in v0.10.0
type MountConfig struct {
HostPath string `json:"host_path" toml:"host_path"`
ContainerPath string `json:"container_path" toml:"container_path"`
Readonly bool `json:"readonly" toml:"readonly"`
}
MountConfig contains toml or JSON config for mount security policy constraint description.
type Mounts ¶ added in v0.10.0
func (Mounts) MarshalJSON ¶ added in v0.10.0
type OSAwareMarshalFunc ¶
type OSAwareMarshalFunc func( allowAll bool, linuxContainers []*Container, windowsContainers []*WindowsContainer, osType string, externalProcesses []ExternalProcessConfig, fragments []FragmentConfig, allowPropertiesAccess bool, allowDumpStacks bool, allowRuntimeLogging bool, allowHostNetwork bool, allowEnvironmentVariableDropping bool, allowUnencryptedScratch bool, allowCapabilityDropping bool, allowLogProviderDropping bool, ) (string, error)
OSAwareMarshalFunc is like marshalFunc but works with mixed container types
type OpenDoorSecurityPolicyEnforcer ¶
type OpenDoorSecurityPolicyEnforcer struct {
// contains filtered or unexported fields
}
func (*OpenDoorSecurityPolicyEnforcer) EncodedSecurityPolicy ¶ added in v0.10.0
func (oe *OpenDoorSecurityPolicyEnforcer) EncodedSecurityPolicy() string
func (OpenDoorSecurityPolicyEnforcer) EnforceCreateContainerPolicy ¶
func (OpenDoorSecurityPolicyEnforcer) EnforceCreateContainerPolicyV2 ¶
func (OpenDoorSecurityPolicyEnforcer) EnforceDeviceMountPolicy ¶
func (OpenDoorSecurityPolicyEnforcer) EnforceDeviceUnmountPolicy ¶
func (OpenDoorSecurityPolicyEnforcer) EnforceDeviceUnmountPolicy(context.Context, string) error
func (OpenDoorSecurityPolicyEnforcer) EnforceDumpStacksPolicy ¶ added in v0.10.0
func (OpenDoorSecurityPolicyEnforcer) EnforceDumpStacksPolicy(context.Context) error
func (OpenDoorSecurityPolicyEnforcer) EnforceExecExternalProcessPolicy ¶ added in v0.10.0
func (OpenDoorSecurityPolicyEnforcer) EnforceExecInContainerPolicy ¶ added in v0.10.0
func (OpenDoorSecurityPolicyEnforcer) EnforceExecInContainerPolicyV2 ¶
func (OpenDoorSecurityPolicyEnforcer) EnforceExecInContainerPolicyV2( ctx context.Context, containerID string, argList []string, envList []string, workingDir string, user IDName, opts *ExecOptions, ) (EnvList, *oci.LinuxCapabilities, bool, error)
func (OpenDoorSecurityPolicyEnforcer) EnforceGetPropertiesPolicy ¶ added in v0.10.0
func (OpenDoorSecurityPolicyEnforcer) EnforceGetPropertiesPolicy(context.Context) error
func (OpenDoorSecurityPolicyEnforcer) EnforceHostNetworkPolicy ¶
func (OpenDoorSecurityPolicyEnforcer) EnforceHostNetworkPolicy(context.Context) error
func (OpenDoorSecurityPolicyEnforcer) EnforceLogProviderPolicy ¶
func (OpenDoorSecurityPolicyEnforcer) EnforceMountBlockDevicePolicy ¶
func (OpenDoorSecurityPolicyEnforcer) EnforceMountBlockDevicePolicy(context.Context, string) error
func (OpenDoorSecurityPolicyEnforcer) EnforceOverlayMountPolicy ¶
func (OpenDoorSecurityPolicyEnforcer) EnforceOverlayUnmountPolicy ¶ added in v0.10.0
func (OpenDoorSecurityPolicyEnforcer) EnforceOverlayUnmountPolicy(context.Context, string) error
func (*OpenDoorSecurityPolicyEnforcer) EnforcePlan9MountPolicy ¶ added in v0.10.0
func (*OpenDoorSecurityPolicyEnforcer) EnforcePlan9MountPolicy(context.Context, string) error
func (*OpenDoorSecurityPolicyEnforcer) EnforcePlan9UnmountPolicy ¶ added in v0.10.0
func (*OpenDoorSecurityPolicyEnforcer) EnforcePlan9UnmountPolicy(context.Context, string) error
func (OpenDoorSecurityPolicyEnforcer) EnforceRWDeviceMountPolicy ¶
func (OpenDoorSecurityPolicyEnforcer) EnforceRWDeviceUnmountPolicy ¶
func (OpenDoorSecurityPolicyEnforcer) EnforceRWDeviceUnmountPolicy(context.Context, string) error
func (OpenDoorSecurityPolicyEnforcer) EnforceRegistryChangesPolicy ¶
func (OpenDoorSecurityPolicyEnforcer) EnforceRegistryChangesPolicy(ctx context.Context, containerID string, registryValues interface{}) error
func (OpenDoorSecurityPolicyEnforcer) EnforceRuntimeLoggingPolicy ¶ added in v0.10.0
func (OpenDoorSecurityPolicyEnforcer) EnforceRuntimeLoggingPolicy(context.Context) error
func (OpenDoorSecurityPolicyEnforcer) EnforceScratchMountPolicy ¶ added in v0.10.0
func (OpenDoorSecurityPolicyEnforcer) EnforceScratchUnmountPolicy ¶ added in v0.10.0
func (OpenDoorSecurityPolicyEnforcer) EnforceScratchUnmountPolicy(context.Context, string) error
func (*OpenDoorSecurityPolicyEnforcer) EnforceShutdownContainerPolicy ¶ added in v0.10.0
func (*OpenDoorSecurityPolicyEnforcer) EnforceShutdownContainerPolicy(context.Context, string) error
func (*OpenDoorSecurityPolicyEnforcer) EnforceSignalContainerProcessPolicy ¶ added in v0.10.0
func (*OpenDoorSecurityPolicyEnforcer) EnforceSignalContainerProcessPolicyV2 ¶
func (*OpenDoorSecurityPolicyEnforcer) EnforceSignalContainerProcessPolicyV2(ctx context.Context, containerID string, opts *SignalContainerOptions) error
func (OpenDoorSecurityPolicyEnforcer) EnforceUnmountBlockDevicePolicy ¶
func (OpenDoorSecurityPolicyEnforcer) EnforceUnmountBlockDevicePolicy(context.Context, string) error
func (OpenDoorSecurityPolicyEnforcer) EnforceVerifiedCIMsPolicy ¶
func (OpenDoorSecurityPolicyEnforcer) ExtendDefaultMounts ¶ added in v0.10.0
func (OpenDoorSecurityPolicyEnforcer) ExtendDefaultMounts([]oci.Mount) error
func (OpenDoorSecurityPolicyEnforcer) GetUserInfo ¶ added in v0.10.0
func (OpenDoorSecurityPolicyEnforcer) LoadFragment ¶ added in v0.10.0
func (OpenDoorSecurityPolicyEnforcer) LoadFragment(context.Context, LoadFragmentOptions) error
func (OpenDoorSecurityPolicyEnforcer) LoadTransparencyTrustList ¶
func (OpenDoorSecurityPolicyEnforcer) LoadTransparencyTrustList(context.Context, LoadTransparencyTrustListOptions) error
func (OpenDoorSecurityPolicyEnforcer) WithMetadataRollback ¶
func (OpenDoorSecurityPolicyEnforcer) WithMetadataRollback(fn func() error) error
type Options ¶ added in v0.10.0
type Options StringArrayMap
func (Options) MarshalJSON ¶ added in v0.10.0
type PolicyConfig ¶ added in v0.10.0
type PolicyConfig struct {
AllowAll bool `json:"allow_all" toml:"allow_all"`
Containers []ContainerConfig `json:"containers" toml:"container"`
WindowsContainers []WindowsContainerConfig `json:"windows_containers" toml:"windows_container"`
ExternalProcesses []ExternalProcessConfig `json:"external_processes" toml:"external_process"`
Fragments []FragmentConfig `json:"fragments" toml:"fragment"`
AllowPropertiesAccess bool `json:"allow_properties_access" toml:"allow_properties_access"`
AllowDumpStacks bool `json:"allow_dump_stacks" toml:"allow_dump_stacks"`
AllowRuntimeLogging bool `json:"allow_runtime_logging" toml:"allow_runtime_logging"`
AllowHostNetwork bool `json:"allow_hostnetwork" toml:"allow_hostnetwork"`
AllowEnvironmentVariableDropping bool `json:"allow_environment_variable_dropping" toml:"allow_environment_variable_dropping"`
// AllowUnencryptedScratch is a global policy configuration that allows
// all containers within a pod to be run without scratch encryption.
AllowUnencryptedScratch bool `json:"allow_unencrypted_scratch" toml:"allow_unencrypted_scratch"`
AllowCapabilityDropping bool `json:"allow_capability_dropping" toml:"allow_capability_dropping"`
// AllowLogProviderDropping controls how EnforceLogProviderPolicy handles
// requested ETW providers that are not on the allow-list. When false
// (default, fail-close) any disallowed provider causes the entire
// modifyServiceSettings call to be denied. When true, disallowed providers
// are silently dropped and the call continues with the kept subset.
AllowLogProviderDropping bool `json:"allow_log_provider_dropping" toml:"allow_log_provider_dropping"`
}
PolicyConfig contains toml or JSON config for security policy.
func NewPolicyConfig ¶ added in v0.10.0
func NewPolicyConfig(opts ...PolicyConfigOpt) (*PolicyConfig, error)
type PolicyConfigOpt ¶ added in v0.10.0
type PolicyConfigOpt func(config *PolicyConfig) error
func WithAllowCapabilityDropping ¶ added in v0.10.0
func WithAllowCapabilityDropping(allow bool) PolicyConfigOpt
func WithAllowDumpStacks ¶ added in v0.10.0
func WithAllowDumpStacks(allow bool) PolicyConfigOpt
func WithAllowEnvVarDropping ¶ added in v0.10.0
func WithAllowEnvVarDropping(allow bool) PolicyConfigOpt
func WithAllowHostNetwork ¶
func WithAllowHostNetwork(allow bool) PolicyConfigOpt
func WithAllowLogProviderDropping ¶
func WithAllowLogProviderDropping(allow bool) PolicyConfigOpt
func WithAllowPropertiesAccess ¶ added in v0.10.0
func WithAllowPropertiesAccess(allow bool) PolicyConfigOpt
func WithAllowRuntimeLogging ¶ added in v0.10.0
func WithAllowRuntimeLogging(allow bool) PolicyConfigOpt
func WithAllowUnencryptedScratch ¶ added in v0.10.0
func WithAllowUnencryptedScratch(allow bool) PolicyConfigOpt
func WithContainers ¶ added in v0.10.0
func WithContainers(containers []ContainerConfig) PolicyConfigOpt
WithContainers adds containers to security policy.
func WithExternalProcesses ¶ added in v0.10.0
func WithExternalProcesses(processes []ExternalProcessConfig) PolicyConfigOpt
func WithWindowsContainers ¶
func WithWindowsContainers(containers []WindowsContainerConfig) PolicyConfigOpt
WithWindowsContainers adds Windows containers to a security policy config.
type SecurityOptions ¶
type SecurityOptions struct {
// state required for the security policy enforcement
PolicyEnforcer SecurityPolicyEnforcer
PolicyEnforcerSet bool
UvmReferenceInfo string
UvmHashEnvelopeReferenceInfo string
// contains filtered or unexported fields
}
func NewSecurityOptions ¶
func NewSecurityOptions(enforcer SecurityPolicyEnforcer, enforcerSet bool, uvmReferenceInfo string, uvmHashEnvelopeReferenceInfo string, logWriter io.Writer) *SecurityOptions
func (*SecurityOptions) InjectFragment ¶
func (s *SecurityOptions) InjectFragment(ctx context.Context, fragment *guestresource.SecurityPolicyFragment) (err error)
Fragment extends current security policy with additional constraints from the incoming fragment. Note that it is base64 encoded over the bridge/
There are three checking steps: 1 - Unpack the cose document and check it was actually signed with the cert chain inside its header 2 - Check that the issuer field did:x509 identifier is for that cert chain (ie fingerprint of a non leaf cert and the subject matches the leaf cert) 3 - Check that this issuer/feed match the requirement of the user provided security policy (done in the regoby LoadFragment)
func (*SecurityOptions) SetConfidentialOptions ¶
func (s *SecurityOptions) SetConfidentialOptions(ctx context.Context, enforcerType string, encodedSecurityPolicy string, encodedUVMReference string, encodedUVMHashEnvelopeReference string) error
SetConfidentialOptions takes guestresource.ConfidentialOptions to set up our internal data structures we use to store and enforce security policy. The options can contain security policy enforcer type, encoded security policy and signed UVM reference information The security policy and uvm reference information can be further presented to workload containers for validation and attestation purposes.
func (*SecurityOptions) WriteSecurityContextDir ¶
func (s *SecurityOptions) WriteSecurityContextDir(spec *specs.Spec) (string, error)
Write security policy, signed UVM reference and host AMD certificate to container's rootfs, so that application and sidecar containers can have access to it. The security policy is required by containers which need to extract init-time claims found in the security policy. The directory path containing the files is exposed via UVM_SECURITY_CONTEXT_DIR env var. It may be an error to have a security policy but not expose it to the container as in that case it can never be checked as correct by a verifier.
On success it returns the path (in the UVM/guest namespace) of the created security context directory, or an empty string if no directory was created because there was nothing to write.
type SecurityPolicy ¶
type SecurityPolicy struct {
// Flag that when set to true allows for all checks to pass. Currently, used
// to run with security policy enforcement "running dark"; checks can be in
// place but the default policy that is created on startup has AllowAll set
// to true, thus making policy enforcement effectively "off" from a logical
// standpoint. Policy enforcement isn't actually off as the policy is "allow
// everything".
AllowAll bool `json:"allow_all"`
// One or more containers that are allowed to run
Containers Containers `json:"containers"`
WindowsContainers WindowsContainers `json:"windows_containers"`
}
func (*SecurityPolicy) EncodeToString ¶ added in v0.10.0
func (sp *SecurityPolicy) EncodeToString() (string, error)
EncodeToString returns base64 encoded string representation of SecurityPolicy.
type SecurityPolicyEnforcer ¶
type SecurityPolicyEnforcer interface {
EnforceDeviceMountPolicy(ctx context.Context, target string, deviceHash string) (err error)
EnforceRWDeviceMountPolicy(ctx context.Context, target string, encrypted, ensureFilesystem bool, filesystem string) (err error)
EnforceMountBlockDevicePolicy(ctx context.Context, target string) (err error)
EnforceDeviceUnmountPolicy(ctx context.Context, unmountTarget string) (err error)
EnforceRWDeviceUnmountPolicy(ctx context.Context, unmountTarget string) (err error)
EnforceUnmountBlockDevicePolicy(ctx context.Context, unmountTarget string) (err error)
EnforceOverlayMountPolicy(ctx context.Context, containerID string, layerPaths []string, target string) (err error)
EnforceOverlayUnmountPolicy(ctx context.Context, target string) (err error)
EnforceCreateContainerPolicy(
ctx context.Context,
sandboxID string,
containerID string,
argList []string,
envList []string,
workingDir string,
mounts []oci.Mount,
privileged bool,
noNewPrivileges bool,
user IDName,
groups []IDName,
umask string,
capabilities *oci.LinuxCapabilities,
seccompProfileSHA256 string,
) (EnvList, *oci.LinuxCapabilities, bool, error)
EnforceCreateContainerPolicyV2(
ctx context.Context,
containerID string,
argList []string,
envList []string,
workingDir string,
mounts []oci.Mount,
user IDName,
opts *CreateContainerOptions,
) (EnvList, *oci.LinuxCapabilities, bool, error)
ExtendDefaultMounts([]oci.Mount) error
EncodedSecurityPolicy() string
EnforceExecInContainerPolicy(
ctx context.Context,
containerID string,
argList []string,
envList []string,
workingDir string,
noNewPrivileges bool,
user IDName,
groups []IDName,
umask string,
capabilities *oci.LinuxCapabilities,
) (EnvList, *oci.LinuxCapabilities, bool, error)
EnforceExecInContainerPolicyV2(
ctx context.Context,
containerID string,
argList []string,
envList []string,
workingDir string,
user IDName,
opts *ExecOptions,
) (EnvList, *oci.LinuxCapabilities, bool, error)
EnforceExecExternalProcessPolicy(ctx context.Context, argList []string, envList []string, workingDir string) (EnvList, bool, error)
EnforceShutdownContainerPolicy(ctx context.Context, containerID string) error
EnforceSignalContainerProcessPolicy(ctx context.Context, containerID string, signal syscall.Signal, isInitProcess bool, startupArgList []string) error
EnforceSignalContainerProcessPolicyV2(ctx context.Context, containerID string, opts *SignalContainerOptions) error
EnforcePlan9MountPolicy(ctx context.Context, target string) (err error)
EnforcePlan9UnmountPolicy(ctx context.Context, target string) (err error)
EnforceGetPropertiesPolicy(ctx context.Context) error
EnforceDumpStacksPolicy(ctx context.Context) error
EnforceRuntimeLoggingPolicy(ctx context.Context) (err error)
EnforceHostNetworkPolicy(ctx context.Context) error
LoadFragment(ctx context.Context, opts LoadFragmentOptions) error
LoadTransparencyTrustList(ctx context.Context, opts LoadTransparencyTrustListOptions) error
EnforceScratchMountPolicy(ctx context.Context, scratchPath string, encrypted bool) (err error)
EnforceScratchUnmountPolicy(ctx context.Context, scratchPath string) (err error)
GetUserInfo(spec *oci.Process, rootPath string) (IDName, []IDName, string, error)
EnforceVerifiedCIMsPolicy(ctx context.Context, containerID string, layerHashes []string, mountedCim []string) (err error)
EnforceRegistryChangesPolicy(ctx context.Context, containerID string, registryValues interface{}) error
// EnforceLogProviderPolicy validates a batch of requested ETW provider
// names against the policy's allowed_log_providers list. It returns the
// subset of provider names that the caller should forward to the inbox
// GCS, plus any policy error. When the policy has
// allow_log_provider_dropping := true, providers not on the allow-list are
// silently dropped from the returned slice; otherwise the whole call is
// denied (returning a non-nil error) if any provider is not allowed.
EnforceLogProviderPolicy(ctx context.Context, providerNames []string) ([]string, error)
WithMetadataRollback(fn func() error) error
}
func CreateSecurityPolicyEnforcer ¶ added in v0.10.0
func CreateSecurityPolicyEnforcer( enforcer string, base64EncodedPolicy string, criMounts, criPrivilegedMounts []oci.Mount, maxErrorMessageLength int, ) (SecurityPolicyEnforcer, error)
CreateSecurityPolicyEnforcer returns an appropriate enforcer for input parameters. Returns an error if the requested `enforcer` implementation isn't registered.
This function can be called both on confidential and non-confidential containers, but in the non-confidential case the policy would be empty. Normally enforcer is not specified, in which case we use either the default for confidential (Rego), or the open door enforcer, depending on whether policy is not empty. However, the host may override this. This override is not measured in the SNP hostData, and so the enforcer must make sure the policy provided is a valid policy for that enforcer. (For example, for open_door, it must either be empty or contain only the "allow_all" field set to true.)
type SignalContainerOptions ¶
type SignalContainerOptions struct {
IsInitProcess bool
// One of these will be set depending on platform
LinuxSignal syscall.Signal
WindowsSignal guestrequest.SignalValueWCOW
LinuxStartupArgs []string
WindowsCommand []string
}
type StringArrayMap ¶ added in v0.10.0
type StringArrayMap struct {
Length int `json:"length"`
Elements map[string]string `json:"elements"`
}
StringArrayMap wraps an array of strings as a string map.
func (StringArrayMap) MarshalJSON ¶ added in v0.10.0
func (s StringArrayMap) MarshalJSON() ([]byte, error)
type UserConfig ¶ added in v0.10.0
type UserConfig struct {
UserIDName IDNameConfig `json:"user_idname" toml:"user_idname"`
GroupIDNames []IDNameConfig `json:"group_idnames" toml:"group_idname"`
Umask string `json:"umask" toml:"umask"`
}
type WindowsContainer ¶
type WindowsContainer struct {
Command CommandArgs `json:"command"`
EnvRules EnvRules `json:"env_rules"`
Layers Layers `json:"layers"`
MountedCim []string `json:"mounted_cim"`
WorkingDir string `json:"working_dir"`
ExecProcesses []WindowsExecProcessConfig `json:"-"`
Signals []guestrequest.SignalValueWCOW `json:"-"`
AllowStdioAccess bool `json:"-"`
User string `json:"-"`
}
func CreateWindowsContainerPolicy ¶
func CreateWindowsContainerPolicy( command, layers, mountedCim []string, envRules []EnvRuleConfig, workingDir string, execProcesses []WindowsExecProcessConfig, signals []guestrequest.SignalValueWCOW, allowStdioAccess bool, user string, ) (*WindowsContainer, error)
CreateWindowsContainerPolicy creates a Windows container policy instance from the provided constraints or returns an error if validation fails.
func (*WindowsContainer) ToInternalContainer ¶
func (c *WindowsContainer) ToInternalContainer() (interface{}, error)
Implement ContainerInterface for WindowsContainer
type WindowsContainerConfig ¶
type WindowsContainerConfig struct {
ImageName string `json:"image_name" toml:"image_name"`
Auth AuthConfig `json:"auth" toml:"auth"`
Command []string `json:"command" toml:"command"`
EnvRules []EnvRuleConfig `json:"env_rules" toml:"env_rule"`
WorkingDir string `json:"working_dir" toml:"working_dir"`
ExecProcesses []WindowsExecProcessConfig `json:"exec_processes" toml:"exec_process"`
Signals []guestrequest.SignalValueWCOW `json:"signals" toml:"signals"`
AllowStdioAccess bool `json:"allow_stdio_access" toml:"allow_stdio_access"`
User string `json:"user" toml:"user"`
}
WindowsContainerConfig contains TOML or JSON configuration for a Windows container described in a security policy. Like ContainerConfig, ImageName is the input; the tooling computes the verified Block CIM layer digests and the merged CIM digest from the image.
type WindowsContainerConfigOpt ¶
type WindowsContainerConfigOpt func(config *WindowsContainerConfig) error
func WithWindowsAllowStdioAccess ¶
func WithWindowsAllowStdioAccess(allow bool) WindowsContainerConfigOpt
WithWindowsAllowStdioAccess enables or disables Windows container init process stdio.
func WithWindowsCommand ¶
func WithWindowsCommand(command []string) WindowsContainerConfigOpt
WithWindowsCommand sets the command in a Windows container policy config.
func WithWindowsEnvVarRules ¶
func WithWindowsEnvVarRules(envs []EnvRuleConfig) WindowsContainerConfigOpt
WithWindowsEnvVarRules adds environment variable constraints to a Windows container policy config.
func WithWindowsExecProcesses ¶
func WithWindowsExecProcesses(processes []WindowsExecProcessConfig) WindowsContainerConfigOpt
WithWindowsExecProcesses adds allowed exec processes to a Windows container policy config.
func WithWindowsImageName ¶
func WithWindowsImageName(imageName string) WindowsContainerConfigOpt
WithWindowsImageName sets the image whose verified Block CIM digests the tooling computes for a Windows container policy config.
func WithWindowsSignals ¶
func WithWindowsSignals(signals []guestrequest.SignalValueWCOW) WindowsContainerConfigOpt
WithWindowsSignals sets the signals allowed for the Windows container init process.
func WithWindowsUser ¶
func WithWindowsUser(user string) WindowsContainerConfigOpt
WithWindowsUser sets the Windows container user.
func WithWindowsWorkingDir ¶
func WithWindowsWorkingDir(workingDir string) WindowsContainerConfigOpt
WithWindowsWorkingDir sets the Windows container working directory.
type WindowsContainers ¶
type WindowsContainers struct {
Length int `json:"length"`
Elements map[string]WindowsContainer `json:"elements"`
}
type WindowsExecProcessConfig ¶
type WindowsExecProcessConfig struct {
Command string `json:"command" toml:"command"`
Signals []guestrequest.SignalValueWCOW `json:"signals" toml:"signals"`
}