Skip to content

3.0.2: see an existing Key Vault or storage IP rule before adding one - #2

Open
craigthackerx wants to merge 1 commit into
mainfrom
fix/ip-rule-existing-check
Open

craigthackerx wants to merge 1 commit into
mainfrom
fix/ip-rule-existing-check

Conversation

@craigthackerx

@craigthackerx craigthackerx commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Add-LdoKeyVaultCurrentIpRule and Add-LdoStorageCurrentIpRule checked for the runner's rule with a top-level filter ([?ipAddress=='<ip>']), but az keyvault network-rule list and az storage account network-rule list both return an object ({ ipRules: [...] }), not a list. The check never matched, so the rule was added again on every call. The Azure CLI deduplicated it (IP/CIDR ... overlaps ... Not adding duplicates), so nothing broke, but the log always claimed a new rule. Found during a live Key Vault dance in the azure-orchestration build.

This PR fixes

  1. Both helpers now project the addresses (ipRules[].value for Key Vault, ipRules[].ipAddressOrRange for storage; both shapes checked against live resources), match the address with or without /32 (Key Vault stores a single address as a /32), and log "already present" when it is.
  2. Regression tests that mock az the way the real CLI behaves (only the ipRules projection reaches the addresses).
  3. Version 3.0.2 and a CHANGELOG entry. Merging publishes to PSGallery.

Breaking changes

None.

Testing evidence

  • The new tests pass on this code and fail the four "already present" cases on the old code (checked by stashing the fix).
  • Full suite: 557 passed, 0 failed. PSScriptAnalyzer: no findings on the changed files. Test-ModuleManifest passes at 3.0.2.

Add-LdoKeyVaultCurrentIpRule and Add-LdoStorageCurrentIpRule checked for
the runner's rule with a top-level filter ([?ipAddress=='<ip>']), but
both network-rule list commands return an object ({ ipRules: [...] }),
so the check never matched and the rule was added again on every call.
The Azure CLI deduplicated it ("IP/CIDR overlaps ... Not adding
duplicates"), so nothing broke, but the log always claimed a new rule.

Both now project the addresses (ipRules[].value for Key Vault,
ipRules[].ipAddressOrRange for storage, shapes checked against live
resources), match the address with or without /32 (Key Vault stores a
single address as a /32), and log "already present" when it is.

Regression tests mock az the way the real CLI behaves (only the ipRules
projection reaches the addresses): they pass on this code and fail the
"already present" cases on the old code.
@craigthackerx
craigthackerx force-pushed the fix/ip-rule-existing-check branch from bc9c3f1 to ebcce62 Compare November 12, 2026 23:46
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.

1 participant