[BUG] translate_imports uses blind str.replace — corrupts identifiers and string contents

Đang mở
#26 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
55/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
python
Lĩnh vực
cli

Hướng nghiên cứu

Start in translate_imports in maithili_dsl/cli.py, where module names are swapped with plain str.replace, then read _make_keyword_pattern in transpile.py to see the word-boundary approach to reuse. Switch the module rewrite to word boundaries applied only outside string literals and comments, and record translated_modules from actual import statements. Done when both reproductions (the substring case and the string-literal case) produce unchanged output in tests/test_cli.py or tests/test_security.py, and आयात गणित followed by गणित.sqrt(...) still works.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

area:cli bug help wanted P2 security

File: maithili_dsl/cli.py (translate_imports)

translate_imports() still uses blind str.replace() — the exact class of bug that was fixed in the transpiler for keywords (see v0.3.0 hardening). Two verified reproductions:

Substring corruption:

Input:  उच्चगणित.कोष = १
Output: उच्चmath.कोष = १     # गणित matched inside उच्चगणित

Rewrites inside string literals:

Input:  छपाउ("गणित.")
Output: छपाउ("math.")        # user-visible output changed

Side effect: because "{module}." appearing anywhere (including strings/comments) adds the module to translated_modules, the import whitelist gets looser than intended.

Fix: reuse the word-boundary pattern machinery from transpile.py (_make_keyword_pattern) and run module translation on code regions only (after/with tokenization), not on the raw source. Track translated_modules from actual आयात statements rather than substring hits.

Tests: both repros above in tests/test_cli.py or tests/test_security.py, plus regression tests that legitimate आयात गणित + गणित.sqrt(...) still work.

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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của alphacrack/python-maithili-dsl

Tất cả issue của alphacrack/python-maithili-dsl

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.