Skip to content

Conversation

@KendallHarterAtWork
Copy link
Collaborator

Summary

If merged this pull request will add support for extracting files from Motorola SREC and Intel HEX files into a user-specified directory. This address #257.

@github-actions
Copy link

github-actions bot commented Nov 17, 2025

🆕 New Folders (1)

  • binary

🧪 SBOM Results (2/17)

srectest_no1 (Link)

---
+++
@@ -38,6 +38,41 @@
       "supplementaryFiles": [],
       "vendor": [],
       "version": ""
+    },
+    {
+      "UUID": "39b66a99-f18e-40ee-b76d-146d4643dde4",
+      "captureTime": 1609459200,
+      "comments": "",
+      "components": [],
+      "containerPath": [],
+      "description": "",
+      "fileName": [
+        "HexFile.hex"
+      ],
+      "installPath": [
+        "/home/runner/work/Surfactant/Surfactant/HexFile.hex/HexFile.hex"
+      ],
+      "md5": "079fd903dab17c8862d6de5ad802429e",
+      "metadata": [
+        {
+          "collectedBy": "Surfactant",
+          "collectionPlatform": "Linux-6.11.0-1018-azure-x86_64-with-glibc2.39",
+          "fileInfo": {
+            "hidden": false,
+            "mode": "-rw-r--r--"
+          }
+        }
+      ],
+      "name": null,
+      "provenance": null,
+      "recordedInstitution": null,
+      "relationshipAssertion": "Unknown",
+      "sha1": "7c92689f00a82e154bea6b59270b8416016b1762",
+      "sha256": "560edf62c61654fa40c06960c72480b61e85c5057452df337c998d0c155789e7",
+      "size": 100,
+      "supplementaryFiles": [],
+      "vendor": [],
+      "version": ""
     }
   ],
   "starRelationships": [],

binary (Link)

---
+++
@@ -0,0 +1,252 @@
+{
+  "analysisData": [],
+  "hardware": [],
+  "observations": [],
+  "relationships": [
+    {
+      "relationship": "Contains",
+      "xUUID": "ef7fb89c-8195-4c60-a2a3-43baff01bbc5",
+      "yUUID": "b91c1fab-4e51-4c68-8014-10b9b6d36fec"
+    }
+  ],
+  "software": [
+    {
+      "UUID": "52f1e504-b79c-4e6d-b0d4-397882a55ee6",
+      "captureTime": 1609459200,
+      "comments": "",
+      "components": [],
+      "containerPath": [],
+      "description": "",
+      "fileName": [
+        "test.srec"
+      ],
+      "installPath": [
+        "/home/runner/work/Surfactant/Surfactant/tests/data/binary/test.srec"
+      ],
+      "md5": "8d945b70c74ae0bc0f9a87bc562fffba",
+      "metadata": [
+        {
+          "collectedBy": "Surfactant",
+          "collectionPlatform": "Linux-6.11.0-1018-azure-x86_64-with-glibc2.39",
+          "fileInfo": {
+            "hidden": false,
+            "mode": "-rw-r--r--"
+          }
+        }
+      ],
+      "name": null,
+      "provenance": null,
+      "recordedInstitution": null,
+      "relationshipAssertion": "Unknown",
+      "sha1": "5c6d627e2e4d881700af787171746eb1e4ae451f",
+      "sha256": "f85844d0cd99f80afdec5b839f189bf3b81c8d9229a918411ae180aac5406408",
+      "size": 28884,
+      "supplementaryFiles": [],
+      "vendor": [],
+      "version": ""
+    },
+    {
+      "UUID": "39b66a99-f18e-40ee-b76d-146d4643dde4",
+      "captureTime": 1609459200,
+      "comments": "",
+      "components": [],
+      "containerPath": [],
+      "description": "",
+      "fileName": [
+        "test.hex"
+      ],
+      "installPath": [
+        "/home/runner/work/Surfactant/Surfactant/tests/data/binary/test.hex"
+      ],
+      "md5": "792ce4a8260e6cccf2b34c70490545d3",
+      "metadata": [
+        {
+          "collectedBy": "Surfactant",
+          "collectionPlatform": "Linux-6.11.0-1018-azure-x86_64-with-glibc2.39",
+          "fileInfo": {
+            "hidden": false,
+            "mode": "-rw-r--r--"
+          }
+        }
+      ],
+      "name": null,
+      "provenance": null,
+      "recordedInstitution": null,
+      "relationshipAssertion": "Unknown",
+      "sha1": "415c68ff7c5cba1f11c8ac1804158724e0200fe1",
+      "sha256": "34e9127f38ea35cbda9405d25a1a3e85bca1f9138b3659ad2ef9d7c8412f2b24",
+      "size": 29212,
+      "supplementaryFiles": [],
+      "vendor": [],
+      "version": ""
+    },
+    {
+      "UUID": "ef7fb89c-8195-4c60-a2a3-43baff01bbc5",
+      "captureTime": 1609459200,
+      "comments": "This is a test file to create an msi.",
+      "components": [],
+      "containerPath": [],
+      "description": "",
+      "fileName": [
+        "test.srec",
+        "test.hex"
+      ],
+      "installPath": [
+        "/home/runner/work/Surfactant/Surfactant/test.srec/test.srec",
+        "/home/runner/work/Surfactant/Surfactant/test.hex/test.hex"
+      ],
... and 155 more lines

For commit 899cc80 (Run 20284414056)
Compared against commit 294c1d8 (Run 20251316355)

Copy link
Member

@WorkingRobot WorkingRobot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except for a few spots. I wonder if we should refactor this and the file decompression to compartmentalize the cache handling system?

Comment on lines +485 to +499
default_value = False
else:
# Have to convert from string to Boolean
default_value = default_value.lower() == "true"
self.value = self.__config_manager.get(self.plugin_name, self.info.name, default_value)
self.value = str(
self.__config_manager.get(self.plugin_name, self.info.name, default_value)
)
elif self.info.type_ == "int":
self.input_field = textual.widgets.Input(type="integer")
default_value = self.info.default
if default_value is None:
default_value = 0
self.value = str(
self.__config_manager.get(self.plugin_name, self.info.name, int(default_value))
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this TUI code be in a separate PR?


MAX_FILE_SIZE = int(ConfigManager().get("srec_hex", "max_file_size", 1000000))
STRIP_LEADING_ZEROS = bool(ConfigManager().get("srec_hex", "strip_leading_zeros", False))
EXTRACT_DIR = pathlib.Path(ConfigManager().get("srec_hex", "output_path", "")).absolute()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EXTRACT_DIR should imitate file_decompression.py and use tempfile.gettempdir() as a default. pathlib.Path("").absolute() uses the current working directory.


def get_first_and_last_address(data: List[WriteInfo]) -> Tuple[int, int]:
# Arbitrarly large number so smaller addresses will always compare true
first_address = 2 << 65
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably fine? Feels wrong to have a magic number here.


_base_path = pathlib.Path(__file__).parent.absolute()
_data_dir = os.path.join(_base_path, "..", "data", "binary")
_expected_output_loc = os.path.join(_base_path, "..", "data", "msitest_no1", "test.msi")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a good idea to move the msi into the data/binary folder so we can separate the msi test files from the srec/hex test files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants