* Fixed: [statement: require-instance should be true if not present according to rfc7950 Sec 9.9.3](https://github.com/clicon/clixon/issues/302)

This commit is contained in:
Olof hagsand 2022-02-17 10:09:23 +01:00
parent 12695c5d87
commit 1324c914dc
5 changed files with 22 additions and 13 deletions

View file

@ -46,6 +46,9 @@ Expected: March 2022
Users may have to change how they access the system Users may have to change how they access the system
* YANG leafref `require-instance` default changed to `true`
* This makes leafref validation stricter
* See [statement: require-instance should be true if not present according to rfc7950 Sec 9.9.3](https://github.com/clicon/clixon/issues/302)
* `configure --with-wwwdir=<dir>` is removed * `configure --with-wwwdir=<dir>` is removed
* Command field of clixon-lib:process-control RPC reply used CDATA encoding but now uses regular XML encoding * Command field of clixon-lib:process-control RPC reply used CDATA encoding but now uses regular XML encoding
@ -59,9 +62,8 @@ Users may have to change how they access the system
### Corrected Bugs ### Corrected Bugs
* Fixed: [statement: require-instance should be true if not present according to rfc7950 Sec 9.9.3](https://github.com/clicon/clixon/issues/302)
* See also API changes
* Fixed: input RPC validation of choice (non-case) * Fixed: input RPC validation of choice (non-case)
* Fixed: More than one unknown/extension in combination with augment of extension resulted in extension being skipped. * Fixed: More than one unknown/extension in combination with augment of extension resulted in extension being skipped.

View file

@ -134,7 +134,7 @@ validate_leafref(cxobj *xt,
char *path_arg; char *path_arg;
yang_stmt *ymod; yang_stmt *ymod;
cg_var *cv; cg_var *cv;
int require_instance = 0; int require_instance = 1;
/* require instance */ /* require instance */
if ((yreqi = yang_find(ytype, Y_REQUIRE_INSTANCE, NULL)) != NULL){ if ((yreqi = yang_find(ytype, Y_REQUIRE_INSTANCE, NULL)) != NULL){

View file

@ -1,5 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# transitive leafref->leafref leafref->identityref completion # transitive leafref->leafref leafref->identityref completion
#
# Magic line must be first in script (see README.md) # Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
@ -67,31 +68,33 @@ module example-leafref{
} }
/* first level leafref */ /* first level leafref */
container leafrefs { container leafrefs {
description "Relative path"; description "Leafref relative path, no require-instance";
list leafref{ list leafref{
key name; key name;
leaf name { leaf name {
type leafref{ type leafref{
path "../../../table/parameter/name"; path "../../../table/parameter/name";
require-instance false;
} }
} }
} }
} }
/* first level leafref absolute */ /* first level leafref absolute */
container leafrefstop { container leafrefsabs {
description "Same but absolute path"; description "Leafref absolute path, no require-instance";
list leafref{ list leafref{
key name; key name;
leaf name { leaf name {
type leafref{ type leafref{
path "/table/parameter/name"; path "/table/parameter/name";
require-instance false;
} }
} }
} }
} }
/* first level leafref require-instance */ /* first level leafref require-instance */
container leafrefsreqi { container leafrefsreqinst {
description "Same but absolute path"; description "Leafref absolute path, require-instance true";
list leafref{ list leafref{
key name; key name;
leaf name { leaf name {
@ -105,6 +108,7 @@ module example-leafref{
/* first level identityrefs */ /* first level identityrefs */
container identityrefs { container identityrefs {
list identityref{ list identityref{
description "Identityref base";
key name; key name;
leaf name { leaf name {
type identityref{ type identityref{
@ -120,6 +124,7 @@ module example-leafref{
leaf name { leaf name {
type leafref{ type leafref{
path "../../../leafrefs/leafref/name"; path "../../../leafrefs/leafref/name";
require-instance false;
} }
} }
} }
@ -131,6 +136,7 @@ module example-leafref{
leaf name { leaf name {
type leafref{ type leafref{
path "../../../identityrefs/identityref/name"; path "../../../identityrefs/identityref/name";
require-instance false;
} }
} }
} }
@ -175,10 +181,10 @@ new "expand leafref 1st level"
expectpart "$(echo "set leafrefs leafref ?" | $clixon_cli -f $cfg 2> /dev/null)" 0 "91" "92" "93" expectpart "$(echo "set leafrefs leafref ?" | $clixon_cli -f $cfg 2> /dev/null)" 0 "91" "92" "93"
new "expand leafref top" new "expand leafref top"
expectpart "$(echo "set leafrefstop leafref ?" | $clixon_cli -f $cfg 2> /dev/null)" 0 "91" "92" "93" expectpart "$(echo "set leafrefsabs leafref ?" | $clixon_cli -f $cfg 2> /dev/null)" 0 "91" "92" "93"
new "expand leafref require-instance" new "expand leafref require-instance"
expectpart "$(echo "set leafrefsreqi leafref ?" | $clixon_cli -f $cfg 2> /dev/null)" 0 "91" "92" "93" expectpart "$(echo "set leafrefsreqinst leafref ?" | $clixon_cli -f $cfg 2> /dev/null)" 0 "91" "92" "93"
# First level id/leaf refs # First level id/leaf refs
new "set identityref des" new "set identityref des"
@ -217,7 +223,7 @@ expectpart "$($clixon_cli -1 -f $cfg -l o commit)" 0 "^$"
# require-instance # require-instance
new "set leafref require-instance 99 (non-existent)" new "set leafref require-instance 99 (non-existent)"
expectpart "$($clixon_cli -1 -f $cfg set leafrefsreqi leafref 99)" 0 "^"$ expectpart "$($clixon_cli -1 -f $cfg set leafrefsreqinst leafref 99)" 0 "^"$
new "cli validate expect failure" new "cli validate expect failure"
expectpart "$($clixon_cli -1 -f $cfg -l o validate)" 255 "Leafref validation failed: No leaf 99 matching path" expectpart "$($clixon_cli -1 -f $cfg -l o validate)" 255 "Leafref validation failed: No leaf 99 matching path"

View file

@ -63,7 +63,6 @@ module leafref{
leaf ref{ leaf ref{
type leafref { type leafref {
path "/ex:sender-config/ex:name"; path "/ex:sender-config/ex:name";
require-instance true;
} }
} }
} }
@ -90,6 +89,7 @@ module leafref{
leaf ref{ leaf ref{
type leafref { type leafref {
path "/ex:sender-config/ex:name"; path "/ex:sender-config/ex:name";
require-instance false;
} }
} }
} }

View file

@ -79,6 +79,7 @@ cat <<EOF > $dir/startup_db
</config> </config>
</fdb> </fdb>
<config> <config>
<name>default</name>
<type>oc-ni-types:DEFAULT_INSTANCE</type> <type>oc-ni-types:DEFAULT_INSTANCE</type>
<enabled>true</enabled> <enabled>true</enabled>
<router-id>1.2.3.4</router-id> <router-id>1.2.3.4</router-id>