Repository navigation
Fix empty leafref value passing validation without referred instance - #702
Open
khromenokroman wants to merge 2 commits into
Open
khromenokroman wants to merge 2 commits into
khromenokroman wants to merge 2 commits into
Conversation
validate_leafref() returned OK immediately if the leafref node had no
body, so an empty value was accepted even with require-instance true and
no referred instance with empty value, eg:
set test object object1 group ""
An empty value is a value like any other: it must refer to an existing
instance with the same (empty) value. Treat a missing body as an empty
string both for the leafref and for the referred instances, so that an
empty leafref is valid only if some referred node is also empty.
The LEAFREF_OPTIMIZE binary search builds a key from the value, so use
the linear search for an empty value. Also avoid printing "(null)" in
the instance-required error.
Fixes clicon#647
Empty leafref to leaf-list, list key and non-key leaf must fail validation, unless the referred node has an empty value.
This branch has not been deployed
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.
@olofhagsand Hello
Description:
Fixes #647
Problem
validate_leafref()returned OK immediately if the leafref node had no body:So an empty value was always accepted, even with
require-instance trueandno referred instance with an empty value:
Fix
An empty value is a value like any other (RFC 7950 9.9): it must refer to an
existing instance with the same value.
the referred instances. An empty leafref is valid only if some referred node
also has an empty value.
LEAFREF_OPTIMIZEbinary search builds a lookup key from the value, souse the linear search for an empty value. Empty leafrefs are rare, so this
has no performance impact.
validate_leafref_err(): print an empty body instead of(null)in theinstance-requirederror, i.e.<error-info><group/></error-info>.Behavior change
Configurations that contain an empty leafref without a matching empty referred
value were accepted before and now fail validation with
instance-required.This is the intended fix, but it may affect existing datastores.
Testing
New
test/test_leafref_empty.sh(separate file to not interfere with Fix leafref binary search accepting entries excluded by xpath predicates #700):empty leafref to a leaf-list (the scenario from An empty value passes leafref validation #647), to a list key (binary
search path) and to a non-key leaf must fail; an empty leafref to an existing
empty value must pass.
Verified the same YANG and data with a standalone validation program
(
xml_yang_validate_all_top):Performance unchanged: 20000 list entries + 20000 leafrefs validate in the
same time as on master.
Merges cleanly with Fix leafref binary search accepting entries excluded by xpath predicates #700.