Skip to content

Cross‑platform bootstrap script with embedded Python 3.14#3

Merged
PythonChicken123 merged 9 commits into
mainfrom
automatic
Mar 19, 2026
Merged

Cross‑platform bootstrap script with embedded Python 3.14#3
PythonChicken123 merged 9 commits into
mainfrom
automatic

Conversation

@PythonChicken123

@PythonChicken123 PythonChicken123 commented Mar 17, 2026

Copy link
Copy Markdown
Owner

Cross‑platform bootstrap script with embedded Python 3.14
Attempts to download the native portablemc binary, falls back to pip.
Run with any Python (e.g., system 3.11) to set up and launch the launcher.

This main.py file will run "launch.py" will try the following things:

  1. Find the absolute path of python 3.14 ".\python\python.exe"
  2. Set user variables to the absolute path of python 3.14 if found
  3. If not found, attempt to download python 3.14 from "https://www.python.org/ftp/python/3.14.3/python-3.14.3-embed-amd64.zip"
  4. Extract the embed.zip and rename the folder directory to "python"
  5. Fix "python314._pth" by enabling "site-packages"
  6. Download "get-pip.py" by curl -o get-pip.py https://bootstrap.pypa.io/get-pip.py
  7. Run "get-pip.py" via the embedded python at "/python/python.exe" using /python/python.exe get-pip.py --trusted-host=files.pythonhosted.org --trusted-host=pypi.org
  8. Upgrade the pip by /python/python.exe -m pip install --upgrade pip and use "--user" argument if required
  9. Install project dependencies: python -m pip install flask flask-socketio psutil ansi2html portablemc
  10. Using the absolute path found for python 3.14 (see step 1), add the path to the SYSTEM environment variables as FIRST PROIRITY, but without administrator permission, fallback to the USER environmental variables in step 11
  11. Using the absolute path found for python 3.14 (see step 1), add the path to the USER environment variables as FIRST PROIRTY.
  12. Run the launcher of "portablemc.py" via embedded python in the same process using environment __compat_layer = runasinvoker with embedded.

Summary by Sourcery

Introduce a cross-platform bootstrapper that provisions an embedded Python runtime and launches the web-based PortableMC launcher, which now supports both native binary and Python module execution modes.

New Features:

  • Add a main bootstrap script that downloads and configures an embedded Python 3.14 environment, installs required packages, and starts the launcher.
  • Support using a native portablemc binary when available, falling back to the Python portablemc module via pip if needed.

Enhancements:

  • Rename and adjust the launcher script to work with the new bootstrap flow and to adapt its command-line arguments depending on whether the portablemc binary or module is used.
  • Streamline server-side logging, event handling, and output formatting while preserving existing web socket and streaming behavior.

@sourcery-ai

sourcery-ai Bot commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Introduces a new cross‑platform bootstrapper (main.py) that provisions an embedded Python 3.14 environment, installs dependencies, prefers a native portablemc binary when available, and launches the existing Flask/SocketIO Minecraft launcher (renamed to portablemc.py), which is updated to handle both the portablemc binary and Python module modes and to simplify/normalize various server‑side behaviors and logging.

Sequence diagram for bootstrap and launcher execution with portablemc modes

sequenceDiagram
    actor User
    participant SystemPython as system_python
    participant Main as main_py
    participant Embedded as embedded_python_3_14
    participant Pip as pip
    participant PmcBin as portablemc_binary
    participant PmcMod as portablemc_module
    participant Launcher as portablemc_py
    participant MCServer as minecraft_server

    User->>SystemPython: run main_py
    SystemPython->>Main: execute main()

    Main->>Main: ensure_embedded_python()
    Main->>Main: fix_pth_file()

    Main->>Embedded: check -m pip --version
    alt pip not installed
        Main->>Embedded: run get_pip_py
        Embedded->>Pip: bootstrap pip
    end

    Main->>Embedded: pip install base packages
    Main->>Embedded: ensure_portablemc()

    alt portablemc binary available
        Embedded->>PmcBin: test --help
        Main->>Main: method = binary
    else portablemc module via pip
        Embedded->>Pip: pip install portablemc
        Embedded->>PmcMod: python -m portablemc --help
        Main->>Main: method = module
    end

    Main->>Embedded: launch_launcher(method)
    Embedded->>Launcher: run portablemc_py
    note right of Launcher: PORTABLEMC_METHOD env set to binary or module

    alt method is binary
        Launcher->>PmcBin: portablemc --main-dir . start --join-server SERVER_IP --jvm-arg=opts -u user
    else method is module
        Launcher->>Embedded: python -m portablemc --main-dir . --timeout 60 --output human-color start --server SERVER_IP --jvm-args opts -u user
        Embedded->>PmcMod: start game
    end

    par game session
        PmcBin-->>MCServer: connect and run Minecraft
        PmcMod-->>MCServer: connect and run Minecraft
    end
Loading

Sequence diagram for portablemc_py stream route launching portablemc

sequenceDiagram
    participant Browser as web_client
    participant Flask as flask_app_portablemc_py
    participant Gen as stream_generator
    participant Sub as subprocess_portablemc
    participant MC as minecraft_server

    Browser->>Flask: GET /stream?user=...
    Flask->>Flask: validate username and password
    Flask->>Flask: check active_processes for user
    alt core busy
        Flask-->>Browser: SSE error CORE BUSY and CLOSE
    else core free
        Flask->>Gen: create generator(generate)
        Flask-->>Browser: SSE stream from Gen
        note right of Flask: PORTABLEMC_METHOD env controls
        note right of Flask: binary vs module command

        Gen->>Flask: build launcher_cmd
        alt PORTABLEMC_METHOD == binary
            Gen->>Gen: cmd = [portablemc, --main-dir ., start, --join-server SERVER_IP, --jvm-arg=opts, fabric:, -u user]
        else module mode
            Gen->>Gen: cmd = [python_exe, -m portablemc, --main-dir ., --timeout 60, --output human-color, start, --server SERVER_IP, --jvm-args opts, fabric:, -u user]
        end

        Gen->>Sub: subprocess_popen(cmd, stdout=PIPE)
        Gen->>Sub: read stdout lines
        loop forward console output
            Sub-->>Gen: line
            Gen-->>Browser: SSE data payload (ansi or html)
        end

        Sub-->>MC: connect to minecraft_server and run game

        alt client disconnects
            Browser--xFlask: close SSE connection
            Gen->>Sub: terminate or kill process tree
        else game exits normally
            Sub-->>Gen: process exit
            Gen-->>Browser: SSE SESSION ENDED and CLOSE
        end
    end
Loading

File-Level Changes

Change Details Files
Rename the Flask/SocketIO launcher entrypoint and adapt it to support both portablemc binary and Python module execution modes.
  • Rename launch.py to portablemc.py and adjust string/style conventions (consistent single quotes, minor logging/emit tweaks).
  • On client connect, immediately emit initial core/minecraft status instead of just printing.
  • Refactor portablemc launch command construction to branch on PORTABLEMC_METHOD environment variable and correctly build arguments for binary (--join-server, --jvm-arg=...) versus module (--server, --jvm-args ...), while still honoring a bundled Java runtime via --jvm.
  • Remove the custom env copy and __compat_layer injection in the subprocess.Popen call (environment now inherited from the parent) while keeping Windows startupinfo/CREATE_NO_WINDOW behavior.
  • Reorder psutil and ansi2html setup, but keep behavior: psutil remains optional for tree killing; ansi2html remains optional with fallback to raw ANSI, with some minor log and payload formatting simplifications.
launch.py
portablemc.py
Streamline SSE/Socket.IO handlers and generator output formatting without changing core protocol semantics.
  • Normalize event names and JSON payload creation to single-quoted strings and compact dict literals, reducing verbosity while keeping the same message types and fields.
  • Keep Minecraft ping (/ping and ping_minecraft) logic but remove redundant comments/docstrings and ensure consistent emit/response shapes.
  • Simplify error_gen helpers for username validation, forbidden usernames, and core-busy states while preserving ANSI messages and CLOSE markers.
  • Tighten the main streaming generator by simplifying the CORE BUSY recheck, connection-closed handling, progress throttling, and final SESSION ENDED/TIP messages, without changing when or what is sent.
  • Keep graceful shutdown and kill_process_tree semantics intact while trimming comments and small logging details.
portablemc.py
Add a cross‑platform bootstrapper that provisions an embedded Python 3.14 runtime, installs dependencies and portablemc, then launches the web launcher with the correct mode indicated via environment variables.
  • Download and unpack the official Python 3.14.3 embedded distribution into a local python/ directory if not already present, and enable site-packages by rewriting the *_._pth file to uncomment import site.
  • Ensure pip is available inside the embedded environment by downloading get-pip.py and running it with appropriate PYTHONNOUSERSITE/PYTHONPATH isolation and trusted-host flags.
  • Install core Python dependencies (flask, flask-socketio, psutil, ansi2html) into the embedded environment and upgrade pip; all pip calls are run via the embedded interpreter with a helper that captures output and reports errors.
  • Determine OS/architecture and attempt to download a native portablemc v5.0.2 binary from GitHub into portablemc_bin/, extracting and flattening the archive; if the binary test fails, fall back to installing portablemc via pip and re-testing via python -m portablemc --help.
  • Launch portablemc.py using the embedded interpreter with a controlled environment (PATH prefixed with embedded python and portablemc_bin, PYTHONHOME set, colors forced, usersite disabled) and set PORTABLEMC_METHOD so the launcher can choose between binary and module execution paths.
main.py
Remove the old package entrypoint in favor of the new bootstrap flow.
  • Delete main.py so package execution is now intended to go through main.py and the embedded runtime bootstrap rather than the previous entrypoint.
__main__.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New security issues found

Comment thread main.py
env["PYTHONNOUSERSITE"] = "1"
env["PYTHONPATH"] = ""
cmd = [str(EMBEDDED_PYTHON)] + args
result = subprocess.run(cmd, env=env, capture_output=True, text=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security (python.lang.security.audit.dangerous-subprocess-use-audit): Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

Source: opengrep

Comment thread main.py
cmd = [str(EMBEDDED_PYTHON), str(pip_script),
"--trusted-host=files.pythonhosted.org",
"--trusted-host=pypi.org"]
result = subprocess.run(cmd, env=env, capture_output=True, text=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security (python.lang.security.audit.dangerous-subprocess-use-audit): Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

Source: opengrep

Comment thread main.py
Comment on lines +203 to +204
result = subprocess.run([str(binary_path), "--help"], env=env,
capture_output=True, text=True, timeout=5)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security (python.lang.security.audit.dangerous-subprocess-use-audit): Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

Source: opengrep

Comment thread main.py Outdated
env["PYTHONNOUSERSITE"] = "1"
env["PYTHONPATH"] = ""
cmd = [str(EMBEDDED_PYTHON), "-m", "portablemc", "--help"]
result = subprocess.run(cmd, env=env, capture_output=True, text=True, timeout=5)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security (python.lang.security.audit.dangerous-subprocess-use-audit): Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

Source: opengrep

Comment thread main.py
cmd = [str(EMBEDDED_PYTHON), str(launcher_script)]
print(f"🚀 Launching: {' '.join(cmd)}")
try:
subprocess.run(cmd, env=env, check=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security (python.lang.security.audit.dangerous-subprocess-use-audit): Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

Source: opengrep

Comment thread main.py
Comment on lines +276 to +277
pip_check = subprocess.run([str(EMBEDDED_PYTHON), "-m", "pip", "--version"],
env=env_check, capture_output=True, text=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security (python.lang.security.audit.dangerous-subprocess-use-audit): Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

Source: opengrep

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 6 security issues, 2 other issues, and left some high level feedback:

Security issues:

  • Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'. (link)
  • Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'. (link)
  • Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'. (link)
  • Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'. (link)
  • Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'. (link)
  • Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'. (link)

General comments:

  • The bootstrap script hardcodes the Windows embeddable Python URL and python.exe path but is labeled cross‑platform; on non‑Windows systems this will fail—consider gating the embedded-Python flow to Windows only or adding OS-specific download/exec logic.
  • In portablemc.py, launcher_cmd is chosen solely via shutil.which("portablemc")/module fallback, while argument selection depends on PORTABLEMC_METHOD; this can result in using binary-style arguments with a module CLI (or vice versa) if multiple portablemc executables are on PATH—tie launcher selection directly to PORTABLEMC_METHOD to avoid mismatches.
  • In test_portablemc, the module check uses subprocess.run(..., timeout=5) without catching subprocess.TimeoutExpired, so a slow or hung portablemc module will crash the bootstrapper; wrap this call in a try/except similar to the binary branch.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The bootstrap script hardcodes the Windows embeddable Python URL and `python.exe` path but is labeled cross‑platform; on non‑Windows systems this will fail—consider gating the embedded-Python flow to Windows only or adding OS-specific download/exec logic.
- In `portablemc.py`, `launcher_cmd` is chosen solely via `shutil.which("portablemc")`/module fallback, while argument selection depends on `PORTABLEMC_METHOD`; this can result in using binary-style arguments with a module CLI (or vice versa) if multiple `portablemc` executables are on PATH—tie launcher selection directly to `PORTABLEMC_METHOD` to avoid mismatches.
- In `test_portablemc`, the module check uses `subprocess.run(..., timeout=5)` without catching `subprocess.TimeoutExpired`, so a slow or hung `portablemc` module will crash the bootstrapper; wrap this call in a try/except similar to the binary branch.

## Individual Comments

### Comment 1
<location path="main.py" line_range="19-22" />
<code_context>
+from pathlib import Path
+
+# --- Configuration ---
+EMBEDDED_DIR = Path(__file__).parent / "python"
+EMBEDDED_PYTHON = EMBEDDED_DIR / "python.exe"
+PYTHON_VERSION = "3.14.3"
+PYTHON_URL = f"https://www.python.org/ftp/python/{PYTHON_VERSION}/python-{PYTHON_VERSION}-embed-amd64.zip"
+GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py"
+BASE_PACKAGES = ["flask", "flask-socketio", "psutil", "ansi2html"]
</code_context>
<issue_to_address>
**issue (bug_risk):** Bootstrap is described as cross‑platform but uses a Windows‑only embedded Python distribution.

`EMBEDDED_PYTHON` is fixed to `python.exe` and `PYTHON_URL` targets the Windows embedded ZIP, so `ensure_embedded_python()` and any use of `EMBEDDED_PYTHON` will fail on non‑Windows systems. To align with the cross‑platform claim, you’ll need OS‑specific Python downloads/paths or reuse system Python on non‑Windows. If this bootstrap is meant to be Windows‑only, add an early, explicit OS check and fail fast with a clear message on other platforms.
</issue_to_address>

### Comment 2
<location path="main.py" line_range="214" />
<code_context>
+    env = os.environ.copy()
+    env["PYTHONNOUSERSITE"] = "1"
+    env["PYTHONPATH"] = ""
+    cmd = [str(EMBEDDED_PYTHON), "-m", "portablemc", "--help"]
+    result = subprocess.run(cmd, env=env, capture_output=True, text=True, timeout=5)
+    if result.returncode == 0:
</code_context>
<issue_to_address>
**issue (bug_risk):** Module `portablemc` probe uses a timeout but doesn’t catch `TimeoutExpired` like the binary probe does.

Unlike the binary probe, this path doesn’t catch `subprocess.TimeoutExpired` around `subprocess.run(..., timeout=5)`. If `-m portablemc --help` hangs, the bootstrap will crash instead of simply treating the module as unavailable. Please wrap this call in `try/except TimeoutExpired` and handle it the same way as the binary branch so timeouts are treated as a probe failure, not a hard error.
</issue_to_address>

### Comment 3
<location path="main.py" line_range="122" />
<code_context>
    result = subprocess.run(cmd, env=env, capture_output=True, text=True)
</code_context>
<issue_to_address>
**security (python.lang.security.audit.dangerous-subprocess-use-audit):** Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

*Source: opengrep*
</issue_to_address>

### Comment 4
<location path="main.py" line_range="140" />
<code_context>
    result = subprocess.run(cmd, env=env, capture_output=True, text=True)
</code_context>
<issue_to_address>
**security (python.lang.security.audit.dangerous-subprocess-use-audit):** Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

*Source: opengrep*
</issue_to_address>

### Comment 5
<location path="main.py" line_range="203-204" />
<code_context>
            result = subprocess.run([str(binary_path), "--help"], env=env,
                                    capture_output=True, text=True, timeout=5)
</code_context>
<issue_to_address>
**security (python.lang.security.audit.dangerous-subprocess-use-audit):** Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

*Source: opengrep*
</issue_to_address>

### Comment 6
<location path="main.py" line_range="215" />
<code_context>
    result = subprocess.run(cmd, env=env, capture_output=True, text=True, timeout=5)
</code_context>
<issue_to_address>
**security (python.lang.security.audit.dangerous-subprocess-use-audit):** Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

*Source: opengrep*
</issue_to_address>

### Comment 7
<location path="main.py" line_range="258" />
<code_context>
        subprocess.run(cmd, env=env, check=True)
</code_context>
<issue_to_address>
**security (python.lang.security.audit.dangerous-subprocess-use-audit):** Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

*Source: opengrep*
</issue_to_address>

### Comment 8
<location path="main.py" line_range="276-277" />
<code_context>
    pip_check = subprocess.run([str(EMBEDDED_PYTHON), "-m", "pip", "--version"],
                               env=env_check, capture_output=True, text=True)
</code_context>
<issue_to_address>
**security (python.lang.security.audit.dangerous-subprocess-use-audit):** Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

*Source: opengrep*
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread main.py
Comment thread main.py
Comment thread main.py
env["PYTHONNOUSERSITE"] = "1"
env["PYTHONPATH"] = ""
cmd = [str(EMBEDDED_PYTHON)] + args
result = subprocess.run(cmd, env=env, capture_output=True, text=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security (python.lang.security.audit.dangerous-subprocess-use-audit): Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

Source: opengrep

Comment thread main.py
cmd = [str(EMBEDDED_PYTHON), str(pip_script),
"--trusted-host=files.pythonhosted.org",
"--trusted-host=pypi.org"]
result = subprocess.run(cmd, env=env, capture_output=True, text=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security (python.lang.security.audit.dangerous-subprocess-use-audit): Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

Source: opengrep

Comment thread main.py
Comment on lines +203 to +204
result = subprocess.run([str(binary_path), "--help"], env=env,
capture_output=True, text=True, timeout=5)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security (python.lang.security.audit.dangerous-subprocess-use-audit): Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

Source: opengrep

Comment thread main.py Outdated
env["PYTHONNOUSERSITE"] = "1"
env["PYTHONPATH"] = ""
cmd = [str(EMBEDDED_PYTHON), "-m", "portablemc", "--help"]
result = subprocess.run(cmd, env=env, capture_output=True, text=True, timeout=5)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security (python.lang.security.audit.dangerous-subprocess-use-audit): Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

Source: opengrep

Comment thread main.py
cmd = [str(EMBEDDED_PYTHON), str(launcher_script)]
print(f"🚀 Launching: {' '.join(cmd)}")
try:
subprocess.run(cmd, env=env, check=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security (python.lang.security.audit.dangerous-subprocess-use-audit): Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

Source: opengrep

Comment thread main.py
Comment on lines +276 to +277
pip_check = subprocess.run([str(EMBEDDED_PYTHON), "-m", "pip", "--version"],
env=env_check, capture_output=True, text=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security (python.lang.security.audit.dangerous-subprocess-use-audit): Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

Source: opengrep

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New security issues found

Comment thread portablemc.py Outdated
Comment thread portablemc.py Outdated
Comment thread portablemc.py Outdated
Comment thread portablemc.py Outdated
Comment thread portablemc.py Outdated
Comment thread portablemc.py Outdated

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New security issues found

Comment thread main.py
cmd = [str(EMBEDDED_PYTHON), str(launcher_script)]
print(f"🚀 Launching: {' '.join(cmd)}")
try:
subprocess.run(cmd, env=env, check=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security (python.lang.security.audit.dangerous-subprocess-use-audit): Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

Source: opengrep

Comment thread main.py
Comment on lines +359 to +360
pip_check = subprocess.run([str(EMBEDDED_PYTHON), "-m", "pip", "--version"],
env=env_check, capture_output=True, text=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security (python.lang.security.audit.dangerous-subprocess-use-audit): Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

Source: opengrep

@PythonChicken123

Copy link
Copy Markdown
Owner Author

Fully works, but does not bypass group policy, this will be merged, but the main pull request is with .NET

@PythonChicken123
PythonChicken123 merged commit ec2dedf into main Mar 19, 2026
0 of 3 checks passed
@PythonChicken123
PythonChicken123 deleted the automatic branch March 20, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant