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

Pre-release v3.0.0-B0203 #1835

Merged

Conversation

BernieWhite
Copy link
Member

PR Summary

What's changed since pre-release v3.0.0-B0198:

  • New features:
    • Breaking change: Simplify handling of inputs from files using emitters by @BernieWhite.
      #1179
      • Files are automatically read from input paths and emitted as objects to the pipeline.
      • Emitter interface can be used to implement custom file readers and expansion of custom file types.
      • The File and Detect input formats are no longer required and have been removed.
      • Processing files and objects with rules is no longer recommended, and disabled by default.
      • The Input.FileObjects can be set to true to enable processing of files as objects with rules.
  • Engineering:
    • Bump Microsoft.NET.Test.Sdk to v17.10.0.
      #1826
  • Bug fixes:

PR Checklist

  • PR has a meaningful title
  • Summarized changes
  • Change is not breaking
  • This PR is ready to merge and is not Work in Progress

@BernieWhite BernieWhite requested a review from a team as a code owner May 24, 2024 16:00
@BernieWhite BernieWhite merged commit 884f6b6 into microsoft:main May 24, 2024
14 checks passed
@BernieWhite BernieWhite deleted the users/bewhite/release-v3.0.0-B0203 branch May 24, 2024 16:10
@lassehastrup
Copy link

My apologies, @BernieWhite , you're correct.

However, now that have imported the correct version I receive this:

image

In the release notes it states:

The File and Detect input formats are no longer required and have been removed.

After out commenting the: Input.File

image

It can read the yaml option file successfully without errors.

But It doesn't process any of the rules:

image

I have attempted with the Input.FileObjects set to true, but this doesn't change anything.

Any hints?

@BernieWhite
Copy link
Member Author

BernieWhite commented May 28, 2024

Hi @lassehastrup.

PSRule for Azure will be updated to support the new emitters interface but until PSRule v3 is released as stable, setting Input.FileObjects to true is required. Outside of that it should work.

Are you able to share a other options either set via ps-rule.yaml or on the command line in-case there is an edge case that doesn't quite work in the pre-release. Feel free to sanitize any suppressions as required.

@lassehastrup
Copy link

lassehastrup commented May 28, 2024

Hi @BernieWhite ,

Sure, this is the yaml file we're using:

# Options can be found here: https://github.com/microsoft/PSRule/blob/main/docs/concepts/PSRule/en-US/about_PSRule_Options.md
requires:
  PSRule: "3.0.0-B0203"
  PSRule.Rules.Azure: ">=1.27.3"
  PSRule.Rules.CAF: ">=0.3.0"

configuration:
  AZURE_PARAMETER_FILE_EXPANSION: true
  AZURE_PARAMETER_FILE_METADATA_LINK: true

  # Disable expansion of Azure Bicep files as bicep files are discovered via the parameter files
  AZURE_BICEP_FILE_EXPANSION: false
  AZURE_BICEP_FILE_EXPANSION_TIMEOUT: 60

  CAF_ResourceGroupMandatoryTags:
    - TTL
    - RgDeploymentTime

  # Specify the tag (key) and valid values
  CAF_EnvironmentTag: Environment
  CAF_Environments:
    - dev
    - prod

  # Specify the Baseline to scan agents https://azure.github.io/PSRule.Rules.Azure/en/baselines/Azure.All/
  baseline: Azure.All

include:
  module:
    - PSRule.Rules.Azure
    - PSRule.Rules.CAF

output:
  format: NUnit3
  path: tmp/TEST-PSRule.xml
  # outcome: Fail
  culture:
    - en-US

# Configure binding for local rules.
binding:
  preferTargetInfo: true
  targetType:
    - type
    - resourceType

rule:
  includeLocal: true
  exclude:
    # Ignore the following rules for all resources
    - Azure.Resource.UseTags # Tags are set in Resource Groups, an is inherited from these, so this check will
    - Azure.KeyVault.Logs # Logs will be set via diagnostic powershell script
    - Azure.Automation.AuditLogs # Logs will be set via diagnostic powershell script
    - Azure.Automation.PlatformLogs # Logs will be set via diagnostic powershell script
    - Azure.VNET.SingleDNS # The DNS is set to be Azure DNS Resolver which has High Availability
    - Azure.VNET.LocalDNS # The DNS is set to be Azure DNS Resolver which has High Availability

input:
  FileObjects: true

I still haven't managed to process any rules with version: 3.0.0-B0203

Let me know if you need more test-data or information, and I will supply it right away.

@BernieWhite
Copy link
Member Author

BernieWhite commented May 28, 2024

@lassehastrup Thanks. A quick one that I can see is the case for FileObjects should be fileObjects for the YAML syntax, because the keys are case-sensitive.

See: https://microsoft.github.io/PSRule/v3/concepts/PSRule/en-US/about_PSRule_Options/#inputfileobjects

But I'll look at trying to reproducing that later today.

@lassehastrup
Copy link

@BernieWhite , appreciate it. That did the trick.

Everything works as expected now, and the 'reason' is now outputted correct.

image

Thank you very much, Bernie!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants