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 14:21 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 6170A132C21 for <netmod@ietfa.amsl.com>; Wed, 23 Aug 2017 07:21:47 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -7
X-Spam-Level:
X-Spam-Status: No, score=-7 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] 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 FSa-AqRpsfm7 for <netmod@ietfa.amsl.com>; Wed, 23 Aug 2017 07:21:43 -0700 (PDT)
Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (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 4803D13294B for <netmod@ietf.org>; Wed, 23 Aug 2017 07:21:43 -0700 (PDT)
Received: from birdie (unknown [IPv6:2001:718:1a02:1::380]) by mail.nic.cz (Postfix) with ESMTPSA id 6D2BA60E84 for <netmod@ietf.org>; Wed, 23 Aug 2017 16:21:40 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1503498100; bh=UZezoI2TKkQ/mMEYgskBY68WLFaWNzLX/8NOyeN5dXE=; h=From:To:Date; b=eSbCwNFfcbpxu3bGFoz1k72/S0uYd+UQLNPjzdLkFqFMXmlRorvGTqryDX1BonZFT Tk129q4NEb7zwRTUXdt1T80mmsCqAv7QO1+H7UHJqs2F1ge/D1fEW4kbButOwFckBi Oitca2+iXKq2Vinqskyvg02GE+/+/CpTVARWQ62Q=
Message-ID: <1503498125.32530.12.camel@nic.cz>
From: Ladislav Lhotka <lhotka@nic.cz>
To: netmod@ietf.org
Date: Wed, 23 Aug 2017 16:22:05 +0200
In-Reply-To: <20170823133657.76s5wbcxbpgjfkiy@elstar.local>
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>
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/vjPj4vQHB2h-kEHKsBBT86jeK1c>
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 14:21:47 -0000

Juergen Schoenwaelder píše v St 23. 08. 2017 v 15:36 +0200:
> 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.
> 
> > 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?
> 
> > 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:
> 
>    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.

Either way, the regex must not produce false negatives, i.e. reject valid
values. For some regexes this is what makes them complicated.

Also, I don't see any need for replacing existing patterns unless they are
wrong. We have descriptions to tell human readers about the permitted value set.

Lada

> 
> /js
> 
-- 
Ladislav Lhotka
Head, CZ.NIC Labs
PGP Key ID: 0xB8F92B08A9F76C67