FACT_core icon indicating copy to clipboard operation
FACT_core copied to clipboard

device_tree: Use `PluginV1`

Open maringuu opened this issue 1 year ago • 9 comments

Simelar to #1022

The alembic commit is probably not needed and superseded by #1027

maringuu avatar May 04 '23 12:05 maringuu

This is ready! One question I ask myself is how we handle the old plugin results. I really much dislike that we have code in the template that handles these version incompabilities. I would suggest that we implement some logic in the frontend that compares the plugin version it is told to render to the version it received via redis. This way the frontend can detect incompatibilities and just render a message that you should rerun your analysis.

maringuu avatar Jul 03 '23 12:07 maringuu

https://github.com/fkie-cad/FACT_core/actions/runs/5543784794

maringuu avatar Jul 13 '23 13:07 maringuu

https://github.com/fkie-cad/FACT_core/actions/runs/5642242893

maringuu avatar Jul 17 '23 10:07 maringuu

I tried running it and there seem to be problems with the "architecture_detection" plugin (which depends on the device_tree plugin) not expecting None as result:

Traceback (most recent call last):
  File "/usr/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "src/helperFunctions/process.py", line 91, in run
    raise exception
  File "src/helperFunctions/process.py", line 86, in run
    Process.run(self)
  File "/usr/lib/python3.11/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "src/analysis/PluginBase.py", line 196, in process_next_object
    finished_task = self.analyze_file(task)
                    ^^^^^^^^^^^^^^^^^^^^^^^
  File "src/analysis/PluginBase.py", line 159, in analyze_file
    fo = self.process_object(file_object)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "src/plugins/analysis/architecture_detection/code/architecture_detection.py", line 37, in process_object
    arch_dict = construct_result(file_object, self._fs_organizer)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "src/plugins/analysis/architecture_detection/code/architecture_detection.py", line 50, in construct_result
    result.update(dt.construct_result(file_object))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "src/plugins/analysis/architecture_detection/internal/dt.py", line 76, in construct_result
    for dt_dict in file_object.processed_analysis['device_tree'].get('result', {}).get('device_trees', []):
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'

jstucke avatar Aug 28 '23 13:08 jstucke

I tried running it and there seem to be problems with the "architecture_detection" plugin (which depends on the device_tree plugin) not expecting None as result:

Fixed.

maringuu avatar Oct 12 '23 10:10 maringuu

Did you try to run it? I always got an Internal Server Error when trying it out:

I just ran the tests and totally forgot about the frontend.

maringuu avatar Nov 07 '23 09:11 maringuu

Everything should work now.

maringuu avatar Nov 07 '23 10:11 maringuu

I still get the error message when looking at old analysis results:

  File "<template>", line 6, in template
  File "src/web_interface/filter.py", line 448, in hide_dts_binary_data
    device_tree = re.sub(r'\[[0-9a-f ]{32,}]', '(BINARY DATA ...)', device_tree)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/re/__init__.py", line 185, in sub
    return _compile(pattern, flags).sub(repl, string, count)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Normally this should be intercepted by the version check, but since the version changed from 1.0.1 to 1.1.0, it is treated as compatible. So a "fix" would be to set the version to 2.0.0 (which would be kinda appropriate since there are breaking changes).

Apart from that everything seems to work fine.

jstucke avatar Jan 18 '24 14:01 jstucke

Bumped the version to 2.0.0. Sill the above question is unsolved.

maringuu avatar Feb 22 '24 15:02 maringuu