Skip to content

fix: critical bugs, missing tests, and config cleanup - #1

Merged
vispar-tech merged 1 commit into
mainfrom
fix/critical-bugs-and-cleanup
Aug 31, 2026
Merged

vispar-tech merged 1 commit into
mainfrom
fix/critical-bugs-and-cleanup

Conversation

@vispar-tech

@vispar-tech vispar-tech commented Aug 31, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • fix Python 2 comma-except syntax in warp.py, vless.py, bridge.py
  • remove openrot doctor references from bug report template
  • add tar filter to tar.extractall for path traversal safety
  • remove dead code _port_open() from singbox.py
  • make stop_proxy wait for process termination
  • add missing HTTP methods (PUT/DELETE/PATCH/HEAD) to bridge
  • fix .dockerignore inconsistencies
  • fix pre-commit pass_filenames to true
  • add init.py to all test directories
  • fix coverage badge vs pyproject.toml threshold mismatch
  • add tests for self_update.py and warp_health_loop

Verification

  • ruff check — clean
  • mypy — clean
  • pytest — 297 passed, coverage 87%

Summary by Sourcery

Improve proxy lifecycle reliability and update safety while expanding bridge methods, cleaning project configuration, and strengthening test coverage.

New Features:

  • Support PUT, DELETE, PATCH, and HEAD requests in the bridge.

Bug Fixes:

  • Wait for proxy processes to terminate after requesting shutdown.
  • Protect self-update archive extraction against path traversal.
  • Correct Python exception syntax and align the documented coverage threshold with the project configuration.

Enhancements:

  • Remove unused sing-box port-checking code and obsolete bug-report tooling references.
  • Clean up Docker ignore rules and pre-commit file handling.

Documentation:

  • Update the bug report template to request current status and configuration information.

Tests:

  • Add coverage for self-update behavior and WARP health-loop handling.
  • Make test directories importable as Python packages.

@sourcery-ai

sourcery-ai Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Fixes Python exception syntax and several runtime behaviors, adds tar extraction safety and HTTP method support, cleans up repository configuration, and expands tests to cover self-update functionality and WARP health-loop behavior; verification reports 297 passing tests, 87% coverage, and clean Ruff/mypy checks.

Sequence diagram for graceful proxy shutdown

sequenceDiagram
    participant Caller
    participant Proxy as stop_proxy
    participant OS
    participant Process as is_running

    Caller->>Proxy: stop_proxy(pid)
    Proxy->>OS: os.kill(pid, SIGTERM)
    loop up to 50 checks
        Proxy->>Process: is_running(pid)
        alt process terminated
            Process-->>Proxy: false
            Proxy-->>Caller: true
        else still running
            Process-->>Proxy: true
            Proxy->>Proxy: time.sleep(0.1)
        end
    end
    Proxy-->>Caller: true
Loading

Sequence diagram for safe self-update archive extraction

sequenceDiagram
    participant Updater as _do_update
    participant Archive as tarfile
    participant Temp as Temporary directory

    Updater->>Archive: tarfile.open(archive_path, r:gz)
    Updater->>Archive: extractall(tmp, filter=data)
    Archive->>Temp: Extract validated archive paths
    Updater->>Temp: Locate openrot directory
Loading

File-Level Changes

Change Details Files
Harden update archive extraction against path traversal.
  • Enable the tarfile data filter during extraction.
openrot/self_update.py
Improve proxy and bridge runtime behavior.
  • Wait for terminated proxy processes after SIGTERM.
  • Inline port readiness probing and remove the unused helper.
  • Expose PUT, DELETE, PATCH, and HEAD handlers.
  • Correct exception tuple syntax for supported Python versions.
openrot/core/proxy.py
openrot/core/singbox.py
openrot/core/bridge.py
Correct provider exception handling syntax.
  • Use valid tuple-form exception handlers in WARP and VLESS code.
openrot/providers/warp.py
openrot/providers/vless.py
Align project configuration and issue-reporting metadata.
  • Remove obsolete doctor guidance from the bug template.
  • Pass filenames to pre-commit hooks.
  • Synchronize the coverage badge with the configured threshold.
  • Clean up Docker ignore rules.
.github/ISSUE_TEMPLATE/bug_report.md
.pre-commit-config.yaml
README.md
.dockerignore
Expand test package discoverability and coverage.
  • Add package initializers to test directories.
  • Cover self-update helpers and archive/install flows.
  • Test WARP health-loop fallback and connected-loop behavior.
tests/unit/test_self_update.py
tests/unit/core/test_cascade.py
tests/**/__init__.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

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="openrot/core/proxy.py" line_range="127" />
<code_context>
-        return True
     except OSError:
         return False
+    for _ in range(50):
+        if not is_running(pid):
+            return True
+        time.sleep(0.1)
+    return True
</code_context>
<issue_to_address>
**issue (bug_risk):** After the 5-second polling loop, `stop_proxy` returns `True` even when `is_running(pid)` is still true, so callers proceed as though the proxy terminated and can start a replacement process while the old process still owns the proxy port.

**Triggers:** When the proxy ignores or delays SIGTERM for more than five seconds.

**Suggested fix:** Return `False` after the timeout, or perform an escalation and verify termination before returning `True`.

```suggestion
    return False
```
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and the bridge now forwards DELETE, PUT, and PATCH requests that were previously rejected, so a client request can trigger destructive or otherwise security-sensitive upstream behavior that reverting cannot undo. The self-update extraction change is also persistent in effect if an update is installed, though failures can generally be repaired by rerunning the update.

Blocking findings: openrot/core/proxy.py:127


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 openrot/core/proxy.py
if not is_running(pid):
return True
time.sleep(0.1)
return True

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): After the 5-second polling loop, stop_proxy returns True even when is_running(pid) is still true, so callers proceed as though the proxy terminated and can start a replacement process while the old process still owns the proxy port.

Triggers: When the proxy ignores or delays SIGTERM for more than five seconds.

Suggested fix: Return False after the timeout, or perform an escalation and verify termination before returning True.

Suggested change
return True
return False

@vispar-tech
vispar-tech force-pushed the fix/critical-bugs-and-cleanup branch from 86963d1 to 9a387c3 Compare August 31, 2026 21:12
- fix Python 2 comma-except syntax in warp.py, vless.py, bridge.py
- remove openrot doctor references from bug report template
- add tar filter to tar.extractall for path traversal safety
- remove dead code _port_open() from singbox.py
- make stop_proxy wait for process termination
- add missing HTTP methods (PUT/DELETE/PATCH/HEAD) to bridge
- fix .dockerignore inconsistencies
- fix pre-commit pass_filenames to true
- add __init__.py to all test directories
- fix coverage badge vs pyproject.toml threshold mismatch
- add tests for self_update.py and warp_health_loop
@vispar-tech
vispar-tech force-pushed the fix/critical-bugs-and-cleanup branch from 9a387c3 to b4720b4 Compare August 31, 2026 21:15
@vispar-tech
vispar-tech merged commit 8c2b046 into main Aug 31, 2026
9 checks passed
vispar-tech added a commit that referenced this pull request Oct 13, 2026
fix: critical bugs, missing tests, and config cleanup
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