From 52ab38fc28abcad001de995cbcec3ce23094b507 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Thu, 7 Mar 2024 10:58:21 +0100 Subject: utils: handle exceptions caused by the hivex package The mage creation process was being interrupted by an error trying to read the Windows registry by the Hivex library. Now the exceptions are handled and an error is reported. --- src/utils/sw_inventory.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/utils/sw_inventory.py b/src/utils/sw_inventory.py index b2d55c3..c7bb458 100644 --- a/src/utils/sw_inventory.py +++ b/src/utils/sw_inventory.py @@ -84,9 +84,12 @@ def _fill_package_set_2(h, pkg_set): def _get_package_set_windows(hivepath): packages = set() - h = hivex.Hivex(hivepath) - _fill_package_set_1(h, packages) - _fill_package_set_2(h, packages) + try: + h = hivex.Hivex(hivepath) + _fill_package_set_1(h, packages) + _fill_package_set_2(h, packages) + except Exception as e: + logging.error(f'Hivex was not able to operate over {hivepath}. Reported: {e}') return packages -- cgit v1.2.3-18-g5258