/
enums.go
1249 lines (1085 loc) · 41.2 KB
/
enums.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
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Code generated by genenums - DO NOT EDIT
//
// This file implements marshaling and unmarshalling to JSON and XML for the
// purposes of having types with enumerated values - that serialize to different
// values in XML vs. JSON.
//
// Types and their values are defined in a JSON file, and provided to the
// genenums tool.
package vulnrep
import (
"encoding/json"
"encoding/xml"
"fmt"
"strings"
)
func xmlElemAsString(d *xml.Decoder, start xml.StartElement) (string, error) {
var s string
if err := d.DecodeElement(&s, &start); err != nil {
return "", err
}
return s, nil
}
func noQuotes(b []byte) string {
return strings.TrimSuffix(strings.TrimPrefix(string(b), "\""), "\"")
}
/*******************************************************************************
* Generated type RelationshipType
*******************************************************************************/
// RelationshipType defines possible relations between components.
type RelationshipType int
type expRelationshipType RelationshipType
// Values for RelationshipType
const (
RelationshipDefaultComponentOf RelationshipType = iota
RelationshipOptionalComponentOf
RelationshipExternalComponentOf
RelationshipInstalledOn
RelationshipInstalledWith
maxRelationshipType
)
var genRelationshipTypeToXMLStr = map[expRelationshipType]string{
expRelationshipType(RelationshipDefaultComponentOf): "Default Component Of",
expRelationshipType(RelationshipOptionalComponentOf): "Optional Component Of",
expRelationshipType(RelationshipExternalComponentOf): "External Component Of",
expRelationshipType(RelationshipInstalledOn): "Installed On",
expRelationshipType(RelationshipInstalledWith): "Installed With",
}
var genXMLStrToRelationshipType = map[string]expRelationshipType{
"Default Component Of": expRelationshipType(RelationshipDefaultComponentOf),
"Optional Component Of": expRelationshipType(RelationshipOptionalComponentOf),
"External Component Of": expRelationshipType(RelationshipExternalComponentOf),
"Installed On": expRelationshipType(RelationshipInstalledOn),
"Installed With": expRelationshipType(RelationshipInstalledWith),
}
// UnmarshalXML implemented to support reading from XML.
func (obj *expRelationshipType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
s, err := xmlElemAsString(d, start)
if err != nil {
return fmt.Errorf("problem decoding RelationshipType: %v", err)
}
var ok bool
if *obj, ok = genXMLStrToRelationshipType[s]; !ok {
return fmt.Errorf("unrecognized RelationshipType value %v", s)
}
return nil
}
func (obj *expRelationshipType) mapXMLValue(s string) error {
var ok bool
if *obj, ok = genXMLStrToRelationshipType[s]; !ok {
return fmt.Errorf("unrecognized RelationshipType value %v", s)
}
return nil
}
// UnmarshalXMLAttr implemented to support reading from XML
func (obj *expRelationshipType) UnmarshalXMLAttr(attr xml.Attr) error {
return obj.mapXMLValue(attr.Value)
}
// MarshalXMLAttr implemented to support writing to XML.
func (obj expRelationshipType) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
s, ok := genRelationshipTypeToXMLStr[obj]
if !ok {
return xml.Attr{}, fmt.Errorf("unrecognized RelationshipType value %v", obj)
}
return xml.Attr{Name: name, Value: s}, nil
}
// MarshalXML implemented to support writing to XML.
func (obj expRelationshipType) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
s, ok := genRelationshipTypeToXMLStr[obj]
if !ok {
return fmt.Errorf("unrecognized RelationshipType %v", obj)
}
return e.EncodeElement(s, start)
}
var genJSONStrToRelationshipType = map[string]expRelationshipType{
"default_component_of": expRelationshipType(RelationshipDefaultComponentOf),
"optional_component_of": expRelationshipType(RelationshipOptionalComponentOf),
"external_component_of": expRelationshipType(RelationshipExternalComponentOf),
"installed_on": expRelationshipType(RelationshipInstalledOn),
"installed_with": expRelationshipType(RelationshipInstalledWith),
}
var genRelationshipTypeToJSONStr = map[expRelationshipType]string{
expRelationshipType(RelationshipDefaultComponentOf): "default_component_of",
expRelationshipType(RelationshipOptionalComponentOf): "optional_component_of",
expRelationshipType(RelationshipExternalComponentOf): "external_component_of",
expRelationshipType(RelationshipInstalledOn): "installed_on",
expRelationshipType(RelationshipInstalledWith): "installed_with",
}
// UnmarshalJSON implemented to support writing to XML.
func (obj *expRelationshipType) UnmarshalJSON(data []byte) error {
var ok bool
if *obj, ok = genJSONStrToRelationshipType[noQuotes(data)]; !ok {
return fmt.Errorf("unrecognized RelationshipType value %v", string(data))
}
return nil
}
// MarshalJSON implemented to support writing to XML.
func (obj expRelationshipType) MarshalJSON() ([]byte, error) {
s, ok := genRelationshipTypeToJSONStr[obj]
if !ok {
return nil, fmt.Errorf("unrecognized RelationshipType value %v", obj)
}
return json.Marshal(s)
}
func (obj RelationshipType) check(val *validator) {
if obj < 0 || obj >= maxRelationshipType {
val.err(fmt.Sprintf("unrecognized RelationshipType %v", obj))
}
}
/*******************************************************************************
* Generated type InvolvementStatusType
*******************************************************************************/
// InvolvementStatusType captures the ongoing involvement of other parties
type InvolvementStatusType int
type expInvolvementStatusType InvolvementStatusType
// Values for InvolvementStatusType
const (
InvolvementStatusOpen InvolvementStatusType = iota
InvolvementStatusDisputed
InvolvementStatusInProgress
InvolvementStatusCompleted
InvolvementStatusContactAttempted
InvolvementStatusNotContacted
maxInvolvementStatusType
)
var genInvolvementStatusTypeToXMLStr = map[expInvolvementStatusType]string{
expInvolvementStatusType(InvolvementStatusOpen): "Open",
expInvolvementStatusType(InvolvementStatusDisputed): "Disputed",
expInvolvementStatusType(InvolvementStatusInProgress): "In Progress",
expInvolvementStatusType(InvolvementStatusCompleted): "Completed",
expInvolvementStatusType(InvolvementStatusContactAttempted): "Contact Attempted",
expInvolvementStatusType(InvolvementStatusNotContacted): "Not Contacted",
}
var genXMLStrToInvolvementStatusType = map[string]expInvolvementStatusType{
"Open": expInvolvementStatusType(InvolvementStatusOpen),
"Disputed": expInvolvementStatusType(InvolvementStatusDisputed),
"In Progress": expInvolvementStatusType(InvolvementStatusInProgress),
"Completed": expInvolvementStatusType(InvolvementStatusCompleted),
"Contact Attempted": expInvolvementStatusType(InvolvementStatusContactAttempted),
"Not Contacted": expInvolvementStatusType(InvolvementStatusNotContacted),
}
// UnmarshalXML implemented to support reading from XML.
func (obj *expInvolvementStatusType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
s, err := xmlElemAsString(d, start)
if err != nil {
return fmt.Errorf("problem decoding InvolvementStatusType: %v", err)
}
var ok bool
if *obj, ok = genXMLStrToInvolvementStatusType[s]; !ok {
return fmt.Errorf("unrecognized InvolvementStatusType value %v", s)
}
return nil
}
func (obj *expInvolvementStatusType) mapXMLValue(s string) error {
var ok bool
if *obj, ok = genXMLStrToInvolvementStatusType[s]; !ok {
return fmt.Errorf("unrecognized InvolvementStatusType value %v", s)
}
return nil
}
// UnmarshalXMLAttr implemented to support reading from XML
func (obj *expInvolvementStatusType) UnmarshalXMLAttr(attr xml.Attr) error {
return obj.mapXMLValue(attr.Value)
}
// MarshalXMLAttr implemented to support writing to XML.
func (obj expInvolvementStatusType) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
s, ok := genInvolvementStatusTypeToXMLStr[obj]
if !ok {
return xml.Attr{}, fmt.Errorf("unrecognized InvolvementStatusType value %v", obj)
}
return xml.Attr{Name: name, Value: s}, nil
}
// MarshalXML implemented to support writing to XML.
func (obj expInvolvementStatusType) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
s, ok := genInvolvementStatusTypeToXMLStr[obj]
if !ok {
return fmt.Errorf("unrecognized InvolvementStatusType %v", obj)
}
return e.EncodeElement(s, start)
}
var genJSONStrToInvolvementStatusType = map[string]expInvolvementStatusType{
"open": expInvolvementStatusType(InvolvementStatusOpen),
"disputed": expInvolvementStatusType(InvolvementStatusDisputed),
"in_progress": expInvolvementStatusType(InvolvementStatusInProgress),
"completed": expInvolvementStatusType(InvolvementStatusCompleted),
"contact_attempted": expInvolvementStatusType(InvolvementStatusContactAttempted),
"not_contacted": expInvolvementStatusType(InvolvementStatusNotContacted),
}
var genInvolvementStatusTypeToJSONStr = map[expInvolvementStatusType]string{
expInvolvementStatusType(InvolvementStatusOpen): "open",
expInvolvementStatusType(InvolvementStatusDisputed): "disputed",
expInvolvementStatusType(InvolvementStatusInProgress): "in_progress",
expInvolvementStatusType(InvolvementStatusCompleted): "completed",
expInvolvementStatusType(InvolvementStatusContactAttempted): "contact_attempted",
expInvolvementStatusType(InvolvementStatusNotContacted): "not_contacted",
}
// UnmarshalJSON implemented to support writing to XML.
func (obj *expInvolvementStatusType) UnmarshalJSON(data []byte) error {
var ok bool
if *obj, ok = genJSONStrToInvolvementStatusType[noQuotes(data)]; !ok {
return fmt.Errorf("unrecognized InvolvementStatusType value %v", string(data))
}
return nil
}
// MarshalJSON implemented to support writing to XML.
func (obj expInvolvementStatusType) MarshalJSON() ([]byte, error) {
s, ok := genInvolvementStatusTypeToJSONStr[obj]
if !ok {
return nil, fmt.Errorf("unrecognized InvolvementStatusType value %v", obj)
}
return json.Marshal(s)
}
func (obj InvolvementStatusType) check(val *validator) {
if obj < 0 || obj >= maxInvolvementStatusType {
val.err(fmt.Sprintf("unrecognized InvolvementStatusType %v", obj))
}
}
/*******************************************************************************
* Generated type affectedStatusType
*******************************************************************************/
// affectedStatusType only used in XML - captures the status of affected components.
type affectedStatusType int
type expaffectedStatusType affectedStatusType
// Values for affectedStatusType
const (
affectedStatusFirstAffected affectedStatusType = iota
affectedStatusFirstFixed
affectedStatusFixed
affectedStatusKnownAffected
affectedStatusKnownNotAffected
affectedStatusLastAffected
affectedStatusRecommended
maxaffectedStatusType
)
var genaffectedStatusTypeToXMLStr = map[expaffectedStatusType]string{
expaffectedStatusType(affectedStatusFirstAffected): "First Affected",
expaffectedStatusType(affectedStatusFirstFixed): "First Fixed",
expaffectedStatusType(affectedStatusFixed): "Fixed",
expaffectedStatusType(affectedStatusKnownAffected): "Known Affected",
expaffectedStatusType(affectedStatusKnownNotAffected): "Known Not Affected",
expaffectedStatusType(affectedStatusLastAffected): "Last Affected",
expaffectedStatusType(affectedStatusRecommended): "Recommended",
}
var genXMLStrToaffectedStatusType = map[string]expaffectedStatusType{
"First Affected": expaffectedStatusType(affectedStatusFirstAffected),
"First Fixed": expaffectedStatusType(affectedStatusFirstFixed),
"Fixed": expaffectedStatusType(affectedStatusFixed),
"Known Affected": expaffectedStatusType(affectedStatusKnownAffected),
"Known Not Affected": expaffectedStatusType(affectedStatusKnownNotAffected),
"Last Affected": expaffectedStatusType(affectedStatusLastAffected),
"Recommended": expaffectedStatusType(affectedStatusRecommended),
}
// UnmarshalXML implemented to support reading from XML.
func (obj *expaffectedStatusType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
s, err := xmlElemAsString(d, start)
if err != nil {
return fmt.Errorf("problem decoding affectedStatusType: %v", err)
}
var ok bool
if *obj, ok = genXMLStrToaffectedStatusType[s]; !ok {
return fmt.Errorf("unrecognized affectedStatusType value %v", s)
}
return nil
}
func (obj *expaffectedStatusType) mapXMLValue(s string) error {
var ok bool
if *obj, ok = genXMLStrToaffectedStatusType[s]; !ok {
return fmt.Errorf("unrecognized affectedStatusType value %v", s)
}
return nil
}
// UnmarshalXMLAttr implemented to support reading from XML
func (obj *expaffectedStatusType) UnmarshalXMLAttr(attr xml.Attr) error {
return obj.mapXMLValue(attr.Value)
}
// MarshalXMLAttr implemented to support writing to XML.
func (obj expaffectedStatusType) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
s, ok := genaffectedStatusTypeToXMLStr[obj]
if !ok {
return xml.Attr{}, fmt.Errorf("unrecognized affectedStatusType value %v", obj)
}
return xml.Attr{Name: name, Value: s}, nil
}
// MarshalXML implemented to support writing to XML.
func (obj expaffectedStatusType) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
s, ok := genaffectedStatusTypeToXMLStr[obj]
if !ok {
return fmt.Errorf("unrecognized affectedStatusType %v", obj)
}
return e.EncodeElement(s, start)
}
var genJSONStrToaffectedStatusType = map[string]expaffectedStatusType{
"first_affected": expaffectedStatusType(affectedStatusFirstAffected),
"first_fixed": expaffectedStatusType(affectedStatusFirstFixed),
"fixed": expaffectedStatusType(affectedStatusFixed),
"known_affected": expaffectedStatusType(affectedStatusKnownAffected),
"known_not_affected": expaffectedStatusType(affectedStatusKnownNotAffected),
"last_affected": expaffectedStatusType(affectedStatusLastAffected),
"recommended": expaffectedStatusType(affectedStatusRecommended),
}
var genaffectedStatusTypeToJSONStr = map[expaffectedStatusType]string{
expaffectedStatusType(affectedStatusFirstAffected): "first_affected",
expaffectedStatusType(affectedStatusFirstFixed): "first_fixed",
expaffectedStatusType(affectedStatusFixed): "fixed",
expaffectedStatusType(affectedStatusKnownAffected): "known_affected",
expaffectedStatusType(affectedStatusKnownNotAffected): "known_not_affected",
expaffectedStatusType(affectedStatusLastAffected): "last_affected",
expaffectedStatusType(affectedStatusRecommended): "recommended",
}
// UnmarshalJSON implemented to support writing to XML.
func (obj *expaffectedStatusType) UnmarshalJSON(data []byte) error {
var ok bool
if *obj, ok = genJSONStrToaffectedStatusType[noQuotes(data)]; !ok {
return fmt.Errorf("unrecognized affectedStatusType value %v", string(data))
}
return nil
}
// MarshalJSON implemented to support writing to XML.
func (obj expaffectedStatusType) MarshalJSON() ([]byte, error) {
s, ok := genaffectedStatusTypeToJSONStr[obj]
if !ok {
return nil, fmt.Errorf("unrecognized affectedStatusType value %v", obj)
}
return json.Marshal(s)
}
func (obj affectedStatusType) check(val *validator) {
if obj < 0 || obj >= maxaffectedStatusType {
val.err(fmt.Sprintf("unrecognized affectedStatusType %v", obj))
}
}
/*******************************************************************************
* Generated type RemedyType
*******************************************************************************/
// RemedyType enumerates the types of remedies for a vulnerability.
type RemedyType int
type expRemedyType RemedyType
// Values for RemedyType
const (
RemedyWorkaround RemedyType = iota
RemedyMitigation
RemedyVendorFix
RemedyNoneAvailable
RemedyWillNotFix
maxRemedyType
)
var genRemedyTypeToXMLStr = map[expRemedyType]string{
expRemedyType(RemedyWorkaround): "Workaround",
expRemedyType(RemedyMitigation): "Mitigation",
expRemedyType(RemedyVendorFix): "Vendor Fix",
expRemedyType(RemedyNoneAvailable): "None Available",
expRemedyType(RemedyWillNotFix): "Will Not Fix",
}
var genXMLStrToRemedyType = map[string]expRemedyType{
"Workaround": expRemedyType(RemedyWorkaround),
"Mitigation": expRemedyType(RemedyMitigation),
"Vendor Fix": expRemedyType(RemedyVendorFix),
"None Available": expRemedyType(RemedyNoneAvailable),
"Will Not Fix": expRemedyType(RemedyWillNotFix),
}
// UnmarshalXML implemented to support reading from XML.
func (obj *expRemedyType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
s, err := xmlElemAsString(d, start)
if err != nil {
return fmt.Errorf("problem decoding RemedyType: %v", err)
}
var ok bool
if *obj, ok = genXMLStrToRemedyType[s]; !ok {
return fmt.Errorf("unrecognized RemedyType value %v", s)
}
return nil
}
func (obj *expRemedyType) mapXMLValue(s string) error {
var ok bool
if *obj, ok = genXMLStrToRemedyType[s]; !ok {
return fmt.Errorf("unrecognized RemedyType value %v", s)
}
return nil
}
// UnmarshalXMLAttr implemented to support reading from XML
func (obj *expRemedyType) UnmarshalXMLAttr(attr xml.Attr) error {
return obj.mapXMLValue(attr.Value)
}
// MarshalXMLAttr implemented to support writing to XML.
func (obj expRemedyType) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
s, ok := genRemedyTypeToXMLStr[obj]
if !ok {
return xml.Attr{}, fmt.Errorf("unrecognized RemedyType value %v", obj)
}
return xml.Attr{Name: name, Value: s}, nil
}
// MarshalXML implemented to support writing to XML.
func (obj expRemedyType) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
s, ok := genRemedyTypeToXMLStr[obj]
if !ok {
return fmt.Errorf("unrecognized RemedyType %v", obj)
}
return e.EncodeElement(s, start)
}
var genJSONStrToRemedyType = map[string]expRemedyType{
"workaround": expRemedyType(RemedyWorkaround),
"mitigation": expRemedyType(RemedyMitigation),
"vendor_fix": expRemedyType(RemedyVendorFix),
"none_available": expRemedyType(RemedyNoneAvailable),
"will_not_fix": expRemedyType(RemedyWillNotFix),
}
var genRemedyTypeToJSONStr = map[expRemedyType]string{
expRemedyType(RemedyWorkaround): "workaround",
expRemedyType(RemedyMitigation): "mitigation",
expRemedyType(RemedyVendorFix): "vendor_fix",
expRemedyType(RemedyNoneAvailable): "none_available",
expRemedyType(RemedyWillNotFix): "will_not_fix",
}
// UnmarshalJSON implemented to support writing to XML.
func (obj *expRemedyType) UnmarshalJSON(data []byte) error {
var ok bool
if *obj, ok = genJSONStrToRemedyType[noQuotes(data)]; !ok {
return fmt.Errorf("unrecognized RemedyType value %v", string(data))
}
return nil
}
// MarshalJSON implemented to support writing to XML.
func (obj expRemedyType) MarshalJSON() ([]byte, error) {
s, ok := genRemedyTypeToJSONStr[obj]
if !ok {
return nil, fmt.Errorf("unrecognized RemedyType value %v", obj)
}
return json.Marshal(s)
}
func (obj RemedyType) check(val *validator) {
if obj < 0 || obj >= maxRemedyType {
val.err(fmt.Sprintf("unrecognized RemedyType %v", obj))
}
}
/*******************************************************************************
* Generated type DocStatus
*******************************************************************************/
// DocStatus enumerates the possible states of a document.
type DocStatus int
type expDocStatus DocStatus
// Values for DocStatus
const (
DocStatusDraft DocStatus = iota
DocStatusInterim
DocStatusFinal
maxDocStatus
)
var genDocStatusToXMLStr = map[expDocStatus]string{
expDocStatus(DocStatusDraft): "Draft",
expDocStatus(DocStatusInterim): "Interim",
expDocStatus(DocStatusFinal): "Final",
}
var genXMLStrToDocStatus = map[string]expDocStatus{
"Draft": expDocStatus(DocStatusDraft),
"Interim": expDocStatus(DocStatusInterim),
"Final": expDocStatus(DocStatusFinal),
}
// UnmarshalXML implemented to support reading from XML.
func (obj *expDocStatus) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
s, err := xmlElemAsString(d, start)
if err != nil {
return fmt.Errorf("problem decoding DocStatus: %v", err)
}
var ok bool
if *obj, ok = genXMLStrToDocStatus[s]; !ok {
return fmt.Errorf("unrecognized DocStatus value %v", s)
}
return nil
}
func (obj *expDocStatus) mapXMLValue(s string) error {
var ok bool
if *obj, ok = genXMLStrToDocStatus[s]; !ok {
return fmt.Errorf("unrecognized DocStatus value %v", s)
}
return nil
}
// UnmarshalXMLAttr implemented to support reading from XML
func (obj *expDocStatus) UnmarshalXMLAttr(attr xml.Attr) error {
return obj.mapXMLValue(attr.Value)
}
// MarshalXMLAttr implemented to support writing to XML.
func (obj expDocStatus) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
s, ok := genDocStatusToXMLStr[obj]
if !ok {
return xml.Attr{}, fmt.Errorf("unrecognized DocStatus value %v", obj)
}
return xml.Attr{Name: name, Value: s}, nil
}
// MarshalXML implemented to support writing to XML.
func (obj expDocStatus) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
s, ok := genDocStatusToXMLStr[obj]
if !ok {
return fmt.Errorf("unrecognized DocStatus %v", obj)
}
return e.EncodeElement(s, start)
}
var genJSONStrToDocStatus = map[string]expDocStatus{
"draft": expDocStatus(DocStatusDraft),
"interim": expDocStatus(DocStatusInterim),
"final": expDocStatus(DocStatusFinal),
}
var genDocStatusToJSONStr = map[expDocStatus]string{
expDocStatus(DocStatusDraft): "draft",
expDocStatus(DocStatusInterim): "interim",
expDocStatus(DocStatusFinal): "final",
}
// UnmarshalJSON implemented to support writing to XML.
func (obj *expDocStatus) UnmarshalJSON(data []byte) error {
var ok bool
if *obj, ok = genJSONStrToDocStatus[noQuotes(data)]; !ok {
return fmt.Errorf("unrecognized DocStatus value %v", string(data))
}
return nil
}
// MarshalJSON implemented to support writing to XML.
func (obj expDocStatus) MarshalJSON() ([]byte, error) {
s, ok := genDocStatusToJSONStr[obj]
if !ok {
return nil, fmt.Errorf("unrecognized DocStatus value %v", obj)
}
return json.Marshal(s)
}
func (obj DocStatus) check(val *validator) {
if obj < 0 || obj >= maxDocStatus {
val.err(fmt.Sprintf("unrecognized DocStatus %v", obj))
}
}
/*******************************************************************************
* Generated type ReferenceType
*******************************************************************************/
// ReferenceType enumerates whether a reference is self or external.
type ReferenceType int
type expReferenceType ReferenceType
// Values for ReferenceType
const (
ReferenceExternal ReferenceType = iota
ReferenceSelf
maxReferenceType
)
var genReferenceTypeToXMLStr = map[expReferenceType]string{
expReferenceType(ReferenceExternal): "External",
expReferenceType(ReferenceSelf): "Self",
}
var genXMLStrToReferenceType = map[string]expReferenceType{
"External": expReferenceType(ReferenceExternal),
"Self": expReferenceType(ReferenceSelf),
}
// UnmarshalXML implemented to support reading from XML.
func (obj *expReferenceType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
s, err := xmlElemAsString(d, start)
if err != nil {
return fmt.Errorf("problem decoding ReferenceType: %v", err)
}
var ok bool
if *obj, ok = genXMLStrToReferenceType[s]; !ok {
return fmt.Errorf("unrecognized ReferenceType value %v", s)
}
return nil
}
func (obj *expReferenceType) mapXMLValue(s string) error {
var ok bool
if *obj, ok = genXMLStrToReferenceType[s]; !ok {
return fmt.Errorf("unrecognized ReferenceType value %v", s)
}
return nil
}
// UnmarshalXMLAttr implemented to support reading from XML
func (obj *expReferenceType) UnmarshalXMLAttr(attr xml.Attr) error {
return obj.mapXMLValue(attr.Value)
}
// MarshalXMLAttr implemented to support writing to XML.
func (obj expReferenceType) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
s, ok := genReferenceTypeToXMLStr[obj]
if !ok {
return xml.Attr{}, fmt.Errorf("unrecognized ReferenceType value %v", obj)
}
return xml.Attr{Name: name, Value: s}, nil
}
// MarshalXML implemented to support writing to XML.
func (obj expReferenceType) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
s, ok := genReferenceTypeToXMLStr[obj]
if !ok {
return fmt.Errorf("unrecognized ReferenceType %v", obj)
}
return e.EncodeElement(s, start)
}
var genJSONStrToReferenceType = map[string]expReferenceType{
"external": expReferenceType(ReferenceExternal),
"self": expReferenceType(ReferenceSelf),
}
var genReferenceTypeToJSONStr = map[expReferenceType]string{
expReferenceType(ReferenceExternal): "external",
expReferenceType(ReferenceSelf): "self",
}
// UnmarshalJSON implemented to support writing to XML.
func (obj *expReferenceType) UnmarshalJSON(data []byte) error {
var ok bool
if *obj, ok = genJSONStrToReferenceType[noQuotes(data)]; !ok {
return fmt.Errorf("unrecognized ReferenceType value %v", string(data))
}
return nil
}
// MarshalJSON implemented to support writing to XML.
func (obj expReferenceType) MarshalJSON() ([]byte, error) {
s, ok := genReferenceTypeToJSONStr[obj]
if !ok {
return nil, fmt.Errorf("unrecognized ReferenceType value %v", obj)
}
return json.Marshal(s)
}
func (obj ReferenceType) check(val *validator) {
if obj < 0 || obj >= maxReferenceType {
val.err(fmt.Sprintf("unrecognized ReferenceType %v", obj))
}
}
/*******************************************************************************
* Generated type NoteType
*******************************************************************************/
// NoteType enumerates the different types of Notes.
type NoteType int
type expNoteType NoteType
// Values for NoteType
const (
NoteDescription NoteType = iota
NoteDetails
NoteFAQ
NoteGeneral
NoteLegalDisclaimer
NoteOther
NoteSummary
maxNoteType
)
var genNoteTypeToXMLStr = map[expNoteType]string{
expNoteType(NoteDescription): "Description",
expNoteType(NoteDetails): "Details",
expNoteType(NoteFAQ): "FAQ",
expNoteType(NoteGeneral): "General",
expNoteType(NoteLegalDisclaimer): "Legal Disclaimer",
expNoteType(NoteOther): "Other",
expNoteType(NoteSummary): "Summary",
}
var genXMLStrToNoteType = map[string]expNoteType{
"Description": expNoteType(NoteDescription),
"Details": expNoteType(NoteDetails),
"FAQ": expNoteType(NoteFAQ),
"General": expNoteType(NoteGeneral),
"Legal Disclaimer": expNoteType(NoteLegalDisclaimer),
"Other": expNoteType(NoteOther),
"Summary": expNoteType(NoteSummary),
}
// UnmarshalXML implemented to support reading from XML.
func (obj *expNoteType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
s, err := xmlElemAsString(d, start)
if err != nil {
return fmt.Errorf("problem decoding NoteType: %v", err)
}
var ok bool
if *obj, ok = genXMLStrToNoteType[s]; !ok {
return fmt.Errorf("unrecognized NoteType value %v", s)
}
return nil
}
func (obj *expNoteType) mapXMLValue(s string) error {
var ok bool
if *obj, ok = genXMLStrToNoteType[s]; !ok {
return fmt.Errorf("unrecognized NoteType value %v", s)
}
return nil
}
// UnmarshalXMLAttr implemented to support reading from XML
func (obj *expNoteType) UnmarshalXMLAttr(attr xml.Attr) error {
return obj.mapXMLValue(attr.Value)
}
// MarshalXMLAttr implemented to support writing to XML.
func (obj expNoteType) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
s, ok := genNoteTypeToXMLStr[obj]
if !ok {
return xml.Attr{}, fmt.Errorf("unrecognized NoteType value %v", obj)
}
return xml.Attr{Name: name, Value: s}, nil
}
// MarshalXML implemented to support writing to XML.
func (obj expNoteType) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
s, ok := genNoteTypeToXMLStr[obj]
if !ok {
return fmt.Errorf("unrecognized NoteType %v", obj)
}
return e.EncodeElement(s, start)
}
var genJSONStrToNoteType = map[string]expNoteType{
"description": expNoteType(NoteDescription),
"details": expNoteType(NoteDetails),
"faq": expNoteType(NoteFAQ),
"general": expNoteType(NoteGeneral),
"legal_disclaimer": expNoteType(NoteLegalDisclaimer),
"other": expNoteType(NoteOther),
"summary": expNoteType(NoteSummary),
}
var genNoteTypeToJSONStr = map[expNoteType]string{
expNoteType(NoteDescription): "description",
expNoteType(NoteDetails): "details",
expNoteType(NoteFAQ): "faq",
expNoteType(NoteGeneral): "general",
expNoteType(NoteLegalDisclaimer): "legal_disclaimer",
expNoteType(NoteOther): "other",
expNoteType(NoteSummary): "summary",
}
// UnmarshalJSON implemented to support writing to XML.
func (obj *expNoteType) UnmarshalJSON(data []byte) error {
var ok bool
if *obj, ok = genJSONStrToNoteType[noQuotes(data)]; !ok {
return fmt.Errorf("unrecognized NoteType value %v", string(data))
}
return nil
}
// MarshalJSON implemented to support writing to XML.
func (obj expNoteType) MarshalJSON() ([]byte, error) {
s, ok := genNoteTypeToJSONStr[obj]
if !ok {
return nil, fmt.Errorf("unrecognized NoteType value %v", obj)
}
return json.Marshal(s)
}
func (obj NoteType) check(val *validator) {
if obj < 0 || obj >= maxNoteType {
val.err(fmt.Sprintf("unrecognized NoteType %v", obj))
}
}
/*******************************************************************************
* Generated type PublisherType
*******************************************************************************/
// PublisherType enumerates the different publishers of vulnerabilities.
type PublisherType int
type expPublisherType PublisherType
// Values for PublisherType
const (
PubTypeVendor PublisherType = iota
PubTypeDiscoverer
PubTypeCoordinator
PubTypeUser
PubTypeOther
maxPublisherType
)
var genPublisherTypeToXMLStr = map[expPublisherType]string{
expPublisherType(PubTypeVendor): "Vendor",
expPublisherType(PubTypeDiscoverer): "Discoverer",
expPublisherType(PubTypeCoordinator): "Coordinator",
expPublisherType(PubTypeUser): "User",
expPublisherType(PubTypeOther): "Other",
}
var genXMLStrToPublisherType = map[string]expPublisherType{
"Vendor": expPublisherType(PubTypeVendor),
"Discoverer": expPublisherType(PubTypeDiscoverer),
"Coordinator": expPublisherType(PubTypeCoordinator),
"User": expPublisherType(PubTypeUser),
"Other": expPublisherType(PubTypeOther),
}
// UnmarshalXML implemented to support reading from XML.
func (obj *expPublisherType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
s, err := xmlElemAsString(d, start)
if err != nil {
return fmt.Errorf("problem decoding PublisherType: %v", err)
}
var ok bool
if *obj, ok = genXMLStrToPublisherType[s]; !ok {
return fmt.Errorf("unrecognized PublisherType value %v", s)
}
return nil
}
func (obj *expPublisherType) mapXMLValue(s string) error {
var ok bool
if *obj, ok = genXMLStrToPublisherType[s]; !ok {
return fmt.Errorf("unrecognized PublisherType value %v", s)
}
return nil
}
// UnmarshalXMLAttr implemented to support reading from XML
func (obj *expPublisherType) UnmarshalXMLAttr(attr xml.Attr) error {
return obj.mapXMLValue(attr.Value)
}
// MarshalXMLAttr implemented to support writing to XML.
func (obj expPublisherType) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
s, ok := genPublisherTypeToXMLStr[obj]
if !ok {
return xml.Attr{}, fmt.Errorf("unrecognized PublisherType value %v", obj)
}
return xml.Attr{Name: name, Value: s}, nil
}
// MarshalXML implemented to support writing to XML.
func (obj expPublisherType) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
s, ok := genPublisherTypeToXMLStr[obj]
if !ok {
return fmt.Errorf("unrecognized PublisherType %v", obj)
}
return e.EncodeElement(s, start)
}
var genJSONStrToPublisherType = map[string]expPublisherType{
"vendor": expPublisherType(PubTypeVendor),
"discoverer": expPublisherType(PubTypeDiscoverer),
"coordinator": expPublisherType(PubTypeCoordinator),
"user": expPublisherType(PubTypeUser),
"other": expPublisherType(PubTypeOther),
}
var genPublisherTypeToJSONStr = map[expPublisherType]string{
expPublisherType(PubTypeVendor): "vendor",
expPublisherType(PubTypeDiscoverer): "discoverer",
expPublisherType(PubTypeCoordinator): "coordinator",
expPublisherType(PubTypeUser): "user",
expPublisherType(PubTypeOther): "other",
}
// UnmarshalJSON implemented to support writing to XML.
func (obj *expPublisherType) UnmarshalJSON(data []byte) error {
var ok bool
if *obj, ok = genJSONStrToPublisherType[noQuotes(data)]; !ok {
return fmt.Errorf("unrecognized PublisherType value %v", string(data))
}
return nil
}
// MarshalJSON implemented to support writing to XML.
func (obj expPublisherType) MarshalJSON() ([]byte, error) {
s, ok := genPublisherTypeToJSONStr[obj]
if !ok {
return nil, fmt.Errorf("unrecognized PublisherType value %v", obj)
}
return json.Marshal(s)
}
func (obj PublisherType) check(val *validator) {
if obj < 0 || obj >= maxPublisherType {
val.err(fmt.Sprintf("unrecognized PublisherType %v", obj))
}
}
/*******************************************************************************
* Generated type BranchType
*******************************************************************************/
// BranchType captures the type of branch in the product tree.
type BranchType int
type expBranchType BranchType
// Values for BranchType
const (
BranchVendor BranchType = iota
BranchProductFamily
BranchProductName
BranchProductVersion
BranchPatchLevel
BranchServicePack
BranchArchitecture
BranchLanguage