Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to force enabling snippet directives #7665

Merged
merged 1 commit into from
Sep 19, 2021

Conversation

rikatz
Copy link
Contributor

@rikatz rikatz commented Sep 19, 2021

Signed-off-by: Ricardo Pchevuzinske Katz ricardo.katz@gmail.com

What this PR does / why we need it:

This PR adds a new ConfigMap option that allows admins to disable users snippets (like server-snippet and configuration-snippet).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Which issue/s this PR fixes

Fixes: TBD

How Has This Been Tested?

Added e2e tests and all the other stuff

/triage accepted
/kind feature

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 19, 2021
@rikatz
Copy link
Contributor Author

rikatz commented Sep 19, 2021

/assign @ElvinEfendi @bowei @strongjz

@k8s-ci-robot k8s-ci-robot added area/docs area/helm Issues or PRs related to helm charts approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Sep 19, 2021
@rikatz rikatz requested review from bowei, strongjz and ElvinEfendi and removed request for tao12345666333 and ChiefAlexander September 19, 2021 17:49
@rikatz rikatz force-pushed the disable-snippets branch 2 times, most recently from 727e35e to 55f62a6 Compare September 19, 2021 17:51
cfg := n.store.GetBackendConfiguration()
cfg.Resolver = n.resolver

for key := range ing.ObjectMeta.GetAnnotations() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For those wondering about this change, as we have a bunch of "fors" in admission webhook for annotations I though it would be better to move all of them to a single iteraction (performance yeeey)

@rikatz rikatz force-pushed the disable-snippets branch 2 times, most recently from e4e73da to 0ba62a0 Compare September 19, 2021 18:01
Signed-off-by: Ricardo Pchevuzinske Katz <ricardo.katz@gmail.com>
@strongjz
Copy link
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 19, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rikatz, strongjz

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rikatz rikatz added this to the v1.0.1 milestone Sep 19, 2021
@k8s-ci-robot k8s-ci-robot merged commit 5e6ab65 into kubernetes:main Sep 19, 2021
rikatz added a commit that referenced this pull request Sep 19, 2021
Signed-off-by: Ricardo Pchevuzinske Katz <ricardo.katz@gmail.com>
k8s-ci-robot pushed a commit that referenced this pull request Sep 20, 2021
* Add option to force enabling snippet directives (#7665)

Signed-off-by: Ricardo Pchevuzinske Katz <ricardo.katz@gmail.com>

* Add missing key when cherry-picking
@@ -46,6 +46,7 @@ The following table shows a configuration option's name, type, and the default v
|[disable-access-log](#disable-access-log)|bool|false|
|[disable-ipv6](#disable-ipv6)|bool|false|
|[disable-ipv6-dns](#disable-ipv6-dns)|bool|false|
|[enable-snippet-directives](#enable-snippet-directives)|bool|true|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about allow-snippet-annotations?

## enable-snippet-directives

Enables Ingress to parse and add *-snippet annotations/directives created by the user. _**default:**_ `true`;
Obs.: We recommend enabling this option only if you TRUST users with permission to create Ingress objects, as this
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is Obs.? Maybe not shorten it? For the text I'd probably go with:

Allows snippets annotations that can inject any NGINX configuration. Set this to `false` if you do not trust the users configuring the ingresses. _**default:**_ `true`;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, agreed. I will change this one here.

Obs is a shorten for "Observação" in portuguese and my head though this made all sense in english...hahaha

I will change here for WARNING

@strongjz @cpanato enable-snippet-directives vs allow-snippet-annotations

I'm tempted now in changing to allow-snippet-annotations as Elvin proposed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Observação

👍🏼 i learned some portuguese

@ElvinEfendi
Copy link
Member

@bowei
Copy link
Member

bowei commented Sep 20, 2021

lgtm

@rikatz
Copy link
Contributor Author

rikatz commented Sep 20, 2021

I wonder if it'd be better to implement the validation at https://github.com/rikatz/ingress-nginx/blob/9e20453abec1be35f110c50b779ce0f992b5f10a/internal/ingress/annotations/annotations.go#L210

I didn't there because the Extractor structure is not aware of the flag/configmap that enables/disables the snippet directives :/

Didn't wanted to change the whole structure for that.

rchshld pushed a commit to joomcode/ingress-nginx that referenced this pull request May 19, 2023
Signed-off-by: Ricardo Pchevuzinske Katz <ricardo.katz@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/docs area/helm Issues or PRs related to helm charts cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants