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

Robert Wilton <rwilton@cisco.com> Wed, 23 August 2017 16:58 UTC

Return-Path: <rwilton@cisco.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 61FE113208E for <netmod@ietfa.amsl.com>; Wed, 23 Aug 2017 09:58:47 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -14.501
X-Spam-Level:
X-Spam-Status: No, score=-14.501 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, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=cisco.com
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 pNaXKFK0LEo2 for <netmod@ietfa.amsl.com>; Wed, 23 Aug 2017 09:58:46 -0700 (PDT)
Received: from aer-iport-3.cisco.com (aer-iport-3.cisco.com [173.38.203.53]) (using TLSv1.2 with cipher DHE-RSA-SEED-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id B9419132025 for <netmod@ietf.org>; Wed, 23 Aug 2017 09:58:45 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2219; q=dns/txt; s=iport; t=1503507525; x=1504717125; h=subject:to:references:from:message-id:date:mime-version: in-reply-to:content-transfer-encoding; bh=UL7jgJPDG/BUQnuZyntcAJWo3Xh0+G1rsoqTdgYQ9CM=; b=FAp4qYbLObhvAZHaJ2/CXo041TzISL/PFg5gts/CEhT3rsHkpoj31N2p j+KywK4DSUd7fJ38J13zctwCwbnLxyVy+JhzIOgIEcy/hDdhB+QFLULea ONpMIqr9Mp17fckeFBP0QRPxREIhasqYx/Ije4tLfYrz6Id9+K/NJYZtQ o=;
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: A0DiAQDOsp1Z/xbLJq1aAxoBAQEBAgEBAQEIAQEBAZRbkReWMoIEhUcChQkUAQIBAQEBAQEBayiFGAEBAQECASMPAQVGCwkCGAICJgICVwYBDAgBAYolCJJdnWaCJothAQEBAQEBAQMBAQEBAQEBASCBDYIdg06CDoFwWDSEQAESAUAmgkyCYQWgWIsriRmCEok8JIZyjT6IcDYhfwsyIQgcFUmFTIFPP4h4DRcHghQBAQE
X-IronPort-AV: E=Sophos;i="5.41,417,1498521600"; d="scan'208";a="655164329"
Received: from aer-iport-nat.cisco.com (HELO aer-core-4.cisco.com) ([173.38.203.22]) by aer-iport-3.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Aug 2017 16:58:41 +0000
Received: from [10.63.23.66] (dhcp-ensft1-uk-vla370-10-63-23-66.cisco.com [10.63.23.66]) by aer-core-4.cisco.com (8.14.5/8.14.5) with ESMTP id v7NGwfWq018232; Wed, 23 Aug 2017 16:58:41 GMT
To: Ladislav Lhotka <lhotka@nic.cz>, 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> <1503498125.32530.12.camel@nic.cz>
From: Robert Wilton <rwilton@cisco.com>
Message-ID: <c7190863-4cfb-9d97-79c2-589d75d17814@cisco.com>
Date: Wed, 23 Aug 2017 17:58:41 +0100
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1
MIME-Version: 1.0
In-Reply-To: <1503498125.32530.12.camel@nic.cz>
Content-Type: text/plain; charset="utf-8"; format="flowed"
Content-Transfer-Encoding: 8bit
Content-Language: en-US
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/_81g2u48ztdXBHSC30XWge0dn1o>
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 16:58:47 -0000


On 23/08/2017 15:22, Ladislav Lhotka wrote:
> 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.
I agree.

>
> Also, I don't see any need for replacing existing patterns unless they are
> wrong.
I also agree.  I'm not trying to retroactively change existing regexes, 
just tweak the guidance when new regexes are being constructed so that 
they end up being a bit simpler.

Thanks,
Rob


>   We have descriptions to tell human readers about the permitted value set.
>
> Lada
>
>> /js
>>