acidjunk / pyang

Automatically exported from code.google.com/p/pyang
ISC License
0 stars 0 forks source link

pyang does not verify a default value for a leafref type based statements #107

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
pyang does not verify a default value for a leafref type based statement 
(leaf/leaf-list, typedef, refine). There are four errors in attached module, 
but pyang only detects one.

What is the expected output? What do you see instead?
An error, if the value does not match the leafref's target node typespec.

What version of the product are you using? On what operating system?
Latest svn code.

Please provide any additional information below.
pyang behaves this way, since validating a default value in PathTypeSpec relies 
on presence of the "i_target_node" member. If this member is missing, the 
PathTypeSpec.str_to_val method will return true. This is always the case for 
leafrefs, since the phases of validation that handle default values are done 
*before* the phase, that fills out "i_target_node". You should check leafref 
leaf's default value *after* statements.v_reference_leaf_leafref(ctx, s) is 
called.

Jernej

Original issue reported on code.google.com by jernej.t...@gmail.com on 4 Apr 2014 at 9:12

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by lada.lho...@gmail.com on 21 Jul 2014 at 8:19

GoogleCodeExporter commented 9 years ago
Comment: defaults on leafrefs are pretty dangerous.  we should probably add a 
warning for this.  the problem is that the leafref target must exist, and if 
someone deletes the target node you're in trouble...

Original comment by mbj4...@gmail.com on 24 Jul 2014 at 9:14