cddlc 0.2.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea4f2c1a1ecedae6a543bebad045a0063e3b7103b757306a8f1da1fea694c3ca
4
- data.tar.gz: 247a51f6016e133358fb37e524e0692eec3c84104ea63137b9549e3164ff65ad
3
+ metadata.gz: f35079da2cf258708ed948eb0c9b11bddff20f5a37c5967f0eed5bbc24d37821
4
+ data.tar.gz: cb4a9ac9618a27734cb1ab088b493f852e323227e19362b7012ab7b16c48b714
5
5
  SHA512:
6
- metadata.gz: 1d039d6618590fea6f3baaf19888583afdddcab37887cb4e9fb24b56c1fcf52455964426c8ea8325f2d57fa67e19008c05de791278664c094e3da500455387d8
7
- data.tar.gz: be73e1a03f41bb0052eac06e1fac77bddb3ef55eade8e2b8f0e4c9f625cd5c7bd928a5b464a693e07826521135bd402583d32d801908a95c2749c9f3508eb253
6
+ metadata.gz: 7edb8b482557190e6b7a79f0646183f7b32308fc5574931ae9d6e281af11cfa66640395057e6611c308ac713aac2958dde5d0f609bc405c6467ff86db64f47a2
7
+ data.tar.gz: c51b2735ae93b9ba9ca3671bec546e46345498829c14c0ed338fa782e8d95d7999ac0afcf97c7eabc5a11f564108cf816e975a1ee72c66f9244685f2eb82fa95
data/cddlc.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cddlc"
3
- s.version = "0.2.1"
3
+ s.version = "0.2.3"
4
4
  s.summary = "CDDL (Concise Data Definition Language) converters and miscellaneous tools"
5
5
  s.description = %q{cddlc implements converters and miscellaneous tools for CDDL, RFC 8610}
6
6
  s.author = "Carsten Bormann"
