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

fix: updated regex on validateNetwork to support special characters. #18158

Merged

Conversation

alessandrocapanna
Copy link
Contributor

Fix issue #17614

Now the regex support special characters as mentioned on issue.

Test made with faked credential: "http://user:fake%[email protected]:80"

Before:
Schermata 2024-02-13 alle 01 16 07

After:

Schermata 2024-02-13 alle 00 58 13

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 13, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @alessandrocapanna!

It looks like this is your first PR to kubernetes/minikube 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/minikube has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 13, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @alessandrocapanna. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Feb 13, 2024
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@Zhongyi-Lu
Copy link

@alessandrocapanna

I noticed the use of a lazy quantifier in the pattern //(\w+):.*?@. This approach definitely has its merits, especially for ensuring that we capture the least amount necessary before reaching the first @ symbol.

However, I was wondering if we might achieve the same result with a slightly simpler pattern: //(\w+):.*@. This version omits the lazy quantifier in favor of a more straightforward match up to the last @ symbol in cases where URLs might contain multiple @ symbols, like in http://jdoe:%n0tRe@[email protected]:8080.

I am not sure if we have such cases because I just walked around and visited this GitHub repository :)

@spowelljr
Copy link
Member

I agree with @Zhongyi-Lu, using his example string http://jdoe:%n0tRe@[email protected]:8080

Using //(\w+):.*?@ matches //jdoe:%n0tRe@

While //(\w+):.*@ matches //jdoe:%n0tRe@alPassword!@

@alessandrocapanna
Copy link
Contributor Author

Yeah... I also agree with @Zhongyi-Lu, I will modify the pull request, I will also insert strings like those suggested in the tests :D

@spowelljr
Copy link
Member

spowelljr commented Mar 21, 2024

Hi @alessandrocapanna, I just realized we have a function somewhere else in our code that does this as well.

maskProxyPassword in pkg/minikube/node/config.go

Could you make the function public and move it to pkg/util, then update any refernces to it, and then we can make the code you modified to use the function as well. There is also a test for the function in pkg/minikube/node/config_test.go you could move as well and add additional test cases if needed. Feel free to change the function if it's not working as expected.

Edit: maskProxyPassword expects an input of HTTP(S)_PROXY=<value> where the code you modified we're just looking for the value, so probably makes sense to have two funcs MaskProxyPassword & MaskProxyPasswordWithKey or something like that and the latter first isolates the value before calling MaskProxyPassword.

If anything is unclear just let me know

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 26, 2024
… & tests, introduced MaskProxyPasswordWithKey

refactor(util): Move maskProxyPassword to pkg/util, update references & tests, introduced MaskProxyPasswordWithKey
@alessandrocapanna
Copy link
Contributor Author

Hi @spowelljr.
I've completed the refactor you suggested. I split the maskProxyPassword function into two separate functions (under pkg/util) and made the necessary corrections. Additionally, I updated the references accordingly and added tests for both functions.

@spowelljr
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 27, 2024
@minikube-pr-bot
Copy link

kvm2 driver with docker runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 18158) |
+----------------+----------+---------------------+
| minikube start | 51.4s    | 52.2s               |
| enable ingress | 26.5s    | 26.0s               |
+----------------+----------+---------------------+

Times for minikube start: 50.5s 51.1s 51.1s 51.7s 52.6s
Times for minikube (PR 18158) start: 51.3s 54.0s 52.9s 50.4s 52.2s

Times for minikube ingress: 26.5s 28.1s 26.4s 24.0s 27.5s
Times for minikube (PR 18158) ingress: 25.1s 23.1s 27.5s 26.5s 28.0s

docker driver with docker runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 18158) |
+----------------+----------+---------------------+
| minikube start | 23.7s    | 23.7s               |
| enable ingress | 21.6s    | 21.1s               |
+----------------+----------+---------------------+

Times for minikube start: 24.4s 23.6s 24.3s 20.8s 25.2s
Times for minikube (PR 18158) start: 24.7s 24.4s 23.8s 24.4s 21.4s

Times for minikube ingress: 21.8s 22.3s 21.2s 21.3s 21.3s
Times for minikube (PR 18158) ingress: 21.3s 20.8s 20.7s 21.3s 21.3s

docker driver with containerd runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 18158) |
+----------------+----------+---------------------+
| minikube start | 22.4s    | 21.8s               |
| enable ingress | 31.6s    | 34.8s               |
+----------------+----------+---------------------+

