microsoft / PSRule

Validate infrastructure as code (IaC) and objects using PowerShell rules.
https://microsoft.github.io/PSRule/v2/
MIT License
395 stars 49 forks source link

Dependent rule execution is skipped for consequent input objects #657

Closed vitali-pozniak closed 3 years ago

vitali-pozniak commented 3 years ago

Description of the issue

Dependent rules being skipped execution for all consequent input objects in case if any single object fails rule assessment.

To Reproduce

Steps to reproduce the issue:

#rules.ps1
Rule "r1" { $TargetObject }
Rule "r2" -DependsOn "r1" { $TargetObject }
Rule "r3" -DependsOn "r2" { $TargetObject }

#and then run
$true, $false, $true | Invoke-PSRule -Path "rules.ps1" -Outcome All

Actual behaviour

   TargetName: $true

RuleName                            Outcome    Recommendation
--------                            -------    --------------
r1                                  Pass
r2                                  Pass
r3                                  Pass

   TargetName: $false

RuleName                            Outcome    Recommendation
--------                            -------    --------------
r1                                  Fail
r2                                  None
r3                                  None

   TargetName: $true

RuleName                            Outcome    Recommendation
--------                            -------    --------------
r1                                  Pass
r2                                  None
r3                                  None

Expected behaviour

   TargetName: $true
RuleName                            Outcome    Recommendation
--------                            -------    --------------
r1                                  Pass
r2                                  Pass
r3                                  Pass

   TargetName: $false

RuleName                            Outcome    Recommendation
--------                            -------    --------------
r1                                  Fail
r2                                  None
r3                                  None

   TargetName: $true

RuleName                            Outcome    Recommendation
--------                            -------    --------------
r1                                  Pass
r2                                  Pass
r3                                  Pass

Error output

N/A

Module in use and version:

Captured output from $PSVersionTable:

Name                      Value
----                      -----
PSVersion                 7.1.2
PSEdition                 Core 
GitCommitId               7.1.2
OS                        Microsoft Windows 10.0.18363
Platform                  Win32NT
PSCompatibleVersions      {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion      1.1.0.1
WSManStackVersion         3.0

Additional context

N/A

BernieWhite commented 3 years ago

@vitali-pozniak Thanks for reporting.

Yes that doesn't look right, expected behaviour is correct. Let me have a look.