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

Add assertion helpers for complex rules #250

Closed
BernieWhite opened this issue Jul 31, 2019 · 0 comments · Fixed by #251
Closed

Add assertion helpers for complex rules #250

BernieWhite opened this issue Jul 31, 2019 · 0 comments · Fixed by #251
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@BernieWhite
Copy link
Member

PSRule already includes a number of built-in keywords that can be used to build out rules quickly.

In complex scenarios the behavior may not be desirable.

Consider:

# Synopsis: VNETs should have at least two DNS servers assigned
Rule 'Azure.VirtualNetwork.SingleDNS' {
    # If DNS servers are customized, at least two IP addresses should be defined
    if (!(Exists 'properties.dhcpOptions.dnsServers') -or ($TargetObject.properties.dhcpOptions.dnsServers.Count -eq 0)) {
        $True;
    }
    else {
        $TargetObject.properties.dhcpOptions.dnsServers.Count -ge 2;
    }
}

In this example Exists is useful for checking if a nested field exists. However logging within verbose logs may confuse the intent of the rule.

Secondarily, while builtin keywords make it easy to build out rules quickly, the vocabulary is must be limited to reduce keyword clash with other DSL PowerShell modules.

@BernieWhite BernieWhite added the enhancement New feature or request label Jul 31, 2019
@BernieWhite BernieWhite added this to the v0.8.0 milestone Jul 31, 2019
@BernieWhite BernieWhite self-assigned this Jul 31, 2019
This was referenced Jul 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant