Re: [netmod] Pattern statements [was Re: Query about augmenting module from submodule in YANG 1.0]

Per Hedeland <per@tail-f.com> Wed, 23 August 2017 20:03 UTC

Return-Path: <per@tail-f.com>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 58C421323C9 for <netmod@ietfa.amsl.com>; Wed, 23 Aug 2017 13:03:36 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.9
X-Spam-Level:
X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id i8z3jrkJFodj for <netmod@ietfa.amsl.com>; Wed, 23 Aug 2017 13:03:34 -0700 (PDT)
Received: from mail.tail-f.com (mail.tail-f.com [46.21.102.45]) by ietfa.amsl.com (Postfix) with ESMTP id 9E62113209C for <netmod@ietf.org>; Wed, 23 Aug 2017 13:03:33 -0700 (PDT)
Received: from pluto.hedeland.org (81-228-155-109-no289.tbcn.telia.com [81.228.155.109]) by mail.tail-f.com (Postfix) with ESMTPSA id AC0F91AE01AA; Wed, 23 Aug 2017 22:03:32 +0200 (CEST)
To: Vladimir Vassilev <vladimir@transpacket.com>, "netmod@ietf.org" <netmod@ietf.org>
References: <E3378E0605547F4E854DEE0CB1116AB0210631@gbcdcmbx03.intl.att.com> <defe35bb-bb8b-f1f0-d8c4-2d2d0f23731b@transpacket.com> <1502290869.16638.15.camel@nic.cz> <20170809151312.GC42207@elstar.local> <6ef68131-f731-0edc-b731-d7ec85924f03@cisco.com> <E3378E0605547F4E854DEE0CB1116AB021CE2D@gbcdcmbx03.intl.att.com> <D5C05EB3.C2681%acee@cisco.com> <7614040f-9f8f-09c2-1854-63ad9ffb6be1@cisco.com> <5929631c-e51d-ae66-52d1-cbc87ca3506b@transpacket.com> <321a45fb-77e1-23c7-184b-d3bff9d41c39@cisco.com> <20170823133657.76s5wbcxbpgjfkiy@elstar.local> <9fc4b41f-5994-79f6-43dc-f3ba5b09f36d@transpacket.com>
From: Per Hedeland <per@tail-f.com>
Message-ID: <f9602344-4801-35a1-08f8-faafcc959043@tail-f.com>
Date: Wed, 23 Aug 2017 22:03:32 +0200
User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1
MIME-Version: 1.0
In-Reply-To: <9fc4b41f-5994-79f6-43dc-f3ba5b09f36d@transpacket.com>
Content-Type: text/plain; charset="windows-1252"; format="flowed"
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/zB7RN9lkT4XACuCawod4MlNk_c0>
Subject: Re: [netmod] Pattern statements [was Re: Query about augmenting module from submodule in YANG 1.0]
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 23 Aug 2017 20:03:36 -0000

On 2017-08-23 20:09, Vladimir Vassilev wrote:
> On 08/23/2017 03:36 PM, Juergen Schoenwaelder wrote:
> 
>> On Wed, Aug 23, 2017 at 02:23:12PM +0100, Robert Wilton wrote:
>>> 1) Email address.  I understand that the full regex to validate all email
>>> addresses is very complex, but checking that it at least contains an @
>>> symbol still has benefit.  It would seem that a short imperfect regex is
>>> better than a complete perfect regex.
>> What is your definition of 'better'? A stricter pattern catches more
>> errors. An imperfect pattern is better than none.
> In the case of e-mail address string pattern complying without exceptions to rfc5322#section-3.4 specification a ~500 characters of pattern expression is needed. There is value in defining data types 
> that can be automatically verified by YANG. IMO in this case a strict pattern is justified.
>>> 2) A list of VLAN ranges, e.g. want to allow strings that look like this:
>>> "1-10,20-400,600,2000-3000", but only with non overlapping values in
>>> ascending order.  It is easy to write a regex to check that the structure is
>>> right, but AFAIK it is hard (impossible?) to write a regex that ensures that
>>> the ranges don't overlap and are specified in ascending order.
>> So what. Does this provide a helpful argument whether patterns should
>> be strict or imperfect?
> IMO loading strings with semantics instead of using YANG is example of bad model design. There is no RFC (like in the e-mail example) that mandates use of string with complex format instead of YANG to 
> model range configuration. Complex strings can and should be avoided in cases like this one.
>>> So, I propose that we use regexes for checking that the string is
>>> structurally correct, but don't use regexes to perform numerical range
>>> checks of string encoded numbers, since it makes the regexes hard to
>>> read/verify, and doesn't improve the readability of the YANG file either.
>> So here is the point I think:
>> c.
>>     It is desirable that regexes are as strict as they can be.
>>     However, if regexes become so complicated that they become a
>>     verification and maintenance problem by themself, then less strict
>>     regexes may be a better choice.
> I agree. But it is the enthropy of having configuration that can not be strictly validated by model aware automation tools that has been the reason for introduction of leafref, must, when, range, 
> pattern etc. So giving up the goal of handling validation in automated model driven way to the advantage of readability is a tough compromise.

If I may offer a more "philosophical" view: in my mind, a YANG module is
not an instruction for a server (or client) implementation as to what
validation to perform (and I say that with the bias of working for a
company that uses YANG modules precisely for that, and with the specific
components that translate them into such instructions) - it is a
specification of the data model. If the pattern statement allows values
that are actually invalid, the specification is incorrect.

I.e. I'm with your original comment - if you can't get it right, leave
it out. "Under-specification" will always exist, and is acceptable in my
opinion. Specification that gives the appearance of being complete
(admittedly this is also subjective), but actually isn't, is not (in my
opinion).

--Per

> I agree with Rob that the pattern in draft-ietf-rtgwg-routing-types-09 is complicated to read. I have the feeling the design can be improved without compromising the strictnes of the data type. 
> Redefinig the typedef as a union of 5 string based types with seperate strict patterns is one suggestion for moving logic from the string type to YANG.
> 
> Vladimir
>> /js
>>
> 
> _______________________________________________
> netmod mailing list
> netmod@ietf.org
> https://www.ietf.org/mailman/listinfo/netmod