Skip to content

Conversation

danxmoran
Copy link

@danxmoran danxmoran commented Aug 7, 2025

  • Update our URL-splitting utils to check if the host is ipv6, to prevent the :s in the host from being interpreted as a port separator
  • Add test cases in our utils suite
  • Add a test case for an ipv6 URI in the AWS HTTP credentials test suite (my entry-point for finding the bug)

Closes #10699


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

Backporting

  • Backport to latest stable release.

#10707


Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of IPv6 addresses in URLs, ensuring correct parsing and exclusion of brackets and colons when identifying host and port components.
  • Tests

    • Added tests to verify URL parsing for IPv6 addresses.
    • Introduced a test to validate AWS credentials retrieval using an IPv6 endpoint.

Copy link

coderabbitai bot commented Aug 7, 2025

Walkthrough

The changes update URL parsing logic to correctly handle IPv6 addresses enclosed in brackets, ensuring that colons within IPv6 literals are not mistaken for port separators. Corresponding unit tests and AWS credentials HTTP provider tests are added to verify correct behavior with IPv6 endpoints.

Changes

Cohort / File(s) Change Summary
IPv6 URL Parsing Logic
src/flb_utils.c
Adjusted parsing logic in utility functions to properly handle IPv6 addresses in URLs, ensuring correct host and port extraction.
Unit Tests for URL Parsing
tests/internal/utils.c
Added test cases for parsing URLs containing IPv6 addresses with and without explicit ports.
AWS Credentials HTTP Provider IPv6 Test
tests/internal/aws_credentials_http.c
Introduced a new test to verify AWS credentials HTTP provider correctly handles IPv6 endpoints in environment variables.

Sequence Diagram(s)

sequenceDiagram
    participant TestCase as Test (aws_credentials_http.c)
    participant Provider as AWS HTTP Provider
    participant Utils as URL Parsing Logic
    participant MockHTTP as Mock HTTP Server

    TestCase->>Provider: Set AWS_CONTAINER_CREDENTIALS_FULL_URI to IPv6 URL
    Provider->>Utils: Parse URL (IPv6 in brackets)
    Utils-->>Provider: Return protocol, host, port, URI
    Provider->>MockHTTP: GET /iam_credentials/pod1 (IPv6 host)
    MockHTTP-->>Provider: Return credentials JSON
    Provider-->>TestCase: Provide credentials
    TestCase->>Provider: Refresh credentials
    Provider->>MockHTTP: GET /iam_credentials/pod1 (again)
    MockHTTP-->>Provider: Return new credentials JSON
    Provider-->>TestCase: Provide refreshed credentials
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective Addressed Explanation
Correctly handle IPv6 addresses in AWS_CONTAINER_CREDENTIALS_FULL_URI for HTTP provider (#10699)
Add unit tests for IPv6 URL parsing in utils.c (#10699)
Add integration test for AWS HTTP provider with IPv6 endpoint (#10699)
Ensure no silent failures or parsing errors for valid IPv6 URLs (#10699)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Poem

A bunny hopped through code so neat,
IPv6 now tastes so sweet!
Brackets and colons, parsed just right,
No silent fails in the night.
Tests now prove what once was myth—
IPv6 and Fluent Bit, a perfect pith!
🐇💻🌐

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 50993f9 and 44d77dd.

📒 Files selected for processing (3)
  • src/flb_utils.c (5 hunks)
  • tests/internal/aws_credentials_http.c (2 hunks)
  • tests/internal/utils.c (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • tests/internal/utils.c
  • src/flb_utils.c
  • tests/internal/aws_credentials_http.c
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
  • 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 explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @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 to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@danxmoran danxmoran force-pushed the danxmoran/url-split-ipv6 branch from 50993f9 to 44d77dd Compare August 7, 2025 17:16
@@ -36,6 +36,8 @@ struct url_check url_checks[] = {
{0, "https://fluentbit.io:1234/", "https", "fluentbit.io", "1234", "/"},
{0, "https://fluentbit.io:1234/v", "https", "fluentbit.io", "1234", "/v"},
{-1, "://", NULL, NULL, NULL, NULL},
{0, "http://[fd00:ec2::23]/v1/credentials", "http", "fd00:ec2::23", "80", "/v1/credentials"},
{0, "https://[::192.9.5.5]:1234/v", "https", "::192.9.5.5", "1234", "/v"}
Copy link
Author

Choose a reason for hiding this comment

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

Self-review: I am not sure here if there will be a problem when actually trying to use the hosts because we stripped out the enclosing []s. The existing *_copy_host_* functions were stripping the brackets (or trying to) so I kept the behavior. Would appreciate a sanity-check!

@danxmoran
Copy link
Author

@PettitWesley @edsiper @leonardo-albertovich @fujimotos @koleini (sorry for the spam) do you have an ETA on when you'll be able to review this + the backport PR? Trying to decide if I should give in and enable IRSA on my auto mode cluster or hold out for a bit longer to use pod identity

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

Successfully merging this pull request may close these issues.

Creation of AWS HTTP provider silently fails with ipv6 AWS_CONTAINER_CREDENTIALS_FULL_URI
1 participant