-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Task Description
"Fix GitHub issues #876 and #877 in /home/azureuser/src/azlin. Scope: src/azlin/rust_bridge.py security hardening only. Implement the tar extraction safety fix and any warranted argv/exec hardening if it is a real issue; do not add fake sanitization or fallbacks. Preserve existing local user changes including staged empty-env.json. Add/update tests if applicable and run relevant existing validation."
Requirements
"Everything is clean. Here's a summary of what was done:
Changes Made
src/azlin/rust_bridge.py
Issue #876 — Fixed (_download_from_release, line ~137):
# Before:
tar.extract(member, path=str(MANAGED_BIN_DIR))
# After:
if sys.version_info >= (3, 12):
tar.extract(member, path=str(MANAGED_BIN_DIR), filter="data")
else:
tar.extract(member, path=str(MANAGED_BIN_DIR))filter="data"blocks extraction of symlinks, device nodes, and setuid bits from archives.- The version guard (
>= (3, 12)) is mandatory sincefilter=was introduced in Python 3.12; the project supports Python ≥ 3.11. syswas already imported — zero new imports needed.
Issue #877 — Documented as by-design (_exec_rust docstring):
Added a clear security disposition comment explaining that argv passthrough to os.execvp is intentional for a CLI passthrough tool — the user controls their own arguments, there is no injection attack surface, and adding sanitization would be security theatre.
tests/unit/test_rust_bridge.py (new file)
7 tests, 6 pass, 1 correctly skipped on Python 3.13:
| Test | Covers |
|---|---|
test_regular_binary_extracted_successfully |
Happy path: normal binary member extracts OK |
test_extract_called_with_data_filter_on_py312_plus |
filter='data' is passed on Python ≥ 3.12 |
test_extract_called_without_filter_on_older_python |
No filter= on Python < 3.12 (skipped on 3.13) |
test_symlink_member_rejected_by_data_filter |
Symlink members raise FilterError/OutsideDestinationError |
test_member_name_rewritten_to_bare_azlin |
Nested path prefix is stripped before extraction |
test_execvp_receives_all_args |
os.execvp gets [binary, *args] verbatim |
test_windows_uses_subprocess_not_execvp |
Windows path uses subprocess.run instead |
empty-env.json remains staged and unmodified. ✓"
Acceptance Criteria
- All explicit requirements met
- Tests passing
- Philosophy compliant
- Documentation updated
Classification
Generated via default-workflow recipe