[HARDENING] _validate_imports misses non-line-start imports — switch to AST-based validation
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 50/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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).
- Vorherrschende Sprache
- Python
- Sterne
- 1
- Forks
- 4
- Ø Merge
- 12 T. 21 Std.
- Gemergte PRs (30 T.)
- 1
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus alphacrack/python-maithili-dsl
-
help wanted infra P2 testing
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 80/100
-
documentation enhancement good first issue help wanted P3
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
-
documentation good first issue P3
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
-
area:linter enhancement good first issue P3 translation
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 66/100
-
area:cli enhancement good first issue P3
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Alle Issues in alphacrack/python-maithili-dsl
Ähnliche Issues
-
ライブラリを追加Offenpriority middle
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 62/100
KATO-Hiro/AtCoderClans#13015 ·
Maintainer antworten meist innerhalb von 1 Tag
-
StringLiteral to IntegerType/LongType silently truncates fractional strings, changing predicate meaningEvtl. vergeben @Shahzeb-DataEngineer hat das heute übernommen. Offenkind:bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
apache/iceberg-python#4382 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
request-theme
Schwierigkeit 2/5 Unter einer Stunde Anfängerfreundlichkeit 62/100
LizardByte/ThemerrDB#10024 · 2 Kommentare ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
btclib-org/btclib-node#2505 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
open-webui/open-webui#34462 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag