Disable user snippets per default
This commit is contained in:
parent
93e006c2ce
commit
a7666ebc52
6 changed files with 15 additions and 8 deletions
|
@ -73,7 +73,7 @@ controller:
|
|||
# their own *-snippet annotations, otherwise this is forbidden / dropped
|
||||
# when users add those annotations.
|
||||
# Global snippets in ConfigMap are still respected
|
||||
allowSnippetAnnotations: true
|
||||
allowSnippetAnnotations: false
|
||||
# -- Required for use with CNI based kubernetes installations (such as ones set up by kubeadm),
|
||||
# since CNI and hostport don't mix yet. Can be deprecated once https://github.com/kubernetes/kubernetes/issues/23920
|
||||
# is merged
|
||||
|
|
|
@ -30,7 +30,7 @@ The following table shows a configuration option's name, type, and the default v
|
|||
|[add-headers](#add-headers)|string|""||
|
||||
|[allow-backend-server-header](#allow-backend-server-header)|bool|"false"||
|
||||
|[allow-cross-namespace-resources](#allow-cross-namespace-resources)|bool|"true"||
|
||||
|[allow-snippet-annotations](#allow-snippet-annotations)|bool|true||
|
||||
|[allow-snippet-annotations](#allow-snippet-annotations)|bool|false||
|
||||
|[annotations-risk-level](#annotations-risk-level)|string|Critical||
|
||||
|[annotation-value-word-blocklist](#annotation-value-word-blocklist)|string array|""||
|
||||
|[hide-headers](#hide-headers)|string array|empty||
|
||||
|
@ -257,7 +257,7 @@ Enables users to consume cross namespace resource on annotations, when was previ
|
|||
|
||||
## allow-snippet-annotations
|
||||
|
||||
Enables Ingress to parse and add *-snippet annotations/directives created by the user. _**default:**_ `true`
|
||||
Enables Ingress to parse and add *-snippet annotations/directives created by the user. _**default:**_ `false`
|
||||
|
||||
Warning: We recommend enabling this option only if you TRUST users with permission to create Ingress objects, as this
|
||||
may allow a user to add restricted configurations to the final nginx.conf file
|
||||
|
|
|
@ -865,7 +865,7 @@ func NewDefault() Configuration {
|
|||
defGlobalExternalAuth := GlobalExternalAuth{"", "", "", "", "", append(defResponseHeaders, ""), "", "", "", []string{}, map[string]string{}, false}
|
||||
|
||||
cfg := Configuration{
|
||||
AllowSnippetAnnotations: true,
|
||||
AllowSnippetAnnotations: false,
|
||||
AllowCrossNamespaceResources: true,
|
||||
AllowBackendServerHeader: false,
|
||||
AnnotationValueWordBlocklist: "",
|
||||
|
|
|
@ -33,6 +33,11 @@ var _ = framework.DescribeAnnotation("configuration-snippet", func() {
|
|||
|
||||
ginkgo.It("set snippet more_set_headers in all locations", func() {
|
||||
host := "configurationsnippet.foo.com"
|
||||
|
||||
f.SetNginxConfigMapData(map[string]string{
|
||||
"allow-snippet-annotations": "true",
|
||||
})
|
||||
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/configuration-snippet": `more_set_headers "Foo1: Bar1";`,
|
||||
}
|
||||
|
@ -76,10 +81,6 @@ var _ = framework.DescribeAnnotation("configuration-snippet", func() {
|
|||
annotations)
|
||||
|
||||
f.UpdateNginxConfigMapData("allow-snippet-annotations", "false")
|
||||
defer func() {
|
||||
// Return to the original value
|
||||
f.UpdateNginxConfigMapData("allow-snippet-annotations", "true")
|
||||
}()
|
||||
|
||||
// Sleep a while just to guarantee that the configmap is applied
|
||||
framework.Sleep()
|
||||
|
|
|
@ -39,6 +39,11 @@ var _ = framework.DescribeSetting("stream-snippet", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should add value of stream-snippet to nginx config", func() {
|
||||
|
||||
f.SetNginxConfigMapData(map[string]string{
|
||||
"allow-snippet-annotations": "true",
|
||||
})
|
||||
|
||||
host := "foo.com"
|
||||
|
||||
snippet := `server {listen 8000; proxy_pass 127.0.0.1:80;}`
|
||||
|
|
|
@ -37,6 +37,7 @@ var _ = framework.DescribeSetting("configmap server-snippet", func() {
|
|||
hostAnnots := "serverannotssnippet1.foo.com"
|
||||
|
||||
f.SetNginxConfigMapData(map[string]string{
|
||||
"allow-snippet-annotations": "true",
|
||||
"server-snippet": `
|
||||
more_set_headers "Globalfoo: Foooo";`,
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue