-
Notifications
You must be signed in to change notification settings - Fork 2
/
option.go
1527 lines (1332 loc) · 44 KB
/
option.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
// Copyright 2021 Joakim Kennedy. All rights reserved. Use of
// this source code is governed by the included BSD license.
package stix2
import (
"reflect"
"github.com/pkg/errors"
)
// STIXOption is an optional parameter when constructing an
// STIX object.
type STIXOption func(a STIXObject) error
/*
Options for Common Properties
*/
// OptionSpecVersion sets the STIX spec version. This option is valid for the types:
// - STIX Domain Objects
// - STIX Relationships Objects
// - LanguageContent
// - MarkingDefinition
// - Bundle
func OptionSpecVersion(ver string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "SpecVersion", ver, reflect.String)
}
}
// OptionCreatedBy sets the created by by attribute. This option is valid for the types:
// - STIX Domain Objects
// - STIX Relationships Objects
// - LanguageContent
// - MarkingDefinition
func OptionCreatedBy(id Identifier) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "CreatedBy", id, reflect.String)
}
}
// OptionCreated sets the created attribute. This option is valid for the types:
// - STIX Domain Objects
// - STIX Relationships Objects
// - LanguageContent
// - MarkingDefinition
func OptionCreated(t *Timestamp) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Created", t, reflect.Ptr)
}
}
// OptionModified sets the modified attribute. This option is valid for the types:
// - STIX Domain Objects
// - STIX Relationships Objects
// - LanguageContent
func OptionModified(t *Timestamp) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Modified", t, reflect.Ptr)
}
}
// OptionRevoked sets the revoked attribute. This option is valid for the types:
// - STIX Domain Objects
// - STIX Relationships Objects
// - LanguageContent
func OptionRevoked(rev bool) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Revoked", rev, reflect.Bool)
}
}
// OptionLabels sets the labels attribute. This option is valid for the types:
// - STIX Domain Objects
// - STIX Relationships Objects
// - LanguageContent
func OptionLabels(labels []string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Labels", labels, reflect.Slice)
}
}
// OptionConfidence sets the confidence attribute. This option is valid for the types:
// - STIX Domain Objects
// - STIX Relationships Objects
// - LanguageContent
func OptionConfidence(confidence int) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Confidence", confidence, reflect.Int)
}
}
// OptionLang sets the lang attribute. This option is valid for the types:
// - STIX Domain Objects
// - STIX Relationships Objects
func OptionLang(lang string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Lang", lang, reflect.String)
}
}
// OptionExternalReferences sets the external references attribute. This option is valid for the types:
// - STIX Domain Objects
// - STIX Relationships Objects
// - LanguageContent
// - MarkingDefinition
func OptionExternalReferences(refs []*ExternalReference) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "ExternalReferences", refs, reflect.Slice)
}
}
// OptionObjectMarking sets the object marking attribute. This option is valid for the types:
// - STIX Domain Objects
// - STIX Cyber-observable Objects
// - STIX Relationships Objects
// - LanguageContent
// - MarkingDefinition
func OptionObjectMarking(om []Identifier) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "ObjectMarking", om, reflect.Slice)
}
}
// OptionGranularMarking sets the granular marking attribute. This option is valid for the types:
// - STIX Domain Objects
// - STIX Cyber-observable Objects
// - STIX Relationships Objects
// - LanguageContent
// - MarkingDefinition
func OptionGranularMarking(gm []*GranularMarking) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "GranularMarking", gm, reflect.Slice)
}
}
// OptionDefanged sets the defanged attribute. This option is valid for the types:
// - STIX Cyber-observable Objects
func OptionDefanged(b bool) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Defanged", b, reflect.Bool)
}
}
// OptionExtension adds an extension. This option is valid for the types:
// - All types execpt Bundle and Extension.
func OptionExtension(name string, value interface{}) STIXOption {
return func(obj STIXObject) error {
val, err := reflectValue(obj)
if err != nil {
return err
}
ev, err := findFieldForExtension(val)
if err != nil {
return err
}
// If this cast fails, we are dealing with an incorrect implemented type.
// In this case, we let it panic.
ext := ev.Interface().(Extensions)
if ext == nil {
ext = Extensions{}
}
ext[name] = value
// Save the extensions field
ev.Set(reflect.ValueOf(ext))
return nil
}
}
func findFieldForExtension(val reflect.Value) (reflect.Value, error) {
var subStruct *reflect.Value
// Check if it is in a potential substruct.
f := val.FieldByName("STIXCyberObservableObject")
if f.IsValid() && f.CanSet() && f.Kind() == reflect.Struct {
cpy := f
subStruct = &cpy
}
f = val.FieldByName("STIXDomainObject")
if f.IsValid() && f.CanSet() && f.Kind() == reflect.Struct {
cpy := f
subStruct = &cpy
}
f = val.FieldByName("STIXRelationshipObject")
if f.IsValid() && f.CanSet() && f.Kind() == reflect.Struct {
cpy := f
subStruct = &cpy
}
if subStruct != nil {
// Substruct found so set val to it.
val = *subStruct
}
f = val.FieldByName("Extensions")
if f.IsValid() && f.CanSet() && f.Kind() == reflect.Map {
return f, nil
}
return f, errors.Errorf("object can not have extensions")
}
// OptionExtensionProperties adds an extension. This option is valid for the types:
// - STIX ExtensionDefinition
func OptionExtensionProperties(value []string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "ExtensionProperties", value, reflect.Slice)
}
}
/*
Other properties
*/
// OptionDescription sets the description attribute. This option is valid for the types:
// - AttackPattern
// - Campaign
// - CourseOfAction
// - Grouping
// - Identity
// - Indicator
// - Infrastructure
// - IntrusionSet
// - Location
// - Malware
// - Report
// - ThreatActor
// - Tool
// - Vulnerability
// - Relationship
// - Sighting
func OptionDescription(des string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Description", des, reflect.String)
}
}
// OptionAliases sets the aliases attribute. This option is valid for the types:
// - AttackPattern
// - Campaign
// - Infrastructure
// - IntrusionSet
// - Malware
// - ThreatActor
// - Tool
func OptionAliases(a []string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Aliases", a, reflect.Slice)
}
}
// OptionKillChainPhase sets the kill chain phase attribute. This option is valid for the types:
// - AttackPattern
// - Indicator
// - Infrastructure
// - Malware
// - Tool
func OptionKillChainPhase(k []*KillChainPhase) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "KillChainPhase", k, reflect.Slice)
}
}
// OptionFirstSeen sets the first seen attribute. This option is valid for the types:
// - Campaign
// - Infrastructure
// - IntrusionSet
// - Malware
// - ThreatActor
// - Sighting
func OptionFirstSeen(t *Timestamp) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "FirstSeen", t, reflect.Ptr)
}
}
// OptionLastSeen sets the last seen attribute. This option is valid for the types:
// - Campaign
// - Infrastructure
// - IntrusionSet
// - Malware
// - ThreatActor
// - Sighting
func OptionLastSeen(t *Timestamp) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "LastSeen", t, reflect.Ptr)
}
}
// OptionObjective sets the objective attribute. This option is valid for the types:
// - Campaign
func OptionObjective(o string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Objective", o, reflect.String)
}
}
// OptionName sets the name attribute. This option is valid for the types:
// - Grouping
// - Indicator
// - Location
// - Malware
// - AutonomousSystem
// - MarkingDefinition
func OptionName(n string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Name", n, reflect.String)
}
}
// OptionClass sets the identity class attribute. This option is valid for the types:
// - Identity
func OptionClass(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Class", s, reflect.String)
}
}
// OptionRoles sets the roles attribute. This option is valid for the types:
// - Identity
// - ThreatActor
func OptionRoles(s []string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Roles", s, reflect.Slice)
}
}
// OptionSectors sets the sectors attribute. This option is valid for the types:
// - Identity
func OptionSectors(s []string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Sectors", s, reflect.Slice)
}
}
// OptionContactInformation sets the contact information attribute. This option is valid for the types:
// - Identity
func OptionContactInformation(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "ContactInformation", s, reflect.String)
}
}
// OptionTypes sets the indicator types attribute. This option is valid for the types:
// - Indicator
// - Infrastructure
// - Malware
// - Report
// - ThreatActor
// - Tool
func OptionTypes(s []string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Types", s, reflect.Slice)
}
}
// OptionPatternVersion sets the pattern version attribute. This option is valid for the types:
// - Indicator
func OptionPatternVersion(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "PatternVersion", s, reflect.String)
}
}
// OptionValidUntil sets the valid until attribute. This option is valid for the types:
// - Indicator
func OptionValidUntil(t *Timestamp) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "ValidUntil", t, reflect.Ptr)
}
}
// OptionGoals sets the goals attribute. This option is valid for the types:
// - IntrusionSet
// - ThreatActor
func OptionGoals(s []string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Goals", s, reflect.Slice)
}
}
// OptionResourceLevel sets the resource level attribute. This option is valid for the types:
// - IntrusionSet
// - ThreatActor
func OptionResourceLevel(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "ResourceLevel", s, reflect.String)
}
}
// OptionPrimaryMotivation sets the primary motivation attribute. This option is valid for the types:
// - IntrusionSet
// - ThreatActor
func OptionPrimaryMotivation(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "PrimaryMotivation", s, reflect.String)
}
}
// OptionSecondaryMotivations sets the secondary motivation attribute. This option is valid for the types:
// - IntrusionSet
// - ThreatActor
func OptionSecondaryMotivations(s []string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "SecondaryMotivations", s, reflect.Slice)
}
}
// OptionPrecision sets the precision attribute. This option is valid for the types:
// - Location
func OptionPrecision(p float64) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Precision", p, reflect.Float64)
}
}
// OptionAdministrativeArea sets the administrative area attribute. This option is valid for the types:
// - Location
func OptionAdministrativeArea(a string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "AdministrativeArea", a, reflect.String)
}
}
// OptionCity sets the city attribute. This option is valid for the types:
// - Location
func OptionCity(c string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "City", c, reflect.String)
}
}
// OptionStreetAddress sets the street address attribute. This option is valid for the types:
// - Location
func OptionStreetAddress(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "StreetAddress", s, reflect.String)
}
}
// OptionPostalCode sets the postal code attribute. This option is valid for the types:
// - Location
func OptionPostalCode(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "PostalCode", s, reflect.String)
}
}
// OptionOperatingSystems sets the OS attribute. This option is valid for the types:
// - Malware
func OptionOperatingSystems(s []Identifier) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "OperatingSystems", s, reflect.Slice)
}
}
// OptionArchitecture sets the architecture attribute. This option is valid for the types:
// - Malware
func OptionArchitecture(s []string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Architecture", s, reflect.Slice)
}
}
// OptionLanguages sets the languages attribute. This option is valid for the types:
// - Malware
// - Software
func OptionLanguages(s []string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Languages", s, reflect.Slice)
}
}
// OptionCapabilities sets the capabilities attribute. This option is valid for the types:
// - Malware
func OptionCapabilities(s []string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Capabilities", s, reflect.Slice)
}
}
// OptionSamples sets the samples attribute. This option is valid for the types:
// - Malware
func OptionSamples(s []Identifier) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Samples", s, reflect.Slice)
}
}
// OptionVersion sets the version attribute. This option is valid for the types:
// - MalwareAnalysis
// - Tool
// - Software
// - X509Certificate
func OptionVersion(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Version", s, reflect.String)
}
}
// OptionHostVM sets the host VM attribute. This option is valid for the types:
// - MalwareAnalysis
func OptionHostVM(s Identifier) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "HostVM", s, reflect.String)
}
}
// OptionOperatingSystem sets the OS attribute. This option is valid for the types:
// - MalwareAnalysis
func OptionOperatingSystem(s Identifier) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "OperatingSystem", s, reflect.String)
}
}
// OptionInstalledSoftware sets the installed software attribute. This option is valid for the types:
// - MalwareAnalysis
func OptionInstalledSoftware(s []Identifier) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "InstalledSoftware", s, reflect.Slice)
}
}
// OptionConfigurationVersion sets the configuration version This option is valid for the types:
// - MalwareAnalysis
// attribute. This option is valid for the types:
func OptionConfigurationVersion(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "ConfigurationVersion", s, reflect.String)
}
}
// OptionModules sets the modules attribute. This option is valid for the types:
// - MalwareAnalysis
func OptionModules(s []string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Modules", s, reflect.Slice)
}
}
// OptionAnalysisEngineVersion sets the analysis engine version
// attribute. This option is valid for the types:
// - MalwareAnalysis
func OptionAnalysisEngineVersion(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "AnalysisEngineVersion", s, reflect.String)
}
}
// OptionAnalysisDefinitionVersion sets the analysis definition
// version attribute. This option is valid for the types:
// - MalwareAnalysis
func OptionAnalysisDefinitionVersion(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "AnalysisDefinitionVersion", s, reflect.String)
}
}
// OptionSubmitted sets the submitted attribute. This option is valid for the types:
// - MalwareAnalysis
func OptionSubmitted(s *Timestamp) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Submitted", s, reflect.Ptr)
}
}
// OptionAnalysisStarted sets the analysis started attribute. This option is valid for the types:
// - MalwareAnalysis
func OptionAnalysisStarted(s *Timestamp) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "AnalysisStarted", s, reflect.Ptr)
}
}
// OptionAnalysisEnded sets the analysis ended attribute. This option is valid for the types:
// - MalwareAnalysis
func OptionAnalysisEnded(s *Timestamp) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "AnalysisEnded", s, reflect.Ptr)
}
}
// OptionResultName sets the analysis result name attribute. This option is valid for the types:
// - MalwareAnalysis
func OptionResultName(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "ResultName", s, reflect.String)
}
}
// OptionSample sets the analysis sample attribute. This option is valid for the types:
// - MalwareAnalysis
func OptionSample(s Identifier) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Sample", s, reflect.String)
}
}
// OptionAbstract sets the abstract attribute. This option is valid for the types:
// - Note
func OptionAbstract(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Abstract", s, reflect.String)
}
}
// OptionAuthors sets the authors attribute. This option is valid for the types:
// - Note
// - Opinion
func OptionAuthors(s []string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Authors", s, reflect.Slice)
}
}
// OptionExplanation sets the explanation attribute. This option is valid for the types:
// - Opinion
func OptionExplanation(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Explanation", s, reflect.String)
}
}
// OptionSophistication sets the sophistication attribute. This option is valid for the types:
// - ThreatActor
func OptionSophistication(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Sophistication", s, reflect.String)
}
}
// OptionPersonalMotivations sets the personal motivations attribute. This option is valid for the types:
// - ThreatActor
func OptionPersonalMotivations(s []string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "PersonalMotivations", s, reflect.Slice)
}
}
// OptionStartTime sets the start time attribute. This option is valid for the types:
// - Relationship
func OptionStartTime(t *Timestamp) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "StartTime", t, reflect.Ptr)
}
}
// OptionStopTime sets the stop time attribute. This option is valid for the types:
// - Relationship
func OptionStopTime(t *Timestamp) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "StopTime", t, reflect.Ptr)
}
}
// OptionCount sets the count attribute. This option is valid for the types:
// - Sighting
func OptionCount(c int64) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Count", c, reflect.Int64)
}
}
// OptionObservedData sets the ObservedData attribute. This option is valid for the types:
// - Sighting
func OptionObservedData(d []Identifier) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "ObservedData", d, reflect.Slice)
}
}
// OptionWhereSighted sets the WhereSighted attribute. This option is valid for the types:
// - Sighting
func OptionWhereSighted(i []Identifier) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "WhereSighted", i, reflect.Slice)
}
}
// OptionSummary sets the summary attribute. This option is valid for the types:
// - Sighting
func OptionSummary(b bool) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Summary", b, reflect.Bool)
}
}
// OptionMimeType sets the mime type attribute. This option is valid for the types:
// - Artifact
// - File
func OptionMimeType(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "MimeType", s, reflect.String)
}
}
// OptionPayload sets the payload attribute. This option is valid for the types:
// - Artifact
func OptionPayload(s Binary) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Payload", s, reflect.Slice)
}
}
// OptionURL sets the URL attribute. This option is valid for the types:
// - Artifact
func OptionURL(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "URL", s, reflect.String)
}
}
// OptionHashes sets the hashes attribute. This option is valid for the types:
// - Artifact
// - File
// - X509Certificate
func OptionHashes(s Hashes) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Hashes", s, reflect.Map)
}
}
// OptionEncryption sets the encryption algorithm attribute. This option is valid for the types:
// - Artifact
func OptionEncryption(s EncryptionAlgorithm) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Encryption", s, reflect.Uint8)
}
}
// OptionKey sets the decryption key attribute. This option is valid for the types:
// - Artifact
// - RegistryKey
func OptionKey(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Key", s, reflect.String)
}
}
// OptionRIR sets the rir attribute. This option is valid for the types:
// - AutonomousSystem
func OptionRIR(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "RIR", s, reflect.String)
}
}
// OptionPathEncoding sets the path encoding attribute. This option is valid for the types:
// - Directory
func OptionPathEncoding(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "PathEnc", s, reflect.String)
}
}
// OptionCtime sets the ctime attribute. This option is valid for the types:
// - Directory
// - File
func OptionCtime(s *Timestamp) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Ctime", s, reflect.Ptr)
}
}
// OptionMtime sets the mtime attribute. This option is valid for the types:
// - Directory
// - File
func OptionMtime(s *Timestamp) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Mtime", s, reflect.Ptr)
}
}
// OptionAtime sets the atime attribute. This option is valid for the types:
// - Directory
// - File
func OptionAtime(s *Timestamp) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Atime", s, reflect.Ptr)
}
}
// OptionContains sets the contains attribute. This option is valid for the types:
// - Directory
// - File
func OptionContains(s []Identifier) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Contains", s, reflect.Slice)
}
}
// OptionResolvesTo sets the resolves to attribute. This option is valid for the types:
// - DomainName
// - IPv4Address
// - IPv6Address
func OptionResolvesTo(s []Identifier) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "ResolvesTo", s, reflect.Slice)
}
}
// OptionDisplayName sets the display name attribute. This option is valid for the types:
// - EmailAddress
// - UserAccount
func OptionDisplayName(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "DisplayName", s, reflect.String)
}
}
// OptionBelongsTo sets the belongs to attribute. This option is valid for the types:
// - EmailAddress
// - IPv4Address
// - IPv6Address
func OptionBelongsTo(s Identifier) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "BelongsTo", s, reflect.String)
}
}
// OptionDate sets the date attribute. This option is valid for the types:
// - EmailMessage
func OptionDate(s *Timestamp) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Date", s, reflect.Ptr)
}
}
// OptionContentType sets the content type attribute. This option is valid for the types:
// - EmailMessage
func OptionContentType(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "ContentType", s, reflect.String)
}
}
// OptionFrom sets the from attribute. This option is valid for the types:
// - EmailMessage
func OptionFrom(s Identifier) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "From", s, reflect.String)
}
}
// OptionSender sets the sender attribute. This option is valid for the types:
// - EmailMessage
func OptionSender(s Identifier) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Sender", s, reflect.String)
}
}
// OptionTo sets the to attribute. This option is valid for the types:
// - EmailMessage
func OptionTo(s []Identifier) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "To", s, reflect.Slice)
}
}
// OptionCC sets the CC attribute. This option is valid for the types:
// - EmailMessage
func OptionCC(s []Identifier) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "CC", s, reflect.Slice)
}
}
// OptionBCC sets the BCC attribute. This option is valid for the types:
// - EmailMessage
func OptionBCC(s []Identifier) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "BCC", s, reflect.Slice)
}
}
// OptionMessageID sets the message ID attribute. This option is valid for the types:
// - EmailMessage
func OptionMessageID(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "MessageID", s, reflect.String)
}
}
// OptionSubject sets the subject attribute. This option is valid for the types:
// - EmailMessage
func OptionSubject(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Subject", s, reflect.String)
}
}
// OptionReceivedLines sets the received lines attribute. This option is valid for the types:
// - EmailMessage
func OptionReceivedLines(s []string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "ReceivedLines", s, reflect.Slice)
}
}
// OptionAdditionalHeaderFields sets the additional header fields
// attribute. This option is valid for the types:
// - EmailMessage
func OptionAdditionalHeaderFields(s map[string][]string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "AdditionalHeaderFields", s, reflect.Map)
}
}
// OptionBody sets the body attribute. This option is valid for the types:
// - EmailMessage
func OptionBody(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Body", s, reflect.String)
}
}
// OptionBodyMultipart sets the body multipart attribute. This option is valid for the types:
// - EmailMessage
func OptionBodyMultipart(s []EmailMIME) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "BodyMultipart", s, reflect.Slice)
}
}
// OptionRawEmail sets the raw email attribute. This option is valid for the types:
// - EmailMessage
func OptionRawEmail(s Identifier) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "RawEmail", s, reflect.String)
}
}
// OptionSize sets the size attribute. This option is valid for the types:
// - File
func OptionSize(s int64) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Size", s, reflect.Int64)
}
}
// OptionNameEnc sets the name encoding attribute. This option is valid for the types:
// - File
func OptionNameEnc(s string) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "NameEnc", s, reflect.String)
}
}
// OptionMagicNumber sets the magic number attribute. This option is valid for the types:
// - File
func OptionMagicNumber(s Hex) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "MagicNumber", s, reflect.String)
}
}
// OptionParentDirectory sets the parent directory attribute. This option is valid for the types:
// - File
func OptionParentDirectory(s Identifier) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "ParentDirectory", s, reflect.String)
}
}
// OptionContent sets the content attribute. This option is valid for the types:
// - File
func OptionContent(s Identifier) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Content", s, reflect.String)
}
}
// OptionStart sets the start attribute. This option is valid for the types:
// - NetworkTraffic
func OptionStart(s *Timestamp) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "Start", s, reflect.Ptr)
}
}
// OptionEnd sets the end attribute. This option is valid for the types:
// - NetworkTraffic
func OptionEnd(s *Timestamp) STIXOption {
return func(obj STIXObject) error {
return setField(obj, "End", s, reflect.Ptr)
}
}