From 485be0285c4f1b20194a72639517f0c3512bfe5c Mon Sep 17 00:00:00 2001 From: jantari Date: Fri, 12 Jan 2024 17:14:44 +0100 Subject: [PATCH] fail out of AND tests as soon as 1 came back false This could fix / work around issue #103 because the problematic package: https://download.lenovo.com/pccbbs/mobiles/n3acv41w_2_.xml has lots of idependency tests in a long AND-clause and the one that's hanging is the very last one. So if any previous test had already failed we could just skip all the others, thus avoiding the problematic ExternalDetection with MCUFWRevCheck.exe. --- private/Resolve-XMLDependencies.ps1 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/private/Resolve-XMLDependencies.ps1 b/private/Resolve-XMLDependencies.ps1 index dd3d4ce..c498569 100644 --- a/private/Resolve-XMLDependencies.ps1 +++ b/private/Resolve-XMLDependencies.ps1 @@ -6,13 +6,16 @@ [Parameter( Mandatory = $true )] [string]$PackagePath, [switch]$TreatUnsupportedAsPassed, - [switch]$FailInboxDrivers + [switch]$FailInboxDrivers, + [switch]$ParentNodeIsAnd ) $XMLTreeDepth++ [DependencyParserState]$ParserState = 0 + $i = 0 foreach ($XMLTREE in $XMLIN) { + $i++ Write-Debug "$('- ' * $XMLTreeDepth )|> Node: $($XMLTREE.SchemaInfo.Name)" if ($XMLTREE.SchemaInfo.Name -eq 'Not') { @@ -34,7 +37,7 @@ } } } else { - $SubtreeResults = Resolve-XMLDependencies -XMLIN $XMLTREE.ChildNodes -PackagePath $PackagePath -TreatUnsupportedAsPassed:$TreatUnsupportedAsPassed -FailInboxDrivers:$FailInboxDrivers + $SubtreeResults = Resolve-XMLDependencies -XMLIN $XMLTREE.ChildNodes -PackagePath $PackagePath -TreatUnsupportedAsPassed:$TreatUnsupportedAsPassed -FailInboxDrivers:$FailInboxDrivers -ParentNodeIsAnd:($XMLTREE.SchemaInfo.Name -eq 'And') switch ($XMLTREE.SchemaInfo.Name) { 'And' { Write-Debug "$('- ' * $XMLTreeDepth)Tree was AND: Results: $subtreeresults" @@ -50,6 +53,11 @@ Write-Debug "$('- ' * $XMLTreeDepth)< Returning $($Result -bxor $ParserState) from node $($XMLTREE.SchemaInfo.Name)" $Result -bxor $ParserState + if ($ParentNodeIsAnd -and $i -ne $XMLIN.Count -and -not ($Result -bxor $ParserState)) { + Write-Debug "$('- ' * $XMLTreeDepth)Quitting AND evaluation early because we already got one FALSE." + $ParserState = 0 # DO_HAVE + break; + } $ParserState = 0 # DO_HAVE }