acidjunk / acidjunk/pyang

Deviation/deviate grammar not checked properly

Aberta
#76 0 comentários 0 reações 0 responsáveis Ver no GitHub
auto-migrated Priority-Medium Type-Defect
Linguagem predominante
Python
Estrelas
0
Forks
0
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

```
I think this is only an omission due to the nature of deviate statements;
grammar for deviations is not checked correctly. The deviate-stmt seems to be
the only YANG statement which “dynamically” changes substatement grammar
based on a statement's argument (all other do this based on keywords, perhaps
only the type-stmt is similar with it's restrictions).

It is not obvious from the text in RFC6020 but YANG grammar specifies the
following:
1. deviation-stmt must have at least one deviate substatement
2. if a deviate-stmt with “not-supported” argument is present within a
deviation-stmt, then no other deviate-stmt may be present as it's sibling
3. deviate-stmts with arguments “add”, “delete” and “replace” may
appear any number of times within a deviation-stmt as long as a
“not-supported” deviate-stmt is not present.
4. a deviate-stmt with a “not-supported” argument must not contain any
substatements
5. a deviate-stmt with arguments “add”, “delete” and “replace” may
or may not contain substatements, but I suggest generating a warning when such
statements are empty
6. a deviate-stmt with argument “add” may only contain the following
substatements which may appear in any order; units-stmt (0..1), must-stmt
(0..n), unique-stmt (0..n), default-stmt (0..1), config-stmt (0..1),
mandatory-stmt (0..1), min-elements-stmt (0..1) and max-elements-stmt (0..1)
7. a deviate-stmt with argument “delete” may only contain the following
substatements which may appear in any order; units-stmt (0..1), must-stmt
(0..n), unique-stmt (0..n) and default-stmt (0..1)
8. a deviate-stmt with argument “replace” may only contain the following
substatements which may appear in any order; type-stmt (0..1), units-stmt
(0..1), default-stmt (0..1), config-stmt (0..1), mandatory-stmt (0..1),
min-elements-stmt (0..1) and max-elements-stmt (0..1)

You probably wanted to check this within validation phases for deviation-stmt
and deviate-stmt, since you cannot specify such a grammar within grammar.py,
because you'd have to check a statement's argument. You should do it in a way
similar to how you check restrictions of the type-stmt.

I confirmed this in the latest svn rev739.

RFC6020 text in 7.18.3 and it's sub-chapters is extremely vague on this matter
but the grammar in chaper 12 is quite clear. I enclosed a YANG module with a
bunch of grammar errors. Pyang does report some errors with this YANG file, but
they shouldn't even be reported since a grammar check should have higher
priority. For example, attempting to add a type statement should never even be
allowed.
```

Original issue reported on code.google.com by `jernej.t...@gmail.com` on 11 Sep 2012 at 8:16

Attachments:
- [deviation-deviate-errs@2012-09-06.yang](https://storage.googleapis.com/google-code-attachments/pyang/issue-76/comment-0/deviation-deviate-errs@2012-09-06.yang)

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.