@@ -0,0 +1,279 @@
1
+ concise-swid-tag = {
2
+ tag-id => text / bstr .size 16,
3
+ tag-version => integer,
4
+ ? corpus => bool,
5
+ ? patch => bool,
6
+ ? supplemental => bool,
7
+ software-name => text,
8
+ ? software-version => text,
9
+ ? version-scheme => $version-scheme,
10
+ ? media => text,
11
+ ? software-meta => one-or-more<software-meta-entry>,
12
+ entity => one-or-more<entity-entry>,
13
+ ? link => one-or-more<link-entry>,
14
+ ? payload-or-evidence,
15
+ * $$coswid-extension,
16
+ global-attributes,
17
+ }
18
+
19
+ payload-or-evidence //= ( payload => payload-entry )
20
+ payload-or-evidence //= ( evidence => evidence-entry )
21
+
22
+ any-uri = uri
23
+ label = text / int
24
+
25
+ $version-scheme /= multipartnumeric
26
+ $version-scheme /= multipartnumeric-suffix
27
+ $version-scheme /= alphanumeric
28
+ $version-scheme /= decimal
29
+ $version-scheme /= semver
30
+ $version-scheme /= int / text
31
+
32
+ any-attribute = (
33
+ label => one-or-more<text> / one-or-more<int>
34
+ )
35
+
36
+ one-or-more<T> = T / [ 2* T ]
37
+
38
+ global-attributes = (
39
+ ? lang => text,
40
+ * any-attribute,
41
+ )
42
+
43
+ hash-entry = [
44
+ hash-alg-id: int,
45
+ hash-value: bytes,
46
+ ]
47
+
48
+ entity-entry = {
49
+ entity-name => text,
50
+ ? reg-id => any-uri,
51
+ role => one-or-more<$role>,
52
+ ? thumbprint => hash-entry,
53
+ * $$entity-extension,
54
+ global-attributes,
55
+ }
56
+
57
+ $role /= tag-creator
58
+ $role /= software-creator
59
+ $role /= aggregator
60
+ $role /= distributor
61
+ $role /= licensor
62
+ $role /= maintainer
63
+ $role /= int / text
64
+
65
+ link-entry = {
66
+ ? artifact => text,
67
+ href => any-uri,
68
+ ? media => text,
69
+ ? ownership => $ownership,
70
+ rel => $rel,
71
+ ? media-type => text,
72
+ ? use => $use,
73
+ * $$link-extension,
74
+ global-attributes,
75
+ }
76
+
77
+ $ownership /= shared
78
+ $ownership /= private
79
+ $ownership /= abandon
80
+ $ownership /= int / text
81
+
82
+ $rel /= ancestor
83
+ $rel /= component
84
+ $rel /= feature
85
+ $rel /= installationmedia
86
+ $rel /= packageinstaller
87
+ $rel /= parent
88
+ $rel /= patches
89
+ $rel /= requires
90
+ $rel /= see-also
91
+ $rel /= supersedes
92
+ $rel /= supplemental
93
+ $rel /= -256..65536 / text
94
+
95
+ $use /= optional
96
+ $use /= required
97
+ $use /= recommended
98
+ $use /= int / text
99
+
100
+ software-meta-entry = {
101
+ ? activation-status => text,
102
+ ? channel-type => text,
103
+ ? colloquial-version => text,
104
+ ? description => text,
105
+ ? edition => text,
106
+ ? entitlement-data-required => bool,
107
+ ? entitlement-key => text,
108
+ ? generator => text / bstr .size 16,
109
+ ? persistent-id => text,
110
+ ? product => text,
111
+ ? product-family => text,
112
+ ? revision => text,
113
+ ? summary => text,
114
+ ? unspsc-code => text,
115
+ ? unspsc-version => text,
116
+ * $$software-meta-extension,
117
+ global-attributes,
118
+ }
119
+
120
+ path-elements-group = ( ? directory => one-or-more<directory-entry>,
121
+ ? file => one-or-more<file-entry>,
122
+ )
123
+
124
+ resource-collection = (
125
+ path-elements-group,
126
+ ? process => one-or-more<process-entry>,
127
+ ? resource => one-or-more<resource-entry>,
128
+ * $$resource-collection-extension,
129
+ )
130
+
131
+ file-entry = {
132
+ filesystem-item,
133
+ ? size => uint,
134
+ ? file-version => text,
135
+ ? hash => hash-entry,
136
+ * $$file-extension,
137
+ global-attributes,
138
+ }
139
+
140
+ directory-entry = {
141
+ filesystem-item,
142
+ ? path-elements => { path-elements-group },
143
+ * $$directory-extension,
144
+ global-attributes,
145
+ }
146
+
147
+ process-entry = {
148
+ process-name => text,
149
+ ? pid => integer,
150
+ * $$process-extension,
151
+ global-attributes,
152
+ }
153
+
154
+ resource-entry = {
155
+ type => text,
156
+ * $$resource-extension,
157
+ global-attributes,
158
+ }
159
+
160
+ filesystem-item = (
161
+ ? key => bool,
162
+ ? location => text,
163
+ fs-name => text,
164
+ ? root => text,
165
+ )
166
+
167
+ payload-entry = {
168
+ resource-collection,
169
+ * $$payload-extension,
170
+ global-attributes,
171
+ }
172
+
173
+ evidence-entry = {
174
+ resource-collection,
175
+ ? date => integer-time,
176
+ ? device-id => text,
177
+ ? location => text,
178
+ * $$evidence-extension,
179
+ global-attributes,
180
+ }
181
+
182
+ integer-time = #6.1(int)
183
+
184
+ ; "global map member" integer indices
185
+ tag-id = 0
186
+ software-name = 1
187
+ entity = 2
188
+ evidence = 3
189
+ link = 4
190
+ software-meta = 5
191
+ payload = 6
192
+ hash = 7
193
+ corpus = 8
194
+ patch = 9
195
+ media = 10
196
+ supplemental = 11
197
+ tag-version = 12
198
+ software-version = 13
199
+ version-scheme = 14
200
+ lang = 15
201
+ directory = 16
202
+ file = 17
203
+ process = 18
204
+ resource = 19
205
+ size = 20
206
+ file-version = 21
207
+ key = 22
208
+ location = 23
209
+ fs-name = 24
210
+ root = 25
211
+ path-elements = 26
212
+ process-name = 27
213
+ pid = 28
214
+ type = 29
215
+ entity-name = 31
216
+ reg-id = 32
217
+ role = 33
218
+ thumbprint = 34
219
+ date = 35
220
+ device-id = 36
221
+ artifact = 37
222
+ href = 38
223
+ ownership = 39
224
+ rel = 40
225
+ media-type = 41
226
+ use = 42
227
+ activation-status = 43
228
+ channel-type = 44
229
+ colloquial-version = 45
230
+ description = 46
231
+ edition = 47
232
+ entitlement-data-required = 48
233
+ entitlement-key = 49
234
+ generator = 50
235
+ persistent-id = 51
236
+ product = 52
237
+ product-family = 53
238
+ revision = 54
239
+ summary = 55
240
+ unspsc-code = 56
241
+ unspsc-version = 57
242
+
243
+ ; "version-scheme" integer indices
244
+ multipartnumeric = 1
245
+ multipartnumeric-suffix = 2
246
+ alphanumeric = 3
247
+ decimal = 4
248
+ semver = 16384
249
+
250
+ ; "role" integer indices
251
+ tag-creator=1
252
+ software-creator=2
253
+ aggregator=3
254
+ distributor=4
255
+ licensor=5
256
+ maintainer=6
257
+
258
+ ; "ownership" integer indices
259
+ abandon=1
260
+ private=2
261
+ shared=3
262
+
263
+ ; "rel" integer indices
264
+ ancestor=1
265
+ component=2
266
+ feature=3
267
+ installationmedia=4
268
+ packageinstaller=5
269
+ parent=6
270
+ patches=7
271
+ requires=8
272
+ see-also=9
273
+ supersedes=10
274
+ ; supplemental=11 ; already defined
275
+
276
+ ; "use" integer indices
277
+ optional=1
278
+ required=2
279
+ recommended=3
@@ -0,0 +1,26 @@
1
+ COSE_Sign-coswid<payload> = [
2
+ protected: bstr .cbor protected-signed-coswid-header1,
3
+ unprotected: unprotected-signed-coswid-header,
4
+ payload: bstr .cbor payload,
5
+ signature: [ * COSE_Signature ],
6
+ ]
7
+
8
+ protected-signed-coswid-header1 = {
9
+ 3 => "application/swid+cbor",
10
+ * cose-label => cose-values,
11
+ }
12
+
13
+ protected-signature-coswid-header = {
14
+ 1 => int, ; algorithm identifier
15
+ * cose-label => cose-values,
16
+ }
17
+
18
+ unprotected-signed-coswid-header = {
19
+ * cose-label => cose-values,
20
+ }
21
+
22
+ COSE_Signature = [
23
+ protected: bstr .cbor protected-signature-coswid-header,
24
+ unprotected: unprotected-signed-coswid-header,
25
+ signature: bstr
26
+ ]
@@ -0,0 +1,19 @@
1
+ COSE_Sign1-coswid<payload> = [
2
+ protected: bstr .cbor protected-signed-coswid-header,
3
+ unprotected: unprotected-signed-coswid-header,
4
+ payload: bstr .cbor payload,
5
+ signature: bstr,
6
+ ]
7
+
8
+ cose-label = int / tstr
9
+ cose-values = any
10
+
11
+ protected-signed-coswid-header = {
12
+ 1 => int, ; algorithm identifier
13
+ 3 => "application/swid+cbor",
14
+ * cose-label => cose-values,
15
+ }
16
+
17
+ unprotected-signed-coswid-header = {
18
+ * cose-label => cose-values,
19
+ }
@@ -0,0 +1,9 @@
1
+ coswid = unsigned-coswid / signed-coswid
2
+ unsigned-coswid = concise-swid-tag / tagged-coswid<concise-swid-tag>
3
+ signed-coswid1 = signed-coswid-for<unsigned-coswid>
4
+ signed-coswid = signed-coswid1 / tagged-coswid<signed-coswid1>
5
+
6
+ tagged-coswid<T> = #6.1398229316(T)
7
+
8
+ signed-coswid-for<payload> = #6.18(COSE_Sign1-coswid<payload>)
9
+ / #6.98(COSE_Sign-coswid<payload>)
data/data/rfc9393.cddl ADDED
@@ -0,0 +1 @@
1
+ rfc9393-concise-swid-tag.cddl
@@ -2,6 +2,16 @@ require_relative "../cddlc.rb"
2
2
  require_relative "./cddl-visitor.rb"
