Skip to content

Docker: Node env vars to disable/enable VNC view only, password #2489

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

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

VietND96
Copy link
Member

@VietND96 VietND96 commented Dec 3, 2024

User description

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 #2485

Motivation and Context

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, Documentation


Description

  • Fixed the logic for enabling/disabling VNC view-only mode and password authentication in start-vnc.sh by checking if the environment variables are set to "true" or "1".
  • Updated the documentation in README.md to reflect the correct usage of environment variables SE_VNC_NO_PASSWORD and SE_VNC_VIEW_ONLY, recommending the use of "true" instead of "1".

Changes walkthrough 📝

Relevant files
Bug fix
start-vnc.sh
Fix VNC environment variable conditions for correct behavior

NodeBase/start-vnc.sh

  • Updated condition to check for VNC_NO_PASSWORD and VNC_VIEW_ONLY.
  • Changed condition to check for "true" or "1" values.
  • Ensures correct behavior for enabling/disabling VNC options.
  • +2/-2     
    Documentation
    README.md
    Update documentation for VNC environment variables             

    README.md

  • Updated documentation for SE_VNC_NO_PASSWORD and SE_VNC_VIEW_ONLY.
  • Changed recommended value to "true" for enabling options.
  • +2/-2     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
    Copy link
    Contributor

    qodo-merge-pro bot commented Dec 3, 2024

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis ✅

    2485 - Fully compliant

    Compliant requirements:

    • Fixed VNC view-only mode logic to only enable when value is "1" or "true"
    ⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Logic Validation
    Verify that both VNC_NO_PASSWORD and VNC_VIEW_ONLY environment variables properly handle all possible values (0, false, true, 1, other values) as expected

    Copy link
    Contributor

    qodo-merge-pro bot commented Dec 3, 2024

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    General
    Prevent potential shell script errors by properly handling unset variables

    Add quotes around variable references in the if conditions to prevent word splitting
    and handle empty values correctly.

    NodeBase/start-vnc.sh [17]

    -if [ "${VNC_NO_PASSWORD}" = "true" ] || [ "${VNC_NO_PASSWORD}" = "1" ]; then
    +if [ "${VNC_NO_PASSWORD:-}" = "true" ] || [ "${VNC_NO_PASSWORD:-}" = "1" ]; then
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Adding the :- parameter expansion operator provides better handling of unset variables, preventing potential script failures in edge cases where VNC_NO_PASSWORD might be unset despite the earlier assignment.

    7
    Initialize variables before conditional logic to prevent undefined variable issues

    Initialize X11VNC_OPTS before the conditional blocks to ensure it's always defined,
    preventing potential undefined variable usage.

    NodeBase/start-vnc.sh [17-22]

    +X11VNC_OPTS=""
     if [ "${VNC_NO_PASSWORD}" = "true" ] || [ "${VNC_NO_PASSWORD}" = "1" ]; then
       echo "Starting VNC server without password authentication"
    -  X11VNC_OPTS=
     else
    -  X11VNC_OPTS=-usepw
    +  X11VNC_OPTS="-usepw"
     fi
    • Apply this suggestion
    Suggestion importance[1-10]: 6

    Why: Pre-initializing X11VNC_OPTS ensures the variable is always defined, making the code more robust, though the current implementation already handles the variable assignment safely within the conditional blocks.

    6

    💡 Need additional feedback ? start a PR chat

    @VietND96 VietND96 merged commit 363a1d4 into trunk Dec 3, 2024
    50 of 52 checks passed
    @VietND96 VietND96 deleted the vnc-env-var branch December 3, 2024 06:51
    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.

    [🐛 Bug]: Node: Disable/Enable VNC view only (or GUI interaction)
    1 participant