Re: [Cbor] Failure Testcases (was: RE: Simple Value Example)

Joe Hildebrand <jhildebrand@mozilla.com> Wed, 30 January 2019 20:08 UTC

Return-Path: <jhildebrand@mozilla.com>
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 7419A130FCF for <cbor@ietfa.amsl.com>; Wed, 30 Jan 2019 12:08:41 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2
X-Spam-Level:
X-Spam-Status: No, score=-2 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_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=mozilla.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 paCARP66nPqp for <cbor@ietfa.amsl.com>; Wed, 30 Jan 2019 12:08:39 -0800 (PST)
Received: from mail-it1-x141.google.com (mail-it1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 3CD24130E58 for <cbor@ietf.org>; Wed, 30 Jan 2019 12:08:39 -0800 (PST)
Received: by mail-it1-x141.google.com with SMTP id p197so362307itp.0 for <cbor@ietf.org>; Wed, 30 Jan 2019 12:08:39 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mozilla.com; s=google; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=Hs8hqLWMwGZRIVe8VvZE/zCA935EpQNMJJKwYe6aL00=; b=JVcm1uQ3E8MPI2qAHJLao14/JaZHJk0442X6P/nL2UUBHfV7iAXL5aa+TiG2LpPOKz FKT4wfvccL2KtrTyPzJeR7KrhGfjznF0BA4uoP9efpeooyK39XzXQ8E6RO9GvQOvWnGA jJYPT/4BCQmfUGiAnxxdjCD0mSN+R5bTuHzQg=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=Hs8hqLWMwGZRIVe8VvZE/zCA935EpQNMJJKwYe6aL00=; b=XsQgUhUuICOQQSpngSBdgJ6jRCksNdpSMgaYMaSIvW2ituM5kNX32kmed1bpGdPbYD XjdyvBD/xpyGmitNXxd7wAWtBh0P7unOrIn57x1C9PkBMIJzUckxtT0m4HVq04Do7iAC KJS5sknkLds1lWGdyYGh5/hTl7SCG+A5UEQU7HFC0sC6oOxZ5c9v5CFQmoY6kGNKiYiN 6vtDZDV6nnXEmmmERV4EOfZgeUrdiHtrORJhVqd4xbU8KGXTB4iZ6cjFab0MLt4QH/Wv ElCr9j5DmSaxDcf+8npI++R3OZNWXWfDDH7HHnWAftfB86EfLQK+LG2jo9wr1GH51WPw dtEg==
X-Gm-Message-State: AJcUukch1SaCLk0VJ2DH1njwTjV7hlCMq68gs6NQlPpvGK/1T1ZcpIIw J/cAWrZ8njWJa7dQwcMck6XD5A==
X-Google-Smtp-Source: ALg8bN57DheT6vCNB3LgIa1BI4sfNewpMe5Y/rq4Jay8by1OxUfIQZ+fx2Ggn2q7LtbWN4paKm3HXQ==
X-Received: by 2002:a02:a714:: with SMTP id k20mr20429853jam.63.1548878918458; Wed, 30 Jan 2019 12:08:38 -0800 (PST)
Received: from [10.6.17.71] ([128.177.113.102]) by smtp.gmail.com with ESMTPSA id w1sm1035917iop.14.2019.01.30.12.08.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jan 2019 12:08:37 -0800 (PST)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\))
From: Joe Hildebrand <jhildebrand@mozilla.com>
In-Reply-To: <3da886c762564d20a75796733ec73e23@pdv-FS.de>
Date: Wed, 30 Jan 2019 13:08:36 -0700
Cc: Carsten Bormann <cabo@tzi.org>, "cbor@ietf.org" <cbor@ietf.org>
Content-Transfer-Encoding: quoted-printable
Message-Id: <2DA01321-4261-46B1-8FDA-01E7FF8A1EC3@mozilla.com>
References: <3da886c762564d20a75796733ec73e23@pdv-FS.de>
To: "\"Richter, Jörg\"" <Joerg.Richter@pdv-FS.de>
X-Mailer: Apple Mail (2.3445.102.3)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/ONjSFfVistD9en-2rCpEa0Wx6IE>
Subject: Re: [Cbor] Failure Testcases (was: RE: Simple Value Example)
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.29
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: Wed, 30 Jan 2019 20:08:42 -0000

Fantastic.  I already see a couple of places I need to check from this.  PR to the test-vectors project here:

https://github.com/cbor/test-vectors/pull/5

That's just a quick JSONification of your list.


> On Jan 30, 2019, at 5:55 AM, Richter, Jörg <Joerg.Richter@pdv-FS.de> wrote:
> 
>>> BTW: Is there a collection of “corrupt” CBOR messages that must produce
>>> a decode error?
>> 
>> We have talked about this:
>> 
>> https://github.com/cbor-wg/CBORbis/issues/16
>> 
>> But so far nobody has started collecting instances.
>> Do you have some we could start with?
>> I was planning to scan some of the open source CBOR packages for tests of
>> failing decoding.
> 
> Okay. I've been thinking about it for a while.
> 
> One set of test cases can be easily constructed from valid test cases. 
> Just decode a prefix of a valid test case and the decoder should fail with 
> an "end of message" error.  Just generate them during normal testing.
> 
> I think a second set of failing test cases can be constructed by just 
> considering which CBOR prefixes are invalid. This test cases should of course 
> fail with a different error than "end of message".
> 
> I wrote and attached a simple Lua script to generate all invalid 1 and 2 byte 
> prefixes.
> 
> This script outputs 578 test cases.  Also attached.
> 
> Another set of test cases can be constructed when using tags.  But I think
> this is more involved and not clearly defined.  But I might be wrong.
> Consider for example a bigfloat. Is it allowed that the array elements themselves
> are using a tag?  
> 
> Or what if a tag is followed by an element that is not allowed for this tag.  
> Like following a tag for a set (tag=258) with a string instead of an array?  Should this 
> cause a decode error?
> 
> Or is it allowed that Tag 55799 (0xd9d9f7) is the only content of a CBOR file?
> 
> - Jörg
> 
> <generate.lua><fail.txt>_______________________________________________
> CBOR mailing list
> CBOR@ietf.org
> https://www.ietf.org/mailman/listinfo/cbor