Re: [Anima] how to describe JSON examples

Toerless Eckert <tte@cs.fau.de> Wed, 19 July 2023 15:21 UTC

Return-Path: <eckert@i4.informatik.uni-erlangen.de>
X-Original-To: anima@ietfa.amsl.com
Delivered-To: anima@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 269C1C15152D; Wed, 19 Jul 2023 08:21:48 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.649
X-Spam-Level:
X-Spam-Status: No, score=-1.649 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=no autolearn_force=no
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7qOcNpU1miYb; Wed, 19 Jul 2023 08:21:46 -0700 (PDT)
Received: from faui40.informatik.uni-erlangen.de (faui40.informatik.uni-erlangen.de [IPv6:2001:638:a000:4134::ffff:40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 5BAACC15109B; Wed, 19 Jul 2023 08:21:44 -0700 (PDT)
Received: from faui48e.informatik.uni-erlangen.de (faui48e.informatik.uni-erlangen.de [IPv6:2001:638:a000:4134::ffff:51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by faui40.informatik.uni-erlangen.de (Postfix) with ESMTPS id 4R5fg874GKznkVT; Wed, 19 Jul 2023 17:21:40 +0200 (CEST)
Received: by faui48e.informatik.uni-erlangen.de (Postfix, from userid 10463) id 4R5fg86WdczkwTc; Wed, 19 Jul 2023 17:21:40 +0200 (CEST)
Date: Wed, 19 Jul 2023 17:21:40 +0200
From: Toerless Eckert <tte@cs.fau.de>
To: Carsten Bormann <cabo@tzi.org>
Cc: Michael Richardson <mcr+ietf@sandelman.ca>, anima@ietf.org, jose@ietf.org
Message-ID: <ZLf/hB4kmv4OkLPV@faui48e.informatik.uni-erlangen.de>
References: <11058.1689694682@localhost> <66E50E08-A941-456A-9916-FFBA20531B8C@tzi.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <66E50E08-A941-456A-9916-FFBA20531B8C@tzi.org>
Archived-At: <https://mailarchive.ietf.org/arch/msg/anima/Mp1VYfuRD3NRtg2I8M4Lp7EWuzU>
Subject: Re: [Anima] how to describe JSON examples
X-BeenThere: anima@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: Autonomic Networking Integrated Model and Approach <anima.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/anima>, <mailto:anima-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/anima/>
List-Post: <mailto:anima@ietf.org>
List-Help: <mailto:anima-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/anima>, <mailto:anima-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 19 Jul 2023 15:21:48 -0000

Carsten:

The way i see it, the underlying issue seems to be that most IETF specs that
use JSON seem to be happy in specifying their JSON objects without formal
specification of their JSON objects in CDDL. 

For example, i walk through the list of drafts/RFCs referencing RFC7515
(JSON Web Signatures), pick random documents and look for CDDL or other
formal specs of the JSON objects. And i at least didn't find any. Of course,
there may be some, but i would be surprised if we had an actually adoped
practice that says "RFCs that specify JSON structures MUST use a formal
language such as CDDL to define them". 

> > "payload": BASE64URL(ietf-voucher:voucher),
> I don’t know what ietf is, from which voucher:voucher is subtracted; can’t even parse the : without a ? around.

You're too fast. I stilll need to understand this rfc791 spec from 1981:

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |Version|  IHL  |Type of Service|          Total Length         |

I still have not figured out how to add and subtract all those numbers.
I think the result must be 42 though.

Aka: we do have a pretty successful history with make-it-up-as-you-go
(in)formal specifications. And i think such BASE64URL format
falls well into that domain. Of course, we do want to make these as
self-explanatory and self-descriptive as possible and add explanatory text
where they're not.

Cheers
    toerless

On Wed, Jul 19, 2023 at 08:56:05AM +0200, Carsten Bormann wrote:
> On 18. Jul 2023, at 17:38, Michael Richardson <mcr+ietf@sandelman.ca> wrote:
> > 
> > 
> > In the JWS I-D, we have some JSON that is an example.
> > And the content within is BASE64URL encoded.
> > We could, I think, describe this in CDDL, but we aren't trying to be
> > authoritative. (It's a JOSE example)
> 
> OK, CDDL describes possible sentences in the language, while you seem to be trying to express a single example, with input parameters and some processing.

Right. the actual 
> 
> CBOR diagnostic notation is getting some features for application-specific literals, but so far we didn’t really make it compute (or take parameters).
> We could try to import CDDL operators for the compute.
> (And describe how to use CBOR diagnostic notation to compute JSON, but that is trivial given Section 6.1 of RFC 8949.)
> 
> > We are struggling with quoting.  We could write:
> > 
> > "payload": "BASE64URL(ietf-voucher:voucher)",
> 
> Well, what is the point of the example?
> If it is only for illustration, this would work with some text added about what this means.
> If it is intended to specify the outcome, we would need some of the above.
> 
> > which would make it valid JSON, with the literal contents.
> 
> Yes, so you could validate it as JSON, but then the literal contents really are a misrepresentation.
> (If validation is about catching missing commas, this is still useful.)
> 
> > Or we could write:
> > 
> > "payload": BASE64URL(ietf-voucher:voucher),
> 
> Which one could no longer parse, and there would be no meaning right now except as pseudocode.
> 
> > which sorta makes it valid Javascript, assuming such a function existed.
> 
> I don’t know what ietf is, from which voucher:voucher is subtracted; can’t even parse the : without a ? around.
> 
> > here is an example with both variations:
> > 
> >    {
> >      "payload": BASE64URL(ietf-voucher:voucher),
> >      "signatures": [
> >        {
> >          "protected": "BASE64URL(UTF8(JWS Protected Header))",
> >          "signature": "base64encodedvalue=="
> >        }
> >      ]
> >    }
> 
> What is UTF8()?  Do you mean the equivalent of JSON.stringify?
> 
> I summary, these “recipes” are interesting, and we have some 90 % of what we need.
> Maybe we can have a short brainstorming session at IETF 117 Hackathon.
> 
> Grüße, Carsten
> 

-- 
---
tte@cs.fau.de