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

Ladislav Lhotka <lhotka@nic.cz> Wed, 23 August 2017 20:36 UTC

Return-Path: <lhotka@nic.cz>
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 384941326FE for <netmod@ietfa.amsl.com>; Wed, 23 Aug 2017 13:36:52 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -6.999
X-Spam-Level:
X-Spam-Status: No, score=-6.999 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_HI=-5, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=nic.cz
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 dMdN6DJChQps for <netmod@ietfa.amsl.com>; Wed, 23 Aug 2017 13:36:43 -0700 (PDT)
Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 6A17A120720 for <netmod@ietf.org>; Wed, 23 Aug 2017 13:36:43 -0700 (PDT)
Received: from birdie (unknown [IPv6:2a01:5e0:29:ffff:ffc6:c393:cdb9:8db1]) by mail.nic.cz (Postfix) with ESMTPSA id 75F67608F3 for <netmod@ietf.org>; Wed, 23 Aug 2017 22:36:41 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1503520601; bh=4JEgeEcOFwxwwWAG/vjtlr3wWEDosKN89lB9ykPaS5g=; h=From:To:Date; b=RJk8UdtQE+gN0EwdDQZnQpOa7HCzYl+ltFdH2ibfZh+CCdsC4oxexTP4owFuyNjux bQ4oKixN/vnQTc34BYuRxxekmX7VJSW/SnXEXRdrjY4ejwN8BP6TaOWgZ/LKFRZLrU UJkXJBxLYrVo8V6M3SFWAW/7jkAFZo0Gp1ZlfrSs=
Message-ID: <1503520626.8890.6.camel@nic.cz>
From: Ladislav Lhotka <lhotka@nic.cz>
To: netmod@ietf.org
Date: Wed, 23 Aug 2017 22:37:06 +0200
In-Reply-To: <f9602344-4801-35a1-08f8-faafcc959043@tail-f.com>
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> <f9602344-4801-35a1-08f8-faafcc959043@tail-f.com>
Organization: CZ.NIC
Content-Type: text/plain; charset="UTF-8"
X-Mailer: Evolution 3.24.5
Mime-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Virus-Scanned: clamav-milter 0.99.2 at mail
X-Virus-Status: Clean
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/K2g7ElKFFIQF6XwraMd46Gu3gO4>
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:36:52 -0000

Per Hedeland píše v St 23. 08. 2017 v 22:03 +0200:
> 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).

I completely agree.

Lada

> 
> --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
> 
> _______________________________________________
> netmod mailing list
> netmod@ietf.org
> https://www.ietf.org/mailman/listinfo/netmod
-- 
Ladislav Lhotka
Head, CZ.NIC Labs
PGP Key ID: 0xB8F92B08A9F76C67