Times for minikube start: 22.8s 23.6s 19.3s 23.3s 23.1s
Times for minikube (PR 18158) start: 19.8s 22.4s 22.8s 23.4s 20.4s

Times for minikube (PR 18158) ingress: 31.7s 46.7s 31.8s 31.8s 31.8s
Times for minikube ingress: 31.8s 31.8s 30.8s 32.8s 30.8s

@minikube-pr-bot
Copy link

These are the flake rates of all failed tests.

Environment Failed Tests Flake Rate (%)
Docker_Linux_containerd_arm64 TestAddons/parallel/Headlamp (gopogh) 0.00 (chart)
QEMU_macOS TestAddons/Setup (gopogh) 8.82 (chart)
QEMU_macOS TestFunctional/parallel/CpCmd (gopogh) 8.82 (chart)
QEMU_macOS TestFunctional/parallel/FileSync (gopogh) 8.82 (chart)
QEMU_macOS TestFunctional/parallel/NonActiveRuntimeDisabled (gopogh) 8.82 (chart)
QEMU_macOS TestFunctional/parallel/SSHCmd (gopogh) 8.82 (chart)
QEMU_macOS TestFunctional/parallel/UpdateContextCmd/no_clusters (gopogh) 8.82 (chart)
QEMU_macOS TestFunctional/parallel/UpdateContextCmd/no_minikube_cluster (gopogh) 8.82 (chart)
QEMU_macOS TestFunctional/parallel/Version/components (gopogh) 8.82 (chart)
QEMU_macOS TestFunctional/serial/LogsCmd (gopogh) 8.82 (chart)
QEMU_macOS TestFunctional/serial/LogsFileCmd (gopogh) 8.82 (chart)
QEMU_macOS TestFunctional/parallel/CertSync (gopogh) 10.29 (chart)
QEMU_macOS TestFunctional/parallel/DashboardCmd (gopogh) 10.29 (chart)
QEMU_macOS TestFunctional/parallel/DockerEnv/bash (gopogh) 10.29 (chart)
QEMU_macOS TestFunctional/parallel/ImageCommands/ImageBuild (gopogh) 10.29 (chart)
QEMU_macOS TestFunctional/parallel/ImageCommands/ImageListJson (gopogh) 10.29 (chart)
QEMU_macOS TestFunctional/parallel/ImageCommands/ImageListShort (gopogh) 10.29 (chart)
QEMU_macOS TestFunctional/parallel/ImageCommands/ImageListTable (gopogh) 10.29 (chart)
QEMU_macOS TestFunctional/parallel/ImageCommands/ImageListYaml (gopogh) 10.29 (chart)
QEMU_macOS TestFunctional/parallel/ImageCommands/ImageLoadDaemon (gopogh) 10.29 (chart)
QEMU_macOS TestFunctional/parallel/ImageCommands/ImageLoadFromFile (gopogh) 10.29 (chart)
QEMU_macOS TestFunctional/parallel/ImageCommands/ImageReloadDaemon (gopogh) 10.29 (chart)
QEMU_macOS TestFunctional/parallel/ImageCommands/ImageSaveToFile (gopogh) 10.29 (chart)
QEMU_macOS TestFunctional/parallel/NodeLabels (gopogh) 10.29 (chart)
QEMU_macOS TestFunctional/parallel/PersistentVolumeClaim (gopogh) 10.29 (chart)
QEMU_macOS TestFunctional/parallel/ServiceCmd/DeployApp (gopogh) 10.29 (chart)
QEMU_macOS TestFunctional/parallel/ServiceCmd/Format (gopogh) 10.29 (chart)
QEMU_macOS TestFunctional/parallel/ServiceCmd/HTTPS (gopogh) 10.29 (chart)
QEMU_macOS TestFunctional/parallel/ServiceCmd/JSONOutput (gopogh) 10.29 (chart)
QEMU_macOS TestFunctional/parallel/ServiceCmd/List (gopogh) 10.29 (chart)
More tests... Continued...

Too many tests failed - See test logs for more details.

To see the flake rates of all tests by environment, click here.

Copy link
Member

@spowelljr spowelljr left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

@spowelljr spowelljr merged commit 68ed09b into kubernetes:master Mar 28, 2024
26 of 41 checks passed
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alessandrocapanna, spowelljr

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 28, 2024
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants