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

Improve support for match to process an array of string #1691

Open
BernieWhite opened this issue Dec 6, 2023 Discussed in #1687 · 0 comments
Open

Improve support for match to process an array of string #1691

BernieWhite opened this issue Dec 6, 2023 Discussed in #1687 · 0 comments
Labels
enhancement New feature or request feature: language Issues that affect language such keywords and variables

Comments

@BernieWhite
Copy link
Member

Discussed in #1687

Originally posted by JonasCordsen December 5, 2023
Hello

I am trying to create a custom rule, that should match if a parameter I pass match the format for a subnet.
The parameter is an array. I am wondering if I am using it wrong, or this is something that is no support for yet

I have tested with a string, and that seems to work.

The parameter looks like this:
"Subnets": [
"172.16.0.0/24",
"172.16.1.0/24"
],

And the Rule looks like this
`

apiVersion: github.com/microsoft/PSRule/v1
kind: Rule
recommend: "VPN Local gateways onPremise network should be a subnet"
metadata:
name: "Local.YAML.localNetworkGateways.Subnet"
spec:
type:
- "Microsoft.Network/localNetworkGateways"
condition:
allOf:
- field: "properties.localNetworkAddressSpace.addressPrefixes"
isArray: true
- field: "properties.localNetworkAddressSpace.addressPrefixes"
match: '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/([1-3][0-2]$|[0-2][0-9]$|0?[0-9]$)'
`

@BernieWhite BernieWhite added enhancement New feature or request feature: language Issues that affect language such keywords and variables labels Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature: language Issues that affect language such keywords and variables
Projects
None yet
Development

No branches or pull requests

1 participant