cabo / cbor-diag

CBOR diagnostic utilities
55 stars 10 forks source link

using cbor2diag on damaged data #9

Open mcr opened 6 years ago

mcr commented 6 years ago

{{{ dooku-projects/pandora/fountain mcr 10006 %cbor2diag.rb tmp/ff1.cbor
/usr/local/rvm/gems/ruby-2.3.0/gems/cbor-diag-0.2.5/lib/cbor-pure.rb:193:in `take': Out of bytes to decode: 290 (CBOR::OutOfBytesError) }}}

So something has truncated my CBOR, pretty sad for me, and I'm debugging it. I wonder if there is someway that cbor2diag could show me what it does have, and at which point the shortage of data has occured?

cabo commented 6 years ago

How about

dd if=/dev/zero bs=4711 count=1 >> tmp/ff1.cbor
cborseq2yaml.rb tmp/ff1.cbor

OK, this needs some work on the user interface side, but it does give you some hints what's in there.

cabo commented 6 years ago

Slightly cleaned up:

(cat tmp/ff1.cbor; ruby -e 'print 247.chr*333') | cborseq2yaml.rb

(Probably redirect that somewhere so you can more easily ignore the junk at the end.)

cabo commented 6 years ago

Just pushed 0.5.5 with a "cborleader2diag.rb" so you have less junk to look at:

(cat tmp/ff1.cbor; ruby -e 'print 247.chr*333') | cborleader2diag.rb

I may have to consolidate all these little tool-lets at some point...