Skip to content
New issue

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

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

Already on GitHub? # to your account

fix: Parse hostname correctly from repoURL to fetch correct CA cert #19488

Merged
merged 2 commits into from
Aug 14, 2024

Conversation

svghadi
Copy link
Contributor

@svghadi svghadi commented Aug 12, 2024

Fixes #19138

getCAPath func doesn't correctly return the path for the tls cert if the repoURL passed contains path or port number without a schema. This is mainly because how the url.Parse() treats a url without schema. Stackoverflow REF
eg:

'registry.default/helm-charts' ---parsed-as---> 'registry.default/helm-charts'   #should be 'registry.default'
'registry.example.com:5000' ---parsed-as---> ''    # should be 'registry.example.com'

Below changes are made to ensure the hostname is correctly parsed to return a valid cert path(if present) belonging to the repoURL. The new change works like before for oci case where the schema oci:// is not part of repoURL string, no separate handling is required.

Change:

  • Prepend repoURL with dummy schema if not present to ensure net/url correctly parse the hostname.
  • Strip port number from hostname if any using net/url's Hostname() func.

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

@svghadi svghadi requested a review from a team as a code owner August 12, 2024 11:00
Copy link

bunnyshell bot commented Aug 12, 2024

❌ Preview Environment deleted from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

Copy link

bunnyshell bot commented Aug 12, 2024

❌ Preview Environment deleted from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

Copy link

codecov bot commented Aug 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.83%. Comparing base (6296b17) to head (bfde103).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #19488      +/-   ##
==========================================
+ Coverage   55.79%   55.83%   +0.04%     
==========================================
  Files         316      316              
  Lines       43735    43737       +2     
==========================================
+ Hits        24402    24421      +19     
+ Misses      16780    16752      -28     
- Partials     2553     2564      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@svghadi svghadi marked this pull request as draft August 12, 2024 14:17
@svghadi svghadi marked this pull request as draft August 12, 2024 14:17
Signed-off-by: Siddhesh Ghadi <sghadi1203@gmail.com>
@svghadi svghadi marked this pull request as ready for review August 13, 2024 04:46
Copy link
Member

@jannfis jannfis left a comment

Choose a reason for hiding this comment

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

LGTM!

@jannfis jannfis enabled auto-merge (squash) August 14, 2024 19:50
@jannfis jannfis merged commit 58543f3 into argoproj:master Aug 14, 2024
27 of 28 checks passed
@svghadi svghadi deleted the repo-url-path-certs branch August 15, 2024 06:29
ChichiCaleb pushed a commit to ChichiCaleb/argo-cd that referenced this pull request Aug 15, 2024
…rgoproj#19488)

Signed-off-by: Siddhesh Ghadi <sghadi1203@gmail.com>
Co-authored-by: Jann Fischer <jann@mistrust.net>
Signed-off-by: ChichiCaleb <ChichiCaleb@chichiuchenna@gmail.com>
ChichiCaleb pushed a commit to ChichiCaleb/argo-cd that referenced this pull request Aug 15, 2024
…rgoproj#19488)

Signed-off-by: Siddhesh Ghadi <sghadi1203@gmail.com>
Co-authored-by: Jann Fischer <jann@mistrust.net>
Signed-off-by: ChichiCaleb <ChichiCaleb@chichiuchenna@gmail.com>
Signed-off-by: ChichiCaleb <chichiuchenna@gmail.com>
@svghadi
Copy link
Contributor Author

svghadi commented Aug 20, 2024

Thanks @jannfis.

@ishitasequeira - It would be great if this could be backported to 2.12.x and 2.11.x.

@ishitasequeira
Copy link
Member

/cherry-pick release-2.12

gcp-cherry-pick-bot bot pushed a commit that referenced this pull request Aug 20, 2024
…19488)

Signed-off-by: Siddhesh Ghadi <sghadi1203@gmail.com>
Co-authored-by: Jann Fischer <jann@mistrust.net>
@ishitasequeira
Copy link
Member

/cherry-pick release-2.11

gcp-cherry-pick-bot bot pushed a commit that referenced this pull request Aug 20, 2024
…19488)

Signed-off-by: Siddhesh Ghadi <sghadi1203@gmail.com>
Co-authored-by: Jann Fischer <jann@mistrust.net>
ishitasequeira pushed a commit that referenced this pull request Aug 21, 2024
…19488) (#19603)

Signed-off-by: Siddhesh Ghadi <sghadi1203@gmail.com>
Co-authored-by: Siddhesh Ghadi <61187612+svghadi@users.noreply.github.com>
Co-authored-by: Jann Fischer <jann@mistrust.net>
ishitasequeira pushed a commit that referenced this pull request Aug 21, 2024
…19488) (#19602)

Signed-off-by: Siddhesh Ghadi <sghadi1203@gmail.com>
Co-authored-by: Siddhesh Ghadi <61187612+svghadi@users.noreply.github.com>
Co-authored-by: Jann Fischer <jann@mistrust.net>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TLS certs not passed correctly if helm repo contains path in repository URL
3 participants