/
export_configuration.go
869 lines (808 loc) · 39.2 KB
/
export_configuration.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
package appsec
import (
"context"
"encoding/json"
"fmt"
"net/http"
"reflect"
"time"
)
type (
// The ExportConfiguration interface supports exporting comprehensive details about a security
// configuration version. This operation returns more data than Get configuration version details,
// including rate and security policies, rules, hostnames, and numerous additional settings.
ExportConfiguration interface {
// GetExportConfigurations returns comprehensive details about a security configurations version.
//
// See: https://techdocs.akamai.com/application-security/reference/get-export-config-version
// Deprecated: this method will be removed in a future release. Use GetExportConfiguration instead.
GetExportConfigurations(ctx context.Context, params GetExportConfigurationsRequest) (*GetExportConfigurationsResponse, error)
// GetExportConfiguration returns comprehensive details about a security configuration version.
//
// See: https://techdocs.akamai.com/application-security/reference/get-export-config-version
GetExportConfiguration(ctx context.Context, params GetExportConfigurationRequest) (*GetExportConfigurationResponse, error)
}
// ConditionsValue is a slice of strings that describe conditions.
ConditionsValue []string
// GetExportConfigurationRequest is used to call GetExportConfiguration.
GetExportConfigurationRequest struct {
ConfigID int `json:"configId"`
Version int `json:"version"`
}
// EvaluatingSecurityPolicy is returned from a call to GetExportConfiguration.
EvaluatingSecurityPolicy struct {
EffectiveSecurityControls struct {
ApplyApplicationLayerControls bool `json:"applyApplicationLayerControls,omitempty"`
ApplyRateControls bool `json:"applyRateControls,omitempty"`
ApplySlowPostControls bool `json:"applySlowPostControls,omitempty"`
}
Hostnames []string `json:"hostnames,omitempty"`
SecurityPolicyID string `json:"id"`
}
// GetExportConfigurationResponse is returned from a call to GetExportConfiguration.
GetExportConfigurationResponse struct {
ConfigID int `json:"configId"`
ConfigName string `json:"configName"`
Version int `json:"version"`
BasedOn int `json:"basedOn"`
Staging struct {
Status string `json:"status"`
} `json:"staging"`
Production struct {
Status string `json:"status"`
} `json:"production"`
CreateDate time.Time `json:"-"`
CreatedBy string `json:"createdBy"`
SelectedHosts []string `json:"selectedHosts"`
SelectableHosts []string `json:"selectableHosts"`
RatePolicies []struct {
AdditionalMatchOptions []struct {
PositiveMatch bool `json:"positiveMatch"`
Type string `json:"type"`
Values []string `json:"values"`
} `json:"additionalMatchOptions"`
AllTraffic bool `json:"allTraffic,omitempty"`
AverageThreshold int `json:"averageThreshold"`
BurstThreshold int `json:"burstThreshold"`
ClientIdentifier string `json:"clientIdentifier"`
CreateDate time.Time `json:"-"`
Description string `json:"description,omitempty"`
FileExtensions *RatePolicyFileExtensions `json:"fileExtensions,omitempty"`
Hosts *RatePoliciesHosts `json:"hosts,omitempty"`
Hostnames []string `json:"hostnames,omitempty"`
ID int `json:"id"`
MatchType string `json:"matchType"`
Name string `json:"name"`
Path *RatePoliciesPath `json:"path,omitempty"`
PathMatchType string `json:"pathMatchType,omitempty"`
PathURIPositiveMatch bool `json:"pathUriPositiveMatch"`
QueryParameters *RatePoliciesQueryParameters `json:"queryParameters,omitempty"`
RequestType string `json:"requestType"`
SameActionOnIpv6 bool `json:"sameActionOnIpv6"`
Type string `json:"type"`
UpdateDate time.Time `json:"-"`
UseXForwardForHeaders bool `json:"useXForwardForHeaders"`
Used bool `json:"-"`
} `json:"ratePolicies"`
ReputationProfiles []struct {
Condition *ConditionReputationProfile `json:"condition,omitempty"`
Context string `json:"context,omitempty"`
ContextReadable string `json:"-"`
Enabled bool `json:"-"`
ID int `json:"id"`
Name string `json:"name"`
SharedIPHandling string `json:"sharedIpHandling"`
Threshold int `json:"threshold"`
} `json:"reputationProfiles"`
CustomRules []struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Version int `json:"-"`
RuleActivated bool `json:"-"`
Structured bool `json:"-"`
Tag []string `json:"tag,omitempty"`
Conditions []struct {
Name *json.RawMessage `json:"name,omitempty"`
NameCase *bool `json:"nameCase,omitempty"`
NameWildcard *bool `json:"nameWildcard,omitempty"`
PositiveMatch bool `json:"positiveMatch"`
Type string `json:"type"`
Value *json.RawMessage `json:"value,omitempty"`
ValueCase *bool `json:"valueCase,omitempty"`
ValueExactMatch *bool `json:"valueExactMatch,omitempty"`
ValueIgnoreSegment *bool `json:"valueIgnoreSegment,omitempty"`
ValueNormalize *bool `json:"valueNormalize,omitempty"`
ValueRecursive *bool `json:"valueRecursive,omitempty"`
ValueWildcard *bool `json:"valueWildcard,omitempty"`
UseXForwardForHeaders *bool `json:"useXForwardForHeaders,omitempty"`
} `json:"conditions,omitempty"`
EffectiveTimePeriod *CustomRuleEffectivePeriod `json:"effectiveTimePeriod,omitempty"`
SamplingRate int `json:"samplingRate,omitempty"`
LoggingOptions *json.RawMessage `json:"loggingOptions,omitempty"`
Operation string `json:"operation,omitempty"`
} `json:"customRules"`
Rulesets []struct {
ID int `json:"id"`
RulesetVersionID int `json:"rulesetVersionId"`
Type string `json:"type"`
ReleaseDate time.Time `json:"releaseDate"`
Rules *RulesetsRules `json:"rules,omitempty"`
AttackGroups []struct {
Group string `json:"group"`
GroupName string `json:"groupName"`
Threshold int `json:"threshold,omitempty"`
} `json:"attackGroups,omitempty"`
} `json:"rulesets"`
MatchTargets struct {
APITargets []struct {
Sequence int `json:"sequence"`
ID int `json:"id,omitempty"`
TargetID int `json:"targetId"`
Type string `json:"type,omitempty"`
Apis []struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
} `json:"apis,omitempty"`
SecurityPolicy struct {
PolicyID string `json:"policyId,omitempty"`
} `json:"securityPolicy,omitempty"`
BypassNetworkLists []struct {
Name string `json:"name,omitempty"`
ID string `json:"id,omitempty"`
} `json:"bypassNetworkLists,omitempty"`
} `json:"apiTargets,omitempty"`
WebsiteTargets []struct {
Type string `json:"type"`
BypassNetworkLists []struct {
ID string `json:"id"`
Name string `json:"name"`
} `json:"bypassNetworkLists,omitempty"`
DefaultFile string `json:"defaultFile"`
FilePaths []string `json:"filePaths,omitempty"`
FileExtensions []string `json:"fileExtensions,omitempty"`
Hostnames []string `json:"hostnames,omitempty"`
ID int `json:"id"`
IsNegativeFileExtensionMatch bool `json:"isNegativeFileExtensionMatch"`
IsNegativePathMatch bool `json:"isNegativePathMatch"`
SecurityPolicy struct {
PolicyID string `json:"policyId"`
} `json:"securityPolicy"`
Sequence int `json:"-"`
} `json:"websiteTargets"`
} `json:"matchTargets"`
SecurityPolicies []struct {
ID string `json:"id"`
Name string `json:"name"`
HasRatePolicyWithAPIKey bool `json:"hasRatePolicyWithApiKey"`
SecurityControls struct {
ApplyAPIConstraints bool `json:"applyApiConstraints"`
ApplyApplicationLayerControls bool `json:"applyApplicationLayerControls"`
ApplyBotmanControls bool `json:"applyBotmanControls"`
ApplyNetworkLayerControls bool `json:"applyNetworkLayerControls"`
ApplyRateControls bool `json:"applyRateControls"`
ApplyReputationControls bool `json:"applyReputationControls"`
ApplySlowPostControls bool `json:"applySlowPostControls"`
ApplyMalwareControls bool `json:"applyMalwareControls"`
} `json:"securityControls"`
WebApplicationFirewall struct {
RuleActions []struct {
Action string `json:"action"`
ID int `json:"id"`
RulesetVersionID int `json:"rulesetVersionId"`
Conditions *RuleConditions `json:"conditions,omitempty"`
AdvancedExceptionsList *AdvancedExceptions `json:"advancedExceptions,omitempty"`
Exception *RuleException `json:"exception,omitempty"`
} `json:"ruleActions,omitempty"`
AttackGroupActions []struct {
Action string `json:"action"`
Group string `json:"group"`
RulesetVersionID int `json:"rulesetVersionId"`
AdvancedExceptionsList *AttackGroupAdvancedExceptions `json:"advancedExceptions,omitempty"`
Exception *AttackGroupException `json:"exception,omitempty"`
} `json:"attackGroupActions,omitempty"`
Evaluation *WebApplicationFirewallEvaluation `json:"evaluation,omitempty"`
ThreatIntel string `json:"threatIntel"`
} `json:"webApplicationFirewall"`
CustomRuleActions []struct {
Action string `json:"action"`
ID int `json:"id"`
} `json:"customRuleActions,omitempty"`
APIRequestConstraints *APIRequestConstraintsexp `json:"apiRequestConstraints,omitempty"`
ClientReputation struct {
ReputationProfileActions *ClientReputationReputationProfileActions `json:"reputationProfileActions,omitempty"`
} `json:"clientReputation"`
RatePolicyActions *SecurityPoliciesRatePolicyActions `json:"ratePolicyActions,omitempty"`
MalwarePolicyActions []MalwarePolicyActionBody `json:"malwarePolicyActions,omitempty"`
IPGeoFirewall *IPGeoFirewall `json:"ipGeoFirewall,omitempty"`
PenaltyBox *SecurityPoliciesPenaltyBox `json:"penaltyBox,omitempty"`
EvaluationPenaltyBox *SecurityPoliciesPenaltyBox `json:"evaluationPenaltyBox,omitempty"`
SlowPost *SlowPostexp `json:"slowPost,omitempty"`
LoggingOverrides *LoggingOverridesexp `json:"loggingOverrides,omitempty"`
AttackPayloadLoggingOverrides *AttackPayloadLoggingOverrides `json:"attackPayloadLoggingOverrides,omitempty"`
PragmaHeader *GetAdvancedSettingsPragmaResponse `json:"pragmaHeader,omitempty"`
EvasivePathMatch *EvasivePathMatchexp `json:"evasivePathMatch,omitempty"`
RequestBody *RequestBody `json:"requestBody,omitempty"`
BotManagement *BotManagement `json:"botManagement,omitempty"`
} `json:"securityPolicies"`
Siem *Siemexp `json:"siem,omitempty"`
AdvancedOptions *AdvancedOptionsexp `json:"advancedOptions,omitempty"`
CustomDenyList *CustomDenyListexp `json:"customDenyList,omitempty"`
Evaluating struct {
SecurityPolicies []EvaluatingSecurityPolicy `json:"securityPolicies,omitempty"`
} `json:"evaluating,omitempty"`
MalwarePolicies []MalwarePolicyBody `json:"malwarePolicies,omitempty"`
CustomBotCategories []map[string]interface{} `json:"customBotCategories,omitempty"`
CustomDefinedBots []map[string]interface{} `json:"customDefinedBots,omitempty"`
CustomBotCategorySequence []string `json:"customBotCategorySequence,omitempty"`
CustomClients []map[string]interface{} `json:"customClients,omitempty"`
ResponseActions *ResponseActions `json:"responseActions,omitempty"`
AdvancedSettings *AdvancedSettings `json:"advancedSettings,omitempty"`
}
// GetExportConfigurationsRequest is used to call GetExportConfigurations.
// Deprecated: this struct will be removed in a future release.
GetExportConfigurationsRequest struct {
ConfigID int `json:"configId"`
Version int `json:"version"`
}
// GetExportConfigurationsResponse is returned from a call to GetExportConfigurations.
// Deprecated: this struct will be removed in a future release.
GetExportConfigurationsResponse struct {
ConfigID int `json:"configId"`
ConfigName string `json:"configName"`
Version int `json:"version"`
BasedOn int `json:"basedOn"`
Staging struct {
Status string `json:"status"`
} `json:"staging"`
Production struct {
Status string `json:"status"`
} `json:"production"`
CreateDate time.Time `json:"-"`
CreatedBy string `json:"createdBy"`
SelectedHosts []string `json:"selectedHosts"`
SelectableHosts []string `json:"selectableHosts"`
RatePolicies []struct {
AdditionalMatchOptions []struct {
PositiveMatch bool `json:"positiveMatch"`
Type string `json:"type"`
Values []string `json:"values"`
} `json:"additionalMatchOptions"`
AllTraffic bool `json:"allTraffic,omitempty"`
AverageThreshold int `json:"averageThreshold"`
BurstThreshold int `json:"burstThreshold"`
ClientIdentifier string `json:"clientIdentifier"`
CreateDate time.Time `json:"-"`
Description string `json:"description,omitempty"`
FileExtensions *RatePolicyFileExtensions `json:"fileExtensions,omitempty"`
Hosts *RatePoliciesHosts `json:"hosts,omitempty"`
Hostnames []string `json:"hostnames,omitempty"`
ID int `json:"id"`
MatchType string `json:"matchType"`
Name string `json:"name"`
Path *RatePoliciesPath `json:"path,omitempty"`
PathMatchType string `json:"pathMatchType,omitempty"`
PathURIPositiveMatch bool `json:"pathUriPositiveMatch"`
QueryParameters *RatePoliciesQueryParameters `json:"queryParameters,omitempty"`
RequestType string `json:"requestType"`
SameActionOnIpv6 bool `json:"sameActionOnIpv6"`
Type string `json:"type"`
UpdateDate time.Time `json:"-"`
UseXForwardForHeaders bool `json:"useXForwardForHeaders"`
Used bool `json:"-"`
} `json:"ratePolicies"`
ReputationProfiles []struct {
Condition *ConditionReputationProfile `json:"condition,omitempty"`
Context string `json:"context,omitempty"`
ContextReadable string `json:"-"`
Enabled bool `json:"-"`
ID int `json:"id"`
Name string `json:"name"`
SharedIPHandling string `json:"sharedIpHandling"`
Threshold int `json:"threshold"`
} `json:"reputationProfiles"`
CustomRules []struct {
Conditions *ConditionsExp `json:"conditions,omitempty"`
Description string `json:"description,omitempty"`
ID int `json:"id"`
Name string `json:"name"`
RuleActivated bool `json:"-"`
Structured bool `json:"-"`
Tag []string `json:"tag"`
Version int `json:"-"`
} `json:"customRules"`
Rulesets []struct {
ID int `json:"id"`
RulesetVersionID int `json:"rulesetVersionId"`
Type string `json:"type"`
ReleaseDate time.Time `json:"releaseDate"`
Rules *RulesetsRules `json:"rules,omitempty"`
AttackGroups []struct {
Group string `json:"group"`
GroupName string `json:"groupName"`
Threshold int `json:"threshold,omitempty"`
} `json:"attackGroups,omitempty"`
} `json:"rulesets"`
MatchTargets struct {
APITargets []struct {
Sequence int `json:"-"`
ID int `json:"id,omitempty"`
Type string `json:"type,omitempty"`
Apis []struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
} `json:"apis,omitempty"`
SecurityPolicy struct {
PolicyID string `json:"policyId,omitempty"`
} `json:"securityPolicy,omitempty"`
BypassNetworkLists []struct {
Name string `json:"name,omitempty"`
ID string `json:"id,omitempty"`
} `json:"bypassNetworkLists,omitempty"`
} `json:"apiTargets,omitempty"`
WebsiteTargets []struct {
Type string `json:"type"`
BypassNetworkLists []struct {
ID string `json:"id"`
Name string `json:"name"`
} `json:"bypassNetworkLists,omitempty"`
DefaultFile string `json:"defaultFile"`
FilePaths []string `json:"filePaths,omitempty"`
FileExtensions []string `json:"fileExtensions,omitempty"`
Hostnames []string `json:"hostnames,omitempty"`
ID int `json:"id"`
IsNegativeFileExtensionMatch bool `json:"isNegativeFileExtensionMatch"`
IsNegativePathMatch bool `json:"isNegativePathMatch"`
SecurityPolicy struct {
PolicyID string `json:"policyId"`
} `json:"securityPolicy"`
Sequence int `json:"-"`
} `json:"websiteTargets"`
} `json:"matchTargets"`
SecurityPolicies []struct {
ID string `json:"id"`
Name string `json:"name"`
HasRatePolicyWithAPIKey bool `json:"hasRatePolicyWithApiKey"`
SecurityControls struct {
ApplyAPIConstraints bool `json:"applyApiConstraints"`
ApplyApplicationLayerControls bool `json:"applyApplicationLayerControls"`
ApplyBotmanControls bool `json:"applyBotmanControls"`
ApplyNetworkLayerControls bool `json:"applyNetworkLayerControls"`
ApplyRateControls bool `json:"applyRateControls"`
ApplyReputationControls bool `json:"applyReputationControls"`
ApplySlowPostControls bool `json:"applySlowPostControls"`
ApplyMalwareControls bool `json:"applyMalwareControls"`
} `json:"securityControls"`
WebApplicationFirewall struct {
RuleActions []struct {
Action string `json:"action"`
ID int `json:"id"`
RulesetVersionID int `json:"rulesetVersionId"`
Conditions *RuleConditions `json:"conditions,omitempty"`
Exception *RuleException `json:"exception,omitempty"`
} `json:"ruleActions,omitempty"`
AttackGroupActions []struct {
Action string `json:"action"`
Group string `json:"group"`
RulesetVersionID int `json:"rulesetVersionId"`
AdvancedExceptionsList *AttackGroupAdvancedExceptions `json:"advancedExceptions,omitempty"`
Exception *AttackGroupException `json:"exception,omitempty"`
} `json:"attackGroupActions,omitempty"`
Evaluation *WebApplicationFirewallEvaluation `json:"evaluation,omitempty"`
ThreatIntel string `json:"threatIntel"`
} `json:"webApplicationFirewall"`
CustomRuleActions []struct {
Action string `json:"action"`
ID int `json:"id"`
} `json:"customRuleActions,omitempty"`
APIRequestConstraints *APIRequestConstraintsexp `json:"apiRequestConstraints,omitempty"`
ClientReputation struct {
ReputationProfileActions *ClientReputationReputationProfileActions `json:"reputationProfileActions,omitempty"`
} `json:"clientReputation"`
RatePolicyActions *SecurityPoliciesRatePolicyActions `json:"ratePolicyActions,omitempty"`
IPGeoFirewall struct {
Block string `json:"block"`
GeoControls struct {
BlockedIPNetworkLists struct {
NetworkList []string `json:"networkList,omitempty"`
} `json:"blockedIPNetworkLists"`
} `json:"geoControls"`
IPControls struct {
AllowedIPNetworkLists struct {
NetworkList []string `json:"networkList,omitempty"`
} `json:"allowedIPNetworkLists"`
BlockedIPNetworkLists struct {
NetworkList []string `json:"networkList,omitempty"`
} `json:"blockedIPNetworkLists"`
} `json:"ipControls"`
} `json:"ipGeoFirewall,omitempty"`
PenaltyBox *SecurityPoliciesPenaltyBox `json:"penaltyBox,omitempty"`
EvaluationPenaltyBox *SecurityPoliciesPenaltyBox `json:"evaluationPenaltyBox,omitempty"`
SlowPost *SlowPostexp `json:"slowPost,omitempty"`
LoggingOverrides *LoggingOverridesexp `json:"loggingOverrides,omitempty"`
AttackPayloadLoggingOverrides *AttackPayloadLoggingOverrides `json:"attackPayloadLoggingOverrides,omitempty"`
PragmaHeader *GetAdvancedSettingsPragmaResponse `json:"pragmaHeader,omitempty"`
EvasivePathMatch *EvasivePathMatchexp `json:"evasivePathMatch,omitempty"`
} `json:"securityPolicies"`
Siem *Siemexp `json:"siem,omitempty"`
AdvancedOptions *AdvancedOptionsexp `json:"advancedOptions,omitempty"`
CustomDenyList *CustomDenyListexp `json:"customDenyList,omitempty"`
Evaluating struct {
SecurityPolicies []struct {
EffectiveSecurityControls struct {
ApplyApplicationLayerControls bool `json:"applyApplicationLayerControls,omitempty"`
ApplyRateControls bool `json:"applyRateControls,omitempty"`
ApplySlowPostControls bool `json:"applySlowPostControls,omitempty"`
}
Hostnames []string `json:"hostnames,omitempty"`
SecurityPolicyID string `json:"id"`
}
} `json:"evaluating"`
}
// RatePoliciesPath is returned as part of GetExportConfigurationResponse.
RatePoliciesPath struct {
PositiveMatch bool `json:"positiveMatch"`
Values *RatePoliciesPathValues `json:"values,omitempty"`
}
// ReputationProfileActionsexp is returned as part of GetExportConfigurationResponse.
ReputationProfileActionsexp []struct {
Action string `json:"action"`
ID int `json:"id"`
}
// RatePolicyActionsexp is returned as part of GetExportConfigurationResponse.
RatePolicyActionsexp []struct {
ID int `json:"id"`
Ipv4Action string `json:"ipv4Action"`
Ipv6Action string `json:"ipv6Action"`
}
// SlowRateThresholdExp is returned as part of GetExportConfigurationResponse.
SlowRateThresholdExp struct {
Period int `json:"period"`
Rate int `json:"rate"`
}
// DurationThresholdExp is returned as part of GetExportConfigurationResponse.
DurationThresholdExp struct {
Timeout int `json:"timeout"`
}
// SlowPostexp is returned as part of GetExportConfigurationResponse.
SlowPostexp struct {
Action string `json:"action"`
SlowRateThreshold *SlowRateThresholdExp `json:"slowRateThreshold,omitempty"`
DurationThreshold *DurationThresholdExp `json:"durationThreshold,omitempty"`
}
// AdvancedOptionsexp is returned as part of GetExportConfigurationResponse.
AdvancedOptionsexp struct {
Logging *Loggingexp `json:"logging"`
AttackPayloadLogging *AttackPayloadLogging `json:"attackPayloadLogging"`
EvasivePathMatch *EvasivePathMatchexp `json:"evasivePathMatch,omitempty"`
Prefetch struct {
AllExtensions bool `json:"allExtensions"`
EnableAppLayer bool `json:"enableAppLayer"`
EnableRateControls bool `json:"enableRateControls"`
Extensions []string `json:"extensions,omitempty"`
} `json:"prefetch"`
PragmaHeader *GetAdvancedSettingsPragmaResponse `json:"pragmaHeader,omitempty"`
RequestBody *RequestBody `json:"requestBody,omitempty"`
}
// CustomDenyListexp is returned as part of GetExportConfigurationResponse.
CustomDenyListexp []struct {
Description string `json:"description,omitempty"`
Name string `json:"name"`
ID string `json:"id"`
Parameters []struct {
DisplayName string `json:"-"`
Name string `json:"name"`
Value string `json:"value"`
} `json:"parameters"`
}
// CustomRuleActionsexp is returned as part of GetExportConfigurationResponse.
CustomRuleActionsexp []struct {
Action string `json:"action"`
ID int `json:"id"`
}
// Siemexp is returned as part of GetExportConfigurationResponse.
Siemexp struct {
EnableForAllPolicies bool `json:"enableForAllPolicies,omitempty"`
EnableSiem bool `json:"enableSiem"`
EnabledBotmanSiemEvents bool `json:"enabledBotmanSiemEvents,omitempty"`
FirewallPolicyIds []string `json:"firewallPolicyIds,omitempty"`
SiemDefinitionID int `json:"siemDefinitionId,omitempty"`
}
// PenaltyBoxexp is returned as part of GetExportConfigurationResponse.
PenaltyBoxexp struct {
Action string `json:"action"`
PenaltyBoxProtection bool `json:"penaltyBoxProtection"`
}
// APIRequestConstraintsexp is returned as part of GetExportConfigurationResponse.
APIRequestConstraintsexp struct {
Action string `json:"action,omitempty"`
APIEndpoints []struct {
Action string `json:"action"`
ID int `json:"id"`
} `json:"apiEndpoints,omitempty"`
}
// Evaluationexp is returned as part of GetExportConfigurationResponse.
Evaluationexp struct {
AttackGroupActions []struct {
Action string `json:"action"`
Group string `json:"group"`
} `json:"attackGroupActions"`
EvaluationID int `json:"evaluationId"`
EvaluationVersion int `json:"evaluationVersion"`
RuleActions []struct {
Action string `json:"action"`
ID int `json:"id"`
Conditions *RuleConditions `json:"conditions,omitempty"`
Exception *RuleException `json:"exception,omitempty"`
} `json:"ruleActions"`
RulesetVersionID int `json:"rulesetVersionId"`
}
// ConditionReputationProfile is returned as part of GetExportConfigurationResponse.
ConditionReputationProfile struct {
AtomicConditions *AtomicConditionsexp `json:"atomicConditions,omitempty"`
CanDelete bool `json:"-"`
ConfigVersionID int `json:"-"`
ID int `json:"-"`
Name string `json:"-"`
PositiveMatch *json.RawMessage `json:"positiveMatch,omitempty"`
UUID string `json:"-"`
Version int64 `json:"-"`
}
// HeaderCookieOrParamValuesattackgroup is returned as part of GetExportConfigurationResponse.
HeaderCookieOrParamValuesattackgroup []struct {
Criteria []struct {
Hostnames []string `json:"hostnames,omitempty"`
Paths []string `json:"paths,omitempty"`
Values []string `json:"values,omitempty"`
} `json:"criteria"`
ValueWildcard bool `json:"valueWildcard,omitempty"`
Values []string `json:"values,omitempty"`
}
// SpecificHeaderCookieOrParamNameValueexp is returned as part of GetExportConfigurationResponse.
SpecificHeaderCookieOrParamNameValueexp struct {
Name *json.RawMessage `json:"name,omitempty"`
Selector string `json:"selector,omitempty"`
Value *json.RawMessage `json:"value,omitempty"`
}
// AtomicConditionsexp is returned as part of GetExportConfigurationResponse.
AtomicConditionsexp []struct {
CheckIps *json.RawMessage `json:"checkIps,omitempty"`
ClassName string `json:"className,omitempty"`
Index int `json:"index,omitempty"`
PositiveMatch *json.RawMessage `json:"positiveMatch,omitempty"`
Value []string `json:"value,omitempty"`
Name *json.RawMessage `json:"name,omitempty"`
NameCase bool `json:"nameCase,omitempty"`
NameWildcard *json.RawMessage `json:"nameWildcard,omitempty"`
ValueCase bool `json:"valueCase,omitempty"`
ValueWildcard *json.RawMessage `json:"valueWildcard,omitempty"`
Host []string `json:"host,omitempty"`
}
// Loggingexp is returned as part of GetExportConfigurationResponse.
Loggingexp struct {
AllowSampling bool `json:"allowSampling"`
Cookies struct {
Type string `json:"type"`
Values []string `json:"values,omitempty"`
} `json:"cookies"`
CustomHeaders struct {
Type string `json:"type"`
Values []string `json:"values,omitempty"`
} `json:"customHeaders"`
StandardHeaders struct {
Type string `json:"type"`
Values []string `json:"values,omitempty"`
} `json:"standardHeaders"`
}
// LoggingOverridesexp is returned as part of GetExportConfigurationResponse.
LoggingOverridesexp struct {
AllowSampling bool `json:"allowSampling"`
Cookies struct {
Type string `json:"type"`
Values []string `json:"values,omitempty"`
} `json:"cookies"`
CustomHeaders struct {
Type string `json:"type"`
Values []string `json:"values,omitempty"`
} `json:"customHeaders"`
Override bool `json:"override"`
StandardHeaders struct {
Type string `json:"type"`
Values []string `json:"values,omitempty"`
} `json:"standardHeaders"`
}
// AttackPayloadLogging is returned as part of GetExportConfigurationResponse.
AttackPayloadLogging struct {
Enabled bool `json:"enabled"`
RequestBody struct {
Type string `json:"type"`
} `json:"requestBody"`
ResponseBody struct {
Type string `json:"type"`
} `json:"responseBody"`
}
// AttackPayloadLoggingOverrides is returned as part of GetExportConfigurationResponse.
AttackPayloadLoggingOverrides struct {
Enabled bool `json:"enabled"`
RequestBody struct {
Type string `json:"type"`
} `json:"requestBody"`
ResponseBody struct {
Type string `json:"type"`
} `json:"responseBody"`
Override bool `json:"override"`
}
// EvasivePathMatchexp contains the EnablePathMatch setting
EvasivePathMatchexp struct {
EnablePathMatch bool `json:"enabled"`
}
// RequestBody is returned as part of GetExportConfigurationResponse.
RequestBody struct {
RequestBodyInspectionLimitInKB string `json:"requestBodyInspectionLimitInKB"`
}
// ConditionsExp is returned as part of GetExportConfigurationResponse.
ConditionsExp []struct {
Type string `json:"type"`
PositiveMatch bool `json:"positiveMatch"`
Name *json.RawMessage `json:"name,omitempty"`
NameCase *json.RawMessage `json:"nameCase,omitempty"`
NameWildcard *json.RawMessage `json:"nameWildcard,omitempty"`
Value *json.RawMessage `json:"value,omitempty"`
ValueCase *json.RawMessage `json:"valueCase,omitempty"`
ValueWildcard *json.RawMessage `json:"valueWildcard,omitempty"`
}
// RatePoliciesPathValues is returned as part of GetExportConfigurationResponse.
RatePoliciesPathValues []string
// RatePoliciesQueryParameters is returned as part of GetExportConfigurationResponse.
RatePoliciesQueryParameters []struct {
Name string `json:"name"`
PositiveMatch bool `json:"positiveMatch"`
ValueInRange bool `json:"valueInRange"`
Values *RatePoliciesQueryParametersValues `json:"values,omitempty"`
}
// RatePoliciesQueryParametersValues is returned as part of GetExportConfigurationResponse.
RatePoliciesQueryParametersValues []string
// SecurityPoliciesPenaltyBox is returned as part of GetExportConfigurationResponse.
SecurityPoliciesPenaltyBox struct {
Action string `json:"action,omitempty"`
PenaltyBoxProtection bool `json:"penaltyBoxProtection,omitempty"`
}
// WebApplicationFirewallEvaluation is returned as part of GetExportConfigurationResponse.
WebApplicationFirewallEvaluation struct {
AttackGroupActions []struct {
Action string `json:"action"`
Group string `json:"group"`
Exception *RuleException `json:"exception,omitempty"`
AdvancedExceptionsList *AdvancedExceptions `json:"advancedExceptions,omitempty"`
} `json:"attackGroupActions,omitempty"`
EvaluationID int `json:"evaluationId"`
EvaluationVersion int `json:"evaluationVersion"`
RuleActions []struct {
Action string `json:"action"`
ID int `json:"id"`
Conditions *RuleConditions `json:"conditions,omitempty"`
Exception *RuleException `json:"exception,omitempty"`
AdvancedExceptionsList *AdvancedExceptions `json:"advancedExceptions,omitempty"`
} `json:"ruleActions,omitempty"`
RulesetVersionID int `json:"rulesetVersionId"`
}
// RulesetsRules is returned as part of GetExportConfigurationResponse.
RulesetsRules []struct {
ID int `json:"id"`
InspectRequestBody bool `json:"inspectRequestBody"`
InspectResponseBody bool `json:"inspectResponseBody"`
Outdated bool `json:"outdated"`
RuleVersion int `json:"ruleVersion"`
Score int `json:"score"`
Tag string `json:"tag"`
Title string `json:"title"`
AttackGroups []string `json:"attackGroups,omitempty"`
}
// ClientReputationReputationProfileActions is returned as part of GetExportConfigurationResponse.
ClientReputationReputationProfileActions []struct {
Action string `json:"action"`
ID int `json:"id"`
}
// SecurityPoliciesRatePolicyActions is returned as part of GetExportConfigurationResponse.
SecurityPoliciesRatePolicyActions []struct {
ID int `json:"id"`
Ipv4Action string `json:"ipv4Action"`
Ipv6Action string `json:"ipv6Action"`
}
// AdvancedSettings is returned as part of GetExportConfigurationResponse
AdvancedSettings struct {
BotAnalyticsCookieSettings map[string]interface{} `json:"botAnalyticsCookieSettings,omitempty"`
ClientSideSecuritySettings map[string]interface{} `json:"clientSideSecuritySettings,omitempty"`
TransactionalEndpointProtectionSettings map[string]interface{} `json:"transactionalEndpointProtectionSettings,omitempty"`
}
// ResponseActions is returned as part of GetExportConfigurationResponse
ResponseActions struct {
ChallengeActions []map[string]interface{} `json:"challengeActions,omitempty"`
ConditionalActions []map[string]interface{} `json:"conditionalActions,omitempty"`
CustomDenyActions []map[string]interface{} `json:"customDenyActions,omitempty"`
ServeAlternateActions []map[string]interface{} `json:"serveAlternateActions,omitempty"`
ChallengeInterceptionRules map[string]interface{} `json:"challengeInterceptionRules,omitempty"`
}
// BotManagement is returned as part of GetExportConfigurationResponse
BotManagement struct {
AkamaiBotCategoryActions []map[string]interface{} `json:"akamaiBotCategoryActions,omitempty"`
BotDetectionActions []map[string]interface{} `json:"botDetectionActions,omitempty"`
BotManagementSettings map[string]interface{} `json:"botManagementSettings,omitempty"`
CustomBotCategoryActions []map[string]interface{} `json:"customBotCategoryActions,omitempty"`
JavascriptInjectionRules map[string]interface{} `json:"javascriptInjectionRules,omitempty"`
TransactionalEndpoints *TransactionalEndpoints `json:"transactionalEndpoints,omitempty"`
}
// TransactionalEndpoints is returned as port of GetExportConfigurationResponse
TransactionalEndpoints struct {
BotProtection []map[string]interface{} `json:"botProtection,omitempty"`
BotProtectionExceptions map[string]interface{} `json:"botProtectionExceptions,omitempty"`
}
)
// UnmarshalJSON reads a ConditionsValue struct from its data argument.
func (c *ConditionsValue) UnmarshalJSON(data []byte) error {
var nums interface{}
err := json.Unmarshal(data, &nums)
if err != nil {
return err
}
items := reflect.ValueOf(nums)
switch items.Kind() {
case reflect.String:
*c = append(*c, items.String())
case reflect.Slice:
*c = make(ConditionsValue, 0, items.Len())
for i := 0; i < items.Len(); i++ {
item := items.Index(i)
switch item.Kind() {
case reflect.String:
*c = append(*c, item.String())
case reflect.Interface:
*c = append(*c, item.Interface().(string))
}
}
}
return nil
}
func (p *appsec) GetExportConfiguration(ctx context.Context, params GetExportConfigurationRequest) (*GetExportConfigurationResponse, error) {
logger := p.Log(ctx)
logger.Debug("GetExportConfiguration")
uri := fmt.Sprintf(
"/appsec/v1/export/configs/%d/versions/%d",
params.ConfigID,
params.Version)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil, fmt.Errorf("failed to create GetExportConfiguration request: %w", err)
}
var result GetExportConfigurationResponse
resp, err := p.Exec(req, &result)
if err != nil {
return nil, fmt.Errorf("get export configuration request failed: %w", err)
}
if resp.StatusCode != http.StatusOK {
return nil, p.Error(resp)
}
return &result, nil
}
// Deprecated: this method will be removed in a future release.
func (p *appsec) GetExportConfigurations(ctx context.Context, params GetExportConfigurationsRequest) (*GetExportConfigurationsResponse, error) {
logger := p.Log(ctx)
logger.Debug("GetExportConfigurations")
uri := fmt.Sprintf(
"/appsec/v1/export/configs/%d/versions/%d",
params.ConfigID,
params.Version)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil, fmt.Errorf("failed to create GetExportConfigurations request: %w", err)
}
var result GetExportConfigurationsResponse
resp, err := p.Exec(req, &result)
if err != nil {
return nil, fmt.Errorf("get export configurations request failed: %w", err)
}
if resp.StatusCode != http.StatusOK {
return nil, p.Error(resp)
}
return &result, nil
}