Validate nodeattrib IPs and MACs - #252
Draft
Obihoernchen wants to merge 2 commits into
Draft
Conversation
net.ipv4_address, net.ipv4_gateway, net.ipv6_address, net.ipv6_gateway
and net.hwaddr (including interface-scoped forms like
net.eth0.ipv4_address) previously accepted any string, deferring
discovery of typos to deployment time.
Extend the declarative attribute schema with a 'validate' callable and
enforce it in the common attribute set path in configmanager, covering
nodeattrib, nodegroupattrib and the HTTP API alike. Addresses accept
an optional /prefix suffix (gateways do not), and hardware addresses
accept colon or hyphen delimited hex octets of length 6 (Ethernet),
8 (EUI-64) or 20 (InfiniBand).
Expression values such as 172.16.1.{n1} continue to be accepted
unexamined; empty values and clears are unaffected.
Expression values such as net.ipv4_address=172.16.1.{n1} were accepted
without any inspection of what they would produce. Now, when setting
such an expression on an attribute that declares a format validator,
evaluate it against the current configuration and validate the result:
per target node when set on a node, and per current member node when
set on a group.
The check is best effort by design: an expression that cannot be
evaluated yet (the node is still being created in the same request, a
dependency attribute is not set, or group membership changes later) is
let through unexamined; only a cleanly evaluated but malformed result
is rejected. Results are also not re-validated when expressions are
re-evaluated on later renames or dependency changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is just a POC for now.
It validates nodeattrib
net.hwaddr,net.ipv4_address,net.ipv6_address,net.ipv4_gateway,net.ipv6_gateway.nodeattribexpressions are validated with a best effort approach.
Not sure this will ever be useful but it might be a good starting point for some discussion about additional attribute validation.
Some examples: