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

Abierto
#26 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Tranquilo
Stack tecnológico
python
Área
cli

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
1
Forks
4
Merge medio
12 d 21 h
PR fusionados (30 d)
1

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de alphacrack/python-maithili-dsl

Todos los issues de alphacrack/python-maithili-dsl

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.