Cobertos / bobskater

An AST based Python obfuscator that robustly mangles variable names
MIT License
4 stars 0 forks source link

AttributeError: 'NoneType' object has no attribute 'parent' #3

Open kwatsen opened 4 years ago

kwatsen commented 4 years ago

Sorry for the long delay, but I finally got around to packaging and, well, here we are again... :)

Unfortunately, I hit an issue right away. This code similar to the code you provided in Issue #2.

FILE: obfuscate.py

from bobskater.obfuscate import obfuscateFile
import glob
print("Minifier/Obfuscation...")
for file in glob.glob("src/sztpd/*.py"):
    print(file + ": Obfuscating... ", end='')
    obfuscateFile(file)

Output:

Queried identifier "_handle_device_created" was not been seen at the given scope stack
Minifier/Obfuscation...
src/sztpd/sztpd.py: Obfuscating... Traceback (most recent call last):
  File "obfuscate.py", line 7, in <module>
    obfuscateFile(file)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/site-packages/bobskater/obfuscate.py", line 328, in obfuscateFile
    s = obfuscateString(s, *args, **kwargs)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/site-packages/bobskater/obfuscate.py", line 320, in obfuscateString
    sAst = ObfuscationTransformer(ftnv.getRootFrame(), *args, **kwargs).visit(sAst)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/site-packages/bobskater/obfuscate.py", line 306, in generic_visit
    super().generic_visit(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 326, in generic_visit
    value = self.visit(value)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/site-packages/bobskater/obfuscate.py", line 306, in generic_visit
    super().generic_visit(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 326, in generic_visit
    value = self.visit(value)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/site-packages/bobskater/obfuscate.py", line 306, in generic_visit
    super().generic_visit(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 326, in generic_visit
    value = self.visit(value)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/site-packages/bobskater/obfuscate.py", line 306, in generic_visit
    super().generic_visit(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 326, in generic_visit
    value = self.visit(value)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/site-packages/bobskater/obfuscate.py", line 306, in generic_visit
    super().generic_visit(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 326, in generic_visit
    value = self.visit(value)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/site-packages/bobskater/obfuscate.py", line 306, in generic_visit
    super().generic_visit(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 335, in generic_visit
    new_node = self.visit(old_value)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/site-packages/bobskater/obfuscate.py", line 306, in generic_visit
    super().generic_visit(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 326, in generic_visit
    value = self.visit(value)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/site-packages/bobskater/obfuscate.py", line 292, in generic_visit
    mangleTo = self.getMangledName(self._nodeStack, strId)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/site-packages/bobskater/obfuscate.py", line 224, in getMangledName
    isBuiltin = frameEntry.parent == self._rootFrame
AttributeError: 'NoneType' object has no attribute 'parent'

Any thoughts?

kwatsen commented 4 years ago

Looking at the message:

Queried identifier "_handle_device_created" was not been seen at the given scope stack

I see this message being generated on line 85 in frameUtils.py. Just above the message is this comment:

        #This happens if the identifier was not seen in the given scope stack.
        #Most likely passing something erroneously in

FWIW, _handle_device_created() is a global function (not a class method) that is declared as follows:

async def _handle_device_created(watched_node_path: str, jsob: dict, data_path: str, nvh: NativeViewHandler) -> None:
   pass  # real code hidden

Don't know if this helps any though...

Cobertos commented 4 years ago

Can you set your log level to debug and rerun it, it looks like there's a full debug printout of the parsed information related to the frames?

https://github.com/Cobertos/bobskater/blob/master/bobskater/obfuscate.py#L314-L317

#Walk the AST once total to get all the scope information
ftnv = FrameTrackingNodeVisitor()
ftnv.visit(sAst)
logging.getLogger(__name__).debug(ftnv.getRootFrame())

Feel free to censor anything you don't want to show.

I hadn't ever used or learned about Python's async syntax when I wrote this so it wasn't something I tested. If it has different a different AST object format that's one thing that might cause this issue.

Looks like https://greentreesnakes.readthedocs.io/en/latest/nodes.html#AsyncFunctionDef would need to be handled in https://github.com/Cobertos/bobskater/blob/master/bobskater/frameUtils.py#L189 and possibly adding a warning or something when bobskater doesn't recognize the node type to make debugging this easier in the future.

I'm also not familiar with the : type definitions. Is that something that Python natively handles? I'd need to look into what ast sees this as.

kwatsen commented 4 years ago

Here is the output with DEBUG enabled (I only redacted one thing -> "xxxxx"):

DEBUG:FrameTrackingNodeVisitor:[+Frame]: Module ""
DEBUG:FrameTrackingNodeVisitor:[+Entry]: alias "gc"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: alias "tracemalloc"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: alias "os"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: alias "re"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: alias "json"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: alias "signal"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: alias "asyncio"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: alias "datetime"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: alias "functools"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: alias "yl"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: alias "DataAccessLayer"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: alias "RestconfServer"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: alias "sha256_crypt"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: alias "TenantViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: alias "xxxxxViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: alias "NativeViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: alias "Period"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: alias "TimeUnit"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "loop"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "sig"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: FunctionDef "signal_handler"
DEBUG:FrameTrackingNodeVisitor:[+Frame]: FunctionDef "signal_handler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "name"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "sig"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "name"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "loop"
DEBUG:FrameTrackingNodeVisitor:[-Frame]
DEBUG:FrameTrackingNodeVisitor:[+Entry]: FunctionDef "run"
DEBUG:FrameTrackingNodeVisitor:[+Frame]: FunctionDef "run"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "debug"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "db_url"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "cacert_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "dal"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "mode"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "firsttime"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "dal"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "DataAccessLayer"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "db_url"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "cacert_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: ExceptHandler "e"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "SyntaxError"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "AssertionError"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: ExceptHandler "e"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "NotImplementedError"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "firsttime"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "mode"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "dal"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "firsttime"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "env_var"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "os"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "env_var"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "type"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "env_var"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "str"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "env_var"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "print"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "mode"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "env_var"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "print"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "print"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "print"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "print"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "print"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "print"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "mode"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "input"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "mode"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "print"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "dal"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "DataAccessLayer"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "db_url"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "cacert_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "json"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "getattr"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "yl"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "mode"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "mode"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "mode"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: ExceptHandler "e"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "Exception"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "e"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "mode"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "dal"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "tracemalloc"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "loop"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "asyncio"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "loop"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "signal"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "functools"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "signal_handler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "loop"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "signal"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "functools"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "signal_handler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "loop"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "signal"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "functools"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "signal_handler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "loop"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "signal"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "functools"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "signal_handler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "sig"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "rc_svr_list"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "async_def"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "dal"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "dal"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "transport_cfg"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "loop"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "async_def"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "endpoint_cfg"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "transport_cfg"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "dal"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "endpoint_cfg"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "nativeViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "NativeViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "dal"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "mode"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "loop"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "mode"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "device_schema_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "dal"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "mode"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "device_schema_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "dal"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "mode"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "device_schema_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "dal"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "nativeViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "device_schema_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "_handle_device_created"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "activation_code_schema_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "device_schema_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "nativeViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "activation_code_schema_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "_handle_device_act_code_changed"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "nativeViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "device_schema_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "_handle_device_subtree_changed"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "nativeViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "device_schema_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "_handle_device_somehow_changed"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "nativeViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "device_schema_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "_handle_device_deleted"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "nativeViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "Period"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "TimeUnit"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "datetime"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "_check_expirations"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "rcsvr"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "RestconfServer"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "loop"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "dal"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "endpoint_cfg"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "nativeViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "endpoint_cfg"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "tenantViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "TenantViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "nativeViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "rcsvr"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "RestconfServer"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "loop"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "dal"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "endpoint_cfg"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "tenantViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "endpoint_cfg"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "facade_yl"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "json"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "getattr"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "yl"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "xxxxxViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "xxxxxViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "dal"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "mode"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "facade_yl"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "rcsvr"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "RestconfServer"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "loop"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "dal"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "endpoint_cfg"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "xxxxxViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "facade_yl"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "rc_svr_list"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "rcsvr"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "endpoint_cfg"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "transport_cfg"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "loop"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "rc_svr"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "rc_svr_list"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "async_def"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "rc_svr"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "loop"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "async_def"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "rc_svr"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "rc_svr_list"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "async_def"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "rc_svr"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "loop"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "async_def"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "rc_svr"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "rc_svr_list"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "async_def"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "rc_svr"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "loop"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "async_def"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "rc_svr"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "rc_svr_list"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "rc_svr"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "rc_svr_list"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "sig"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "sig"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "loop"
DEBUG:FrameTrackingNodeVisitor:[-Frame]
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "watched_node_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "str"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "jsob"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "dict"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "jsob_data_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "str"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "nvh"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "NativeViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "type"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "jsob"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "dict"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "jsob_data_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "jsob"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "item"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "jsob"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "jsob"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "item"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "jsob"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "item"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "datetime"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "item"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "item"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "item"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "item"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "sha256_crypt"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "item"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "watched_node_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "str"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "jsob"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "dict"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "jsob_data_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "str"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "nvh"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "NativeViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "type"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "jsob"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "dict"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "jsob_data_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "jsob"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "item"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "jsob"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "jsob"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "item"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "jsob"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "item"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "item"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "item"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "sha256_crypt"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "item"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "watched_node_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "str"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "jsob"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "dict"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "jsob_data_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "str"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "nvh"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "NativeViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "NotImplementedError"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "watched_node_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "str"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "jsob"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "dict"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "jsob_data_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "str"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "nvh"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "NativeViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "NotImplementedError"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "data_path"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "str"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "nvh"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "NativeViewHandler"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: FunctionDef "_check_expirations"
DEBUG:FrameTrackingNodeVisitor:[+Frame]: FunctionDef "_check_expirations"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "nvh"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "NativeViewHandler"
DEBUG:FrameTrackingNodeVisitor:[-Frame]
DEBUG:FrameTrackingNodeVisitor:[-Frame]
DEBUG:bobskater.obfuscate:
Frame {ArithmeticError: NoneType(Store)
  AssertionError: NoneType(Store)
  AttributeError: NoneType(Store)
  BaseException: NoneType(Store)
  BlockingIOError: NoneType(Store)
  BrokenPipeError: NoneType(Store)
  BufferError: NoneType(Store)
  BytesWarning: NoneType(Store)
  ChildProcessError: NoneType(Store)
  ConnectionAbortedError: NoneType(Store)
  ConnectionError: NoneType(Store)
  ConnectionRefusedError: NoneType(Store)
  ConnectionResetError: NoneType(Store)
  DeprecationWarning: NoneType(Store)
  EOFError: NoneType(Store)
  Ellipsis: NoneType(Store)
  EnvironmentError: NoneType(Store)
  Exception: NoneType(Store)
  False: NoneType(Store)
  FileExistsError: NoneType(Store)
  FileNotFoundError: NoneType(Store)
  FloatingPointError: NoneType(Store)
  FutureWarning: NoneType(Store)
  GeneratorExit: NoneType(Store)
  IOError: NoneType(Store)
  ImportError: NoneType(Store)
  ImportWarning: NoneType(Store)
  IndentationError: NoneType(Store)
  IndexError: NoneType(Store)
  InterruptedError: NoneType(Store)
  IsADirectoryError: NoneType(Store)
  KeyError: NoneType(Store)
  KeyboardInterrupt: NoneType(Store)
  LookupError: NoneType(Store)
  MemoryError: NoneType(Store)
  ModuleNotFoundError: NoneType(Store)
  NameError: NoneType(Store)
  None: NoneType(Store)
  NotADirectoryError: NoneType(Store)
  NotImplemented: NoneType(Store)
  NotImplementedError: NoneType(Store)
  OSError: NoneType(Store)
  OverflowError: NoneType(Store)
  PendingDeprecationWarning: NoneType(Store)
  PermissionError: NoneType(Store)
  ProcessLookupError: NoneType(Store)
  RecursionError: NoneType(Store)
  ReferenceError: NoneType(Store)
  ResourceWarning: NoneType(Store)
  RuntimeError: NoneType(Store)
  RuntimeWarning: NoneType(Store)
  StopAsyncIteration: NoneType(Store)
  StopIteration: NoneType(Store)
  SyntaxError: NoneType(Store)
  SyntaxWarning: NoneType(Store)
  SystemError: NoneType(Store)
  SystemExit: NoneType(Store)
  TabError: NoneType(Store)
  TimeoutError: NoneType(Store)
  True: NoneType(Store)
  TypeError: NoneType(Store)
  UnboundLocalError: NoneType(Store)
  UnicodeDecodeError: NoneType(Store)
  UnicodeEncodeError: NoneType(Store)
  UnicodeError: NoneType(Store)
  UnicodeTranslateError: NoneType(Store)
  UnicodeWarning: NoneType(Store)
  UserWarning: NoneType(Store)
  ValueError: NoneType(Store)
  Warning: NoneType(Store)
  ZeroDivisionError: NoneType(Store)
  __build_class__: NoneType(Store)
  __debug__: NoneType(Store)
  __doc__: NoneType(Store)
  __import__: NoneType(Store)
  __loader__: NoneType(Store)
  __name__: NoneType(Store)
  __package__: NoneType(Store)
  __spec__: NoneType(Store)
  abs: NoneType(Store)
  all: NoneType(Store)
  any: NoneType(Store)
  ascii: NoneType(Store)
  bin: NoneType(Store)
  bool: NoneType(Store)
  breakpoint: NoneType(Store)
  bytearray: NoneType(Store)
  bytes: NoneType(Store)
  callable: NoneType(Store)
  chr: NoneType(Store)
  classmethod: NoneType(Store)
  compile: NoneType(Store)
  complex: NoneType(Store)
  copyright: NoneType(Store)
  credits: NoneType(Store)
  delattr: NoneType(Store)
  dict: NoneType(Store)
  dir: NoneType(Store)
  divmod: NoneType(Store)
  enumerate: NoneType(Store)
  eval: NoneType(Store)
  exec: NoneType(Store)
  exit: NoneType(Store)
  filter: NoneType(Store)
  float: NoneType(Store)
  format: NoneType(Store)
  frozenset: NoneType(Store)
  getattr: NoneType(Store)
  globals: NoneType(Store)
  hasattr: NoneType(Store)
  hash: NoneType(Store)
  help: NoneType(Store)
  hex: NoneType(Store)
  id: NoneType(Store)
  input: NoneType(Store)
  int: NoneType(Store)
  isinstance: NoneType(Store)
  issubclass: NoneType(Store)
  iter: NoneType(Store)
  len: NoneType(Store)
  license: NoneType(Store)
  list: NoneType(Store)
  locals: NoneType(Store)
  map: NoneType(Store)
  max: NoneType(Store)
  memoryview: NoneType(Store)
  min: NoneType(Store)
  next: NoneType(Store)
  object: NoneType(Store)
  oct: NoneType(Store)
  open: NoneType(Store)
  ord: NoneType(Store)
  pow: NoneType(Store)
  print: NoneType(Store)
  property: NoneType(Store)
  quit: NoneType(Store)
  range: NoneType(Store)
  repr: NoneType(Store)
  reversed: NoneType(Store)
  round: NoneType(Store)
  set: NoneType(Store)
  setattr: NoneType(Store)
  slice: NoneType(Store)
  sorted: NoneType(Store)
  staticmethod: NoneType(Store)
  str: NoneType(Store)
  sum: NoneType(Store)
  super: NoneType(Store)
  tuple: NoneType(Store)
  type: NoneType(Store)
  vars: NoneType(Store)
  zip: NoneType(Store)
  __file__: NoneType(Store)}
=> v v v v
=> Module {gc: alias(Store)
=>   tracemalloc: alias(Store)
=>   os: alias(Store)
=>   re: alias(Store)
=>   json: alias(Store)
=>   signal: alias(Store)
=>   asyncio: alias(Store)
=>   datetime: alias(Store)
=>   functools: alias(Store)
=>   yl: alias(Store)
=>   DataAccessLayer: alias(Store)
=>   RestconfServer: alias(Store)
=>   sha256_crypt: alias(Store)
=>   TenantViewHandler: alias(Store)
=>   xxxxxViewHandler: alias(Store)
=>   NativeViewHandler: alias(Store)
=>   Period: alias(Store)
=>   TimeUnit: alias(Store)
=>   loop: Name(Store)
=>   sig: Name(Store)
=>   signal_handler: FunctionDef(Store)
=>   run: FunctionDef(Store)
=>   watched_node_path: arg(Store)
=>   str: Name(Load)
=>   jsob: arg(Store)
=>   dict: Name(Load)
=>   jsob_data_path: arg(Store)
=>   nvh: arg(Store)
=>   type: Name(Load)
=>   item: Name(Store)
=>   NotImplementedError: Name(Load)
=>   data_path: arg(Store)
=>   _check_expirations: FunctionDef(Store)}
=> => v v v v
=> => FunctionDef {name: arg(Store)
=> =>   loop: Global(Load)
=> =>   sig: Global(Load)} && 
=> => FunctionDef {debug: arg(Store)
=> =>   db_url: arg(Store)
=> =>   cacert_path: arg(Store)
=> =>   loop: Global(Load)
=> =>   sig: Global(Load)
=> =>   dal: Name(Store)
=> =>   mode: Name(Store)
=> =>   firsttime: Name(Store)
=> =>   DataAccessLayer: Name(Load)
=> =>   e: ExceptHandler(Store)
=> =>   SyntaxError: Name(Load)
=> =>   AssertionError: Name(Load)
=> =>   NotImplementedError: Name(Load)
=> =>   env_var: Name(Store)
=> =>   os: Name(Load)
=> =>   type: Name(Load)
=> =>   str: Name(Load)
=> =>   print: Name(Load)
=> =>   input: Name(Load)
=> =>   json: Name(Load)
=> =>   getattr: Name(Load)
=> =>   yl: Name(Load)
=> =>   Exception: Name(Load)
=> =>   tracemalloc: Name(Load)
=> =>   asyncio: Name(Load)
=> =>   signal: Name(Load)
=> =>   functools: Name(Load)
=> =>   signal_handler: Name(Load)
=> =>   rc_svr_list: Name(Store)
=> =>   async_def: Name(Store)
=> =>   transport_cfg: Name(Store)
=> =>   endpoint_cfg: Name(Store)
=> =>   nativeViewHandler: Name(Store)
=> =>   NativeViewHandler: Name(Load)
=> =>   device_schema_path: Name(Store)
=> =>   _handle_device_created: Name(Load)
=> =>   activation_code_schema_path: Name(Store)
=> =>   _handle_device_act_code_changed: Name(Load)
=> =>   _handle_device_subtree_changed: Name(Load)
=> =>   _handle_device_somehow_changed: Name(Load)
=> =>   _handle_device_deleted: Name(Load)
=> =>   Period: Name(Load)
=> =>   TimeUnit: Name(Load)
=> =>   datetime: Name(Load)
=> =>   _check_expirations: Name(Load)
=> =>   rcsvr: Name(Store)
=> =>   RestconfServer: Name(Load)
=> =>   tenantViewHandler: Name(Store)
=> =>   TenantViewHandler: Name(Load)
=> =>   facade_yl: Name(Store)
=> =>   xxxxxViewHandler: Name(Store)
=> =>   xxxxxViewHandler: Name(Load)
=> =>   rc_svr: Name(Store)} && 
=> => FunctionDef {nvh: arg(Store)
=> =>   NativeViewHandler: Name(Load)}
DEBUG:ObfuscationTransformer:alias: ['gc'] => ['gc'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:alias: ['tracemalloc'] => ['tracemalloc'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:alias: ['os'] => ['os'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:alias: ['re'] => ['re'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:alias: ['json'] => ['json'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:alias: ['signal'] => ['signal'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:alias: ['asyncio'] => ['asyncio'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:alias: ['datetime'] => ['datetime'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:alias: ['functools'] => ['functools'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:alias: ['yl'] => ['yl'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:alias: ['DataAccessLayer'] => ['DataAccessLayer'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:alias: ['RestconfServer'] => ['RestconfServer'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:alias: ['sha256_crypt'] => ['sha256_crypt'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:alias: ['TenantViewHandler'] => ['TenantViewHandler'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:alias: ['RFC8572ViewHandler'] => ['RFC8572ViewHandler'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:alias: ['NativeViewHandler'] => ['NativeViewHandler'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:alias: ['Period'] => ['Period'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:alias: ['TimeUnit'] => ['TimeUnit'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:Name: ['loop'] => ['loop'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:Name: ['sig'] => ['sig'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:FunctionDef: ['signal_handler'] => ['signal_handler'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:arg: ['name'] => ['a'] []
DEBUG:ObfuscationTransformer:Global: ['loop'] => ['loop'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Global: ['sig'] => ['sig'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['sig'] => ['sig'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['name'] => ['a'] [Already mangled; "a"]
DEBUG:ObfuscationTransformer:Name: ['loop'] => ['loop'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:FunctionDef: ['run'] => ['run'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:arg: ['debug'] => ['b'] []
DEBUG:ObfuscationTransformer:arg: ['db_url'] => ['c'] []
DEBUG:ObfuscationTransformer:arg: ['cacert_path'] => ['d'] []
DEBUG:ObfuscationTransformer:Global: ['loop'] => ['loop'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Global: ['sig'] => ['sig'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['dal'] => ['f'] []
DEBUG:ObfuscationTransformer:Name: ['mode'] => ['g'] []
DEBUG:ObfuscationTransformer:Name: ['firsttime'] => ['h'] []
DEBUG:ObfuscationTransformer:Name: ['dal'] => ['f'] [Already mangled; "f"]
DEBUG:ObfuscationTransformer:Name: ['DataAccessLayer'] => ['DataAccessLayer'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['db_url'] => ['c'] [Already mangled; "c"]
DEBUG:ObfuscationTransformer:Name: ['cacert_path'] => ['d'] [Already mangled; "d"]
DEBUG:ObfuscationTransformer:ExceptHandler: ['e'] => ['i'] []
DEBUG:ObfuscationTransformer:Name: ['SyntaxError'] => ['SyntaxError'] [Don't mangle; Builtin]
DEBUG:ObfuscationTransformer:Name: ['AssertionError'] => ['AssertionError'] [Don't mangle; Builtin]
DEBUG:ObfuscationTransformer:ExceptHandler: ['e'] => ['i'] [Already mangled; "i"]
DEBUG:ObfuscationTransformer:Name: ['NotImplementedError'] => ['NotImplementedError'] [Don't mangle; Builtin]
DEBUG:ObfuscationTransformer:Name: ['firsttime'] => ['h'] [Already mangled; "h"]
DEBUG:ObfuscationTransformer:Name: ['mode'] => ['g'] [Already mangled; "g"]
DEBUG:ObfuscationTransformer:Name: ['dal'] => ['f'] [Already mangled; "f"]
DEBUG:ObfuscationTransformer:Name: ['firsttime'] => ['h'] [Already mangled; "h"]
DEBUG:ObfuscationTransformer:Name: ['env_var'] => ['j'] []
DEBUG:ObfuscationTransformer:Name: ['os'] => ['os'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['env_var'] => ['j'] [Already mangled; "j"]
DEBUG:ObfuscationTransformer:Name: ['type'] => ['type'] [Don't mangle; Builtin]
DEBUG:ObfuscationTransformer:Name: ['env_var'] => ['j'] [Already mangled; "j"]
DEBUG:ObfuscationTransformer:Name: ['str'] => ['str'] [Don't mangle; Builtin]
DEBUG:ObfuscationTransformer:Name: ['env_var'] => ['j'] [Already mangled; "j"]
DEBUG:ObfuscationTransformer:Name: ['print'] => ['print'] [Don't mangle; Builtin]
DEBUG:ObfuscationTransformer:Name: ['mode'] => ['g'] [Already mangled; "g"]
DEBUG:ObfuscationTransformer:Name: ['env_var'] => ['j'] [Already mangled; "j"]
DEBUG:ObfuscationTransformer:Name: ['print'] => ['print'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['print'] => ['print'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['print'] => ['print'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['print'] => ['print'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['print'] => ['print'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['print'] => ['print'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['mode'] => ['g'] [Already mangled; "g"]
DEBUG:ObfuscationTransformer:Name: ['input'] => ['input'] [Don't mangle; Builtin]
DEBUG:ObfuscationTransformer:Name: ['mode'] => ['g'] [Already mangled; "g"]
DEBUG:ObfuscationTransformer:Name: ['print'] => ['print'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['dal'] => ['f'] [Already mangled; "f"]
DEBUG:ObfuscationTransformer:Name: ['DataAccessLayer'] => ['DataAccessLayer'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['db_url'] => ['c'] [Already mangled; "c"]
DEBUG:ObfuscationTransformer:Name: ['cacert_path'] => ['d'] [Already mangled; "d"]
DEBUG:ObfuscationTransformer:Name: ['json'] => ['json'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['getattr'] => ['getattr'] [Don't mangle; Builtin]
DEBUG:ObfuscationTransformer:Name: ['yl'] => ['yl'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['mode'] => ['g'] [Already mangled; "g"]
DEBUG:ObfuscationTransformer:Name: ['mode'] => ['g'] [Already mangled; "g"]
DEBUG:ObfuscationTransformer:Name: ['mode'] => ['g'] [Already mangled; "g"]
DEBUG:ObfuscationTransformer:ExceptHandler: ['e'] => ['i'] [Already mangled; "i"]
DEBUG:ObfuscationTransformer:Name: ['Exception'] => ['Exception'] [Don't mangle; Builtin]
DEBUG:ObfuscationTransformer:Name: ['e'] => ['i'] [Already mangled; "i"]
DEBUG:ObfuscationTransformer:Name: ['mode'] => ['g'] [Already mangled; "g"]
DEBUG:ObfuscationTransformer:Name: ['dal'] => ['f'] [Already mangled; "f"]
DEBUG:ObfuscationTransformer:Name: ['tracemalloc'] => ['tracemalloc'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['loop'] => ['loop'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['asyncio'] => ['asyncio'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['loop'] => ['loop'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['signal'] => ['signal'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['functools'] => ['functools'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['signal_handler'] => ['signal_handler'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['loop'] => ['loop'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['signal'] => ['signal'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['functools'] => ['functools'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['signal_handler'] => ['signal_handler'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['loop'] => ['loop'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['signal'] => ['signal'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['functools'] => ['functools'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['signal_handler'] => ['signal_handler'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['loop'] => ['loop'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['signal'] => ['signal'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['functools'] => ['functools'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['signal_handler'] => ['signal_handler'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['sig'] => ['sig'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['rc_svr_list'] => ['k'] []
DEBUG:ObfuscationTransformer:Name: ['async_def'] => ['l'] []
DEBUG:ObfuscationTransformer:Name: ['dal'] => ['f'] [Already mangled; "f"]
DEBUG:ObfuscationTransformer:Name: ['dal'] => ['f'] [Already mangled; "f"]
DEBUG:ObfuscationTransformer:Name: ['transport_cfg'] => ['m'] []
DEBUG:ObfuscationTransformer:Name: ['loop'] => ['loop'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['async_def'] => ['l'] [Already mangled; "l"]
DEBUG:ObfuscationTransformer:Name: ['endpoint_cfg'] => ['n'] []
DEBUG:ObfuscationTransformer:Name: ['transport_cfg'] => ['m'] [Already mangled; "m"]
DEBUG:ObfuscationTransformer:Name: ['dal'] => ['f'] [Already mangled; "f"]
DEBUG:ObfuscationTransformer:Name: ['endpoint_cfg'] => ['n'] [Already mangled; "n"]
DEBUG:ObfuscationTransformer:Name: ['nativeViewHandler'] => ['o'] []
DEBUG:ObfuscationTransformer:Name: ['NativeViewHandler'] => ['NativeViewHandler'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['dal'] => ['f'] [Already mangled; "f"]
DEBUG:ObfuscationTransformer:Name: ['mode'] => ['g'] [Already mangled; "g"]
DEBUG:ObfuscationTransformer:Name: ['loop'] => ['loop'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['mode'] => ['g'] [Already mangled; "g"]
DEBUG:ObfuscationTransformer:Name: ['device_schema_path'] => ['p'] []
DEBUG:ObfuscationTransformer:Name: ['dal'] => ['f'] [Already mangled; "f"]
DEBUG:ObfuscationTransformer:Name: ['mode'] => ['g'] [Already mangled; "g"]
DEBUG:ObfuscationTransformer:Name: ['device_schema_path'] => ['p'] [Already mangled; "p"]
DEBUG:ObfuscationTransformer:Name: ['dal'] => ['f'] [Already mangled; "f"]
DEBUG:ObfuscationTransformer:Name: ['mode'] => ['g'] [Already mangled; "g"]
DEBUG:ObfuscationTransformer:Name: ['device_schema_path'] => ['p'] [Already mangled; "p"]
DEBUG:ObfuscationTransformer:Name: ['dal'] => ['f'] [Already mangled; "f"]
DEBUG:ObfuscationTransformer:Name: ['nativeViewHandler'] => ['o'] [Already mangled; "o"]
DEBUG:ObfuscationTransformer:Name: ['device_schema_path'] => ['p'] [Already mangled; "p"]
ERROR:Frame:Queried identifier "_handle_device_created" was not been seen at the given scope stack
Minifier/Obfuscation...
src/sztpd/sztpd.py: Obfuscating... Traceback (most recent call last):
  File "obfuscate.py", line 9, in <module>
    obfuscateFile(file)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/site-packages/bobskater/obfuscate.py", line 328, in obfuscateFile
    s = obfuscateString(s, *args, **kwargs)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/site-packages/bobskater/obfuscate.py", line 320, in obfuscateString
    sAst = ObfuscationTransformer(ftnv.getRootFrame(), *args, **kwargs).visit(sAst)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/site-packages/bobskater/obfuscate.py", line 306, in generic_visit
    super().generic_visit(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 326, in generic_visit
    value = self.visit(value)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/site-packages/bobskater/obfuscate.py", line 306, in generic_visit
    super().generic_visit(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 326, in generic_visit
    value = self.visit(value)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/site-packages/bobskater/obfuscate.py", line 306, in generic_visit
    super().generic_visit(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 326, in generic_visit
    value = self.visit(value)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/site-packages/bobskater/obfuscate.py", line 306, in generic_visit
    super().generic_visit(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 326, in generic_visit
    value = self.visit(value)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/site-packages/bobskater/obfuscate.py", line 306, in generic_visit
    super().generic_visit(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 326, in generic_visit
    value = self.visit(value)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/site-packages/bobskater/obfuscate.py", line 306, in generic_visit
    super().generic_visit(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 335, in generic_visit
    new_node = self.visit(old_value)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/site-packages/bobskater/obfuscate.py", line 306, in generic_visit
    super().generic_visit(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 326, in generic_visit
    value = self.visit(value)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/site-packages/bobskater/obfuscate.py", line 292, in generic_visit
    mangleTo = self.getMangledName(self._nodeStack, strId)
  File "/Users/kent/.pyenv/versions/3.7.5/lib/python3.7/site-packages/bobskater/obfuscate.py", line 224, in getMangledName
    isBuiltin = frameEntry.parent == self._rootFrame
AttributeError: 'NoneType' object has no attribute 'parent'

I see the line => => _handle_device_created: Name(Load), so apparently the code did see it?

To be clear, _handle_device_created is a callback function that gets called by a framework the code implements. In this file (sztpd.py), the string "_handle_device_created" only appears twice:

1) function definition (described previously) 2) callback registration (nativeViewHandler.register_create_callback(device_schema_path, _handle_device_created))

As for the type (':') syntax, I'm pretty sure that it has no affect on the AST. The type values aren't processed, AFAIK. They are only there for help developers document the code.

Cobertos commented 4 years ago

IIRC, Name(Load) means that it's use in the AST was a load operation (read). When you read from an identifier in Python, it has no effect on the scope (so it doesn't get tracked and it assumes that you probably had a syntax error). There should be a Name(Store)/store operation (write) which is what actually gets tracked by the FrameTrackingNodeVisitor to determine scope (because when you write to an identifier, it succeeds if the identifier doesn't exist yet).

So It looks like it's reading the callback registration (where it loads/reads the identifier _handle_device_created) but didn't properly parse the function definition (the store/write operation). Or at least that's what it looks like.

This seems in line with my original hunch:

https://greentreesnakes.readthedocs.io/en/latest/nodes.html#AsyncFunctionDef would need to be handled in https://github.com/Cobertos/bobskater/blob/master/bobskater/frameUtils.py#L189

so when I have time to debug/look at this again, I'd probably be adding support for AsyncFunctionDef

The

DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "_handle_device_created"

makes me think I'm wrong though but I cant remember how that one gets printed out at the moment

kwatsen commented 4 years ago

Yes, this is definitely an asyncio issue.

The below (non-async) test code obfuscates correctly:

def test(var_x, var_y):
    '''
    doc string
    '''
    var_z = var_x + var_y
    print("z = " + str(var_z))

test(1, 2)

However, this asyncio code throws errors:

import asyncio

async def test(var_x, var_y):
    '''
    doc string
    '''
    var_z = var_x + var_y
    print("z = " + str(var_z))

loop = asyncio.get_event_loop()
async_def = test(1, 2)
loop.run_until_complete(async_def)
kwatsen commented 4 years ago

Changing line #189 as follows:

-    elif isinstance(node, (ast.FunctionDef,ast.ClassDef)):
+    elif isinstance(node, (ast.FunctionDef,ast.ClassDef,ast.AsyncFunctionDef)):

Resolves the obfuscation error, but the result is not obfuscated, though you can tell that it's been processed due to the docstring being converted...

import asyncio

async def test(var_x, var_y):
    '\n    doc string\n    '
    var_z = (var_x + var_y)
    print(('z = ' + str(var_z)))
loop = asyncio.get_event_loop()
async_def = test(1, 2)
loop.run_until_complete(async_def)

Any more "hunches" ???

Cobertos commented 4 years ago

Docstrings should be obfuscating properly (it works in the tests) so I would assume it's another async function thing. Looks like this line https://github.com/Cobertos/bobskater/blob/master/bobskater/obfuscate.py#L282

In your example, asyncio, test, loop, async_def should all remain unobfuscated. var_x, var_y, and var_z should obfuscate. Arguments are handled in https://github.com/Cobertos/bobskater/blob/master/bobskater/frameUtils.py#L202-L203 and looking at https://docs.python.org/3/library/ast.html it should not be different for async functions. If you give the debug output for your test I might be more help on that front.

You're also going to want to make sure you change this line https://github.com/Cobertos/bobskater/blob/master/bobskater/frameUtils.py#L225 . When it gets an ID from getIdsFromNode and obfuscates them and tries to reapply to the AST, if setIdsOnNode isn't updated, it won't reapply the newly obfuscated names for the new object type.

kwatsen commented 4 years ago

I was about to say that the docstring DID get modified, but I think your point is that the docstring shouldn't appear at all...

Changing line 112 of tests/test_integration.py as follows:

-        print(obf)
+        print("BEFORE: code = " + code)
+        print("AFTER: obf = " + obf)

Produces the following output with pytest -s (which passes, incorrectly?):

BEFORE: code =                                                                                                                                 
def testDocString2():                                                                                                                          
    '''                                                                                                                                        
    Gottem                                                                                                                                     
    '''                                                                                                                                        
    asdf = 2                                                                                                                                   

AFTER: obf =                                                                                                                                                                                                                                                                            
def testDocString2():                                                  
    '\n    Gottem\n    '                                               
    asdf = 2                 

This result matches what I saw before (without async). The docstring is changed, to being a one-liner, but not removed.

kwatsen commented 4 years ago

Changing line 225 as follows:

-    elif isinstance(node, (ast.FunctionDef,ast.ClassDef,ast.ExceptHandler)):
+    elif isinstance(node, (ast.FunctionDef,ast.AsyncFunctionDef,ast.ClassDef,ast.ExceptHandler)):

Didn't help.

ORIGINAL (UNOBFUSCATED):

import asyncio
async def test(var_x: int, var_y: int) -> int:
    '''
    doc string
    '''
    var_z = var_x + var_y
    print("z = " + str(var_z))

loop = asyncio.get_event_loop()
async_def = test(1, 2)
loop.run_until_complete(async_def)

AFTER OBFUSCATION:

import asyncio
async def test(var_x: int, var_y: int) -> int:
    '\n    doc string\n    '
    var_z = (var_x + var_y)
    print(('z = ' + str(var_z)))
loop = asyncio.get_event_loop()
async_def = test(1, 2)
loop.run_until_complete(async_def)

BTW, note that the "types" (e.g., : and ->) flow through to the output, which I think is fine, since types are not revealing in any way. That said, it might be better if they were stripped too, only because they're intended to be developer-friendly, but obfuscation is not, and so they seem out of place...

Here is the debug output:

DEBUG:FrameTrackingNodeVisitor:[+Frame]: Module ""
DEBUG:FrameTrackingNodeVisitor:[+Entry]: alias "asyncio"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: AsyncFunctionDef "test"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "var_x"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "int"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "var_y"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "int"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "var_z"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "var_x"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "var_y"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "print"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "str"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "var_z"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "int"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "loop"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "asyncio"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "async_def"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "test"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "loop"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "async_def"
DEBUG:FrameTrackingNodeVisitor:[-Frame]
DEBUG:bobskater.obfuscate:
Frame {ArithmeticError: NoneType(Store)
  AssertionError: NoneType(Store)
  AttributeError: NoneType(Store)
  BaseException: NoneType(Store)
  BlockingIOError: NoneType(Store)
  BrokenPipeError: NoneType(Store)
  BufferError: NoneType(Store)
  BytesWarning: NoneType(Store)
  ChildProcessError: NoneType(Store)
  ConnectionAbortedError: NoneType(Store)
  ConnectionError: NoneType(Store)
  ConnectionRefusedError: NoneType(Store)
  ConnectionResetError: NoneType(Store)
  DeprecationWarning: NoneType(Store)
  EOFError: NoneType(Store)
  Ellipsis: NoneType(Store)
  EnvironmentError: NoneType(Store)
  Exception: NoneType(Store)
  False: NoneType(Store)
  FileExistsError: NoneType(Store)
  FileNotFoundError: NoneType(Store)
  FloatingPointError: NoneType(Store)
  FutureWarning: NoneType(Store)
  GeneratorExit: NoneType(Store)
  IOError: NoneType(Store)
  ImportError: NoneType(Store)
  ImportWarning: NoneType(Store)
  IndentationError: NoneType(Store)
  IndexError: NoneType(Store)
  InterruptedError: NoneType(Store)
  IsADirectoryError: NoneType(Store)
  KeyError: NoneType(Store)
  KeyboardInterrupt: NoneType(Store)
  LookupError: NoneType(Store)
  MemoryError: NoneType(Store)
  ModuleNotFoundError: NoneType(Store)
  NameError: NoneType(Store)
  None: NoneType(Store)
  NotADirectoryError: NoneType(Store)
  NotImplemented: NoneType(Store)
  NotImplementedError: NoneType(Store)
  OSError: NoneType(Store)
  OverflowError: NoneType(Store)
  PendingDeprecationWarning: NoneType(Store)
  PermissionError: NoneType(Store)
  ProcessLookupError: NoneType(Store)
  RecursionError: NoneType(Store)
  ReferenceError: NoneType(Store)
  ResourceWarning: NoneType(Store)
  RuntimeError: NoneType(Store)
  RuntimeWarning: NoneType(Store)
  StopAsyncIteration: NoneType(Store)
  StopIteration: NoneType(Store)
  SyntaxError: NoneType(Store)
  SyntaxWarning: NoneType(Store)
  SystemError: NoneType(Store)
  SystemExit: NoneType(Store)
  TabError: NoneType(Store)
  TimeoutError: NoneType(Store)
  True: NoneType(Store)
  TypeError: NoneType(Store)
  UnboundLocalError: NoneType(Store)
  UnicodeDecodeError: NoneType(Store)
  UnicodeEncodeError: NoneType(Store)
  UnicodeError: NoneType(Store)
  UnicodeTranslateError: NoneType(Store)
  UnicodeWarning: NoneType(Store)
  UserWarning: NoneType(Store)
  ValueError: NoneType(Store)
  Warning: NoneType(Store)
  ZeroDivisionError: NoneType(Store)
  __build_class__: NoneType(Store)
  __debug__: NoneType(Store)
  __doc__: NoneType(Store)
  __import__: NoneType(Store)
  __loader__: NoneType(Store)
  __name__: NoneType(Store)
  __package__: NoneType(Store)
  __spec__: NoneType(Store)
  abs: NoneType(Store)
  all: NoneType(Store)
  any: NoneType(Store)
  ascii: NoneType(Store)
  bin: NoneType(Store)
  bool: NoneType(Store)
  breakpoint: NoneType(Store)
  bytearray: NoneType(Store)
  bytes: NoneType(Store)
  callable: NoneType(Store)
  chr: NoneType(Store)
  classmethod: NoneType(Store)
  compile: NoneType(Store)
  complex: NoneType(Store)
  copyright: NoneType(Store)
  credits: NoneType(Store)
  delattr: NoneType(Store)
  dict: NoneType(Store)
  dir: NoneType(Store)
  divmod: NoneType(Store)
  enumerate: NoneType(Store)
  eval: NoneType(Store)
  exec: NoneType(Store)
  exit: NoneType(Store)
  filter: NoneType(Store)
  float: NoneType(Store)
  format: NoneType(Store)
  frozenset: NoneType(Store)
  getattr: NoneType(Store)
  globals: NoneType(Store)
  hasattr: NoneType(Store)
  hash: NoneType(Store)
  help: NoneType(Store)
  hex: NoneType(Store)
  id: NoneType(Store)
  input: NoneType(Store)
  int: NoneType(Store)
  isinstance: NoneType(Store)
  issubclass: NoneType(Store)
  iter: NoneType(Store)
  len: NoneType(Store)
  license: NoneType(Store)
  list: NoneType(Store)
  locals: NoneType(Store)
  map: NoneType(Store)
  max: NoneType(Store)
  memoryview: NoneType(Store)
  min: NoneType(Store)
  next: NoneType(Store)
  object: NoneType(Store)
  oct: NoneType(Store)
  open: NoneType(Store)
  ord: NoneType(Store)
  pow: NoneType(Store)
  print: NoneType(Store)
  property: NoneType(Store)
  quit: NoneType(Store)
  range: NoneType(Store)
  repr: NoneType(Store)
  reversed: NoneType(Store)
  round: NoneType(Store)
  set: NoneType(Store)
  setattr: NoneType(Store)
  slice: NoneType(Store)
  sorted: NoneType(Store)
  staticmethod: NoneType(Store)
  str: NoneType(Store)
  sum: NoneType(Store)
  super: NoneType(Store)
  tuple: NoneType(Store)
  type: NoneType(Store)
  vars: NoneType(Store)
  zip: NoneType(Store)
  __file__: NoneType(Store)}
=> v v v v
=> Module {asyncio: alias(Store)
=>   test: AsyncFunctionDef(Store)
=>   var_x: arg(Store)
=>   int: Name(Load)
=>   var_y: arg(Store)
=>   var_z: Name(Store)
=>   print: Name(Load)
=>   str: Name(Load)
=>   loop: Name(Store)
=>   async_def: Name(Store)}
DEBUG:ObfuscationTransformer:alias: ['asyncio'] => ['asyncio'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:AsyncFunctionDef: ['test'] => ['test'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:arg: ['var_x'] => ['var_x'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:Name: ['int'] => ['int'] [Don't mangle; Builtin]
DEBUG:ObfuscationTransformer:arg: ['var_y'] => ['var_y'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:Name: ['int'] => ['int'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['var_z'] => ['var_z'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:Name: ['var_x'] => ['var_x'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['var_y'] => ['var_y'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['print'] => ['print'] [Don't mangle; Builtin]
DEBUG:ObfuscationTransformer:Name: ['str'] => ['str'] [Don't mangle; Builtin]
DEBUG:ObfuscationTransformer:Name: ['var_z'] => ['var_z'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['int'] => ['int'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['loop'] => ['loop'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:Name: ['asyncio'] => ['asyncio'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['async_def'] => ['async_def'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:Name: ['test'] => ['test'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['loop'] => ['loop'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['async_def'] => ['async_def'] [Already mangled; Don't mangle]
kwatsen commented 4 years ago

I note the DEBUG output says:

DEBUG:ObfuscationTransformer:arg: ['var_x'] => ['var_x'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:arg: ['var_y'] => ['var_y'] [Don't mangle; Class or Module namespace]

The message is found on line 246 in bobskater/obfuscate.py:

        if isinstance(stackNode, (ast.ClassDef,ast.Module)):
            #Anything in the class namespace (static variables, methods)
            #and anything in the module namespace (will probs be exported)
            #should not be mangled
            self._debugMsg = "Don't mangle; Class or Module namespace"
            frameEntry.value = False
            return False

Does make sense that these variables are "ast.ClassDef" or "ast.Module"? - or is it that an earlier test above didn't catch before this block was hit?

kwatsen commented 4 years ago

I updated my test and found an anomaly. The "update" is essentially to have both the async and non-async func defs in the same file so as to do A-B tests.

Here's the new input:

def non_async_test(var_i: int, var_j: int) -> int:
    '''
    doc string
    '''
    var_k = var_i + var_j
    print("k = " + str(var_k))

non_async_test(3, 4)

import asyncio
async def async_test(var_x: int, var_y: int) -> int:
    '''
    doc string
    '''
    var_z = var_x + var_y
    print("z = " + str(var_z))

loop = asyncio.get_event_loop()
async_def = async_test(1, 2)
loop.run_until_complete(async_def)

Here's the new output (obfuscated):

def non_async_test(a: int, b: int) -> int:
    pass
    c = (a + b)
    print(('k = ' + str(c)))
non_async_test(3, 4)
import asyncio

async def async_test(var_x: int, var_y: int) -> int:
    '\n    doc string\n    '
    var_z = (var_x + var_y)
    print(('z = ' + str(var_z)))
loop = asyncio.get_event_loop()
async_def = async_test(1, 2)
loop.run_until_complete(async_def)

And here's the output (reduced, see "SNIP"):

DEBUG:FrameTrackingNodeVisitor:[+Frame]: Module ""
DEBUG:FrameTrackingNodeVisitor:[+Entry]: FunctionDef "non_async_test"
DEBUG:FrameTrackingNodeVisitor:[+Frame]: FunctionDef "non_async_test"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "var_i"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "int"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "var_j"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "int"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "var_k"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "var_i"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "var_j"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "print"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "str"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "var_k"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "int"
DEBUG:FrameTrackingNodeVisitor:[-Frame]
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "non_async_test"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: alias "asyncio"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: AsyncFunctionDef "async_test"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "var_x"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "int"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: arg "var_y"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "int"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "var_z"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "var_x"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "var_y"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "print"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "str"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "var_z"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "int"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "loop"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "asyncio"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "async_def"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "async_test"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "loop"
DEBUG:FrameTrackingNodeVisitor:[+Entry]: Name "async_def"
DEBUG:FrameTrackingNodeVisitor:[-Frame]
DEBUG:bobskater.obfuscate:
Frame {<SNIP>}
=> v v v v
=> Module {non_async_test: FunctionDef(Store)
=>   asyncio: alias(Store)
=>   async_test: AsyncFunctionDef(Store)
=>   var_x: arg(Store)
=>   int: Name(Load)
=>   var_y: arg(Store)
=>   var_z: Name(Store)
=>   print: Name(Load)
=>   str: Name(Load)
=>   loop: Name(Store)
=>   async_def: Name(Store)}
=> => v v v v
=> => FunctionDef {var_i: arg(Store)
=> =>   int: Name(Load)
=> =>   var_j: arg(Store)
=> =>   var_k: Name(Store)
=> =>   print: Name(Load)
=> =>   str: Name(Load)}
DEBUG:ObfuscationTransformer:FunctionDef: ['non_async_test'] => ['non_async_test'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:arg: ['var_i'] => ['a'] []
DEBUG:ObfuscationTransformer:Name: ['int'] => ['int'] [Don't mangle; Builtin]
DEBUG:ObfuscationTransformer:arg: ['var_j'] => ['b'] []
DEBUG:ObfuscationTransformer:Name: ['int'] => ['int'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['var_k'] => ['c'] []
DEBUG:ObfuscationTransformer:Name: ['var_i'] => ['a'] [Already mangled; "a"]
DEBUG:ObfuscationTransformer:Name: ['var_j'] => ['b'] [Already mangled; "b"]
DEBUG:ObfuscationTransformer:Name: ['print'] => ['print'] [Don't mangle; Builtin]
DEBUG:ObfuscationTransformer:Name: ['str'] => ['str'] [Don't mangle; Builtin]
DEBUG:ObfuscationTransformer:Name: ['var_k'] => ['c'] [Already mangled; "c"]
DEBUG:ObfuscationTransformer:Name: ['int'] => ['int'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['non_async_test'] => ['non_async_test'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:alias: ['asyncio'] => ['asyncio'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:AsyncFunctionDef: ['async_test'] => ['async_test'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:arg: ['var_x'] => ['var_x'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:Name: ['int'] => ['int'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:arg: ['var_y'] => ['var_y'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:Name: ['int'] => ['int'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['var_z'] => ['var_z'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:Name: ['var_x'] => ['var_x'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['var_y'] => ['var_y'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['print'] => ['print'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['str'] => ['str'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['var_z'] => ['var_z'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['int'] => ['int'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['loop'] => ['loop'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:Name: ['asyncio'] => ['asyncio'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['async_def'] => ['async_def'] [Don't mangle; Class or Module namespace]
DEBUG:ObfuscationTransformer:Name: ['async_test'] => ['async_test'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['loop'] => ['loop'] [Already mangled; Don't mangle]
DEBUG:ObfuscationTransformer:Name: ['async_def'] => ['async_def'] [Already mangled; Don't mangle]
Obfuscating hello.py...

Note how the non_async_test and async_test functions are handled differently.

kwatsen commented 4 years ago

Hiya! Is the debug output provided not helping? Any hints? I don't mind trying things out... Do you have any time to look at this?

kwatsen commented 4 years ago

Any update here? Would a donation of some sort help?

I thought that your AST-based approach was elegant, hence my desire to see it along. I know that it's not much code, but it would undoubtedly take your a fraction of the time it would take me...

Cobertos commented 4 years ago

Ah sorry, I missed the last comment, been busy.

I can set aside some more time to look at this hopefully before my next project ramps up.

If you wanted to contribute financially and this is more an indie project, you can check out my Patreon. I don't have any of the tiers fleshed out but if you wanted to donate to the Supporter or Commisioner tier it helps me justify working on things like this more.

If you're part of a larger company, consider subscribing to TideLift. The prices are pretty steep but I can get this package "lifted" and integrating with their systems gives a lot of assurances to future stability.