You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR makes a slight change to the logic for finding the Selenium Manager binary, so it doesn't give a false positive if there is a directory named selenium-manager where the executable should be if you build/install from source or a local sdist package. This also adds a check to verify the Selenium Manager binary exists if its location is specified in an environment variable, so it's clear why it is failing.
It also converts some old string formatting to use f-strings and adds information to the docstring about where we look for the binary.
🔄 Types of changes
Cleanup (formatting, renaming)
Bug fix (backwards compatible)
PR Type
Bug fix, Tests
Description
Fix false positive when directory named selenium-manager exists instead of executable
Change compiled_path.exists() to compiled_path.is_file() for proper verification
Convert string formatting to f-strings for consistency
Enhance docstring with binary search order and error conditions
Diagram Walkthrough
flowchart LR
A["Binary Detection Logic"] -->|Check env variable| B["SE_MANAGER_PATH"]
A -->|Check compiled path| C["compiled_path.is_file"]
C -->|Old: exists| D["False Positive<br/>on directory"]
C -->|New: is_file| E["Correct verification<br/>of executable"]
A -->|Check wheel package| F["Platform-specific binary"]
A -->|Fail| G["WebDriverException"]
Loading
File Walkthrough
Relevant files
Bug fix
selenium_manager.py
Fix binary detection and modernize string formatting
py/selenium/webdriver/common/selenium_manager.py
Changed compiled_path.exists() to compiled_path.is_file() to properly verify executable instead of accepting directories
Converted three logger calls from old string formatting (%s) to f-strings
Enhanced docstring with numbered list of binary search locations and additional error condition documentation
Added blank line after license header for PEP 8 compliance
cgoldberg
changed the title
[py] Properly verify Selenium Manager exists if built from source
[py] Properly verify Selenium Manager exists if built from sdist
Dec 9, 2025
Objective: To create a detailed and reliable record of critical system actions for security analysis and compliance.
Status: Action Logging: The new code paths that determine and validate the Selenium Manager binary location do not add or update any audit logging for critical actions, which may be acceptable for library code but cannot be verified from this diff alone.
Referred Code
if (env_path:=os.getenv("SE_MANAGER_PATH")) isnotNone:
logger.debug(f"Selenium Manager set by env SE_MANAGER_PATH to: {env_path}")
path=Path(env_path)
elifcompiled_path.is_file():
path=compiled_pathelse:
allowed= {
("darwin", "any"): "macos/selenium-manager",
("win32", "any"): "windows/selenium-manager.exe",
("cygwin", "any"): "windows/selenium-manager.exe",
("linux", "x86_64"): "linux/selenium-manager",
("freebsd", "x86_64"): "linux/selenium-manager",
("openbsd", "x86_64"): "linux/selenium-manager",
}
arch=platform.machine() ifsys.platformin ("linux", "freebsd", "openbsd") else"any"ifsys.platformin ["freebsd", "openbsd"]:
logger.warning(f"Selenium Manager binary may not be compatible with {sys.platform}; verify settings")
location=allowed.get((sys.platform, arch))
iflocationisNone:
... (clipped10lines)
Objective: To prevent the leakage of sensitive system information through error messages while providing sufficient detail for internal debugging.
Status: Error Detail: Raised WebDriverException messages include platform and path details which are likely acceptable for internal exceptions but could be sensitive if surfaced to end users; visibility cannot be determined from this diff.
Referred Code
location=allowed.get((sys.platform, arch))
iflocationisNone:
raiseWebDriverException(f"Unsupported platform/architecture combination: {sys.platform}/{arch}")
path=Path(__file__).parent.joinpath(location)
ifpathisNoneornotpath.is_file():
raiseWebDriverException(f"Unable to obtain working Selenium Manager binary; {path}")
Compliance status legend
🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label
cgoldberg
changed the title
[py] Properly verify Selenium Manager exists if built from sdist
[py] Properly verify Selenium Manager exists if built from source
Dec 9, 2025
✅ Validate environment variable pathSuggestion Impact:The commit changed the code to create a Path from SE_MANAGER_PATH and only use it if it is a file; otherwise it sets path to None, effectively validating the environment variable.
code diff:
if (env_path := os.getenv("SE_MANAGER_PATH")) is not None:
logger.debug(f"Selenium Manager set by env SE_MANAGER_PATH to: {env_path}")
- path = Path(env_path)+ path_candidate = Path(env_path)+ path = path_candidate if path_candidate.is_file() else None
Validate that SE_MANAGER_PATH points to an existing executable file and ignore or error out if it does not.
if (env_path := os.getenv("SE_MANAGER_PATH")) is not None:
logger.debug(f"Selenium Manager set by env SE_MANAGER_PATH to: {env_path}")
- path = Path(env_path)+ env_path = env_path.strip()+ candidate = Path(env_path)+ if candidate.is_file():+ path = candidate+ else:+ logger.warning(f"SE_MANAGER_PATH does not point to a file: {env_path}")
[Suggestion processed]
Suggestion importance[1-10]: 6
__
Why:
Relevant best practice - Validate and sanitize external inputs such as environment variables before use to avoid invalid paths or injection issues.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
💥 What does this PR do?
This PR makes a slight change to the logic for finding the Selenium Manager binary, so it doesn't give a false positive if there is a directory named
selenium-managerwhere the executable should be if you build/install from source or a local sdist package. This also adds a check to verify the Selenium Manager binary exists if its location is specified in an environment variable, so it's clear why it is failing.It also converts some old string formatting to use f-strings and adds information to the docstring about where we look for the binary.
🔄 Types of changes
PR Type
Bug fix, Tests
Description
Fix false positive when directory named
selenium-managerexists instead of executableChange
compiled_path.exists()tocompiled_path.is_file()for proper verificationConvert string formatting to f-strings for consistency
Enhance docstring with binary search order and error conditions
Diagram Walkthrough
File Walkthrough
selenium_manager.py
Fix binary detection and modernize string formattingpy/selenium/webdriver/common/selenium_manager.py
compiled_path.exists()tocompiled_path.is_file()to properlyverify executable instead of accepting directories
%s) tof-strings
additional error condition documentation