Skip to content

feat: enable IPv6 support for factory resolver endpoints#951

Open
olexii4 wants to merge 3 commits intomainfrom
CHE-1442
Open

feat: enable IPv6 support for factory resolver endpoints#951
olexii4 wants to merge 3 commits intomainfrom
CHE-1442

Conversation

@olexii4
Copy link
Contributor

@olexii4 olexii4 commented Feb 2, 2026

What does this PR do?

This change adds IPv6 support in Eclipse Che Server to enable operation in IPv6-only network environments. As Kubernetes platforms (particularly OpenShift Container Platform 4.20) migrate to IPv6, the factory resolver must handle IPv6 addresses correctly in URLs and API calls.

The implementation involved minimal, focused changes to URL validation patterns and server URL extraction, enabling full IPv6 support while maintaining complete backward compatibility with IPv4-only and dual-stack environments.

Background:

The Eclipse Che factory resolver previously failed to operate with IPv6 git server URLs due to:

  1. URL Validation Issues: Regular expressions rejected IPv6 bracket notation (e.g., http://[::1]:8080)
  2. Manual String Parsing: getServerUrl() methods used pattern matching that didn't account for IPv6 brackets
  3. Regex Escaping: Host strings from IPv6 URLs were inserted into regex patterns without properly escaping the bracket characters

IPv6 Bracket Notation:

IPv6 addresses in URLs require square brackets to distinguish the address from port numbers:

  • ✅ Correct: http://[2001:db8::1]:8080/repo.git
  • ❌ Incorrect: http://2001:db8::1:8080/repo.git (ambiguous)

Changes:

  1. AbstractGitlabUrlParser:

    • Fixed constructor to use URI.getHost() instead of manual substring extraction
    • Added IPv6 bracket escaping in getPatternMatcherByUrl()
    • Updated getServerUrl() to use URI parsing for IPv6 support
  2. AbstractGithubURLParser:

    • Added IPv6 bracket escaping in getPatternMatcherByUrl()
    • Updated getServerUrl() to use URI parsing for IPv6 support
  3. AzureDevOpsURLParser:

    • Added IPv6 bracket escaping in getPatternMatcherByUrl()
    • Updated getServerUrl() to use URI parsing for IPv6 support

Technical Details:

Java's URI.getHost() returns IPv6 addresses WITH brackets (e.g., "[2001:db8::1]"). When constructing regex patterns, these brackets must be escaped as \[ and \] because they are special regex characters. The fix uses:

  • Pattern.quote() to escape the IPv6 address (without brackets)
  • Manual escaping of the brackets themselves

Screenshot/screencast of this PR

What issues does this PR fix or reference?

fixes: eclipse-che/che#23674

How to test this PR?

PR Checklist

As the author of this Pull Request I made sure that:

Release Notes

Reviewers

Reviewers, please comment how you tested the PR when approving it.

@olexii4 olexii4 removed the request for review from vinokurig February 2, 2026 14:35
@openshift-ci
Copy link

openshift-ci bot commented Feb 2, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: olexii4

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

Details 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

@olexii4
Copy link
Contributor Author

olexii4 commented Feb 5, 2026

/retest

@vinokurig
Copy link
Contributor

@olexii4 Please update the related tests with ip v6 examples.

@olexii4 olexii4 force-pushed the CHE-1442 branch 4 times, most recently from 31df750 to 164262d Compare February 9, 2026 11:22
KubernetesClient client = spy(kubernetesClient);
when(cheServerKubernetesClientFactory.create()).thenReturn(client);
kubernetesClient = kubernetesMockServer.createClient();
when(cheServerKubernetesClientFactory.create()).thenReturn(kubernetesClient);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These changes were required because Mockito 5 doesn't allow spy() on mock objects. This is a breaking change from Mockito 3.x:

Changes made:

  1. Removed import static org.mockito.Mockito.spy;
  2. Changed setup from:
   kubernetesClient = spy(kubernetesMockServer.createClient()); 
   KubernetesClient client = spy(kubernetesClient);  
   when(cheServerKubernetesClientFactory.create()).thenReturn(client);

To:

   kubernetesClient = kubernetesMockServer.createClient();  
   when(cheServerKubernetesClientFactory.create()).thenReturn(kubernetesClient);

})
.when(subject)
.checkPermission(anyObject(), anyObject(), anyObject());
.checkPermission(any(), any(), any());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change was required for Mockito 5 compatibility due to the removal of the deprecated anyObject() matcher:

Change made:

  • Import: ArgumentMatchers.anyObject() → ArgumentMatchers.any()
  • Usage: checkPermission(anyObject(), anyObject(), anyObject()) → checkPermission(any(), any(), any())

@olexii4 olexii4 force-pushed the CHE-1442 branch 6 times, most recently from d93322a to 05ab89c Compare February 12, 2026 10:01
@olexii4 olexii4 force-pushed the CHE-1442 branch 3 times, most recently from b556135 to aee02e0 Compare February 17, 2026 01:28
Fix IPv6 bracket handling and SSH URL parsing issues:
- GitLab: Fix double-bracketing bug in getPatternMatcherByUrl() where IPv6 addresses were wrapped in additional brackets
- GitHub: Add sshToUri() helper to correctly handle IPv6 addresses in SSH URLs
- GitLab: Add sshToUri() helper to correctly handle IPv6 addresses in SSH URLs
- Azure DevOps: Fix SSH URL parsing to handle IPv6 bracket notation

Assisted-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Oleksii Orel <oorel@redhat.com>
Add complete IPv6 address support to BitbucketServerURLParser:
- Add IPv6 bracket handling in getUrlPatterns(), isUserTokenPresent(), and getPatternMatcherByUrl()
- Fix SSH URL parsing to correctly handle IPv6 addresses with bracket notation
- Escape scheme parameter in regex patterns to prevent regular expression injection (fixes CodeQL security warnings)

Security: Use Pattern.quote() on user-controlled scheme values before inserting into regex patterns to prevent regex injection attacks.

Assisted-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Oleksii Orel <oorel@redhat.com>
Add 39 new IPv6 test cases across all parsers (from 4 to 43 total):
- Azure DevOps: 8 new IPv6 tests covering branches, tags, loopback, credentials, dynamic pattern matching
- GitHub: 8 new IPv6 tests covering branches, pull requests, dynamic patterns, loopback, .git suffix
- GitLab: 11 new IPv6 tests covering subgroups, validation, branches with slashes, loopback
- Bitbucket Server: 12 new IPv6 tests (from zero coverage) covering HTTPS, SSH, user repos, branches, validation

Test scenarios include:
- IPv6 with branches and tags
- IPv6 with pull request IDs
- IPv6 loopback addresses (::1)
- IPv6 full-form addresses
- IPv6 with ports
- IPv6 with credentials
- IPv6 SSH URLs
- IPv6 URL validation via isValid()
- Dynamic pattern matching for unconfigured hosts

Also update license headers to 2026 in affected test files.

All 238 tests passing across all parsers.

Assisted-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Oleksii Orel <oorel@redhat.com>
@olexii4
Copy link
Contributor Author

olexii4 commented Feb 17, 2026

@olexii4 Please update the related tests with ip v6 examples.

@vinokurig I have fixed it

@olexii4
Copy link
Contributor Author

olexii4 commented Feb 17, 2026

/retest

@olexii4
Copy link
Contributor Author

olexii4 commented Feb 17, 2026

/retest

@openshift-ci
Copy link

openshift-ci bot commented Feb 17, 2026

@olexii4: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/v19-gitlab-no-pat-oauth-flow 28193cb link true /test v19-gitlab-no-pat-oauth-flow
ci/prow/v19-azure-no-pat-oauth-flow-raw-devfile-url 28193cb link true /test v19-azure-no-pat-oauth-flow-raw-devfile-url
ci/prow/v19-bitbucket-no-pat-oauth-flow 28193cb link true /test v19-bitbucket-no-pat-oauth-flow
ci/prow/v19-bitbucket-no-pat-oauth-flow-ssh-url 28193cb link true /test v19-bitbucket-no-pat-oauth-flow-ssh-url
ci/prow/v19-gitea-with-pat-setup-flow 28193cb link true /test v19-gitea-with-pat-setup-flow
ci/prow/v19-gitlab-with-oauth-setup-flow 28193cb link true /test v19-gitlab-with-oauth-setup-flow
ci/prow/v19-gitlab-with-pat-setup-flow 28193cb link true /test v19-gitlab-with-pat-setup-flow
ci/prow/v19-azure-no-pat-oauth-flow-ssh-url 28193cb link true /test v19-azure-no-pat-oauth-flow-ssh-url
ci/prow/v19-gitea-no-pat-oauth-flow 28193cb link true /test v19-gitea-no-pat-oauth-flow
ci/prow/v19-github-no-pat-oauth-flow-ssh-url 28193cb link true /test v19-github-no-pat-oauth-flow-ssh-url
ci/prow/v19-gitlab-no-pat-oauth-flow-ssh-url 28193cb link true /test v19-gitlab-no-pat-oauth-flow-ssh-url
ci/prow/v19-github-with-pat-setup-flow 28193cb link true /test v19-github-with-pat-setup-flow
ci/prow/v19-github-no-pat-oauth-flow 28193cb link true /test v19-github-no-pat-oauth-flow
ci/prow/v19-bitbucket-no-pat-oauth-flow-raw-devfile-url 28193cb link true /test v19-bitbucket-no-pat-oauth-flow-raw-devfile-url
ci/prow/v19-gitlab-no-pat-oauth-flow-raw-devfile-url 28193cb link true /test v19-gitlab-no-pat-oauth-flow-raw-devfile-url
ci/prow/v19-github-no-pat-oauth-flow-raw-devfile-url 28193cb link true /test v19-github-no-pat-oauth-flow-raw-devfile-url
ci/prow/v19-azure-no-pat-oauth-flow 28193cb link true /test v19-azure-no-pat-oauth-flow
ci/prow/v19-azure-with-pat-setup-flow 28193cb link true /test v19-azure-with-pat-setup-flow

Full PR test history. Your PR dashboard.

Details

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-sigs/prow repository. I understand the commands that are listed here.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add IPv6 Support to the User Dashboard

2 participants