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:56 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 C6A0E132113 for <netmod@ietfa.amsl.com>; Wed, 23 Aug 2017 09:56:05 -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 8qeJ6szYxD-3 for <netmod@ietfa.amsl.com>; Wed, 23 Aug 2017 09:56:04 -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 D164E13208E for <netmod@ietf.org>; Wed, 23 Aug 2017 09:56:03 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2319; q=dns/txt; s=iport; t=1503507363; x=1504716963; h=subject:to:references:from:message-id:date:mime-version: in-reply-to:content-transfer-encoding; bh=1K8A77SKHJnA5D+eF2AYsyi1nr417k6FBHe9jvrbRVo=; b=gBj9uwGg285E/JEin/TA7N6oEOebS8lYpJRan6j7JnZIKJ8lw4G61LLT zib/P3e7HLw0i/g3ijn5Y0i4oinBA1kHXJ1pEoSED7dw5zgMlfpvhJCfl nrR/lIA4YgIUUWStaGVCE5LeUO9NL1568fV64DN9DeC09gOU/wIbnRPoS Q=;
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: A0DjAQDOsp1Z/xbLJq1aAxoBAQEBAgEBAQEIAQEBAYMtkS6RF5YyggSFRwKFCRQBAgEBAQEBAQFrHQuFGAEBAQECASMVUQsYAgImAgJXBg0IAQGKJQiwQ4Imi2EBAQEBAQEBAwEBAQEBAQEhgQ2CHYNOgg6BcFg0hEABEgFAJoJMgmEFoFiLK4kZghKJPCSGco0+iHA2IX8LMiEIHBVJhUyBTz+IeA0XB4IUAQEB
X-IronPort-AV: E=Sophos;i="5.41,417,1498521600"; d="scan'208";a="655164264"
Received: from aer-iport-nat.cisco.com (HELO aer-core-3.cisco.com) ([173.38.203.22]) by aer-iport-3.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Aug 2017 16:55:59 +0000
Received: from [10.63.23.66] (dhcp-ensft1-uk-vla370-10-63-23-66.cisco.com [10.63.23.66]) by aer-core-3.cisco.com (8.14.5/8.14.5) with ESMTP id v7NGtxhr019676 for <netmod@ietf.org>; Wed, 23 Aug 2017 16:55:59 GMT
To: "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>
From: Robert Wilton <rwilton@cisco.com>
Message-ID: <1dc6969a-af55-e28a-447f-ad5092d26ec1@cisco.com>
Date: Wed, 23 Aug 2017 17:55:59 +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: <20170823133657.76s5wbcxbpgjfkiy@elstar.local>
Content-Type: text/plain; charset="utf-8"; format="flowed"
Content-Transfer-Encoding: 7bit
Content-Language: en-US
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/eXqUYPdg8JT48CTsSCqx5-dBpHU>
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:56:06 -0000


On 23/08/2017 14:36, 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.
My definition of 'better' is:
- is relatively easy for a human to read/review.
- doesn't exclude any valid values.
- doesn't check numerical ranges, only the number of digits.
- is simple enough to trivially work with most normal regex engines.
- otherwise the pattern is as strict as possible given the constraints 
above.

>
>> 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?
My point is only that it is very easy to produce invalid config that 
passes whatever regex is used so it is better to produce a simpler and 
more human readable regex rather than expand it to perform range 
checking of numerical values as well.

>
>> 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.
I partly agree, but the line of where I would define a regex as being 
too complicated may be different from you ;-).

Thanks,
Rob

>
> /js
>