Skip to content

Add a source expression property #933

Description

@BernieWhite

Currently the expression properties field, name, or type can be used. In PowerShell the source file for the object can be referenced using $PSRule.Source.

For example:

# Synopsis: Policy exemptions must be stored under designated paths for review.
Rule 'Org.Azure.Policy.Path' -Type 'Microsoft.Authorization/policyExemptions' {
    $Assert.WithinPath($PSRule.Source['Parameter'], '.', @(
        'deployments/policy/'
    ));
}

Currently $PSRule.Source is not available within expressions, neither is an equivalent of $Assert.WithinPath.

It would be helpful to provide both options to allow suppression groups to exclude objects based on their origin path.

For example:

---
apiVersion: github.com/microsoft/PSRule/v1
kind: SuppressionGroup
metadata:
  name: Local.IgnoreACRTests
spec:
  if:
    source: 'file'
    withinPath: 'modules/**/*.tests.bicep'

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestfeature: languageIssues that affect language such keywords and variables

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions