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

[BUG] False positive with load balancers that use a public IP #2814

Closed
BernieWhite opened this issue Apr 9, 2024 · 0 comments · Fixed by #2820
Closed

[BUG] False positive with load balancers that use a public IP #2814

BernieWhite opened this issue Apr 9, 2024 · 0 comments · Fixed by #2820
Assignees
Labels
bug Something isn't working rule: network Rules for virtual networking
Milestone

Comments

@BernieWhite
Copy link
Collaborator

Existing rule

Azure.LB.AvailabilityZone

Description of the issue

properties.frontendIPConfigurations[*].zones is only valid with an internal load balancer and not when the load balancer is configured with a public IP.

As a rule the rule is failing with a false positive.

Error messages

No response

Reproduction

var frontendIPConfigurationsVar = [
  for (frontendIPConfiguration, index) in frontendIPConfigurations: {
    name: frontendIPConfiguration.name
    properties: {
      subnet: contains(frontendIPConfiguration, 'subnetId') && !empty(frontendIPConfiguration.subnetId)
        ? {
            id: frontendIPConfiguration.subnetId
          }
        : null
      publicIPAddress: contains(frontendIPConfiguration, 'publicIPAddressId') && !empty(frontendIPConfiguration.publicIPAddressId)
        ? {
            id: frontendIPConfiguration.publicIPAddressId
          }
        : null
      privateIPAddress: contains(frontendIPConfiguration, 'privateIPAddress') && !empty(frontendIPConfiguration.privateIPAddress)
        ? frontendIPConfiguration.privateIPAddress
        : null
      privateIPAddressVersion: contains(frontendIPConfiguration, 'privateIPAddressVersion')
        ? frontendIPConfiguration.privateIPAddressVersion
        : 'IPv4'
      privateIPAllocationMethod: contains(frontendIPConfiguration, 'subnetId') && !empty(frontendIPConfiguration.subnetId)
        ? (contains(frontendIPConfiguration, 'privateIPAddress') ? 'Static' : 'Dynamic')
        : null
      gatewayLoadBalancer: contains(frontendIPConfiguration, 'gatewayLoadBalancer') && !empty(frontendIPConfiguration.gatewayLoadBalancer)
        ? {
            id: frontendIPConfiguration.gatewayLoadBalancer
          }
        : null
      publicIPPrefix: contains(frontendIPConfiguration, 'publicIPPrefix') && !empty(frontendIPConfiguration.publicIPPrefix)
        ? {
            id: frontendIPConfiguration.publicIPPrefix
          }
        : null
    }
    zones: contains(frontendIPConfiguration, 'subnetId') && !empty(frontendIPConfiguration.subnetId)
    ? [
      '1'
      '2'
      '3'
    ]
    :null
  }
]

Version of PSRule

2.9.0

Version of PSRule for Azure

1.35.2

Additional context

https://github.com/arnoldna/bicep-registry-modules/actions/runs/8621385310/job/23630221539

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rule: network Rules for virtual networking
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant