-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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: Git ssh validation regex enhancement #33426
Conversation
WalkthroughWalkthroughThe changes introduce new patterns Changes
Assessment against linked issues
Recent Review DetailsConfiguration used: CodeRabbit UI Files selected for processing (2)
Files skipped from review as they are similar to previous changes (2)
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Out of diff range and nitpick comments (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/GitUtils.java (1)
29-30
: Add a comment explaining the purpose of the new regex pattern.To improve code readability and maintainability, consider adding a comment that explains the purpose of the
URL_PATTERN_WITHOUT_GIT_PREFIX
regex pattern.
Failed server tests
|
@@ -26,6 +26,9 @@ public class GitUtils { | |||
public static final Pattern URL_PATTERN_WITHOUT_SCHEME = | |||
Pattern.compile("^git@(?<host>.+?):/*(?<path>.+?)(\\.git)?$"); | |||
|
|||
public static final Pattern URL_PATTERN_WITHOUT_GIT_PREFIX = | |||
Pattern.compile("^[a-zA-Z0-9]+@(?<host>.+?):/*(?<path>.+?)(\\.git)?$"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if they use ssh prefix with custom username?
@@ -26,6 +26,9 @@ public class GitUtils { | |||
public static final Pattern URL_PATTERN_WITHOUT_SCHEME = | |||
Pattern.compile("^git@(?<host>.+?):/*(?<path>.+?)(\\.git)?$"); | |||
|
|||
public static final Pattern URL_PATTERN_WITHOUT_GIT_PREFIX = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, can we rename this to indicate exactly what we're accepting here, that is, custom username.
|
||
// custom ssh username: | ||
assertThat(GitUtils.convertSshUrlToBrowserSupportedUrl("custom@vs-ssh.visualstudio.com:v3/newJet/ai/zilla")) | ||
.isEqualTo("https://vs-ssh.visualstudio.com/v3/newJet/ai/zilla"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be another check somewhere for repo names. Does that pattern comply with this input already? If it does, can you add a test case there as well to make sure that it does not break in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it does comply, adding test cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a few more inclusions.
## Description > Added regex for supporting custom usernames in ssh Fixes #19881 ## Automation /ok-to-test tags="@tag.Git" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/9090239144> > Commit: 05f2b6f > Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9090239144&attempt=1" target="_blank">Click here!</a> <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No
Description
git
as username and rejected any custom usernames provided by users.Fixes #19881
Automation
/ok-to-test tags="@tag.Git"
🔍 Cypress test results
Tip
🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9090239144
Commit: 05f2b6f
Cypress dashboard url: Click here!
Communication
Should the DevRel and Marketing teams inform users about this change?