SeleniumHQ / docker-selenium

Provides a simple way to run Selenium Grid with Chrome, Firefox, and Edge using Docker, making it easier to perform browser automation
http://www.selenium.dev/docker-selenium/
Other
7.99k stars 2.51k forks source link

fix: bash avoiding newline when Base64 encoding a long string #2437

Closed VietND96 closed 1 month ago

VietND96 commented 1 month ago

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

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

Description

Fixes #2435

Motivation and Context

Types of changes

Checklist

codiumai-pr-agent-pro[bot] commented 1 month ago

PR Reviewer Guide ๐Ÿ”

Here are some key observations to aid the review process:

**๐ŸŽซ Ticket compliance analysis โœ…** **[2435](https://github.com/SeleniumHQ/docker-selenium/issues/2435) - Fully compliant** Fully compliant requirements: - Add `-w 0` option to base64 to override the max column - Fix the issue with longer passwords and usernames causing problems in the graphql health check
โฑ๏ธ Estimated effort to review: 2 ๐Ÿ”ต๐Ÿ”ตโšชโšชโšช
๐Ÿงช No relevant tests
๐Ÿ”’ No security concerns identified
โšก Recommended focus areas for review

Potential Compatibility Issue
The `-w0` option for base64 might not be supported in all environments. Verify compatibility across different systems. Possible Security Concern
Ensure that the `SE_ROUTER_USERNAME` and `SE_ROUTER_PASSWORD` environment variables are properly secured and not exposed in logs or to unauthorized users.
codiumai-pr-agent-pro[bot] commented 1 month ago

PR Code Suggestions โœจ

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Score
Best practice
Use printf instead of echo for more consistent handling of special characters ___ **Consider using printf instead of echo for more consistent behavior across different
systems when dealing with special characters or escape sequences.** [Base/check-grid.sh [8]](https://github.com/SeleniumHQ/docker-selenium/pull/2437/files#diff-0707ce4020543798772b1b4661e6a051d454145938ea228c727d1dd37e72331bR8-R8) ```diff -BASIC_AUTH="$(echo -en "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64 -w0)" +BASIC_AUTH="$(printf '%s:%s' "${SE_ROUTER_USERNAME}" "${SE_ROUTER_PASSWORD}" | base64 -w0)" ``` - [ ] **Apply this suggestion**
Suggestion importance[1-10]: 7 Why:
7
Maintainability
Improve code organization by grouping variable declarations together ___ **Move the BASIC_AUTH variable declaration to the beginning of the script, near other
variable declarations, to improve code organization and readability.** [Video/video.sh [31-32]](https://github.com/SeleniumHQ/docker-selenium/pull/2437/files#diff-7cd0ffe6390f76d290d88e6e4e3c360e9a797096c0b0fb76874303c5ca319f4bR31-R32) ```diff -/opt/bin/validate_endpoint.sh "${NODE_STATUS_ENDPOINT}" BASIC_AUTH="$(echo -en "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64 -w0)" +/opt/bin/validate_endpoint.sh "${NODE_STATUS_ENDPOINT}" + ``` - [ ] **Apply this suggestion**
Suggestion importance[1-10]: 7 Why:
7
Enhancement
Improve variable scope and reduce potential code duplication ___ **Consider moving the BASIC_AUTH variable declaration outside the if block to avoid
potential repetition if the variable is used in multiple places.** [charts/selenium-grid/configs/node/nodeProbe.sh [39-42]](https://github.com/SeleniumHQ/docker-selenium/pull/2437/files#diff-d857ccb50aa21728930ca9f5e0300aeb9fa49db6d34d6664fe2eb221ec50baf3R39-R42) ```diff +BASIC_AUTH="$(echo -en "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64 -w0)" + return_list=($(bash ${NODE_CONFIG_DIRECTORY}/nodeGridUrl.sh)) grid_url=${return_list[0]} grid_check=${return_list[1]} -BASIC_AUTH="$(echo -en "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64 -w0)" ``` - [ ] **Apply this suggestion**
Suggestion importance[1-10]: 7 Why:
7

๐Ÿ’ก Need additional feedback ? start a PR chat