[HARDENING] _validate_imports misses non-line-start imports — switch to AST-based validation
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 50/100
Hướng nghiên cứu
Start with _validate_imports in maithili_dsl/cli.py, which matches imports by line prefix, and reproduce the miss with x = 1; import os. Read CONTRIBUTING.md, since changes to the sandbox require a Security Considerations section in the PR. Replace the line scan with an ast.parse() walk over ast.Import and ast.ImportFrom nodes, and add a SyntaxError path. Done when the semicolon, indented, and from ... import cases are rejected in tests/test_security.py and existing tests still pass.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
File: maithili_dsl/cli.py (_validate_imports)
The pre-exec import check is line-prefix-based (stripped.startswith('import ')), so statements not at the start of a line are missed:
x = 1; import os # passes _validate_imports (verified)
Runtime is still guarded by the __import__ wrapper, so this is not a sandbox escape — only whitelisted modules load either way — but it silently defeats the documented "raw Python imports are rejected before execution" layer, and prefix matching will also miss conditional/indented imports.
Fix: parse with ast.parse() and walk ast.Import / ast.ImportFrom nodes instead of scanning lines. Bonus: this also gives precise line numbers for error messages, and a clean SyntaxError path for malformed code before exec.
Tests: semicolon repro above, indented import inside यदि, from os import path variants — all in tests/test_security.py (per CONTRIBUTING.md this touches the sandbox, so a Security Considerations section is required in the PR).
- Ngôn ngữ chính
- Python
- Star
- 1
- Fork
- 4
- Merge trung bình
- 12 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay 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 alphacrack/python-maithili-dsl
-
help wanted infra P2 testing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
-
documentation enhancement good first issue help wanted P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
documentation good first issue P3
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
area:linter enhancement good first issue P3 translation
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 66/100
-
area:cli enhancement good first issue P3
Độ 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 alphacrack/python-maithili-dsl
Issue tương tự
-
documentation good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
JheysonJhordyHuarauyaRiquelme/sprocguard#18 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
dlq/synthpopcan#59 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
mdn/translated-content#40220 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
ETSInitiative/PETSIRD#243 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
deferred p2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
cuadrao-ai/argus#2160 ·
Maintainer thường phản hồi trong vòng 1 ngày