Skip to content

Conversation

@bonigarcia
Copy link
Member

@bonigarcia bonigarcia commented May 19, 2025

User description

🔗 Related Issues

This PR implements the Rust side of #15754.

💥 What does this PR do?

It is implements a new CLI flag in Selenium Manager called --selenium-version to specify the Selenium version to be reported to Plausible.

🔧 Implementation Notes

The bindings should use this flag to specify its own version.

💡 Additional Considerations

🔄 Types of changes

  • New feature (non-breaking change which adds functionality and tests!)

PR Type

Enhancement


Description

  • Add --selenium-version CLI flag to Selenium Manager

  • Allow bindings to specify Selenium version for analytics

  • Remove automatic version detection logic from Rust code

  • Simplify version handling by delegating to caller


Diagram Walkthrough

flowchart LR
  A["Binding Layer"] -->|"--selenium-version flag"| B["Selenium Manager CLI"]
  B -->|"set_selenium_version()"| C["SeleniumManager Instance"]
  C -->|"Send to Plausible"| D["Analytics"]
Loading

File Walkthrough

Relevant files
Enhancement
lib.rs
Remove SM_BETA_LABEL constant                                                       

rust/src/lib.rs

  • Remove SM_BETA_LABEL constant that was used for version string
    manipulation
  • Simplify version handling by removing beta label stripping logic
+0/-1     
main.rs
Add --selenium-version flag and simplify version handling

rust/src/main.rs

  • Add new --selenium-version CLI argument with empty default value
  • Remove automatic version detection using clap::crate_version!() macro
  • Remove SM_BETA_LABEL import and version string manipulation logic
  • Pass CLI-provided selenium_version directly to manager instead of
    computing it
+6/-4     

@bonigarcia bonigarcia added the C-rust Rust code is mostly Selenium Manager label May 19, 2025
@bonigarcia bonigarcia moved this to In Progress in Selenium Manager May 19, 2025
@selenium-ci selenium-ci added the B-manager Selenium Manager label May 19, 2025
@qodo-code-review
Copy link
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

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

Default Value

The new CLI parameter --selenium-version has an empty string as default value. Consider if this is the intended behavior or if it should default to the current Selenium Manager version.

#[clap(long, value_parser, default_value = "")]
selenium_version: String,
Missing Documentation

The PR removes the internal version detection logic but doesn't document that bindings are now expected to provide their version. This change in responsibility should be clearly documented.

selenium_manager.set_language_binding(cli.language_binding.unwrap_or_default());
selenium_manager.set_selenium_version(cli.selenium_version);

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented May 19, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Improve default version value

The selenium_version parameter has an empty string as default value, which might
cause issues when analytics expect a valid version string. Consider using a more
descriptive default value or adding validation logic to handle empty values.

rust/src/main.rs [148-150]

 /// Selenium version (to be sent to plausible.io)
-#[clap(long, value_parser, default_value = "")]
+#[clap(long, value_parser, default_value = "unknown")]
 selenium_version: String,
  • Apply / Chat
Suggestion importance[1-10]: 5

__

Why: Changing the default from an empty string to "unknown" for selenium_version improves clarity and may help downstream analytics, but it is a minor improvement and not critical to functionality.

Low
  • Update

@github-actions github-actions bot added the J-stale Applied to issues that become stale, and eventually closed. label Nov 15, 2025
@github-actions github-actions bot closed this Nov 29, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in Selenium Manager Nov 29, 2025
@diemol diemol reopened this Nov 29, 2025
@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Nov 29, 2025

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
Audit logging: New CLI flag handling and analytics version setting lack explicit logging of the action
and value, making it unclear if this critical configuration change is traceable.

Referred Code
#[clap(long)]
avoid_browser_download: bool,

/// Selenium language bindings that invokes Selenium Manager (e.g., Java, JavaScript, Python,
/// DotNet, Ruby)
#[clap(long)]
language_binding: Option<String>,

/// Selenium version (to be sent to plausible.io)
#[clap(long, value_parser, default_value = "")]
selenium_version: String,

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Input validation: The new 'selenium_version' CLI input accepts any string (default empty) without
validation or error handling for invalid formats or empty values.

Referred Code
/// Selenium version (to be sent to plausible.io)
#[clap(long, value_parser, default_value = "")]
selenium_version: String,

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status:
Unvalidated input: The new '--selenium-version' external input is passed through to
'set_selenium_version' without sanitization or format checks, which may allow
malformed values to propagate.

Referred Code
    /// Selenium version (to be sent to plausible.io)
    #[clap(long, value_parser, default_value = "")]
    selenium_version: String,

    /// Avoid sends usage statistics to plausible.io
    #[clap(long)]
    avoid_stats: bool,

    /// Not using drivers found in the PATH
    #[clap(long)]
    skip_driver_in_path: bool,

    /// Not using browsers found in the PATH
    #[clap(long)]
    skip_browser_in_path: bool,
}

fn main() {
    let mut cli = Cli::parse();
    let cache_path =
        StringKey(vec![CACHE_PATH_KEY], &cli.cache_path.unwrap_or_default()).get_value();


 ... (clipped 63 lines)

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Use crate version as fallback

Use the crate version as a fallback for the Selenium version when the
--selenium-version flag is not provided to avoid sending an empty string for
analytics.

rust/src/main.rs [230]

-selenium_manager.set_selenium_version(cli.selenium_version);
+let mut selenium_version = cli.selenium_version;
+if selenium_version.is_empty() {
+    selenium_version = clap::crate_version!().to_string();
+}
+selenium_manager.set_selenium_version(selenium_version);
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies that the change introduces a loss of information for analytics by defaulting to an empty string, and proposes a sensible fallback to the crate version, which was the previous behavior.

Low
  • More

@github-actions github-actions bot removed the J-stale Applied to issues that become stale, and eventually closed. label Nov 30, 2025
@cgoldberg
Copy link
Member

@bonigarcia I made the corresponding change for Python in #16659 and tagged you as a reviewer. See my notes in the "Additional Considerations" section. I think it's kind of confusing how we handle versions in development.

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

Labels

B-manager Selenium Manager C-rust Rust code is mostly Selenium Manager Review effort 2/5

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants