/
otm.go
771 lines (641 loc) · 28.9 KB
/
otm.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT.
package otm
import (
"encoding/json"
"fmt"
)
type AssetInstance struct {
// Processed corresponds to the JSON schema field "processed".
Processed []*string `json:"processed,omitempty" yaml:"processed,omitempty" mapstructure:"processed,omitempty"`
// Stored corresponds to the JSON schema field "stored".
Stored []*string `json:"stored,omitempty" yaml:"stored,omitempty" mapstructure:"stored,omitempty"`
}
type OtmSchemaJson struct {
// Assets corresponds to the JSON schema field "assets".
Assets []OtmSchemaJsonAssetsElem `json:"assets,omitempty" yaml:"assets,omitempty" mapstructure:"assets,omitempty"`
// Components corresponds to the JSON schema field "components".
Components []OtmSchemaJsonComponentsElem `json:"components,omitempty" yaml:"components,omitempty" mapstructure:"components,omitempty"`
// Dataflows corresponds to the JSON schema field "dataflows".
Dataflows []OtmSchemaJsonDataflowsElem `json:"dataflows,omitempty" yaml:"dataflows,omitempty" mapstructure:"dataflows,omitempty"`
// Mitigations corresponds to the JSON schema field "mitigations".
Mitigations []OtmSchemaJsonMitigationsElem `json:"mitigations,omitempty" yaml:"mitigations,omitempty" mapstructure:"mitigations,omitempty"`
// OtmVersion corresponds to the JSON schema field "otmVersion".
OtmVersion string `json:"otmVersion" yaml:"otmVersion" mapstructure:"otmVersion"`
// Project corresponds to the JSON schema field "project".
Project OtmSchemaJsonProject `json:"project" yaml:"project" mapstructure:"project"`
// Representations corresponds to the JSON schema field "representations".
Representations []OtmSchemaJsonRepresentationsElem `json:"representations,omitempty" yaml:"representations,omitempty" mapstructure:"representations,omitempty"`
// Threats corresponds to the JSON schema field "threats".
Threats []OtmSchemaJsonThreatsElem `json:"threats,omitempty" yaml:"threats,omitempty" mapstructure:"threats,omitempty"`
// TrustZones corresponds to the JSON schema field "trustZones".
TrustZones []OtmSchemaJsonTrustZonesElem `json:"trustZones,omitempty" yaml:"trustZones,omitempty" mapstructure:"trustZones,omitempty"`
}
type OtmSchemaJsonAssetsElem struct {
// Attributes corresponds to the JSON schema field "attributes".
Attributes OtmSchemaJsonAssetsElemAttributes `json:"attributes,omitempty" yaml:"attributes,omitempty" mapstructure:"attributes,omitempty"`
// Description corresponds to the JSON schema field "description".
Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`
// Id corresponds to the JSON schema field "id".
Id string `json:"id" yaml:"id" mapstructure:"id"`
// Name corresponds to the JSON schema field "name".
Name string `json:"name" yaml:"name" mapstructure:"name"`
// Risk corresponds to the JSON schema field "risk".
Risk OtmSchemaJsonAssetsElemRisk `json:"risk" yaml:"risk" mapstructure:"risk"`
}
type OtmSchemaJsonAssetsElemAttributes map[string]interface{}
type OtmSchemaJsonAssetsElemRisk struct {
// Availability corresponds to the JSON schema field "availability".
Availability float64 `json:"availability" yaml:"availability" mapstructure:"availability"`
// Comment corresponds to the JSON schema field "comment".
Comment *string `json:"comment,omitempty" yaml:"comment,omitempty" mapstructure:"comment,omitempty"`
// Confidentiality corresponds to the JSON schema field "confidentiality".
Confidentiality float64 `json:"confidentiality" yaml:"confidentiality" mapstructure:"confidentiality"`
// Integrity corresponds to the JSON schema field "integrity".
Integrity float64 `json:"integrity" yaml:"integrity" mapstructure:"integrity"`
}
type OtmSchemaJsonComponentsElem struct {
// Assets corresponds to the JSON schema field "assets".
Assets *AssetInstance `json:"assets,omitempty" yaml:"assets,omitempty" mapstructure:"assets,omitempty"`
// Attributes corresponds to the JSON schema field "attributes".
Attributes OtmSchemaJsonComponentsElemAttributes `json:"attributes,omitempty" yaml:"attributes,omitempty" mapstructure:"attributes,omitempty"`
// Description corresponds to the JSON schema field "description".
Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`
// Id corresponds to the JSON schema field "id".
Id string `json:"id" yaml:"id" mapstructure:"id"`
// Name corresponds to the JSON schema field "name".
Name string `json:"name" yaml:"name" mapstructure:"name"`
// Parent corresponds to the JSON schema field "parent".
Parent Parent `json:"parent" yaml:"parent" mapstructure:"parent"`
// Representations corresponds to the JSON schema field "representations".
Representations []RepresentationElement `json:"representations,omitempty" yaml:"representations,omitempty" mapstructure:"representations,omitempty"`
// Tags corresponds to the JSON schema field "tags".
Tags []*string `json:"tags,omitempty" yaml:"tags,omitempty" mapstructure:"tags,omitempty"`
// Threats corresponds to the JSON schema field "threats".
Threats []Threat `json:"threats,omitempty" yaml:"threats,omitempty" mapstructure:"threats,omitempty"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type" yaml:"type" mapstructure:"type"`
}
type OtmSchemaJsonComponentsElemAttributes map[string]interface{}
type OtmSchemaJsonDataflowsElem struct {
// Assets corresponds to the JSON schema field "assets".
Assets []*string `json:"assets,omitempty" yaml:"assets,omitempty" mapstructure:"assets,omitempty"`
// Attributes corresponds to the JSON schema field "attributes".
Attributes OtmSchemaJsonDataflowsElemAttributes `json:"attributes,omitempty" yaml:"attributes,omitempty" mapstructure:"attributes,omitempty"`
// Bidirectional corresponds to the JSON schema field "bidirectional".
Bidirectional *bool `json:"bidirectional,omitempty" yaml:"bidirectional,omitempty" mapstructure:"bidirectional,omitempty"`
// Description corresponds to the JSON schema field "description".
Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`
// Destination corresponds to the JSON schema field "destination".
Destination string `json:"destination" yaml:"destination" mapstructure:"destination"`
// Id corresponds to the JSON schema field "id".
Id string `json:"id" yaml:"id" mapstructure:"id"`
// Name corresponds to the JSON schema field "name".
Name string `json:"name" yaml:"name" mapstructure:"name"`
// Source corresponds to the JSON schema field "source".
Source string `json:"source" yaml:"source" mapstructure:"source"`
// Tags corresponds to the JSON schema field "tags".
Tags []*string `json:"tags,omitempty" yaml:"tags,omitempty" mapstructure:"tags,omitempty"`
// Threats corresponds to the JSON schema field "threats".
Threats []Threat `json:"threats,omitempty" yaml:"threats,omitempty" mapstructure:"threats,omitempty"`
}
type OtmSchemaJsonDataflowsElemAttributes map[string]interface{}
type OtmSchemaJsonMitigationsElem struct {
// Attributes corresponds to the JSON schema field "attributes".
Attributes OtmSchemaJsonMitigationsElemAttributes `json:"attributes,omitempty" yaml:"attributes,omitempty" mapstructure:"attributes,omitempty"`
// Description corresponds to the JSON schema field "description".
Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`
// Id corresponds to the JSON schema field "id".
Id string `json:"id" yaml:"id" mapstructure:"id"`
// Name corresponds to the JSON schema field "name".
Name string `json:"name" yaml:"name" mapstructure:"name"`
// RiskReduction corresponds to the JSON schema field "riskReduction".
RiskReduction float64 `json:"riskReduction" yaml:"riskReduction" mapstructure:"riskReduction"`
}
type OtmSchemaJsonMitigationsElemAttributes map[string]interface{}
type OtmSchemaJsonProject struct {
// Attributes corresponds to the JSON schema field "attributes".
Attributes OtmSchemaJsonProjectAttributes `json:"attributes,omitempty" yaml:"attributes,omitempty" mapstructure:"attributes,omitempty"`
// Description corresponds to the JSON schema field "description".
Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`
// Id corresponds to the JSON schema field "id".
Id string `json:"id" yaml:"id" mapstructure:"id"`
// Name corresponds to the JSON schema field "name".
Name string `json:"name" yaml:"name" mapstructure:"name"`
// Owner corresponds to the JSON schema field "owner".
Owner *string `json:"owner,omitempty" yaml:"owner,omitempty" mapstructure:"owner,omitempty"`
// OwnerContact corresponds to the JSON schema field "ownerContact".
OwnerContact *string `json:"ownerContact,omitempty" yaml:"ownerContact,omitempty" mapstructure:"ownerContact,omitempty"`
// Tags corresponds to the JSON schema field "tags".
Tags []string `json:"tags,omitempty" yaml:"tags,omitempty" mapstructure:"tags,omitempty"`
}
type OtmSchemaJsonProjectAttributes map[string]interface{}
type OtmSchemaJsonRepresentationsElem struct {
// Attributes corresponds to the JSON schema field "attributes".
Attributes OtmSchemaJsonRepresentationsElemAttributes `json:"attributes,omitempty" yaml:"attributes,omitempty" mapstructure:"attributes,omitempty"`
// Description corresponds to the JSON schema field "description".
Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`
// Id corresponds to the JSON schema field "id".
Id string `json:"id" yaml:"id" mapstructure:"id"`
// Name corresponds to the JSON schema field "name".
Name string `json:"name" yaml:"name" mapstructure:"name"`
// Repository corresponds to the JSON schema field "repository".
Repository *OtmSchemaJsonRepresentationsElemRepository `json:"repository,omitempty" yaml:"repository,omitempty" mapstructure:"repository,omitempty"`
// Size corresponds to the JSON schema field "size".
Size *Size `json:"size,omitempty" yaml:"size,omitempty" mapstructure:"size,omitempty"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type" yaml:"type" mapstructure:"type"`
}
type OtmSchemaJsonRepresentationsElemAttributes map[string]interface{}
type OtmSchemaJsonRepresentationsElemRepository struct {
// Url corresponds to the JSON schema field "url".
Url *string `json:"url" yaml:"url" mapstructure:"url"`
}
type OtmSchemaJsonThreatsElem struct {
// Attributes corresponds to the JSON schema field "attributes".
Attributes OtmSchemaJsonThreatsElemAttributes `json:"attributes,omitempty" yaml:"attributes,omitempty" mapstructure:"attributes,omitempty"`
// Categories corresponds to the JSON schema field "categories".
Categories []*string `json:"categories,omitempty" yaml:"categories,omitempty" mapstructure:"categories,omitempty"`
// Cwes corresponds to the JSON schema field "cwes".
Cwes []*string `json:"cwes,omitempty" yaml:"cwes,omitempty" mapstructure:"cwes,omitempty"`
// Description corresponds to the JSON schema field "description".
Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`
// Id corresponds to the JSON schema field "id".
Id string `json:"id" yaml:"id" mapstructure:"id"`
// Name corresponds to the JSON schema field "name".
Name string `json:"name" yaml:"name" mapstructure:"name"`
// Risk corresponds to the JSON schema field "risk".
Risk OtmSchemaJsonThreatsElemRisk `json:"risk" yaml:"risk" mapstructure:"risk"`
// Tags corresponds to the JSON schema field "tags".
Tags []*string `json:"tags,omitempty" yaml:"tags,omitempty" mapstructure:"tags,omitempty"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *OtmSchemaJson) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["otmVersion"]; !ok || v == nil {
return fmt.Errorf("field otmVersion in OtmSchemaJson: required")
}
if v, ok := raw["project"]; !ok || v == nil {
return fmt.Errorf("field project in OtmSchemaJson: required")
}
type Plain OtmSchemaJson
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = OtmSchemaJson(plain)
return nil
}
type Threat struct {
// Mitigations corresponds to the JSON schema field "mitigations".
Mitigations []ThreatMitigationsElem `json:"mitigations,omitempty" yaml:"mitigations,omitempty" mapstructure:"mitigations,omitempty"`
// State corresponds to the JSON schema field "state".
State string `json:"state" yaml:"state" mapstructure:"state"`
// Threat corresponds to the JSON schema field "threat".
Threat string `json:"threat" yaml:"threat" mapstructure:"threat"`
}
type ThreatMitigationsElem struct {
// Mitigation corresponds to the JSON schema field "mitigation".
Mitigation *string `json:"mitigation" yaml:"mitigation" mapstructure:"mitigation"`
// State corresponds to the JSON schema field "state".
State *string `json:"state" yaml:"state" mapstructure:"state"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *OtmSchemaJsonComponentsElem) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["id"]; !ok || v == nil {
return fmt.Errorf("field id in OtmSchemaJsonComponentsElem: required")
}
if v, ok := raw["name"]; !ok || v == nil {
return fmt.Errorf("field name in OtmSchemaJsonComponentsElem: required")
}
if v, ok := raw["parent"]; !ok || v == nil {
return fmt.Errorf("field parent in OtmSchemaJsonComponentsElem: required")
}
if v, ok := raw["type"]; !ok || v == nil {
return fmt.Errorf("field type in OtmSchemaJsonComponentsElem: required")
}
type Plain OtmSchemaJsonComponentsElem
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = OtmSchemaJsonComponentsElem(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *RepresentationElement) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["id"]; !ok || v == nil {
return fmt.Errorf("field id in RepresentationElement: required")
}
if v, ok := raw["representation"]; !ok || v == nil {
return fmt.Errorf("field representation in RepresentationElement: required")
}
type Plain RepresentationElement
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = RepresentationElement(plain)
return nil
}
type RepresentationElement struct {
// Attributes corresponds to the JSON schema field "attributes".
Attributes RepresentationElementAttributes `json:"attributes,omitempty" yaml:"attributes,omitempty" mapstructure:"attributes,omitempty"`
// CodeSnippet corresponds to the JSON schema field "codeSnippet".
CodeSnippet *string `json:"codeSnippet,omitempty" yaml:"codeSnippet,omitempty" mapstructure:"codeSnippet,omitempty"`
// File corresponds to the JSON schema field "file".
File *string `json:"file,omitempty" yaml:"file,omitempty" mapstructure:"file,omitempty"`
// Id corresponds to the JSON schema field "id".
Id string `json:"id" yaml:"id" mapstructure:"id"`
// Line corresponds to the JSON schema field "line".
Line *float64 `json:"line,omitempty" yaml:"line,omitempty" mapstructure:"line,omitempty"`
// Name corresponds to the JSON schema field "name".
Name *string `json:"name,omitempty" yaml:"name,omitempty" mapstructure:"name,omitempty"`
// Position corresponds to the JSON schema field "position".
Position *Position `json:"position,omitempty" yaml:"position,omitempty" mapstructure:"position,omitempty"`
// Representation corresponds to the JSON schema field "representation".
Representation string `json:"representation" yaml:"representation" mapstructure:"representation"`
// Size corresponds to the JSON schema field "size".
Size *Size `json:"size,omitempty" yaml:"size,omitempty" mapstructure:"size,omitempty"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *OtmSchemaJsonDataflowsElem) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["destination"]; !ok || v == nil {
return fmt.Errorf("field destination in OtmSchemaJsonDataflowsElem: required")
}
if v, ok := raw["id"]; !ok || v == nil {
return fmt.Errorf("field id in OtmSchemaJsonDataflowsElem: required")
}
if v, ok := raw["name"]; !ok || v == nil {
return fmt.Errorf("field name in OtmSchemaJsonDataflowsElem: required")
}
if v, ok := raw["source"]; !ok || v == nil {
return fmt.Errorf("field source in OtmSchemaJsonDataflowsElem: required")
}
type Plain OtmSchemaJsonDataflowsElem
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = OtmSchemaJsonDataflowsElem(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *Size) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["height"]; !ok || v == nil {
return fmt.Errorf("field height in Size: required")
}
if v, ok := raw["width"]; !ok || v == nil {
return fmt.Errorf("field width in Size: required")
}
type Plain Size
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = Size(plain)
return nil
}
type Size struct {
// Height corresponds to the JSON schema field "height".
Height float64 `json:"height" yaml:"height" mapstructure:"height"`
// Width corresponds to the JSON schema field "width".
Width float64 `json:"width" yaml:"width" mapstructure:"width"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *OtmSchemaJsonMitigationsElem) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["id"]; !ok || v == nil {
return fmt.Errorf("field id in OtmSchemaJsonMitigationsElem: required")
}
if v, ok := raw["name"]; !ok || v == nil {
return fmt.Errorf("field name in OtmSchemaJsonMitigationsElem: required")
}
if v, ok := raw["riskReduction"]; !ok || v == nil {
return fmt.Errorf("field riskReduction in OtmSchemaJsonMitigationsElem: required")
}
type Plain OtmSchemaJsonMitigationsElem
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = OtmSchemaJsonMitigationsElem(plain)
return nil
}
type RepresentationElementAttributes map[string]interface{}
// UnmarshalJSON implements json.Unmarshaler.
func (j *Position) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["x"]; !ok || v == nil {
return fmt.Errorf("field x in Position: required")
}
if v, ok := raw["y"]; !ok || v == nil {
return fmt.Errorf("field y in Position: required")
}
type Plain Position
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = Position(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *OtmSchemaJsonProject) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["id"]; !ok || v == nil {
return fmt.Errorf("field id in OtmSchemaJsonProject: required")
}
if v, ok := raw["name"]; !ok || v == nil {
return fmt.Errorf("field name in OtmSchemaJsonProject: required")
}
type Plain OtmSchemaJsonProject
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = OtmSchemaJsonProject(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *ThreatMitigationsElem) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["mitigation"]; !ok || v == nil {
return fmt.Errorf("field mitigation in ThreatMitigationsElem: required")
}
if v, ok := raw["state"]; !ok || v == nil {
return fmt.Errorf("field state in ThreatMitigationsElem: required")
}
type Plain ThreatMitigationsElem
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = ThreatMitigationsElem(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *OtmSchemaJsonRepresentationsElemRepository) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["url"]; !ok || v == nil {
return fmt.Errorf("field url in OtmSchemaJsonRepresentationsElemRepository: required")
}
type Plain OtmSchemaJsonRepresentationsElemRepository
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = OtmSchemaJsonRepresentationsElemRepository(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *OtmSchemaJsonAssetsElem) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["id"]; !ok || v == nil {
return fmt.Errorf("field id in OtmSchemaJsonAssetsElem: required")
}
if v, ok := raw["name"]; !ok || v == nil {
return fmt.Errorf("field name in OtmSchemaJsonAssetsElem: required")
}
if v, ok := raw["risk"]; !ok || v == nil {
return fmt.Errorf("field risk in OtmSchemaJsonAssetsElem: required")
}
type Plain OtmSchemaJsonAssetsElem
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = OtmSchemaJsonAssetsElem(plain)
return nil
}
type Position struct {
// X corresponds to the JSON schema field "x".
X float64 `json:"x" yaml:"x" mapstructure:"x"`
// Y corresponds to the JSON schema field "y".
Y float64 `json:"y" yaml:"y" mapstructure:"y"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *OtmSchemaJsonRepresentationsElem) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["id"]; !ok || v == nil {
return fmt.Errorf("field id in OtmSchemaJsonRepresentationsElem: required")
}
if v, ok := raw["name"]; !ok || v == nil {
return fmt.Errorf("field name in OtmSchemaJsonRepresentationsElem: required")
}
if v, ok := raw["type"]; !ok || v == nil {
return fmt.Errorf("field type in OtmSchemaJsonRepresentationsElem: required")
}
type Plain OtmSchemaJsonRepresentationsElem
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = OtmSchemaJsonRepresentationsElem(plain)
return nil
}
type OtmSchemaJsonThreatsElemAttributes map[string]interface{}
type OtmSchemaJsonThreatsElemRisk struct {
// Impact corresponds to the JSON schema field "impact".
Impact float64 `json:"impact" yaml:"impact" mapstructure:"impact"`
// ImpactComment corresponds to the JSON schema field "impactComment".
ImpactComment *string `json:"impactComment,omitempty" yaml:"impactComment,omitempty" mapstructure:"impactComment,omitempty"`
// Likelihood corresponds to the JSON schema field "likelihood".
Likelihood *float64 `json:"likelihood" yaml:"likelihood" mapstructure:"likelihood"`
// LikelihoodComment corresponds to the JSON schema field "likelihoodComment".
LikelihoodComment *string `json:"likelihoodComment,omitempty" yaml:"likelihoodComment,omitempty" mapstructure:"likelihoodComment,omitempty"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *OtmSchemaJsonThreatsElemRisk) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["impact"]; !ok || v == nil {
return fmt.Errorf("field impact in OtmSchemaJsonThreatsElemRisk: required")
}
if v, ok := raw["likelihood"]; !ok || v == nil {
return fmt.Errorf("field likelihood in OtmSchemaJsonThreatsElemRisk: required")
}
type Plain OtmSchemaJsonThreatsElemRisk
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = OtmSchemaJsonThreatsElemRisk(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *Threat) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["state"]; !ok || v == nil {
return fmt.Errorf("field state in Threat: required")
}
if v, ok := raw["threat"]; !ok || v == nil {
return fmt.Errorf("field threat in Threat: required")
}
type Plain Threat
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = Threat(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *OtmSchemaJsonThreatsElem) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["id"]; !ok || v == nil {
return fmt.Errorf("field id in OtmSchemaJsonThreatsElem: required")
}
if v, ok := raw["name"]; !ok || v == nil {
return fmt.Errorf("field name in OtmSchemaJsonThreatsElem: required")
}
if v, ok := raw["risk"]; !ok || v == nil {
return fmt.Errorf("field risk in OtmSchemaJsonThreatsElem: required")
}
type Plain OtmSchemaJsonThreatsElem
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = OtmSchemaJsonThreatsElem(plain)
return nil
}
type OtmSchemaJsonTrustZonesElemAttributes map[string]interface{}
type OtmSchemaJsonTrustZonesElemRisk struct {
// TrustRating corresponds to the JSON schema field "trustRating".
TrustRating float64 `json:"trustRating" yaml:"trustRating" mapstructure:"trustRating"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *OtmSchemaJsonTrustZonesElemRisk) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["trustRating"]; !ok || v == nil {
return fmt.Errorf("field trustRating in OtmSchemaJsonTrustZonesElemRisk: required")
}
type Plain OtmSchemaJsonTrustZonesElemRisk
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = OtmSchemaJsonTrustZonesElemRisk(plain)
return nil
}
type OtmSchemaJsonTrustZonesElem struct {
// Attributes corresponds to the JSON schema field "attributes".
Attributes OtmSchemaJsonTrustZonesElemAttributes `json:"attributes,omitempty" yaml:"attributes,omitempty" mapstructure:"attributes,omitempty"`
// Description corresponds to the JSON schema field "description".
Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`
// Id corresponds to the JSON schema field "id".
Id string `json:"id" yaml:"id" mapstructure:"id"`
// Name corresponds to the JSON schema field "name".
Name string `json:"name" yaml:"name" mapstructure:"name"`
// Parent corresponds to the JSON schema field "parent".
Parent *Parent `json:"parent,omitempty" yaml:"parent,omitempty" mapstructure:"parent,omitempty"`
// Representations corresponds to the JSON schema field "representations".
Representations []RepresentationElement `json:"representations,omitempty" yaml:"representations,omitempty" mapstructure:"representations,omitempty"`
// Risk corresponds to the JSON schema field "risk".
Risk OtmSchemaJsonTrustZonesElemRisk `json:"risk" yaml:"risk" mapstructure:"risk"`
// Type corresponds to the JSON schema field "type".
Type *string `json:"type,omitempty" yaml:"type,omitempty" mapstructure:"type,omitempty"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *OtmSchemaJsonTrustZonesElem) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["id"]; !ok || v == nil {
return fmt.Errorf("field id in OtmSchemaJsonTrustZonesElem: required")
}
if v, ok := raw["name"]; !ok || v == nil {
return fmt.Errorf("field name in OtmSchemaJsonTrustZonesElem: required")
}
if v, ok := raw["risk"]; !ok || v == nil {
return fmt.Errorf("field risk in OtmSchemaJsonTrustZonesElem: required")
}
type Plain OtmSchemaJsonTrustZonesElem
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = OtmSchemaJsonTrustZonesElem(plain)
return nil
}
type Parent struct {
// Component corresponds to the JSON schema field "component".
Component *string `json:"component,omitempty" yaml:"component,omitempty" mapstructure:"component,omitempty"`
// TrustZone corresponds to the JSON schema field "trustZone".
TrustZone *string `json:"trustZone,omitempty" yaml:"trustZone,omitempty" mapstructure:"trustZone,omitempty"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *OtmSchemaJsonAssetsElemRisk) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["availability"]; !ok || v == nil {
return fmt.Errorf("field availability in OtmSchemaJsonAssetsElemRisk: required")
}
if v, ok := raw["confidentiality"]; !ok || v == nil {
return fmt.Errorf("field confidentiality in OtmSchemaJsonAssetsElemRisk: required")
}
if v, ok := raw["integrity"]; !ok || v == nil {
return fmt.Errorf("field integrity in OtmSchemaJsonAssetsElemRisk: required")
}
type Plain OtmSchemaJsonAssetsElemRisk
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = OtmSchemaJsonAssetsElemRisk(plain)
return nil
}