From c5c6735d26eb9e857e7bc00967de44ffe7f49760 Mon Sep 17 00:00:00 2001 From: Andrew LaMarche <39502729+andrewjlamarche@users.noreply.github.com> Date: Tue, 29 Oct 2024 08:49:15 -0400 Subject: [PATCH] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jörg Stucke --- .../plugins/unpacking/broadcom/code/broadcom-sao.py | 2 -- .../broadcom/test/test_plugin_broadcom_sao.py | 10 ++++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fact_extractor/plugins/unpacking/broadcom/code/broadcom-sao.py b/fact_extractor/plugins/unpacking/broadcom/code/broadcom-sao.py index 0043ab9e..8ec5259a 100644 --- a/fact_extractor/plugins/unpacking/broadcom/code/broadcom-sao.py +++ b/fact_extractor/plugins/unpacking/broadcom/code/broadcom-sao.py @@ -34,8 +34,6 @@ def unpack_function(file_path, tmp_dir): except IOError as io_error: return {'output': 'failed to read file: {}'.format(str(io_error))} - except struct.error as struct_error: - return {'output': 'failed to recognized firmware container: {}'.format(str(struct_error))} return { 'output': 'successfully unpacked Broadcom SAO image' diff --git a/fact_extractor/plugins/unpacking/broadcom/test/test_plugin_broadcom_sao.py b/fact_extractor/plugins/unpacking/broadcom/test/test_plugin_broadcom_sao.py index 55ff0614..3cbfbe0b 100644 --- a/fact_extractor/plugins/unpacking/broadcom/test/test_plugin_broadcom_sao.py +++ b/fact_extractor/plugins/unpacking/broadcom/test/test_plugin_broadcom_sao.py @@ -2,7 +2,7 @@ from test.unit.unpacker.test_unpacker import TestUnpackerBase -TEST_DATA_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data') +TEST_DATA_DIR = Path(__file__).parent / 'data' class TestBroadcomSAOUnpacker(TestUnpackerBase): @@ -10,10 +10,12 @@ def test_unpacker_selection_generic(self): self.check_unpacker_selection('firmware/broadcom-sao', 'Broadcom SAO') def test_extraction(self): - test_file_path = os.path.join(TEST_DATA_DIR, 'broadcom-sao.bin') - extracted_files, meta_data = self.unpacker.extract_files_from_file(test_file_path, self.tmp_dir.name) + test_file_path = Path(TEST_DATA_DIR) / 'broadcom-sao.bin' + extracted_files, meta_data = self.unpacker.extract_files_from_file(str(test_file_path), self.tmp_dir.name) assert meta_data['plugin_used'] == 'Broadcom SAO', 'wrong plugin applied' assert len(extracted_files) == 4, 'not all files extracted' - assert all(element in ['META', 'DTBB', 'KRNL', 'RTFS'] for element in extracted_files), 'not all files extracted' + assert all( + Path(element).name in ['META', 'DTBB', 'KRNL', 'RTFS'] for element in extracted_files + ), 'not all files extracted'