FACT_core
FACT_core copied to clipboard
device_tree: Use `PluginV1`
Simelar to #1022
The alembic commit is probably not needed and superseded by #1027
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.
https://github.com/fkie-cad/FACT_core/actions/runs/5543784794
https://github.com/fkie-cad/FACT_core/actions/runs/5642242893
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'
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.
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.
Everything should work now.
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.
Bumped the version to 2.0.0. Sill the above question is unsolved.