Skip to content

Use longest-prefix matching for SNMP credentials - #45

Merged
jacobyoby merged 1 commit into
mainfrom
fix/issue-17-snmp-credential-precedence
Sep 9, 2026
Merged

jacobyoby merged 1 commit into
mainfrom
fix/issue-17-snmp-credential-precedence

Conversation

@jacobyoby

Copy link
Copy Markdown
Owner

SNMP credential selection previously stopped at the first matching JSON property. A Default entry placed first could shadow every subnet credential, and overlapping networks depended on file order.

This change validates every non-default key as IPv4 CIDR, selects the longest matching prefix, and uses Default only when no subnet matches. The selected entry remains authoritative when its secret name is missing; the command warns and skips that configured credential unless -TryPublic was explicitly supplied. Help and the credential-map template document those rules.

Tests cover Default-first and Default-last maps, overlapping /16 and /24 networks, unmatched addresses, malformed CIDRs, and missing secret names.

Validation: git diff --check passed. PowerShell is unavailable on the local host; GitHub Actions will run Pester on Linux, macOS, and Windows plus PSScriptAnalyzer.

Closes #17

@jacobyoby
jacobyoby merged commit 39da711 into main Sep 9, 2026
4 checks passed
@jacobyoby
jacobyoby deleted the fix/issue-17-snmp-credential-precedence branch September 9, 2026 02:51
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.

P1: Resolve SNMP credential maps by longest matching prefix before Default

1 participant