Repository navigation
fix: critical bugs, missing tests, and config cleanup - #1
Conversation
Reviewer's GuideFixes 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 shutdownsequenceDiagram
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
Sequence diagram for safe self-update archive extractionsequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
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
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| if not is_running(pid): | ||
| return True | ||
| time.sleep(0.1) | ||
| return True |
There was a problem hiding this comment.
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.
| return True | |
| return False |
86963d1 to
9a387c3
Compare
- 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
9a387c3 to
b4720b4
Compare
fix: critical bugs, missing tests, and config cleanup
Summary
Verification
Summary by Sourcery
Improve proxy lifecycle reliability and update safety while expanding bridge methods, cleaning project configuration, and strengthening test coverage.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: