From 0f7f079dd8015f5f5fc1376c9bd1aff87d07fa67 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Fri, 10 Feb 2023 08:25:02 -0700 Subject: [PATCH] sys_patch_detect.py: Avoid nested if statements --- resources/sys_patch/sys_patch_detect.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/resources/sys_patch/sys_patch_detect.py b/resources/sys_patch/sys_patch_detect.py index f97cf519e..4474a9360 100644 --- a/resources/sys_patch/sys_patch_detect.py +++ b/resources/sys_patch/sys_patch_detect.py @@ -604,15 +604,19 @@ class DetectRootPatch: int: AMFI level needed """ - if self.amfi_must_disable is True: - if self.constants.detected_os > os_data.os_data.catalina: - if self.constants.detected_os >= os_data.os_data.ventura: - if self.amfi_shim_bins is True: - # Currently we require AMFI outright disabled - # in Ventura to work with shim'd binaries - return amfi_detect.AmfiConfigDetectLevel.ALLOW_ALL - return amfi_detect.AmfiConfigDetectLevel.LIBRARY_VALIDATION - return amfi_detect.AmfiConfigDetectLevel.NO_CHECK + if self.amfi_must_disable is False: + return amfi_detect.AmfiConfigDetectLevel.NO_CHECK + + if self.constants.detected_os < os_data.os_data.big_sur: + return amfi_detect.AmfiConfigDetectLevel.NO_CHECK + + if self.constants.detected_os >= os_data.os_data.ventura: + if self.amfi_shim_bins is True: + # Currently we require AMFI outright disabled + # in Ventura to work with shim'd binaries + return amfi_detect.AmfiConfigDetectLevel.ALLOW_ALL + + return amfi_detect.AmfiConfigDetectLevel.LIBRARY_VALIDATION def verify_patch_allowed(self, print_errors: bool = False):