Skip to content

Commit

Permalink
Merge pull request #20151 from stlaz/sysctl_promotion
Browse files Browse the repository at this point in the history
SCC: Promote sysctl annotations to fields
  • Loading branch information
openshift-merge-robot authored Jul 21, 2018
2 parents be0acc0 + d4a61f6 commit 70e941d
Show file tree
Hide file tree
Showing 22 changed files with 621 additions and 139 deletions.
10 changes: 9 additions & 1 deletion api/docs/api/v1.SecurityContextConstraints.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,19 @@ Expand or mouse-over a field for more information about it.
</summary><div style="margin-left:13px;">- <span title="(string)">[string]</span>:
</div></details><details><summary><span title="(array) AllowedFlexVolumes is a whitelist of allowed Flexvolumes. Empty or nil indicates that all Flexvolumes may be used. This parameter is effective only when the usage of the Flexvolumes is allowed in the &#34;Volumes&#34; field.">allowedFlexVolumes</span>:
</summary><div style="margin-left:13px;">- <span title="(string) Driver is the name of the Flexvolume driver.">driver</span>:
</div></details><details><summary><span title="(array) AllowedUnsafeSysctls is a list of explicitly allowed unsafe sysctls, defaults to none. Each entry is either a plain sysctl name or ends in &#34;*&#34; in which case it is considered as a prefix of allowed sysctls. Single * means all unsafe sysctls are allowed. Kubelet has to whitelist all allowed unsafe sysctls explicitly to avoid rejection.
Examples: e.g. &#34;foo/*&#34; allows &#34;foo/bar&#34;, &#34;foo/baz&#34;, etc. e.g. &#34;foo.*&#34; allows &#34;foo.bar&#34;, &#34;foo.baz&#34;, etc.">allowedUnsafeSysctls</span>:
</summary><div style="margin-left:13px;">- <span title="(string)">[string]</span>:
</div></details><div style="margin-left:13px;"><span title="(string) APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources">apiVersion</span>:
</div><details><summary><span title="(array) DefaultAddCapabilities is the default set of capabilities that will be added to the container unless the pod spec specifically drops the capability. You may not list a capabiility in both DefaultAddCapabilities and RequiredDropCapabilities.">defaultAddCapabilities</span>:
</summary><div style="margin-left:13px;">- <span title="(string)">[string]</span>:
</div></details><div style="margin-left:13px;"><span title="(boolean) DefaultAllowPrivilegeEscalation controls the default setting for whether a process can gain more privileges than its parent process.">defaultAllowPrivilegeEscalation</span>:
</div><details><summary><span title="(v1.FSGroupStrategyOptions) FSGroup is the strategy that will dictate what fs group is used by the SecurityContext.">fsGroup</span>:
</div><details><summary><span title="(array) ForbiddenSysctls is a list of explicitly forbidden sysctls, defaults to none. Each entry is either a plain sysctl name or ends in &#34;*&#34; in which case it is considered as a prefix of forbidden sysctls. Single * means all sysctls are forbidden.
Examples: e.g. &#34;foo/*&#34; forbids &#34;foo/bar&#34;, &#34;foo/baz&#34;, etc. e.g. &#34;foo.*&#34; forbids &#34;foo.bar&#34;, &#34;foo.baz&#34;, etc.">forbiddenSysctls</span>:
</summary><div style="margin-left:13px;">- <span title="(string)">[string]</span>:
</div></details><details><summary><span title="(v1.FSGroupStrategyOptions) FSGroup is the strategy that will dictate what fs group is used by the SecurityContext.">fsGroup</span>:
</summary><details><summary> <span title="(array) Ranges are the allowed ranges of fs groups. If you would like to force a single fs group then supply a single range with the same start and end.">ranges</span>:
</summary><div style="margin-left:13px;"> - <span title="(integer) Max is the end of the range, inclusive.">max</span>:
</div><div style="margin-left:13px;"> <span title="(integer) Min is the start of the range, inclusive.">min</span>:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,19 @@ Expand or mouse-over a field for more information about it.
</summary><div style="margin-left:13px;">- <span title="(string)">[string]</span>:
</div></details><details><summary><span title="(array) AllowedFlexVolumes is a whitelist of allowed Flexvolumes. Empty or nil indicates that all Flexvolumes may be used. This parameter is effective only when the usage of the Flexvolumes is allowed in the &#34;Volumes&#34; field.">allowedFlexVolumes</span>:
</summary><div style="margin-left:13px;">- <span title="(string) Driver is the name of the Flexvolume driver.">driver</span>:
</div></details><details><summary><span title="(array) AllowedUnsafeSysctls is a list of explicitly allowed unsafe sysctls, defaults to none. Each entry is either a plain sysctl name or ends in &#34;*&#34; in which case it is considered as a prefix of allowed sysctls. Single * means all unsafe sysctls are allowed. Kubelet has to whitelist all allowed unsafe sysctls explicitly to avoid rejection.
Examples: e.g. &#34;foo/*&#34; allows &#34;foo/bar&#34;, &#34;foo/baz&#34;, etc. e.g. &#34;foo.*&#34; allows &#34;foo.bar&#34;, &#34;foo.baz&#34;, etc.">allowedUnsafeSysctls</span>:
</summary><div style="margin-left:13px;">- <span title="(string)">[string]</span>:
</div></details><div style="margin-left:13px;"><span title="(string) APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources">apiVersion</span>:
</div><details><summary><span title="(array) DefaultAddCapabilities is the default set of capabilities that will be added to the container unless the pod spec specifically drops the capability. You may not list a capabiility in both DefaultAddCapabilities and RequiredDropCapabilities.">defaultAddCapabilities</span>:
</summary><div style="margin-left:13px;">- <span title="(string)">[string]</span>:
</div></details><div style="margin-left:13px;"><span title="(boolean) DefaultAllowPrivilegeEscalation controls the default setting for whether a process can gain more privileges than its parent process.">defaultAllowPrivilegeEscalation</span>:
</div><details><summary><span title="(v1.FSGroupStrategyOptions) FSGroup is the strategy that will dictate what fs group is used by the SecurityContext.">fsGroup</span>:
</div><details><summary><span title="(array) ForbiddenSysctls is a list of explicitly forbidden sysctls, defaults to none. Each entry is either a plain sysctl name or ends in &#34;*&#34; in which case it is considered as a prefix of forbidden sysctls. Single * means all sysctls are forbidden.
Examples: e.g. &#34;foo/*&#34; forbids &#34;foo/bar&#34;, &#34;foo/baz&#34;, etc. e.g. &#34;foo.*&#34; forbids &#34;foo.bar&#34;, &#34;foo.baz&#34;, etc.">forbiddenSysctls</span>:
</summary><div style="margin-left:13px;">- <span title="(string)">[string]</span>:
</div></details><details><summary><span title="(v1.FSGroupStrategyOptions) FSGroup is the strategy that will dictate what fs group is used by the SecurityContext.">fsGroup</span>:
</summary><details><summary> <span title="(array) Ranges are the allowed ranges of fs groups. If you would like to force a single fs group then supply a single range with the same start and end.">ranges</span>:
</summary><div style="margin-left:13px;"> - <span title="(integer) Max is the end of the range, inclusive.">max</span>:
</div><div style="margin-left:13px;"> <span title="(integer) Min is the start of the range, inclusive.">min</span>:
Expand Down
21 changes: 21 additions & 0 deletions api/protobuf-spec/github_com_openshift_api_security_v1.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions api/swagger-spec/api-v1.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions api/swagger-spec/openshift-openapi-spec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pkg/cmd/server/bootstrappolicy/securitycontextconstraints.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ func GetBootstrapSecurityContextConstraints(sccNameToAdditionalGroups map[string
SupplementalGroups: securityapi.SupplementalGroupsStrategyOptions{
Type: securityapi.SupplementalGroupsStrategyRunAsAny,
},
SeccompProfiles: []string{"*"},
SeccompProfiles: []string{"*"},
AllowedUnsafeSysctls: []string{"*"},
},
// SecurityContextConstraintNonRoot does not allow host access, allocates SELinux labels
// and allows the user to request a specific UID or provide the default in the dockerfile.
Expand Down
6 changes: 6 additions & 0 deletions pkg/oc/lib/describe/describer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1896,6 +1896,8 @@ func describeSecurityContextConstraints(scc *securityapi.SecurityContextConstrai
fmt.Fprintf(out, " Allowed Seccomp Profiles:\t%s\n", stringOrNone(strings.Join(scc.SeccompProfiles, ",")))
fmt.Fprintf(out, " Allowed Volume Types:\t%s\n", fsTypeToString(scc.Volumes))
fmt.Fprintf(out, " Allowed Flexvolumes:\t%s\n", flexVolumesToString(scc.AllowedFlexVolumes))
fmt.Fprintf(out, " Allowed Unsafe Sysctls:\t%s\n", sysctlsToString(scc.AllowedUnsafeSysctls))
fmt.Fprintf(out, " Forbidden Sysctls:\t%s\n", sysctlsToString(scc.ForbiddenSysctls))
fmt.Fprintf(out, " Allow Host Network:\t%t\n", scc.AllowHostNetwork)
fmt.Fprintf(out, " Allow Host Ports:\t%t\n", scc.AllowHostPorts)
fmt.Fprintf(out, " Allow Host PID:\t%t\n", scc.AllowHostPID)
Expand Down Expand Up @@ -1971,6 +1973,10 @@ func flexVolumesToString(flexVolumes []securityapi.AllowedFlexVolume) string {
return stringOrDefaultValue(strings.Join(volumes, ","), "<all>")
}

func sysctlsToString(sysctls []string) string {
return stringOrNone(strings.Join(sysctls, ","))
}

func idRangeToString(ranges []securityapi.IDRange) string {
formattedString := ""
if ranges != nil {
Expand Down
28 changes: 28 additions & 0 deletions pkg/openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions pkg/security/apis/security/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,26 @@ type SecurityContextConstraints struct {
Users []string
// The groups that have permission to use this security context constraints
Groups []string

// AllowedUnsafeSysctls is a list of explicitly allowed unsafe sysctls, defaults to none.
// Each entry is either a plain sysctl name or ends in "*" in which case it is considered
// as a prefix of allowed sysctls. Single * means all unsafe sysctls are allowed.
// Kubelet has to whitelist all allowed unsafe sysctls explicitly to avoid rejection.
//
// Examples:
// e.g. "foo/*" allows "foo/bar", "foo/baz", etc.
// e.g. "foo.*" allows "foo.bar", "foo.baz", etc.
// +optional
AllowedUnsafeSysctls []string
// ForbiddenSysctls is a list of explicitly forbidden sysctls, defaults to none.
// Each entry is either a plain sysctl name or ends in "*" in which case it is considered
// as a prefix of forbidden sysctls. Single * means all sysctls are forbidden.
//
// Examples:
// e.g. "foo/*" forbids "foo/bar", "foo/baz", etc.
// e.g. "foo.*" forbids "foo.bar", "foo.baz", etc.
// +optional
ForbiddenSysctls []string
}

// FS Type gives strong typing to different file systems that are used by volumes.
Expand Down
4 changes: 4 additions & 0 deletions pkg/security/apis/security/v1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 70e941d

Please sign in to comment.