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

オープン
#26 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
python
領域
cli

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
1
フォーク
4
平均マージ
12日 21時間
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

alphacrack/python-maithili-dsl のほかの issue

alphacrack/python-maithili-dsl の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。