cddl 0.11.3 → 0.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/cddl.gemspec +1 -1
- data/lib/cddl.rb +103 -11
- data/test-data/b64u-strict.cddl +10 -0
- data/test-data/cat-re.cddl +2 -0
- data/test-data/catb64.cddl +8 -0
- data/test-data/enum.cddl +14 -0
- data/test-data/enum1.cddl +12 -0
- data/test-data/json1.cddl +15 -0
- data/test-data/jwt.cddl +15 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 652f1e63847fbed19fceeca1ed0b695b25b5f8aa6d312b2bd17f21c0ac7c6549
|
4
|
+
data.tar.gz: d55f4a0bff69a37b1c6101b11eb003eb93c00df24ede1dded8d7be9844b4afb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6622daf044d0f5a6d0ce4fe90ac57341526f7723aef0ce49e228edd2284711a44302ab0c3a1a28e3e156676db61afb4477a9b97b27269e1509034c41796ca8b9
|
7
|
+
data.tar.gz: 966fd633edc283925e0e4bbb5ca04cb40de60470044bbbd94e7df41fb05c185f59ff09ae4767d5dea2899491d3f82db50d3feb01a585fe03891d60f073e50557
|
data/cddl.gemspec
CHANGED
data/lib/cddl.rb
CHANGED
@@ -747,7 +747,7 @@ module CDDL
|
|
747
747
|
end
|
748
748
|
elsif t[0] == :anno
|
749
749
|
_, conop, target, control = t
|
750
|
-
|
750
|
+
warn ["EXV0", conop, target, control].inspect if ENV["CDDL_TRACE"]
|
751
751
|
if conop == :cat || conop == :plus || conop == :det
|
752
752
|
ok1, v1, vt1 = extract_value(target)
|
753
753
|
ok2, v2, vt2 = extract_value(control)
|
@@ -980,6 +980,19 @@ module CDDL
|
|
980
980
|
}
|
981
981
|
end
|
982
982
|
|
983
|
+
def validate1a_ignore_encoding(d, where)
|
984
|
+
if String === d
|
985
|
+
validate1a(d.force_encoding(Encoding::BINARY), where) or (
|
986
|
+
text = d.force_encoding(Encoding::UTF_8).scrub {
|
987
|
+
fail "can't use bytes as text"
|
988
|
+
} rescue :NOT_A_TEXT_STRING
|
989
|
+
validate1a(text, where)
|
990
|
+
)
|
991
|
+
else
|
992
|
+
validate1a(d, where)
|
993
|
+
end
|
994
|
+
end
|
995
|
+
|
983
996
|
def validate1a(d, where)
|
984
997
|
if ann = validate1(d, where)
|
985
998
|
here = [d, where]
|
@@ -1039,7 +1052,7 @@ module CDDL
|
|
1039
1052
|
if conop == :cat || conop == :plus || conop == :det
|
1040
1053
|
ok1, v1, vt1 = extract_value(target)
|
1041
1054
|
ok2, v2, vt2 = extract_value(control)
|
1042
|
-
|
1055
|
+
warn ["ANNO0", ok1, v1, vt1, ok2, v2, vt2, d].inspect if ENV["CDDL_TRACE"]
|
1043
1056
|
if ok1 && ok2
|
1044
1057
|
v2 = Integer(v2) if vt1 == Integer
|
1045
1058
|
if conop == :det
|
@@ -1048,6 +1061,24 @@ module CDDL
|
|
1048
1061
|
end
|
1049
1062
|
# warn ["ANNO", ok1, v1, vt1, ok2, v2, vt2, d].inspect
|
1050
1063
|
[] if d == v1 + v2 # XXX Focus ArgumentError
|
1064
|
+
elsif conop == :cat && String === d
|
1065
|
+
warn ["CAT-L", ok1, v1, vt1, ok2, v2, vt2, d].inspect if ENV["CDDL_TRACE"]
|
1066
|
+
if ok1 && vt1 == String
|
1067
|
+
# d and lhs (v1) need to agree in encoding
|
1068
|
+
if d.encoding == v1.encoding
|
1069
|
+
if d[0...v1.length] == v1
|
1070
|
+
d2 = d[v1.length..-1]
|
1071
|
+
warn ["CAT-L1", d2, d2.encoding, control].inspect if ENV["CDDL_TRACE"]
|
1072
|
+
validate1a_ignore_encoding(d2, control)
|
1073
|
+
end
|
1074
|
+
end
|
1075
|
+
elsif ok2 && vt2 == String
|
1076
|
+
warn ["CAT-R", ok1, v1, vt1, ok2, v2, vt2, d].inspect if ENV["CDDL_TRACE"]
|
1077
|
+
if d[-v2.length..-1] == v2
|
1078
|
+
d1 = d[0...-v2.length]
|
1079
|
+
validate1a(d1, control)
|
1080
|
+
end
|
1081
|
+
end
|
1051
1082
|
elsif conop == :plus && Integer === d
|
1052
1083
|
if ok1 && vt1 == Integer
|
1053
1084
|
validate1a(d - Integer(v1), control)
|
@@ -1163,14 +1194,75 @@ module CDDL
|
|
1163
1194
|
end
|
1164
1195
|
)
|
1165
1196
|
when :join
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1197
|
+
t = control
|
1198
|
+
v = if t[0] == :array
|
1199
|
+
t[1..-1].map { |el|
|
1200
|
+
if el[0..2] == [:member, 1, 1]
|
1201
|
+
ok, v, vt = extract_value(el[4])
|
1202
|
+
if ok
|
1203
|
+
[true, v, vt]
|
1204
|
+
else
|
1205
|
+
[false, el[4]]
|
1206
|
+
end
|
1207
|
+
end
|
1208
|
+
}
|
1209
|
+
end
|
1210
|
+
warn "@@@JOIN@@@ #{v.inspect}" if ENV["CDDL_TRACE"]
|
1211
|
+
ok = true
|
1212
|
+
if v
|
1213
|
+
ix = 0
|
1214
|
+
rest = d.dup
|
1215
|
+
while ix < v.length
|
1216
|
+
if left = v[ix]
|
1217
|
+
if left[0] # match constant value first
|
1218
|
+
fail "Not a string for #{left.inspect} in #{where}" unless String == left[2]
|
1219
|
+
want = left[1]
|
1220
|
+
have = rest[0...left[1].length]
|
1221
|
+
if want == have
|
1222
|
+
rest[0...left[1].length] = ''
|
1223
|
+
ix += 1
|
1224
|
+
next
|
1225
|
+
else
|
1226
|
+
fail ".join: want #{want.inspect}, have #{have.inspect}"
|
1227
|
+
end
|
1228
|
+
else
|
1229
|
+
ix += 1
|
1230
|
+
if ix == v.length # match remaining
|
1231
|
+
warn "@@@JOIN ok in #{ok.inspect} rest #{rest.inspect}" if ENV["CDDL_TRACE"]
|
1232
|
+
ok &&= validate1(rest, left[1])
|
1233
|
+
warn "@@@JOIN ok out #{ok.inspect}" if ENV["CDDL_TRACE"]
|
1234
|
+
# more diag
|
1235
|
+
rest = ''
|
1236
|
+
next
|
1237
|
+
else
|
1238
|
+
if mid = v[ix]
|
1239
|
+
if mid[0] # have constant value to split over
|
1240
|
+
fail "Not a string for #{mid} in #{where}" unless String == mid[2]
|
1241
|
+
rest1, rest2 = rest.split(mid[1], 2)
|
1242
|
+
if rest2
|
1243
|
+
warn "@@@JOIN ok in #{ok.inspect} rest1 #{rest1.inspect}" if ENV["CDDL_TRACE"]
|
1244
|
+
ok &&= validate1(rest1, left[1])
|
1245
|
+
warn "@@@JOIN ok out #{ok.inspect}" if ENV["CDDL_TRACE"]
|
1246
|
+
rest = rest2
|
1247
|
+
ix += 1
|
1248
|
+
next
|
1249
|
+
else
|
1250
|
+
fail "Can't find #{mid[1].inspect} in #{rest.inspect}"
|
1251
|
+
end
|
1252
|
+
else
|
1253
|
+
fail "Cannot validate consecutive non-constant members of .join in #{where}"
|
1254
|
+
end
|
1255
|
+
else
|
1256
|
+
fail "Cannot handle .join over #{t[ix+1]} in #{where}"
|
1257
|
+
end
|
1258
|
+
end
|
1259
|
+
end
|
1260
|
+
else
|
1261
|
+
fail "Cannot handle .join over #{t[ix+1]} in #{where}"
|
1262
|
+
end
|
1263
|
+
end
|
1264
|
+
fail "Can't match #{rest.inspect} for .join in #{where}" if rest != ''
|
1265
|
+
ann if ok
|
1174
1266
|
else
|
1175
1267
|
fail "Don't know yet how to validate against #{where}"
|
1176
1268
|
end
|
@@ -1179,7 +1271,7 @@ module CDDL
|
|
1179
1271
|
String === d && (
|
1180
1272
|
decoded = case conop
|
1181
1273
|
when :b64u
|
1182
|
-
|
1274
|
+
/[+\/=]/ !~ d &&
|
1183
1275
|
Base64.urlsafe_decode64(d)
|
1184
1276
|
when :"b64u-sloppy"
|
1185
1277
|
/[-_=]/ !~ d &&
|
data/test-data/cat-re.cddl
CHANGED
data/test-data/enum.cddl
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
terminal-color = &basecolors
|
2
|
+
basecolors = (
|
3
|
+
black: 0, red: 1, green: 2, yellow: 3,
|
4
|
+
blue: 4, magenta: 5, cyan: 6, white: 7,
|
5
|
+
reserved: (8..255) .feature "extension"
|
6
|
+
)
|
7
|
+
; extended-color = &(
|
8
|
+
; basecolors,
|
9
|
+
; orange: 8, pink: 9, purple: 10, brown: 11,
|
10
|
+
; )
|
11
|
+
|
12
|
+
;;gp 10
|
13
|
+
;;vp 42
|
14
|
+
;;vp 433
|
@@ -0,0 +1,12 @@
|
|
1
|
+
terminal-color = $terminal-color / text .feature "extension"
|
2
|
+
$terminal-color /= &basecolors
|
3
|
+
basecolors = (
|
4
|
+
black: "black", red: "red", green: "green",
|
5
|
+
)
|
6
|
+
|
7
|
+
pastelcolors = ( pink: "pink", mauve: "mauve", peach: "peach", lavender: "lavender" )
|
8
|
+
$terminal-color /= &pastelcolors
|
9
|
+
|
10
|
+
;;gp 10
|
11
|
+
;;vp "florp"
|
12
|
+
;;vp "lavender"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
; JWT-JWS = text .join ([
|
2
|
+
; b64u<jwt-headers>, ".",
|
3
|
+
; b64u<jwt-payload>, ".",
|
4
|
+
; b64u<jwt-signature>])
|
5
|
+
; ; a = jwt-headers
|
6
|
+
; ; a = b64u<"abc"> ; fails
|
7
|
+
; ; a = b64u<'abc'> ; succeeds
|
8
|
+
; b64u<B> = text .b64u B
|
9
|
+
jwt-headers = '' .cat jwt-headers1
|
10
|
+
jwt-headers1 = text .json jwt-headermap
|
11
|
+
jwt-headermap = { * text => any } ; simplified
|
12
|
+
jwt-payload = bytes
|
13
|
+
jwt-signature = bytes
|
14
|
+
|
15
|
+
;;gp 10
|
data/test-data/jwt.cddl
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
JWT-JWS = text .join ([
|
2
|
+
b64u<jwt-headers>, ".",
|
3
|
+
b64u<jwt-payload>, ".",
|
4
|
+
b64u<jwt-signature>])
|
5
|
+
; a = jwt-headers
|
6
|
+
; a = b64u<"abc"> ; fails
|
7
|
+
; a = b64u<'abc'> ; succeeds
|
8
|
+
b64u<B> = text .b64u B
|
9
|
+
jwt-headers = '' .cat jwt-headers1
|
10
|
+
jwt-headers1 = text .json jwt-headermap
|
11
|
+
jwt-headermap = { * text => any } ; simplified
|
12
|
+
jwt-payload = bytes
|
13
|
+
jwt-signature = bytes
|
14
|
+
|
15
|
+
;;gp 10
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cddl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cbor-diag
|
@@ -163,6 +163,7 @@ files:
|
|
163
163
|
- test-data/b.cddl
|
164
164
|
- test-data/b64c-sloppy.cddl
|
165
165
|
- test-data/b64c.cddl
|
166
|
+
- test-data/b64u-strict.cddl
|
166
167
|
- test-data/b64u.cddl
|
167
168
|
- test-data/badaddr.cddl
|
168
169
|
- test-data/base32.cddl
|
@@ -173,6 +174,7 @@ files:
|
|
173
174
|
- test-data/bpv7a.cddl
|
174
175
|
- test-data/bpv7b.cddl
|
175
176
|
- test-data/cat-re.cddl
|
177
|
+
- test-data/catb64.cddl
|
176
178
|
- test-data/cdni-ct.cddl
|
177
179
|
- test-data/complex-occ.cddl
|
178
180
|
- test-data/coral.cddl
|
@@ -190,6 +192,8 @@ files:
|
|
190
192
|
- test-data/dotplus3.cddl
|
191
193
|
- test-data/dotplus4.cddl
|
192
194
|
- test-data/dotsize.cddl
|
195
|
+
- test-data/enum.cddl
|
196
|
+
- test-data/enum1.cddl
|
193
197
|
- test-data/extractor-demo.cddl
|
194
198
|
- test-data/feat1.cddl
|
195
199
|
- test-data/feature-controller.cddl
|
@@ -217,8 +221,10 @@ files:
|
|
217
221
|
- test-data/joini.cddl
|
218
222
|
- test-data/joinx.cddl
|
219
223
|
- test-data/json.cddl
|
224
|
+
- test-data/json1.cddl
|
220
225
|
- test-data/json2.cddl
|
221
226
|
- test-data/jsoniodef.cddl
|
227
|
+
- test-data/jwt.cddl
|
222
228
|
- test-data/kevin5.cddl
|
223
229
|
- test-data/lint1.cddl
|
224
230
|
- test-data/map-group.cddl
|