-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
bugSomething isn't workingSomething isn't working
Description
While playing around with example python API provided by the docs I have encountered an error in NamesObfuscator.
Take following source as example:
import urllib.request
from urllib.error import URLError, HTTPError
url = 'http://example.com/'
with urllib.request.urlopen(url) as response:
html = response.read()
html = html.decode('utf-8')
print(html)
While trying to obfuscate the code the following error is thrown:
Traceback (most recent call last):
File "pof_obfuscator.py", line 117, in <module>
open('pof_testing.py','w').write(obfuscate(source))
~~~~~~~~~^^^^^^^^
File "pof_obfuscator.py", line 101, in obfuscate
tokens = NamesObfuscator(generator=generator).obfuscate_tokens(tokens)
File "venv/lib/python3.13/site-packages/pof/obfuscator/names.py", line 493, in obfuscate_tokens
return self.import_as(result, new_names)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "venv/lib/python3.13/site-packages/pof/obfuscator/names.py", line 343, in import_as
raise e
File "venv/lib/python3.13/site-packages/pof/obfuscator/names.py", line 320, in import_as
n.name = inew_names[n.name]
~~~~~~~~~~^^^^^^^^
KeyError: 'oL_9_VR62F._238'
To understand the issue a little more I added couple of debug prints, here is the contents of new_names variable:
{'urllib': 'oL_9_VR62F', 'request': '_238', 'error': 'errnos', 'URLError': 'blob', 'HTTPError': 'mod_name', 'url': 'stdev', 'urlopen': 'tag_remove', 'response': 'listobj', 'html': 'writeHeader'}
It looks like AST library threats urllib.request as a single token, while the pof code splits it into two.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working