github.com/akamai/AkamaiOPEN-edgegrid-golang/v4@v4.1.0/pkg/appsec/export_configuration.go (about) 1 package appsec 2 3 import ( 4 "context" 5 "encoding/json" 6 "fmt" 7 "net/http" 8 "reflect" 9 10 "time" 11 ) 12 13 type ( 14 // The ExportConfiguration interface supports exporting comprehensive details about a security 15 // configuration version. This operation returns more data than Get configuration version details, 16 // including rate and security policies, rules, hostnames, and numerous additional settings. 17 ExportConfiguration interface { 18 // GetExportConfigurations returns comprehensive details about a security configurations version. 19 // 20 // See: https://techdocs.akamai.com/application-security/reference/get-export-config-version 21 // Deprecated: this method will be removed in a future release. Use GetExportConfiguration instead. 22 GetExportConfigurations(ctx context.Context, params GetExportConfigurationsRequest) (*GetExportConfigurationsResponse, error) 23 24 // GetExportConfiguration returns comprehensive details about a security configuration version. 25 // 26 // See: https://techdocs.akamai.com/application-security/reference/get-export-config-version 27 GetExportConfiguration(ctx context.Context, params GetExportConfigurationRequest) (*GetExportConfigurationResponse, error) 28 } 29 30 // ConditionsValue is a slice of strings that describe conditions. 31 ConditionsValue []string 32 33 // GetExportConfigurationRequest is used to call GetExportConfiguration. 34 GetExportConfigurationRequest struct { 35 ConfigID int `json:"configId"` 36 Version int `json:"version"` 37 } 38 39 // EvaluatingSecurityPolicy is returned from a call to GetExportConfiguration. 40 EvaluatingSecurityPolicy struct { 41 EffectiveSecurityControls struct { 42 ApplyApplicationLayerControls bool `json:"applyApplicationLayerControls,omitempty"` 43 ApplyRateControls bool `json:"applyRateControls,omitempty"` 44 ApplySlowPostControls bool `json:"applySlowPostControls,omitempty"` 45 } 46 Hostnames []string `json:"hostnames,omitempty"` 47 SecurityPolicyID string `json:"id"` 48 } 49 50 // GetExportConfigurationResponse is returned from a call to GetExportConfiguration. 51 GetExportConfigurationResponse struct { 52 ConfigID int `json:"configId"` 53 ConfigName string `json:"configName"` 54 Version int `json:"version"` 55 BasedOn int `json:"basedOn"` 56 Staging struct { 57 Status string `json:"status"` 58 } `json:"staging"` 59 Production struct { 60 Status string `json:"status"` 61 } `json:"production"` 62 CreateDate time.Time `json:"-"` 63 CreatedBy string `json:"createdBy"` 64 SelectedHosts []string `json:"selectedHosts"` 65 SelectableHosts []string `json:"selectableHosts"` 66 RatePolicies []struct { 67 AdditionalMatchOptions []struct { 68 PositiveMatch bool `json:"positiveMatch"` 69 Type string `json:"type"` 70 Values []string `json:"values"` 71 } `json:"additionalMatchOptions"` 72 AllTraffic bool `json:"allTraffic,omitempty"` 73 AverageThreshold int `json:"averageThreshold"` 74 BurstThreshold int `json:"burstThreshold"` 75 ClientIdentifier string `json:"clientIdentifier"` 76 CreateDate time.Time `json:"-"` 77 Description string `json:"description,omitempty"` 78 FileExtensions *RatePolicyFileExtensions `json:"fileExtensions,omitempty"` 79 Hosts *RatePoliciesHosts `json:"hosts,omitempty"` 80 Hostnames []string `json:"hostnames,omitempty"` 81 ID int `json:"id"` 82 MatchType string `json:"matchType"` 83 Name string `json:"name"` 84 Path *RatePoliciesPath `json:"path,omitempty"` 85 PathMatchType string `json:"pathMatchType,omitempty"` 86 PathURIPositiveMatch bool `json:"pathUriPositiveMatch"` 87 QueryParameters *RatePoliciesQueryParameters `json:"queryParameters,omitempty"` 88 RequestType string `json:"requestType"` 89 SameActionOnIpv6 bool `json:"sameActionOnIpv6"` 90 Type string `json:"type"` 91 UpdateDate time.Time `json:"-"` 92 UseXForwardForHeaders bool `json:"useXForwardForHeaders"` 93 Used bool `json:"-"` 94 } `json:"ratePolicies"` 95 ReputationProfiles []struct { 96 Condition *ConditionReputationProfile `json:"condition,omitempty"` 97 Context string `json:"context,omitempty"` 98 ContextReadable string `json:"-"` 99 100 Enabled bool `json:"-"` 101 ID int `json:"id"` 102 Name string `json:"name"` 103 SharedIPHandling string `json:"sharedIpHandling"` 104 Threshold int `json:"threshold"` 105 } `json:"reputationProfiles"` 106 CustomRules []struct { 107 ID int `json:"id"` 108 Name string `json:"name"` 109 Description string `json:"description,omitempty"` 110 Version int `json:"-"` 111 RuleActivated bool `json:"-"` 112 Structured bool `json:"-"` 113 Tag []string `json:"tag,omitempty"` 114 Conditions []struct { 115 Name *json.RawMessage `json:"name,omitempty"` 116 NameCase *bool `json:"nameCase,omitempty"` 117 NameWildcard *bool `json:"nameWildcard,omitempty"` 118 PositiveMatch bool `json:"positiveMatch"` 119 Type string `json:"type"` 120 Value *json.RawMessage `json:"value,omitempty"` 121 ValueCase *bool `json:"valueCase,omitempty"` 122 ValueExactMatch *bool `json:"valueExactMatch,omitempty"` 123 ValueIgnoreSegment *bool `json:"valueIgnoreSegment,omitempty"` 124 ValueNormalize *bool `json:"valueNormalize,omitempty"` 125 ValueRecursive *bool `json:"valueRecursive,omitempty"` 126 ValueWildcard *bool `json:"valueWildcard,omitempty"` 127 UseXForwardForHeaders *bool `json:"useXForwardForHeaders,omitempty"` 128 } `json:"conditions,omitempty"` 129 130 EffectiveTimePeriod *CustomRuleEffectivePeriod `json:"effectiveTimePeriod,omitempty"` 131 SamplingRate int `json:"samplingRate,omitempty"` 132 LoggingOptions *json.RawMessage `json:"loggingOptions,omitempty"` 133 Operation string `json:"operation,omitempty"` 134 } `json:"customRules"` 135 Rulesets []struct { 136 ID int `json:"id"` 137 RulesetVersionID int `json:"rulesetVersionId"` 138 Type string `json:"type"` 139 ReleaseDate time.Time `json:"releaseDate"` 140 Rules *RulesetsRules `json:"rules,omitempty"` 141 AttackGroups []struct { 142 Group string `json:"group"` 143 GroupName string `json:"groupName"` 144 Threshold int `json:"threshold,omitempty"` 145 } `json:"attackGroups,omitempty"` 146 } `json:"rulesets"` 147 MatchTargets struct { 148 APITargets []struct { 149 Sequence int `json:"sequence"` 150 ID int `json:"id,omitempty"` 151 TargetID int `json:"targetId"` 152 Type string `json:"type,omitempty"` 153 Apis []struct { 154 ID int `json:"id,omitempty"` 155 Name string `json:"name,omitempty"` 156 } `json:"apis,omitempty"` 157 SecurityPolicy struct { 158 PolicyID string `json:"policyId,omitempty"` 159 } `json:"securityPolicy,omitempty"` 160 BypassNetworkLists []struct { 161 Name string `json:"name,omitempty"` 162 ID string `json:"id,omitempty"` 163 } `json:"bypassNetworkLists,omitempty"` 164 } `json:"apiTargets,omitempty"` 165 WebsiteTargets []struct { 166 Type string `json:"type"` 167 BypassNetworkLists []struct { 168 ID string `json:"id"` 169 Name string `json:"name"` 170 } `json:"bypassNetworkLists,omitempty"` 171 DefaultFile string `json:"defaultFile"` 172 FilePaths []string `json:"filePaths,omitempty"` 173 FileExtensions []string `json:"fileExtensions,omitempty"` 174 Hostnames []string `json:"hostnames,omitempty"` 175 ID int `json:"id"` 176 IsNegativeFileExtensionMatch bool `json:"isNegativeFileExtensionMatch"` 177 IsNegativePathMatch bool `json:"isNegativePathMatch"` 178 SecurityPolicy struct { 179 PolicyID string `json:"policyId"` 180 } `json:"securityPolicy"` 181 Sequence int `json:"-"` 182 } `json:"websiteTargets"` 183 } `json:"matchTargets"` 184 SecurityPolicies []struct { 185 ID string `json:"id"` 186 Name string `json:"name"` 187 HasRatePolicyWithAPIKey bool `json:"hasRatePolicyWithApiKey"` 188 SecurityControls struct { 189 ApplyAPIConstraints bool `json:"applyApiConstraints"` 190 ApplyApplicationLayerControls bool `json:"applyApplicationLayerControls"` 191 ApplyBotmanControls bool `json:"applyBotmanControls"` 192 ApplyNetworkLayerControls bool `json:"applyNetworkLayerControls"` 193 ApplyRateControls bool `json:"applyRateControls"` 194 ApplyReputationControls bool `json:"applyReputationControls"` 195 ApplySlowPostControls bool `json:"applySlowPostControls"` 196 ApplyMalwareControls bool `json:"applyMalwareControls"` 197 } `json:"securityControls"` 198 WebApplicationFirewall struct { 199 RuleActions []struct { 200 Action string `json:"action"` 201 ID int `json:"id"` 202 RulesetVersionID int `json:"rulesetVersionId"` 203 Conditions *RuleConditions `json:"conditions,omitempty"` 204 AdvancedExceptionsList *AdvancedExceptions `json:"advancedExceptions,omitempty"` 205 Exception *RuleException `json:"exception,omitempty"` 206 } `json:"ruleActions,omitempty"` 207 AttackGroupActions []struct { 208 Action string `json:"action"` 209 Group string `json:"group"` 210 RulesetVersionID int `json:"rulesetVersionId"` 211 AdvancedExceptionsList *AttackGroupAdvancedExceptions `json:"advancedExceptions,omitempty"` 212 Exception *AttackGroupException `json:"exception,omitempty"` 213 } `json:"attackGroupActions,omitempty"` 214 Evaluation *WebApplicationFirewallEvaluation `json:"evaluation,omitempty"` 215 ThreatIntel string `json:"threatIntel"` 216 } `json:"webApplicationFirewall"` 217 CustomRuleActions []struct { 218 Action string `json:"action"` 219 ID int `json:"id"` 220 } `json:"customRuleActions,omitempty"` 221 APIRequestConstraints *APIRequestConstraintsexp `json:"apiRequestConstraints,omitempty"` 222 ClientReputation struct { 223 ReputationProfileActions *ClientReputationReputationProfileActions `json:"reputationProfileActions,omitempty"` 224 } `json:"clientReputation"` 225 RatePolicyActions *SecurityPoliciesRatePolicyActions `json:"ratePolicyActions,omitempty"` 226 MalwarePolicyActions []MalwarePolicyActionBody `json:"malwarePolicyActions,omitempty"` 227 IPGeoFirewall *IPGeoFirewall `json:"ipGeoFirewall,omitempty"` 228 PenaltyBox *SecurityPoliciesPenaltyBox `json:"penaltyBox,omitempty"` 229 EvaluationPenaltyBox *SecurityPoliciesPenaltyBox `json:"evaluationPenaltyBox,omitempty"` 230 SlowPost *SlowPostexp `json:"slowPost,omitempty"` 231 LoggingOverrides *LoggingOverridesexp `json:"loggingOverrides,omitempty"` 232 AttackPayloadLoggingOverrides *AttackPayloadLoggingOverrides `json:"attackPayloadLoggingOverrides,omitempty"` 233 PragmaHeader *GetAdvancedSettingsPragmaResponse `json:"pragmaHeader,omitempty"` 234 EvasivePathMatch *EvasivePathMatchexp `json:"evasivePathMatch,omitempty"` 235 BotManagement *BotManagement `json:"botManagement,omitempty"` 236 } `json:"securityPolicies"` 237 Siem *Siemexp `json:"siem,omitempty"` 238 AdvancedOptions *AdvancedOptionsexp `json:"advancedOptions,omitempty"` 239 CustomDenyList *CustomDenyListexp `json:"customDenyList,omitempty"` 240 Evaluating struct { 241 SecurityPolicies []EvaluatingSecurityPolicy `json:"securityPolicies,omitempty"` 242 } `json:"evaluating,omitempty"` 243 MalwarePolicies []MalwarePolicyBody `json:"malwarePolicies,omitempty"` 244 CustomBotCategories []map[string]interface{} `json:"customBotCategories,omitempty"` 245 CustomDefinedBots []map[string]interface{} `json:"customDefinedBots,omitempty"` 246 CustomBotCategorySequence []string `json:"customBotCategorySequence,omitempty"` 247 CustomClients []map[string]interface{} `json:"customClients,omitempty"` 248 ResponseActions *ResponseActions `json:"responseActions,omitempty"` 249 AdvancedSettings *AdvancedSettings `json:"advancedSettings,omitempty"` 250 } 251 252 // GetExportConfigurationsRequest is used to call GetExportConfigurations. 253 // Deprecated: this struct will be removed in a future release. 254 GetExportConfigurationsRequest struct { 255 ConfigID int `json:"configId"` 256 Version int `json:"version"` 257 } 258 259 // GetExportConfigurationsResponse is returned from a call to GetExportConfigurations. 260 // Deprecated: this struct will be removed in a future release. 261 GetExportConfigurationsResponse struct { 262 ConfigID int `json:"configId"` 263 ConfigName string `json:"configName"` 264 Version int `json:"version"` 265 BasedOn int `json:"basedOn"` 266 Staging struct { 267 Status string `json:"status"` 268 } `json:"staging"` 269 Production struct { 270 Status string `json:"status"` 271 } `json:"production"` 272 CreateDate time.Time `json:"-"` 273 CreatedBy string `json:"createdBy"` 274 SelectedHosts []string `json:"selectedHosts"` 275 SelectableHosts []string `json:"selectableHosts"` 276 RatePolicies []struct { 277 AdditionalMatchOptions []struct { 278 PositiveMatch bool `json:"positiveMatch"` 279 Type string `json:"type"` 280 Values []string `json:"values"` 281 } `json:"additionalMatchOptions"` 282 AllTraffic bool `json:"allTraffic,omitempty"` 283 AverageThreshold int `json:"averageThreshold"` 284 BurstThreshold int `json:"burstThreshold"` 285 ClientIdentifier string `json:"clientIdentifier"` 286 CreateDate time.Time `json:"-"` 287 Description string `json:"description,omitempty"` 288 FileExtensions *RatePolicyFileExtensions `json:"fileExtensions,omitempty"` 289 Hosts *RatePoliciesHosts `json:"hosts,omitempty"` 290 Hostnames []string `json:"hostnames,omitempty"` 291 ID int `json:"id"` 292 MatchType string `json:"matchType"` 293 Name string `json:"name"` 294 Path *RatePoliciesPath `json:"path,omitempty"` 295 PathMatchType string `json:"pathMatchType,omitempty"` 296 PathURIPositiveMatch bool `json:"pathUriPositiveMatch"` 297 QueryParameters *RatePoliciesQueryParameters `json:"queryParameters,omitempty"` 298 RequestType string `json:"requestType"` 299 SameActionOnIpv6 bool `json:"sameActionOnIpv6"` 300 Type string `json:"type"` 301 UpdateDate time.Time `json:"-"` 302 UseXForwardForHeaders bool `json:"useXForwardForHeaders"` 303 Used bool `json:"-"` 304 } `json:"ratePolicies"` 305 ReputationProfiles []struct { 306 Condition *ConditionReputationProfile `json:"condition,omitempty"` 307 Context string `json:"context,omitempty"` 308 ContextReadable string `json:"-"` 309 Enabled bool `json:"-"` 310 ID int `json:"id"` 311 Name string `json:"name"` 312 SharedIPHandling string `json:"sharedIpHandling"` 313 Threshold int `json:"threshold"` 314 } `json:"reputationProfiles"` 315 CustomRules []struct { 316 Conditions *ConditionsExp `json:"conditions,omitempty"` 317 Description string `json:"description,omitempty"` 318 ID int `json:"id"` 319 Name string `json:"name"` 320 RuleActivated bool `json:"-"` 321 Structured bool `json:"-"` 322 Tag []string `json:"tag"` 323 Version int `json:"-"` 324 } `json:"customRules"` 325 Rulesets []struct { 326 ID int `json:"id"` 327 RulesetVersionID int `json:"rulesetVersionId"` 328 Type string `json:"type"` 329 ReleaseDate time.Time `json:"releaseDate"` 330 Rules *RulesetsRules `json:"rules,omitempty"` 331 AttackGroups []struct { 332 Group string `json:"group"` 333 GroupName string `json:"groupName"` 334 Threshold int `json:"threshold,omitempty"` 335 } `json:"attackGroups,omitempty"` 336 } `json:"rulesets"` 337 MatchTargets struct { 338 APITargets []struct { 339 Sequence int `json:"-"` 340 ID int `json:"id,omitempty"` 341 Type string `json:"type,omitempty"` 342 Apis []struct { 343 ID int `json:"id,omitempty"` 344 Name string `json:"name,omitempty"` 345 } `json:"apis,omitempty"` 346 SecurityPolicy struct { 347 PolicyID string `json:"policyId,omitempty"` 348 } `json:"securityPolicy,omitempty"` 349 BypassNetworkLists []struct { 350 Name string `json:"name,omitempty"` 351 ID string `json:"id,omitempty"` 352 } `json:"bypassNetworkLists,omitempty"` 353 } `json:"apiTargets,omitempty"` 354 WebsiteTargets []struct { 355 Type string `json:"type"` 356 BypassNetworkLists []struct { 357 ID string `json:"id"` 358 Name string `json:"name"` 359 } `json:"bypassNetworkLists,omitempty"` 360 DefaultFile string `json:"defaultFile"` 361 FilePaths []string `json:"filePaths,omitempty"` 362 FileExtensions []string `json:"fileExtensions,omitempty"` 363 Hostnames []string `json:"hostnames,omitempty"` 364 ID int `json:"id"` 365 IsNegativeFileExtensionMatch bool `json:"isNegativeFileExtensionMatch"` 366 IsNegativePathMatch bool `json:"isNegativePathMatch"` 367 SecurityPolicy struct { 368 PolicyID string `json:"policyId"` 369 } `json:"securityPolicy"` 370 Sequence int `json:"-"` 371 } `json:"websiteTargets"` 372 } `json:"matchTargets"` 373 SecurityPolicies []struct { 374 ID string `json:"id"` 375 Name string `json:"name"` 376 HasRatePolicyWithAPIKey bool `json:"hasRatePolicyWithApiKey"` 377 SecurityControls struct { 378 ApplyAPIConstraints bool `json:"applyApiConstraints"` 379 ApplyApplicationLayerControls bool `json:"applyApplicationLayerControls"` 380 ApplyBotmanControls bool `json:"applyBotmanControls"` 381 ApplyNetworkLayerControls bool `json:"applyNetworkLayerControls"` 382 ApplyRateControls bool `json:"applyRateControls"` 383 ApplyReputationControls bool `json:"applyReputationControls"` 384 ApplySlowPostControls bool `json:"applySlowPostControls"` 385 ApplyMalwareControls bool `json:"applyMalwareControls"` 386 } `json:"securityControls"` 387 WebApplicationFirewall struct { 388 RuleActions []struct { 389 Action string `json:"action"` 390 ID int `json:"id"` 391 RulesetVersionID int `json:"rulesetVersionId"` 392 Conditions *RuleConditions `json:"conditions,omitempty"` 393 Exception *RuleException `json:"exception,omitempty"` 394 } `json:"ruleActions,omitempty"` 395 AttackGroupActions []struct { 396 Action string `json:"action"` 397 Group string `json:"group"` 398 RulesetVersionID int `json:"rulesetVersionId"` 399 AdvancedExceptionsList *AttackGroupAdvancedExceptions `json:"advancedExceptions,omitempty"` 400 Exception *AttackGroupException `json:"exception,omitempty"` 401 } `json:"attackGroupActions,omitempty"` 402 Evaluation *WebApplicationFirewallEvaluation `json:"evaluation,omitempty"` 403 ThreatIntel string `json:"threatIntel"` 404 } `json:"webApplicationFirewall"` 405 CustomRuleActions []struct { 406 Action string `json:"action"` 407 ID int `json:"id"` 408 } `json:"customRuleActions,omitempty"` 409 APIRequestConstraints *APIRequestConstraintsexp `json:"apiRequestConstraints,omitempty"` 410 ClientReputation struct { 411 ReputationProfileActions *ClientReputationReputationProfileActions `json:"reputationProfileActions,omitempty"` 412 } `json:"clientReputation"` 413 RatePolicyActions *SecurityPoliciesRatePolicyActions `json:"ratePolicyActions,omitempty"` 414 IPGeoFirewall struct { 415 Block string `json:"block"` 416 GeoControls struct { 417 BlockedIPNetworkLists struct { 418 NetworkList []string `json:"networkList,omitempty"` 419 } `json:"blockedIPNetworkLists"` 420 } `json:"geoControls"` 421 IPControls struct { 422 AllowedIPNetworkLists struct { 423 NetworkList []string `json:"networkList,omitempty"` 424 } `json:"allowedIPNetworkLists"` 425 BlockedIPNetworkLists struct { 426 NetworkList []string `json:"networkList,omitempty"` 427 } `json:"blockedIPNetworkLists"` 428 } `json:"ipControls"` 429 } `json:"ipGeoFirewall,omitempty"` 430 PenaltyBox *SecurityPoliciesPenaltyBox `json:"penaltyBox,omitempty"` 431 EvaluationPenaltyBox *SecurityPoliciesPenaltyBox `json:"evaluationPenaltyBox,omitempty"` 432 SlowPost *SlowPostexp `json:"slowPost,omitempty"` 433 LoggingOverrides *LoggingOverridesexp `json:"loggingOverrides,omitempty"` 434 AttackPayloadLoggingOverrides *AttackPayloadLoggingOverrides `json:"attackPayloadLoggingOverrides,omitempty"` 435 PragmaHeader *GetAdvancedSettingsPragmaResponse `json:"pragmaHeader,omitempty"` 436 EvasivePathMatch *EvasivePathMatchexp `json:"evasivePathMatch,omitempty"` 437 } `json:"securityPolicies"` 438 Siem *Siemexp `json:"siem,omitempty"` 439 AdvancedOptions *AdvancedOptionsexp `json:"advancedOptions,omitempty"` 440 CustomDenyList *CustomDenyListexp `json:"customDenyList,omitempty"` 441 Evaluating struct { 442 SecurityPolicies []struct { 443 EffectiveSecurityControls struct { 444 ApplyApplicationLayerControls bool `json:"applyApplicationLayerControls,omitempty"` 445 ApplyRateControls bool `json:"applyRateControls,omitempty"` 446 ApplySlowPostControls bool `json:"applySlowPostControls,omitempty"` 447 } 448 Hostnames []string `json:"hostnames,omitempty"` 449 SecurityPolicyID string `json:"id"` 450 } 451 } `json:"evaluating"` 452 } 453 454 // RatePoliciesPath is returned as part of GetExportConfigurationResponse. 455 RatePoliciesPath struct { 456 PositiveMatch bool `json:"positiveMatch"` 457 Values *RatePoliciesPathValues `json:"values,omitempty"` 458 } 459 460 // ReputationProfileActionsexp is returned as part of GetExportConfigurationResponse. 461 ReputationProfileActionsexp []struct { 462 Action string `json:"action"` 463 ID int `json:"id"` 464 } 465 466 // RatePolicyActionsexp is returned as part of GetExportConfigurationResponse. 467 RatePolicyActionsexp []struct { 468 ID int `json:"id"` 469 Ipv4Action string `json:"ipv4Action"` 470 Ipv6Action string `json:"ipv6Action"` 471 } 472 473 // SlowRateThresholdExp is returned as part of GetExportConfigurationResponse. 474 SlowRateThresholdExp struct { 475 Period int `json:"period"` 476 Rate int `json:"rate"` 477 } 478 479 // DurationThresholdExp is returned as part of GetExportConfigurationResponse. 480 DurationThresholdExp struct { 481 Timeout int `json:"timeout"` 482 } 483 484 // SlowPostexp is returned as part of GetExportConfigurationResponse. 485 SlowPostexp struct { 486 Action string `json:"action"` 487 SlowRateThreshold *SlowRateThresholdExp `json:"slowRateThreshold,omitempty"` 488 DurationThreshold *DurationThresholdExp `json:"durationThreshold,omitempty"` 489 } 490 491 // AdvancedOptionsexp is returned as part of GetExportConfigurationResponse. 492 AdvancedOptionsexp struct { 493 Logging *Loggingexp `json:"logging"` 494 AttackPayloadLogging *AttackPayloadLogging `json:"attackPayloadLogging"` 495 EvasivePathMatch *EvasivePathMatchexp `json:"evasivePathMatch,omitempty"` 496 Prefetch struct { 497 AllExtensions bool `json:"allExtensions"` 498 EnableAppLayer bool `json:"enableAppLayer"` 499 EnableRateControls bool `json:"enableRateControls"` 500 Extensions []string `json:"extensions,omitempty"` 501 } `json:"prefetch"` 502 PragmaHeader *GetAdvancedSettingsPragmaResponse `json:"pragmaHeader,omitempty"` 503 } 504 505 // CustomDenyListexp is returned as part of GetExportConfigurationResponse. 506 CustomDenyListexp []struct { 507 Description string `json:"description,omitempty"` 508 Name string `json:"name"` 509 ID string `json:"id"` 510 Parameters []struct { 511 DisplayName string `json:"-"` 512 Name string `json:"name"` 513 Value string `json:"value"` 514 } `json:"parameters"` 515 } 516 517 // CustomRuleActionsexp is returned as part of GetExportConfigurationResponse. 518 CustomRuleActionsexp []struct { 519 Action string `json:"action"` 520 ID int `json:"id"` 521 } 522 523 // Siemexp is returned as part of GetExportConfigurationResponse. 524 Siemexp struct { 525 EnableForAllPolicies bool `json:"enableForAllPolicies,omitempty"` 526 EnableSiem bool `json:"enableSiem"` 527 EnabledBotmanSiemEvents bool `json:"enabledBotmanSiemEvents,omitempty"` 528 FirewallPolicyIds []string `json:"firewallPolicyIds,omitempty"` 529 SiemDefinitionID int `json:"siemDefinitionId,omitempty"` 530 } 531 532 // PenaltyBoxexp is returned as part of GetExportConfigurationResponse. 533 PenaltyBoxexp struct { 534 Action string `json:"action"` 535 PenaltyBoxProtection bool `json:"penaltyBoxProtection"` 536 } 537 538 // APIRequestConstraintsexp is returned as part of GetExportConfigurationResponse. 539 APIRequestConstraintsexp struct { 540 Action string `json:"action,omitempty"` 541 APIEndpoints []struct { 542 Action string `json:"action"` 543 ID int `json:"id"` 544 } `json:"apiEndpoints,omitempty"` 545 } 546 547 // Evaluationexp is returned as part of GetExportConfigurationResponse. 548 Evaluationexp struct { 549 AttackGroupActions []struct { 550 Action string `json:"action"` 551 Group string `json:"group"` 552 } `json:"attackGroupActions"` 553 EvaluationID int `json:"evaluationId"` 554 EvaluationVersion int `json:"evaluationVersion"` 555 RuleActions []struct { 556 Action string `json:"action"` 557 ID int `json:"id"` 558 Conditions *RuleConditions `json:"conditions,omitempty"` 559 Exception *RuleException `json:"exception,omitempty"` 560 } `json:"ruleActions"` 561 RulesetVersionID int `json:"rulesetVersionId"` 562 } 563 564 // ConditionReputationProfile is returned as part of GetExportConfigurationResponse. 565 ConditionReputationProfile struct { 566 AtomicConditions *AtomicConditionsexp `json:"atomicConditions,omitempty"` 567 CanDelete bool `json:"-"` 568 ConfigVersionID int `json:"-"` 569 ID int `json:"-"` 570 Name string `json:"-"` 571 PositiveMatch *json.RawMessage `json:"positiveMatch,omitempty"` 572 UUID string `json:"-"` 573 Version int64 `json:"-"` 574 } 575 576 // HeaderCookieOrParamValuesattackgroup is returned as part of GetExportConfigurationResponse. 577 HeaderCookieOrParamValuesattackgroup []struct { 578 Criteria []struct { 579 Hostnames []string `json:"hostnames,omitempty"` 580 Paths []string `json:"paths,omitempty"` 581 Values []string `json:"values,omitempty"` 582 } `json:"criteria"` 583 ValueWildcard bool `json:"valueWildcard,omitempty"` 584 Values []string `json:"values,omitempty"` 585 } 586 587 // SpecificHeaderCookieOrParamNameValueexp is returned as part of GetExportConfigurationResponse. 588 SpecificHeaderCookieOrParamNameValueexp struct { 589 Name *json.RawMessage `json:"name,omitempty"` 590 Selector string `json:"selector,omitempty"` 591 Value *json.RawMessage `json:"value,omitempty"` 592 } 593 594 // AtomicConditionsexp is returned as part of GetExportConfigurationResponse. 595 AtomicConditionsexp []struct { 596 CheckIps *json.RawMessage `json:"checkIps,omitempty"` 597 ClassName string `json:"className,omitempty"` 598 Index int `json:"index,omitempty"` 599 PositiveMatch *json.RawMessage `json:"positiveMatch,omitempty"` 600 Value []string `json:"value,omitempty"` 601 Name *json.RawMessage `json:"name,omitempty"` 602 NameCase bool `json:"nameCase,omitempty"` 603 NameWildcard *json.RawMessage `json:"nameWildcard,omitempty"` 604 ValueCase bool `json:"valueCase,omitempty"` 605 ValueWildcard *json.RawMessage `json:"valueWildcard,omitempty"` 606 Host []string `json:"host,omitempty"` 607 } 608 609 // Loggingexp is returned as part of GetExportConfigurationResponse. 610 Loggingexp struct { 611 AllowSampling bool `json:"allowSampling"` 612 Cookies struct { 613 Type string `json:"type"` 614 Values []string `json:"values,omitempty"` 615 } `json:"cookies"` 616 CustomHeaders struct { 617 Type string `json:"type"` 618 Values []string `json:"values,omitempty"` 619 } `json:"customHeaders"` 620 StandardHeaders struct { 621 Type string `json:"type"` 622 Values []string `json:"values,omitempty"` 623 } `json:"standardHeaders"` 624 } 625 626 // LoggingOverridesexp is returned as part of GetExportConfigurationResponse. 627 LoggingOverridesexp struct { 628 AllowSampling bool `json:"allowSampling"` 629 Cookies struct { 630 Type string `json:"type"` 631 Values []string `json:"values,omitempty"` 632 } `json:"cookies"` 633 CustomHeaders struct { 634 Type string `json:"type"` 635 Values []string `json:"values,omitempty"` 636 } `json:"customHeaders"` 637 Override bool `json:"override"` 638 StandardHeaders struct { 639 Type string `json:"type"` 640 Values []string `json:"values,omitempty"` 641 } `json:"standardHeaders"` 642 } 643 644 // AttackPayloadLogging is returned as part of GetExportConfigurationResponse. 645 AttackPayloadLogging struct { 646 Enabled bool `json:"enabled"` 647 RequestBody struct { 648 Type string `json:"type"` 649 } `json:"requestBody"` 650 ResponseBody struct { 651 Type string `json:"type"` 652 } `json:"responseBody"` 653 } 654 655 // AttackPayloadLoggingOverrides is returned as part of GetExportConfigurationResponse. 656 AttackPayloadLoggingOverrides struct { 657 Enabled bool `json:"enabled"` 658 RequestBody struct { 659 Type string `json:"type"` 660 } `json:"requestBody"` 661 ResponseBody struct { 662 Type string `json:"type"` 663 } `json:"responseBody"` 664 Override bool `json:"override"` 665 } 666 667 // EvasivePathMatchexp contains the EnablePathMatch setting 668 EvasivePathMatchexp struct { 669 EnablePathMatch bool `json:"enabled"` 670 } 671 672 // ConditionsExp is returned as part of GetExportConfigurationResponse. 673 ConditionsExp []struct { 674 Type string `json:"type"` 675 PositiveMatch bool `json:"positiveMatch"` 676 Name *json.RawMessage `json:"name,omitempty"` 677 NameCase *json.RawMessage `json:"nameCase,omitempty"` 678 NameWildcard *json.RawMessage `json:"nameWildcard,omitempty"` 679 Value *json.RawMessage `json:"value,omitempty"` 680 ValueCase *json.RawMessage `json:"valueCase,omitempty"` 681 ValueWildcard *json.RawMessage `json:"valueWildcard,omitempty"` 682 } 683 684 // RatePoliciesPathValues is returned as part of GetExportConfigurationResponse. 685 RatePoliciesPathValues []string 686 687 // RatePoliciesQueryParameters is returned as part of GetExportConfigurationResponse. 688 RatePoliciesQueryParameters []struct { 689 Name string `json:"name"` 690 PositiveMatch bool `json:"positiveMatch"` 691 ValueInRange bool `json:"valueInRange"` 692 Values *RatePoliciesQueryParametersValues `json:"values,omitempty"` 693 } 694 695 // RatePoliciesQueryParametersValues is returned as part of GetExportConfigurationResponse. 696 RatePoliciesQueryParametersValues []string 697 698 // SecurityPoliciesPenaltyBox is returned as part of GetExportConfigurationResponse. 699 SecurityPoliciesPenaltyBox struct { 700 Action string `json:"action,omitempty"` 701 PenaltyBoxProtection bool `json:"penaltyBoxProtection,omitempty"` 702 } 703 704 // WebApplicationFirewallEvaluation is returned as part of GetExportConfigurationResponse. 705 WebApplicationFirewallEvaluation struct { 706 AttackGroupActions []struct { 707 Action string `json:"action"` 708 Group string `json:"group"` 709 Exception *RuleException `json:"exception,omitempty"` 710 AdvancedExceptionsList *AdvancedExceptions `json:"advancedExceptions,omitempty"` 711 } `json:"attackGroupActions,omitempty"` 712 EvaluationID int `json:"evaluationId"` 713 EvaluationVersion int `json:"evaluationVersion"` 714 RuleActions []struct { 715 Action string `json:"action"` 716 ID int `json:"id"` 717 Conditions *RuleConditions `json:"conditions,omitempty"` 718 Exception *RuleException `json:"exception,omitempty"` 719 AdvancedExceptionsList *AdvancedExceptions `json:"advancedExceptions,omitempty"` 720 } `json:"ruleActions,omitempty"` 721 RulesetVersionID int `json:"rulesetVersionId"` 722 } 723 724 // RulesetsRules is returned as part of GetExportConfigurationResponse. 725 RulesetsRules []struct { 726 ID int `json:"id"` 727 InspectRequestBody bool `json:"inspectRequestBody"` 728 InspectResponseBody bool `json:"inspectResponseBody"` 729 Outdated bool `json:"outdated"` 730 RuleVersion int `json:"ruleVersion"` 731 Score int `json:"score"` 732 Tag string `json:"tag"` 733 Title string `json:"title"` 734 AttackGroups []string `json:"attackGroups,omitempty"` 735 } 736 737 // ClientReputationReputationProfileActions is returned as part of GetExportConfigurationResponse. 738 ClientReputationReputationProfileActions []struct { 739 Action string `json:"action"` 740 ID int `json:"id"` 741 } 742 743 // SecurityPoliciesRatePolicyActions is returned as part of GetExportConfigurationResponse. 744 SecurityPoliciesRatePolicyActions []struct { 745 ID int `json:"id"` 746 Ipv4Action string `json:"ipv4Action"` 747 Ipv6Action string `json:"ipv6Action"` 748 } 749 750 // AdvancedSettings is returned as part of GetExportConfigurationResponse 751 AdvancedSettings struct { 752 BotAnalyticsCookieSettings map[string]interface{} `json:"botAnalyticsCookieSettings,omitempty"` 753 ClientSideSecuritySettings map[string]interface{} `json:"clientSideSecuritySettings,omitempty"` 754 TransactionalEndpointProtectionSettings map[string]interface{} `json:"transactionalEndpointProtectionSettings,omitempty"` 755 } 756 757 // ResponseActions is returned as part of GetExportConfigurationResponse 758 ResponseActions struct { 759 ChallengeActions []map[string]interface{} `json:"challengeActions,omitempty"` 760 ConditionalActions []map[string]interface{} `json:"conditionalActions,omitempty"` 761 CustomDenyActions []map[string]interface{} `json:"customDenyActions,omitempty"` 762 ServeAlternateActions []map[string]interface{} `json:"serveAlternateActions,omitempty"` 763 ChallengeInterceptionRules map[string]interface{} `json:"challengeInterceptionRules,omitempty"` 764 } 765 766 // BotManagement is returned as part of GetExportConfigurationResponse 767 BotManagement struct { 768 AkamaiBotCategoryActions []map[string]interface{} `json:"akamaiBotCategoryActions,omitempty"` 769 BotDetectionActions []map[string]interface{} `json:"botDetectionActions,omitempty"` 770 BotManagementSettings map[string]interface{} `json:"botManagementSettings,omitempty"` 771 CustomBotCategoryActions []map[string]interface{} `json:"customBotCategoryActions,omitempty"` 772 JavascriptInjectionRules map[string]interface{} `json:"javascriptInjectionRules,omitempty"` 773 TransactionalEndpoints *TransactionalEndpoints `json:"transactionalEndpoints,omitempty"` 774 } 775 776 // TransactionalEndpoints is returned as port of GetExportConfigurationResponse 777 TransactionalEndpoints struct { 778 BotProtection []map[string]interface{} `json:"botProtection,omitempty"` 779 BotProtectionExceptions map[string]interface{} `json:"botProtectionExceptions,omitempty"` 780 } 781 ) 782 783 // UnmarshalJSON reads a ConditionsValue struct from its data argument. 784 func (c *ConditionsValue) UnmarshalJSON(data []byte) error { 785 var nums interface{} 786 err := json.Unmarshal(data, &nums) 787 if err != nil { 788 return err 789 } 790 791 items := reflect.ValueOf(nums) 792 switch items.Kind() { 793 case reflect.String: 794 *c = append(*c, items.String()) 795 796 case reflect.Slice: 797 *c = make(ConditionsValue, 0, items.Len()) 798 for i := 0; i < items.Len(); i++ { 799 item := items.Index(i) 800 switch item.Kind() { 801 case reflect.String: 802 *c = append(*c, item.String()) 803 case reflect.Interface: 804 *c = append(*c, item.Interface().(string)) 805 } 806 } 807 } 808 return nil 809 } 810 811 func (p *appsec) GetExportConfiguration(ctx context.Context, params GetExportConfigurationRequest) (*GetExportConfigurationResponse, error) { 812 logger := p.Log(ctx) 813 logger.Debug("GetExportConfiguration") 814 815 uri := fmt.Sprintf( 816 "/appsec/v1/export/configs/%d/versions/%d", 817 params.ConfigID, 818 params.Version) 819 820 req, err := http.NewRequestWithContext(ctx, http.MethodGet, uri, nil) 821 if err != nil { 822 return nil, fmt.Errorf("failed to create GetExportConfiguration request: %w", err) 823 } 824 825 var result GetExportConfigurationResponse 826 resp, err := p.Exec(req, &result) 827 if err != nil { 828 return nil, fmt.Errorf("get export configuration request failed: %w", err) 829 } 830 if resp.StatusCode != http.StatusOK { 831 return nil, p.Error(resp) 832 } 833 834 return &result, nil 835 } 836 837 // Deprecated: this method will be removed in a future release. 838 func (p *appsec) GetExportConfigurations(ctx context.Context, params GetExportConfigurationsRequest) (*GetExportConfigurationsResponse, error) { 839 logger := p.Log(ctx) 840 logger.Debug("GetExportConfigurations") 841 842 uri := fmt.Sprintf( 843 "/appsec/v1/export/configs/%d/versions/%d", 844 params.ConfigID, 845 params.Version) 846 847 req, err := http.NewRequestWithContext(ctx, http.MethodGet, uri, nil) 848 if err != nil { 849 return nil, fmt.Errorf("failed to create GetExportConfigurations request: %w", err) 850 } 851 852 var result GetExportConfigurationsResponse 853 resp, err := p.Exec(req, &result) 854 if err != nil { 855 return nil, fmt.Errorf("get export configurations request failed: %w", err) 856 } 857 if resp.StatusCode != http.StatusOK { 858 return nil, p.Error(resp) 859 } 860 861 return &result, nil 862 }