Skip to content
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

[dotnet] Fix marionette host Firefox argument #15153

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

RenderMichael
Copy link
Contributor

@RenderMichael RenderMichael commented Jan 25, 2025

User description

Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

Fixes the --marionette-host parameter for Firefox execution.

Motivation and Context

This is clearly a bug, but I am not familiar with this setting enough to verify the problematic behavior or the fix.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PR Type

Bug fix


Description

  • Fixed the --marionette-host parameter in FirefoxDriverService.

  • Corrected the argument to use browserCommunicationHost instead of host.


Changes walkthrough 📝

Relevant files
Bug fix
FirefoxDriverService.cs
Corrected `--marionette-host` argument assignment               

dotnet/src/webdriver/Firefox/FirefoxDriverService.cs

  • Fixed the --marionette-host parameter.
  • Replaced this.host with this.browserCommunicationHost.
  • +1/-1     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Parameter Validation

    Verify that browserCommunicationHost is properly initialized and validated before being used as the marionette host parameter

    if (!string.IsNullOrEmpty(this.browserCommunicationHost))
    {
        argsBuilder.AppendFormat(CultureInfo.InvariantCulture, " --marionette-host \"{0}\"", this.browserCommunicationHost);
    }

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Validate host name before use

    Add null check and input validation for browserCommunicationHost to prevent
    potential format exceptions when appending to argsBuilder

    dotnet/src/webdriver/Firefox/FirefoxDriverService.cs [180]

    -argsBuilder.AppendFormat(CultureInfo.InvariantCulture, " --marionette-host \"{0}\"", this.browserCommunicationHost);
    +if (Uri.CheckHostName(this.browserCommunicationHost) != UriHostNameType.Unknown)
    +    argsBuilder.AppendFormat(CultureInfo.InvariantCulture, " --marionette-host \"{0}\"", this.browserCommunicationHost);
    +else
    +    throw new ArgumentException("Invalid host name for marionette host", nameof(browserCommunicationHost));
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: The suggestion adds important input validation for the host name parameter, which could prevent runtime errors and provide better error messages when invalid host names are provided. This is a critical security and reliability improvement.

    8

    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.

    1 participant