Skip to content

Commit 70e941d

Browse files
Merge pull request #20151 from stlaz/sysctl_promotion
SCC: Promote sysctl annotations to fields
2 parents be0acc0 + d4a61f6 commit 70e941d

22 files changed

+621
-139
lines changed

api/docs/api/v1.SecurityContextConstraints.adoc

+9-1
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,19 @@ Expand or mouse-over a field for more information about it.
2929
</summary><div style="margin-left:13px;">- <span title="(string)">[string]</span>:
3030
</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>:
3131
</summary><div style="margin-left:13px;">- <span title="(string) Driver is the name of the Flexvolume driver.">driver</span>:
32+
</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.
33+
34+
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>:
35+
</summary><div style="margin-left:13px;">- <span title="(string)">[string]</span>:
3236
</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>:
3337
</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>:
3438
</summary><div style="margin-left:13px;">- <span title="(string)">[string]</span>:
3539
</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>:
36-
</div><details><summary><span title="(v1.FSGroupStrategyOptions) FSGroup is the strategy that will dictate what fs group is used by the SecurityContext.">fsGroup</span>:
40+
</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.
41+
42+
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>:
43+
</summary><div style="margin-left:13px;">- <span title="(string)">[string]</span>:
44+
</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>:
3745
</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>:
3846
</summary><div style="margin-left:13px;"> - <span title="(integer) Max is the end of the range, inclusive.">max</span>:
3947
</div><div style="margin-left:13px;"> <span title="(integer) Min is the start of the range, inclusive.">min</span>:

api/docs/apis-security.openshift.io/v1.SecurityContextConstraints.adoc

+9-1
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,19 @@ Expand or mouse-over a field for more information about it.
2929
</summary><div style="margin-left:13px;">- <span title="(string)">[string]</span>:
3030
</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>:
3131
</summary><div style="margin-left:13px;">- <span title="(string) Driver is the name of the Flexvolume driver.">driver</span>:
32+
</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.
33+
34+
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>:
35+
</summary><div style="margin-left:13px;">- <span title="(string)">[string]</span>:
3236
</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>:
3337
</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>:
3438
</summary><div style="margin-left:13px;">- <span title="(string)">[string]</span>:
3539
</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>:
36-
</div><details><summary><span title="(v1.FSGroupStrategyOptions) FSGroup is the strategy that will dictate what fs group is used by the SecurityContext.">fsGroup</span>:
40+
</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.
41+
42+
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>:
43+
</summary><div style="margin-left:13px;">- <span title="(string)">[string]</span>:
44+
</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>:
3745
</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>:
3846
</summary><div style="margin-left:13px;"> - <span title="(integer) Max is the end of the range, inclusive.">max</span>:
3947
</div><div style="margin-left:13px;"> <span title="(integer) Min is the start of the range, inclusive.">min</span>:

api/protobuf-spec/github_com_openshift_api_security_v1.proto

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/swagger-spec/api-v1.json

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/swagger-spec/openshift-openapi-spec.json

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

glide.lock

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/cmd/server/bootstrappolicy/securitycontextconstraints.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ func GetBootstrapSecurityContextConstraints(sccNameToAdditionalGroups map[string
9494
SupplementalGroups: securityapi.SupplementalGroupsStrategyOptions{
9595
Type: securityapi.SupplementalGroupsStrategyRunAsAny,
9696
},
97-
SeccompProfiles: []string{"*"},
97+
SeccompProfiles: []string{"*"},
98+
AllowedUnsafeSysctls: []string{"*"},
9899
},
99100
// SecurityContextConstraintNonRoot does not allow host access, allocates SELinux labels
100101
// and allows the user to request a specific UID or provide the default in the dockerfile.

pkg/oc/lib/describe/describer.go

+6
Original file line numberDiff line numberDiff line change
@@ -1896,6 +1896,8 @@ func describeSecurityContextConstraints(scc *securityapi.SecurityContextConstrai
18961896
fmt.Fprintf(out, " Allowed Seccomp Profiles:\t%s\n", stringOrNone(strings.Join(scc.SeccompProfiles, ",")))
18971897
fmt.Fprintf(out, " Allowed Volume Types:\t%s\n", fsTypeToString(scc.Volumes))
18981898
fmt.Fprintf(out, " Allowed Flexvolumes:\t%s\n", flexVolumesToString(scc.AllowedFlexVolumes))
1899+
fmt.Fprintf(out, " Allowed Unsafe Sysctls:\t%s\n", sysctlsToString(scc.AllowedUnsafeSysctls))
1900+
fmt.Fprintf(out, " Forbidden Sysctls:\t%s\n", sysctlsToString(scc.ForbiddenSysctls))
18991901
fmt.Fprintf(out, " Allow Host Network:\t%t\n", scc.AllowHostNetwork)
19001902
fmt.Fprintf(out, " Allow Host Ports:\t%t\n", scc.AllowHostPorts)
19011903
fmt.Fprintf(out, " Allow Host PID:\t%t\n", scc.AllowHostPID)
@@ -1971,6 +1973,10 @@ func flexVolumesToString(flexVolumes []securityapi.AllowedFlexVolume) string {
19711973
return stringOrDefaultValue(strings.Join(volumes, ","), "<all>")
19721974
}
19731975

1976+
func sysctlsToString(sysctls []string) string {
1977+
return stringOrNone(strings.Join(sysctls, ","))
1978+
}
1979+
19741980
func idRangeToString(ranges []securityapi.IDRange) string {
19751981
formattedString := ""
19761982
if ranges != nil {

pkg/openapi/zz_generated.openapi.go

+28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/security/apis/security/types.go

+20
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,26 @@ type SecurityContextConstraints struct {
9292
Users []string
9393
// The groups that have permission to use this security context constraints
9494
Groups []string
95+
96+
// AllowedUnsafeSysctls is a list of explicitly allowed unsafe sysctls, defaults to none.
97+
// Each entry is either a plain sysctl name or ends in "*" in which case it is considered
98+
// as a prefix of allowed sysctls. Single * means all unsafe sysctls are allowed.
99+
// Kubelet has to whitelist all allowed unsafe sysctls explicitly to avoid rejection.
100+
//
101+
// Examples:
102+
// e.g. "foo/*" allows "foo/bar", "foo/baz", etc.
103+
// e.g. "foo.*" allows "foo.bar", "foo.baz", etc.
104+
// +optional
105+
AllowedUnsafeSysctls []string
106+
// ForbiddenSysctls is a list of explicitly forbidden sysctls, defaults to none.
107+
// Each entry is either a plain sysctl name or ends in "*" in which case it is considered
108+
// as a prefix of forbidden sysctls. Single * means all sysctls are forbidden.
109+
//
110+
// Examples:
111+
// e.g. "foo/*" forbids "foo/bar", "foo/baz", etc.
112+
// e.g. "foo.*" forbids "foo.bar", "foo.baz", etc.
113+
// +optional
114+
ForbiddenSysctls []string
95115
}
96116

97117
// FS Type gives strong typing to different file systems that are used by volumes.

pkg/security/apis/security/v1/zz_generated.conversion.go

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)