3
3
 
4
4
  class CDDL
5
+
6
+ class MissingGenericError < StandardError
7
+ attr_reader :name, :args
8
+ def initialize(name_, args_)
9
+ @name = name_
10
+ @args = args_
11
+ super("** no generic for #{name}<#{args}>")
12
+ end
13
+ end
14
+
5
15
  def substitute(prod, parms, subs, &block)
6
16
  visit(prod) do |p, &block1|
7
17
  case p
@@ -18,7 +28,9 @@ class CDDL
18
28
  end
19
29
  def gen_apply(gen_name, gen_args, &block)
20
30
  gen_parms, gen_prod = @gen[gen_name]
21
- fail "** no generic for #{gen_name}<#{gen_args}>" unless gen_parms
31
+ unless gen_parms
32
+ fail MissingGenericError.new(gen_name, gen_args)
33
+ end
22
34
  substitute(gen_prod, gen_parms, gen_args, &block)
23
35
  end
24
36
  def expand_prod(prod)
@@ -27,7 +27,11 @@ class CDDL
27
27
  def cddl_undefined
28
28
  # currently only works on expanded...
29
29
  cddl2 = self.deep_clone # needs deep-clone
30
- cddl2.expand_generics
30
+ begin
31
+ cddl2.expand_generics
32
+ rescue CDDL::MissingGenericError => e
33
+ return [e.name] # make this expandable first by pulling missing generic
34
+ end
31
35
  used = {}
