Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object reference for suppression group will rule not defined #932

Closed
BernieWhite opened this issue Jan 23, 2022 · 2 comments · Fixed by #934
Closed

Object reference for suppression group will rule not defined #932

BernieWhite opened this issue Jan 23, 2022 · 2 comments · Fixed by #934
Assignees
Labels
bug Something isn't working feature: language Issues that affect language such keywords and variables
Milestone

Comments

@BernieWhite
Copy link
Member

Description of the issue

When a suppression group is defined without a rule property an exception occurs.

To Reproduce

Steps to reproduce the issue:

---
apiVersion: github.com/microsoft/PSRule/v1
kind: SuppressionGroup
metadata:
  name: Local.IgnoreKeyVaultTests
spec:
  if:
    name: '.'
    in:
    - 'kv-test-001'

Expected behaviour

I think in this case we should apply the suppression group to all rules. Related to #931

Error output

OperationStopped: Object reference not set to an instance of an object.

Module in use and version:

  • Module: PSRule
  • Version: v2.0.0-B2201117

Captured output from $PSVersionTable:

Name                           Value
----                           -----
PSVersion                      7.2.1
PSEdition                      Core
GitCommitId                    7.2.1
OS                             Microsoft Windows 10.0.22000
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
@BernieWhite BernieWhite added the feature: language Issues that affect language such keywords and variables label Jan 23, 2022
@BernieWhite BernieWhite added this to the v2.0.0 milestone Jan 23, 2022
@BernieWhite BernieWhite added the bug Something isn't working label Jan 23, 2022
@ArmaanMcleod
Copy link
Contributor

@BernieWhite I can probably look at this. I should have probably thought about these edge cases when I added this functionality 😄.

To me it would makes sense to apply the suppression group to all rules for both these cases. Although could it get noisy to have warnings for every rule?

@BernieWhite
Copy link
Member Author

To me it would makes sense to apply the suppression group to all rules for both these cases. Although could it get noisy to have warnings for every rule?

I agree.

@ArmaanMcleod We may need to rework the warnings with more testing. But the summary warnings aren't too bad from my testing.

It will only suppress if the object also matches the if condition.

   WARN  3 rule/s were suppressed by suppression group '.\Local.IgnoreACRTests' for 'cr-test-basic'.
   WARN  3 rule/s were suppressed by suppression group '.\Local.IgnoreACRTests' for 'cr-test-premium'.
   WARN  1 rule/s were suppressed by suppression group '.\Local.IgnoreKeyVaultTests' for 'kv-test-001'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature: language Issues that affect language such keywords and variables
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants