[py] Use double quotes in generate.py by Delta456 ยท Pull Request #16607 ยท SeleniumHQ/selenium

PR Compliance Guide ๐Ÿ”

(Compliance updated until commit 5eaf602)

Below is a summary of compliance checks for this PR:

Security Compliance
โšช
Unvalidated log level

Description: The logging level is controlled via the LOG_LEVEL environment variable without validation,
allowing users to elevate verbosity and potentially leak sensitive info to logs when
running the generator.
generate.py [45-47]

Referred Code
log_level = getattr(logging, os.environ.get("LOG_LEVEL", "warning").upper())
logging.basicConfig(level=log_level)
logger = logging.getLogger("generate")
Ticket Compliance
๐ŸŸก
๐ŸŽซ #5678
๐Ÿ”ด Diagnose and fix ChromeDriver "Error: ConnectFailure (Connection refused)" occurring on
subsequent driver instantiations on Ubuntu 16.04 with Chrome 65 and Chromedriver 2.35
(Selenium 3.9.0).
Provide steps or code changes that prevent the connection refusal after the first
ChromeDriver instance.
Ensure reliability across multiple consecutive ChromeDriver instantiations.
๐ŸŸก
๐ŸŽซ #1234
๐Ÿ”ด Restore or ensure that click() triggers JavaScript in link hrefs as it did in 2.47.1,
which regressed in 2.48.x on Firefox 42.
Provide a fix or behavior change to WebDriver so that click() executes href JavaScript.
Validate behavior specifically on Firefox per the ticket label.
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:
No Audit Logs: The new code adds logging configuration and uses logger.info/debug, but there is no
evidence of audit logging for critical security actions in this diff, which may be outside
the scope of this generator script.

Referred Code
log_level = getattr(logging, os.environ.get("LOG_LEVEL", "warning").upper())
logging.basicConfig(level=log_level)
logger = logging.getLogger("generate")

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:
Missing Validation: Parsing and file operations lack added try/except or validation for schema shape in the
new code changes, though this PR focuses on quoting/style and may rely on existing
behavior.

Referred Code
with open(json_path, encoding="utf-8") as json_file:
    schema = json.load(json_file)
version = schema["version"]
assert (version["major"], version["minor"]) == ("1", "3")
current_version = f"{version['major']}.{version['minor']}"
domains = []
for domain in schema["domains"]:
    domains.append(CdpDomain.from_json(domain))
return domains

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:
Schema Assumptions: The generator assumes schema keys like "version" and "domains" without
added validation in the new code; while unchanged logic, lack of explicit validation may
pose risks depending on input source.

Referred Code
version = schema["version"]
assert (version["major"], version["minor"]) == ("1", "3")
current_version = f"{version['major']}.{version['minor']}"
domains = []
for domain in schema["domains"]:
    domains.append(CdpDomain.from_json(domain))
return domains

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

Compliance status legend ๐ŸŸข - Fully Compliant
๐ŸŸก - Partial Compliant
๐Ÿ”ด - Not Compliant
โšช - Requires Further Human Verification
๐Ÿท๏ธ - Compliance label

Previous compliance checks

Compliance check up to commit f9a2e17
Security Compliance
๐ŸŸข
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
๐ŸŸก
๐ŸŽซ #5678
๐Ÿ”ด Diagnose and resolve "Error: ConnectFailure (Connection refused)" when instantiating
ChromeDriver on Ubuntu 16.04.4 with Chrome 65 / ChromeDriver 2.35 using Selenium 3.9.0.
Ensure subsequent ChromeDriver instances do not produce connection refused errors.
Provide guidance or code changes that address repeated instantiation reliability.
๐ŸŸก
๐ŸŽซ #1234
๐Ÿ”ด Make WebDriver click() trigger JavaScript in a link's href consistently (regression from
2.47.1 to 2.48.x) in Firefox 42.
Provide test coverage ensuring href javascript: links fire alerts/JS handlers on click.
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:
No logging added: The PR only updates docstrings and does not introduce or modify any logging for critical
actions, but the changes appear purely stylistic and may not require audit trail updates.

Referred Code
def parse_json_event(json: T_JSON_DICT) -> typing.Any:
    ''' Parse a JSON dictionary into a CDP event. '''
    return _event_parsers[json['method']].from_json(json['params'])
"""


def indent(s, n):
    """ A shortcut for ``textwrap.indent`` that always uses spaces. """
    return tw_indent(s, n * ' ')


BACKTICK_RE = re.compile(r'`([^`]+)`(\w+)?')


def escape_backticks(docstr):
    """
    Escape backticks in a docstring by doubling them up.
    This is a little tricky because RST requires a non-letter character after
    the closing backticks, but some CDPs docs have things like "`AxNodeId`s".
    If we double the backticks in that string, then it won't be valid RST. The
    fix is to insert an apostrophe if an "s" trails the backticks.


 ... (clipped 883 lines)

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:
No error handling changes: The PR introduces only docstring style changes without adding or altering exception
handling or edge-case logic, which may be acceptable for a non-functional change.

Referred Code
def parse_json_event(json: T_JSON_DICT) -> typing.Any:
    ''' Parse a JSON dictionary into a CDP event. '''
    return _event_parsers[json['method']].from_json(json['params'])
"""


def indent(s, n):
    """ A shortcut for ``textwrap.indent`` that always uses spaces. """
    return tw_indent(s, n * ' ')


BACKTICK_RE = re.compile(r'`([^`]+)`(\w+)?')


def escape_backticks(docstr):
    """
    Escape backticks in a docstring by doubling them up.
    This is a little tricky because RST requires a non-letter character after
    the closing backticks, but some CDPs docs have things like "`AxNodeId`s".
    If we double the backticks in that string, then it won't be valid RST. The
    fix is to insert an apostrophe if an "s" trails the backticks.


 ... (clipped 883 lines)

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:
No validation changes: The PR only standardizes docstrings and does not modify input validation or data handling
paths, which is likely fine given no functional changes but cannot be fully assessed from
the diff.

Referred Code
def parse_json_event(json: T_JSON_DICT) -> typing.Any:
    ''' Parse a JSON dictionary into a CDP event. '''
    return _event_parsers[json['method']].from_json(json['params'])
"""


def indent(s, n):
    """ A shortcut for ``textwrap.indent`` that always uses spaces. """
    return tw_indent(s, n * ' ')


BACKTICK_RE = re.compile(r'`([^`]+)`(\w+)?')


def escape_backticks(docstr):
    """
    Escape backticks in a docstring by doubling them up.
    This is a little tricky because RST requires a non-letter character after
    the closing backticks, but some CDPs docs have things like "`AxNodeId`s".
    If we double the backticks in that string, then it won't be valid RST. The
    fix is to insert an apostrophe if an "s" trails the backticks.


 ... (clipped 883 lines)

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