32
36
  cddl2.rules.each do |k, v|
33
37
  fail unless String === k
@@ -42,7 +42,7 @@ class CDDL
42
42
  in ["gen", id, *parms] # oops -- namep vs. namea; ouch
43
43
  [4, "#{id}<#{parms.map{write_rhs(_1, 2, indent, pn)}.join(", ")}>"]
44
44
  in ["tcho", *types]
45
- [2, types.map{write_rhs(_1, 3, indent, pn)}.join(" / ")]
45
+ [2.1, types.map{write_rhs(_1, 3, indent, pn)}.join(" / ")]
46
46
  in ["gcho", *groups]
47
47
  [0, groups.map{write_rhs(_1, 2, indent, pn)}.join(" // ")]
48
48
  in ["op", op, l, r]
@@ -116,7 +116,7 @@ class CDDL
116
116
  in ["parm", parmnames, _type]
117
117
  else
118
118
  end
119
- "#{write_lhs(k, parmnames)} = #{write_rhs(v, 2)}" # 2: parenthesize groups
119
+ "#{write_lhs(k, parmnames)} = #{write_rhs(v, 2.1)}" # 2: parenthesize groups
120
120
  }.join("\n")
121
121
  end
122
122
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cddlc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-15 00:00:00.000000000 Z
11
+ date: 2024-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -97,6 +97,11 @@ files:
97
97
  - data/rfc9290.cddl
98
98
  - data/rfc9321.cddl
99
99
  - data/rfc9338.cddl
100
+ - data/rfc9393-concise-swid-tag.cddl
101
+ - data/rfc9393-sign.cddl
102
+ - data/rfc9393-sign1.cddl
103
+ - data/rfc9393-tags.cddl
104
+ - data/rfc9393.cddl
100
105
  - lib/cddlc.rb
101
106
  - lib/parser/cddl-util.rb
102
107
  - lib/parser/cddlgrammar.rb