Skip to content

Fixed an issue with vendor.yaml source failing to accept git::ssh URI - #1054

Merged
Erik Osterman (Cloud Posse) (osterman) merged 10 commits into
cloudposse:mainfrom
elsayedmt:git-ssh-vendoring-issue
Feb 19, 2025
Merged

Erik Osterman (Cloud Posse) (osterman) merged 10 commits into
cloudposse:mainfrom
elsayedmt:git-ssh-vendoring-issue

Conversation

@elsayedmt

@elsayedmt Mohamed Elsayed (elsayedmt) commented Feb 12, 2025 •

Copy link
Copy Markdown
Contributor

what

Modified the validation code to accept URL style SSH addresses accepted by go-getter as in [1]

why

I am trying to checkout a bitbucket repo using an SSH key.

bitbucket.org
uses HTTPS

[email protected]
fails with this

Failed to vendor repo-name: error : failed to download package: relative paths require a module with a pwd

ssh://[email protected]
fails with

Vendoring from 'vendor.yaml'
Failed to vendor repo-name: error : failed to download package: download not supported for scheme 'ssh'

ssh::[email protected]
fails with

Vendoring from 'vendor.yaml'
Failed to vendor repo-name: error : failed to download package: relative paths require a module with a pwd

git::ssh://[email protected]
fails before the fix with

Vendoring from 'vendor.yaml'
unsupported URI scheme: git::ssh
successful after the fix

This was the only successful setup without having to modify the GoGetter call to include a Pwd.

references

[1] See here https://github.com/hashicorp/go-getter and the description of URL structures below

The git getter accepts both URL-style SSH addresses like git::ssh://[email protected]/foo/bar, and "scp-style" addresses like git::[email protected]/foo/bar. In the latter case, omitting the git:: force prefix is allowed if the username prefix is exactly git@.

Summary by CodeRabbit

  • New Features
    • Enhanced URI validation by adding support for the "git::ssh" scheme, ensuring improved handling of new URI formats.

@elsayedmt
Mohamed Elsayed (elsayedmt) requested a review from a team as a code owner February 12, 2025 04:22
@mergify mergify Bot added the triage Needs triage label Feb 12, 2025
@coderabbitai

coderabbitai Bot commented Feb 12, 2025 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The pull request introduces an enhancement to the URI validation logic by modifying the IsValidScheme function in internal/exec/go_getter_utils.go. It incorporates the "git::ssh" scheme into the list of valid schemes, enabling the function to recognize URIs with this scheme. This update is aimed at improving the handling of git SSH URLs within the application.

Changes

File(s) Change Summary
internal/exec/go_getter_utils.go Updated IsValidScheme to include "git::ssh" in the valid schemes map.

Suggested labels

minor

Suggested reviewers

  • aknysh

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 473ce22 and d225a83.

📒 Files selected for processing (1)
  • internal/exec/go_getter_utils.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/exec/go_getter_utils.go
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or @auto-summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @auto-title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
internal/exec/go_getter_utils.go (2)

59-59: Fix map formatting for consistency.

The spacing in the map entry is inconsistent with other entries. While the change is functionally correct, let's maintain consistent formatting.

-		"git::ssh"  : true,
+		"git::ssh":   true,

The addition of the "git::ssh" scheme aligns perfectly with the PR objectives and will resolve the Bitbucket repository checkout issues.


239-240: Enhance documentation for git::ssh format.

Consider adding an example specifically for the git::ssh format in the composite schemes section, as it's a critical use case for Bitbucket repositories.

 git::https://github.com/user/repo - Forces the use of git over an HTTPS URL.
 tar::http://example.com/archive.tar.gz - Treats the HTTP resource as a tarball.
+git::ssh://[email protected]/user/repo - Forces the use of git over an SSH URL.
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f10f64c and 473ce22.

📒 Files selected for processing (1)
  • internal/exec/go_getter_utils.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary
🔇 Additional comments (1)
internal/exec/go_getter_utils.go (1)

22-49: Security validation looks solid!

The ValidateURI function maintains strong security checks while accommodating the new git::ssh scheme. The existing validations for URI length, path traversal, and format remain effective.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Feb 12, 2025
@mergify mergify Bot removed the triage Needs triage label Feb 12, 2025
@mergify mergify Bot removed the triage Needs triage label Feb 12, 2025
@osterman

Copy link
Copy Markdown
Member

If this works, then I think that's great. The downside is I don't think we will add automated tests for SSH vendoring.

@osterman Erik Osterman (Cloud Posse) (osterman) added the patch A minor, backward compatible change label Feb 12, 2025
@MrZablah

Copy link
Copy Markdown
Contributor

The git::ssh: it's old ssh style where you had to have git::ssh: where the scp-like style is not expecting that go-getter even had an error for this:
https://github.com/hashicorp/go-getter/blob/main/get_git.go#L65

Though this might be bc this is the git get ssh.

@osterman Erik Osterman (Cloud Posse) (osterman) changed the title Fixed an issue with vendor.yaml source failing to accept git::ssh uri Fixed an issue with vendor.yaml source failing to accept git::ssh URI Feb 12, 2025
@Listener430

Listener430 (Listener430) commented Feb 13, 2025 •

Copy link
Copy Markdown
Contributor

If this works, then I think that's great. The downside is I don't think we will add automated tests for SSH vendoring.

Have tested the proposed change (adding an extra scheme) with the following url

source: "git::ssh://[email protected]/listener430/coonector.git//demo-vendoring?ref=main"

Screenshot from 2025-02-13 10-07-44

Works fine, Andriy Knysh (@aknysh) if no objections, I guess it is ok to merge this one

@elsayedmt

Copy link
Copy Markdown
Contributor Author

Ok If i merge this one?

@osterman
Erik Osterman (Cloud Posse) (osterman) merged commit baaf8c1 into cloudposse:main Feb 19, 2025
@github-actions

Copy link
Copy Markdown

These changes were released in v1.163.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch A minor, backward compatible change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vendor issue when using SSH-formatted Git URLs

5 participants