Subject: [netmod] Printable or visible string in YANG

From: Balázs Lengyel <[email-masked]>
Date: Mon, 18 Oct 2021 10:11:05 +0000

Hello,

Is there a way in YANG to restrict a string to printable or visible
characters? (Something like SNMP DisplayString)

Regards Balazs

-- 

Balazs Lengyel                    Senior Specialist
Ericsson Hungary Ltd. 

Mobile: +36-70-330-7909              email: [email-masked]

---

From: Ladislav Lhotka <[email-masked]>
Date: Mon, 18 Oct 2021 13:24:53 +0200

Hi Balazs,

Unicode (if you mean it) is so convoluted that the notion of 
printable/visible characters doesn't make much sense. It is IMO much 
safer to specify character classes that you want to permit.

Lada

On 18. 10. 21 12:11, Balázs Lengyel wrote:
> Balazs Lengyel                    Senior 
> Specialist                       Ericsson Hungary Ltd.
> 
> _______________________________________________
> netmod mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/netmod
> 

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

---

From: Jan Lindblad <[email-masked]>
Date: Tue, 19 Oct 2021 09:06:29 +0200

Hi Balazs,

And don't forget that in YANG 1.1 you can exclude characters.

type string {
  pattern ".*\n.*" { modifier invert-match; } // Disallow newline characters
  pattern ".*\r.*" { modifier invert-match; } // Disallow carriage return characters
}

/jan

> On 18 Oct 2021, at 13:24, Ladislav Lhotka <[email-masked]> wrote:
> 
> Hi Balazs,
> 
> Unicode (if you mean it) is so convoluted that the notion of printable/visible characters doesn't make much sense. It is IMO much safer to specify character classes that you want to permit.
> 
> Lada
> 
>> Is there a way in YANG to restrict a string to printable or visible characters? (Something like SNMP DisplayString)
>> Regards Balazs
>> -- 
>> Balazs Lengyel                    Senior Specialist                       Ericsson Hungary Ltd.

---

From: Ladislav Lhotka <[email-masked]>
Date: Tue, 19 Oct 2021 09:57:33 +0200

>    pattern ".*\r.*" { modifier invert-match; } // Disallow carriage return characters

It is also worth noting that in fact (sec. 9.4 in RFC 7950) "The string 
built-in type represents human-readable strings in YANG." This may 
possibly be what Balazs wants, although I doubt that there is an 
implementation that can really *print* all such strings.

Lada

---

From: Jan Lindblad <[email-masked]>
Date: Tue, 19 Oct 2021 11:38:21 +0200

Magnus,

You could define your own type and write what you say below in the description. It may not be important to construct a YANG pattern that captures X.680 exactly. Your server (and client) implementations can still reject transactions containing illegal characters based on the description.

Best Regards,
/jan

> The ask from Balázs originated from me who noticed that we in 3GPP have defined some parameters in interfaces to conform to ASN.1 visible and printable strings. Then in specification of IOCs specified that the IOC attributes should conform to the visible and printable string formats defined in ITU-T X.680, but when defined in Yang a normal string type was accidentally used allowing any char to be injected.
> My simple ask was then whether there already exist standardized yang types for the string types defined in ITU-T X.680, or if we should propose such types to be defined (and then of course used in the 3GPP provided Yang files).
> 
> It is of course good the Yang language is supportive to define custom types. Then it is "just do it", which is easier said than done, impacting a significant set or already released 3GPP released yang files.
> BR Magnus
> 
> -----Original Message-----
> From: Ladislav Lhotka <[email-masked]> 
> Sent: den 19 oktober 2021 09:58
> To: Jan Lindblad <[email-masked]>; Balázs Lengyel <balazs.lengyel=[email-masked]>
> Cc: [email-masked]; Magnus Standar <[email-masked]>
> Subject: Re: [netmod] Printable or visible string in YANG
> 
>>   pattern ".*\r.*" { modifier invert-match; } // Disallow carriage 
>> return characters }
> 
> It is also worth noting that in fact (sec. 9.4 in RFC 7950) "The string built-in type represents human-readable strings in YANG." This may possibly be what Balazs wants, although I doubt that there is an implementation that can really *print* all such strings.
> 
> Lada
> 
>> 
>> /jan
>> 
>> 
>> 
>>>> characters? (Something like SNMP DisplayString) Regards Balazs
>>>> --