test : add unit tests for _unshare_net_supported in parser_sandbox
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Read backend/secuscan/parser_sandbox.py to inspect _unshare_net_supported and its cache globals, then run the pytest command given in the issue. Add testing/backend/unit/test_parser_sandbox_unshare_supported.py with the four mocked platform and probe cases, resetting the cache around each test. Done means all four paths pass in isolation; the issue says tmdeveloper007 is handling it, so confirm availability before starting.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary of What Needs to be Done:
Add unit tests for the _unshare_net_supported function in backend/secuscan/parser_sandbox.py. This function probes whether the unshare --user --net system call works on the host, and caches the result to avoid repeated probes.
The function has several distinct code paths that should each be tested:
- Non-Linux platform returns False immediately
unsharebinary not found returns Falseunsharebinary found but probe fails (non-zero exit) returns Falseunsharebinary found and probe succeeds (exit 0) returns True
Changes that Need to be Made:
Create testing/backend/unit/test_parser_sandbox_unshare_supported.py:
- Test non-Linux path by patching
platform.system()to return "Darwin" - Test unshare binary not found by patching
shutil.whichto return None - Test probe failure by patching
subprocess.runto return a non-zero returncode - Test probe success by patching
subprocess.runto return zero returncode - The function uses module-level caching (
_unshare_capability_checked,_unshare_available): each test case needs to reset these globals before and after to ensure test isolation - Import the real production function directly:
from backend.secuscan.parser_sandbox import _unshare_net_supported - Run with
python3 -m pytest testing/backend/unit/test_parser_sandbox_unshare_supported.py -v --noconftest
Impact that it would Provide:
- Tests a code path (capability detection) that is currently completely untested
- Prevents regressions when refactoring the unshare support detection logic
- Ensures the function behaves correctly on different platforms and when the
unsharebinary is unavailable - Uses standard
unittest.mockpatching, no heavy framework dependencies
Note: This task is being handled by tmdeveloper007 — please assign to that account when picking it up.
- Ngôn ngữ chính
- Python
- Star
- 36
- Fork
- 234
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của utksh1/SecuScan
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
area:frontend good first issue level:intermediate priority:low type:testing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
-
area:frontend good first issue level:intermediate priority:low type:testing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
area:frontend good first issue level:beginner priority:low type:testing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
area:frontend good first issue level:intermediate priority:low type:testing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Tất cả issue của utksh1/SecuScan
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày
-
comp/desktop P3 type/feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NousResearch/hermes-agent#154285 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
docs: qualify copied and custom kubectl debug policy notesCó thể đã có người làm @nym01 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
kubescape/cel-admission-library#166 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
SACGF/variantgrid#2804 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] HTTP lifecycle dispatch treats a NO_PROXY-only environment as corporate egress and skips the resolve-and-pinned sessionCó thể đã có người làm @bodapatisaikrishna đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày