[Cbor] Referencing external files/URLs from CBOR diagnostic notation

Carsten Bormann <cabo@tzi.org> Sun, 25 February 2024 13:34 UTC

Return-Path: <cabo@tzi.org>
X-Original-To: cbor@ietfa.amsl.com
Delivered-To: cbor@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 6F5E0C14CE22 for <cbor@ietfa.amsl.com>; Sun, 25 Feb 2024 05:34:22 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.206
X-Spam-Level:
X-Spam-Status: No, score=-4.206 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham 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 nFK5Nc2DDONl for <cbor@ietfa.amsl.com>; Sun, 25 Feb 2024 05:34:18 -0800 (PST)
Received: from smtp.zfn.uni-bremen.de (smtp.zfn.uni-bremen.de [134.102.50.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 6E832C14F6ED for <cbor@ietf.org>; Sun, 25 Feb 2024 05:34:16 -0800 (PST)
Received: from eduroam-0148.wlan.uni-bremen.de (eduroam-0148.wlan.uni-bremen.de [134.102.16.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.zfn.uni-bremen.de (Postfix) with ESMTPSA id 4TjPqB0FXLzDCcB; Sun, 25 Feb 2024 14:34:14 +0100 (CET)
From: Carsten Bormann <cabo@tzi.org>
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-Mao-Original-Outgoing-Id: 730560853.408968-88def563fdc1f129990270c03f988622
Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\))
Date: Sun, 25 Feb 2024 14:34:13 +0100
Message-Id: <C88928A2-5B49-45CB-82B2-35FCA804D64B@tzi.org>
To: cbor@ietf.org
X-Mailer: Apple Mail (2.3608.120.23.2.7)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/wLmzb9OfARwVUoZnhuFiRhwrP58>
Subject: [Cbor] Referencing external files/URLs from CBOR diagnostic notation
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <cbor.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cbor>, <mailto:cbor-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor/>
List-Post: <mailto:cbor@ietf.org>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cbor>, <mailto:cbor-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sun, 25 Feb 2024 13:34:22 -0000


In the context of discussing the module structure for CDDL, Ned Smith
has pointed out that a way to reference external files/URLs might
be useful for CBOR diagnostic notation as well.

Now, fortunately, this is right within the reach of application extensions:

    [1, 2, ref'http://tzi.de/~cabo/123.diag']

123.diag is a file containing

    [1, 2, 3]

so the result is

    [1, 2, [1, 2, 3]]

(Unfortunately, the same extension point does not work for splicing in CBOR sequences, so if a referenced file parses as a CBOR sequence this is currently treated as an error.)

I have implemented a proof of concept in the cbor-diag-ref gem.

    gem install cbor-diag-ref

To use the PoC with the cbor-diag gem, you need to explicitly add the "ref" application extension, e.g., by giving `-aref` to the diag2x.rb commands:

$ echo "[1, 2, ref'http://tzi.de/~cabo/123.diag']" >my.diag
$ diag2diag.rb -aref my.diag
[1, 2, [1, 2, 3]]

➔ Is this application extension useful?
➔ Do we want to enable use of other external forms beyond diagnostic mode (cbor-pretty == hex; actual binary CBOR)?

(Note that this proof of concept does NO SANITIZING of URLs or file names at all; to make this a permanent addition to EDN, we’d need to think about the right restrictions for external references like this.)

Grüße, Carsten