packing-box / docker-packing-box

Docker image gathering packers and tools for making datasets of packed executables and training machine learning models for packing detection
GNU General Public License v3.0
44 stars 10 forks source link

`FileNotFoundError` on default `features` path for `model visualize` #28

Closed smarbal closed 1 year ago

smarbal commented 1 year ago

Running model visualize without providing any specific features path produces the following error :

model -v  visualize -e PE-upx-dataset_pe32-pe64_400_kmeans_f92
00:00:03.882 [INFO    ] model              - Test dataset:  PE-upx-dataset(PE32,PE64)
00:00:03.883 [INFO    ] model              - Computing features...
Traceback (most recent call last):
  File "/home/user/.opt/tools/model", line 107, in <module>
    getattr(name, args.command)(**vars(args))
  File "/home/user/.local/lib/python3.10/site-packages/pbox/learning/model.py", line 613, in visualize
    if not self._prepare(**kw):
  File "/home/user/.local/lib/python3.10/site-packages/pbox/learning/model.py", line 218, in _prepare
    __parse(ds.files.listdir(is_exe), False)
  File "/home/user/.local/lib/python3.10/site-packages/pbox/learning/model.py", line 198, in __parse
    exe = Executable(str(exe))
  File "/home/user/.local/lib/python3.10/site-packages/pbox/learning/executable.py", line 15, in __new__
    Features(None)  # lazily populate Features.registry at first instantiation
  File "/home/user/.local/lib/python3.10/site-packages/tinyscript/preimports/log.py", line 91, in _wrapper
    return f(*args, **kwargs)
  File "/home/user/.local/lib/python3.10/site-packages/pbox/learning/features/__init__.py", line 50, in __init__
    with open(Features.source) as f:
FileNotFoundError: [Errno 2] No such file or directory: '~/.opt/features.yml'

Replacing the path by /home/user/.opt/features.yml seems to work as a temporary fix.

dhondta commented 1 year ago

@smarbal this should be fixed. You can test.

smarbal commented 1 year ago

Hi @dhondta ! I had a few issues that I solved (I think) in packing-box/docker-packing-box#29.

But now I stumble on this error :

model -v visualize -e PE-upx-dataset_pe32-pe64_40_kmeans_f90
00:00:03.610 [INFO    ] model              - Test dataset:  PE-upx-dataset(PE32,PE64)
00:00:03.611 [INFO    ] model              - Computing features...
Traceback (most recent call last):
  File "/home/user/.opt/tools/model", line 107, in <module>
    getattr(name, args.command)(**vars(args))
  File "/home/user/.local/lib/python3.10/site-packages/pbox/learning/model.py", line 613, in visualize
    if not self._prepare(**kw):
  File "/home/user/.local/lib/python3.10/site-packages/pbox/learning/model.py", line 218, in _prepare
    __parse(ds.files.listdir(is_exe), False)
  File "/home/user/.local/lib/python3.10/site-packages/pbox/learning/model.py", line 198, in __parse
    exe = Executable(str(exe))
  File "/home/user/.local/lib/python3.10/site-packages/pbox/learning/executable.py", line 15, in __new__
    Features(None)  # lazily populate Features.registry at first instantiation
  File "/home/user/.local/lib/python3.10/site-packages/tinyscript/preimports/log.py", line 91, in _wrapper
    return f(*args, **kwargs)
  File "/home/user/.local/lib/python3.10/site-packages/pbox/learning/features/__init__.py", line 66, in __init__
    with Features.source.open() as f:
AttributeError: 'NoneType' object has no attribute 'open'
dhondta commented 1 year ago

@smarbal the offending line appears at L65 instead of L66 in the current source code, are you sure you updated the package with pbox-update within the container ?

dhondta commented 1 year ago

Fixed by #29