github.com/akamai/AkamaiOPEN-edgegrid-golang/v5@v5.0.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 RequestBody *RequestBody `json:"requestBody,omitempty"` 236 BotManagement *BotManagement `json:"botManagement,omitempty"` 237 } `json:"securityPolicies"` 238 Siem *Siemexp `json:"siem,omitempty"` 239 AdvancedOptions *AdvancedOptionsexp `json:"advancedOptions,omitempty"` 240 CustomDenyList *CustomDenyListexp `json:"customDenyList,omitempty"` 241 Evaluating struct { 242 SecurityPolicies []EvaluatingSecurityPolicy `json:"securityPolicies,omitempty"` 243 } `json:"evaluating,omitempty"` 244 MalwarePolicies []MalwarePolicyBody `json:"malwarePolicies,omitempty"` 245 CustomBotCategories []map[string]interface{} `json:"customBotCategories,omitempty"` 246 CustomDefinedBots []map[string]interface{} `json:"customDefinedBots,omitempty"` 247 CustomBotCategorySequence []string `json:"customBotCategorySequence,omitempty"` 248 CustomClients []map[string]interface{} `json:"customClients,omitempty"` 249 ResponseActions *ResponseActions `json:"responseActions,omitempty"` 250 AdvancedSettings *AdvancedSettings `json:"advancedSettings,omitempty"` 251 } 252 253 // GetExportConfigurationsRequest is used to call GetExportConfigurations. 254 // Deprecated: this struct will be removed in a future release. 255 GetExportConfigurationsRequest struct { 256 ConfigID int `json:"configId"` 257 Version int `json:"version"` 258 } 259 260 // GetExportConfigurationsResponse is returned from a call to GetExportConfigurations. 261 // Deprecated: this struct will be removed in a future release. 262 GetExportConfigurationsResponse struct { 263 ConfigID int `json:"configId"` 264 ConfigName string `json:"configName"` 265 Version int `json:"version"` 266 BasedOn int `json:"basedOn"` 267 Staging struct { 268 Status string `json:"status"` 269 } `json:"staging"` 270 Production struct { 271 Status string `json:"status"` 272 } `json:"production"` 273 CreateDate time.Time `json:"-"` 274 CreatedBy string `json:"createdBy"` 275 SelectedHosts []string `json:"selectedHosts"` 276 SelectableHosts []string `json:"selectableHosts"` 277 RatePolicies []struct { 278 AdditionalMatchOptions []struct { 279 PositiveMatch bool `json:"positiveMatch"` 280 Type string `json:"type"` 281 Values []string `json:"values"` 282 } `json:"additionalMatchOptions"` 283 AllTraffic bool `json:"allTraffic,omitempty"` 284 AverageThreshold int `json:"averageThreshold"` 285 BurstThreshold int `json:"burstThreshold"` 286 ClientIdentifier string `json:"clientIdentifier"` 287 CreateDate time.Time `json:"-"` 288 Description string `json:"description,omitempty"` 289 FileExtensions *RatePolicyFileExtensions `json:"fileExtensions,omitempty"` 290 Hosts *RatePoliciesHosts `json:"hosts,omitempty"` 291 Hostnames []string `json:"hostnames,omitempty"` 292 ID int `json:"id"` 293 MatchType string `json:"matchType"` 294 Name string `json:"name"` 295 Path *RatePoliciesPath `json:"path,omitempty"` 296 PathMatchType string `json:"pathMatchType,omitempty"` 297 PathURIPositiveMatch bool `json:"pathUriPositiveMatch"` 298 QueryParameters *RatePoliciesQueryParameters `json:"queryParameters,omitempty"` 299 RequestType string `json:"requestType"` 300 SameActionOnIpv6 bool `json:"sameActionOnIpv6"` 301 Type string `json:"type"` 302 UpdateDate time.Time `json:"-"` 303 UseXForwardForHeaders bool `json:"useXForwardForHeaders"` 304 Used bool `json:"-"` 305 } `json:"ratePolicies"` 306 ReputationProfiles []struct { 307 Condition *ConditionReputationProfile `json:"condition,omitempty"` 308 Context string `json:"context,omitempty"` 309 ContextReadable string `json:"-"` 310 Enabled bool `json:"-"` 311 ID int `json:"id"` 312 Name string `json:"name"` 313 SharedIPHandling string `json:"sharedIpHandling"` 314 Threshold int `json:"threshold"` 315 } `json:"reputationProfiles"` 316 CustomRules []struct { 317 Conditions *ConditionsExp `json:"conditions,omitempty"` 318 Description string `json:"description,omitempty"` 319 ID int `json:"id"` 320 Name string `json:"name"` 321 RuleActivated bool `json:"-"` 322 Structured bool `json:"-"` 323 Tag []string `json:"tag"` 324 Version int `json:"-"` 325 } `json:"customRules"` 326 Rulesets []struct { 327 ID int `json:"id"` 328 RulesetVersionID int `json:"rulesetVersionId"` 329 Type string `json:"type"` 330 ReleaseDate time.Time `json:"releaseDate"` 331 Rules *RulesetsRules `json:"rules,omitempty"` 332 AttackGroups []struct { 333 Group string `json:"group"` 334 GroupName string `json:"groupName"` 335 Threshold int `json:"threshold,omitempty"` 336 } `json:"attackGroups,omitempty"` 337 } `json:"rulesets"` 338 MatchTargets struct { 339 APITargets []struct { 340 Sequence int `json:"-"` 341 ID int `json:"id,omitempty"` 342 Type string `json:"type,omitempty"` 343 Apis []struct { 344 ID int `json:"id,omitempty"` 345 Name string `json:"name,omitempty"` 346 } `json:"apis,omitempty"` 347 SecurityPolicy struct { 348 PolicyID string `json:"policyId,omitempty"` 349 } `json:"securityPolicy,omitempty"` 350 BypassNetworkLists []struct { 351 Name string `json:"name,omitempty"` 352 ID string `json:"id,omitempty"` 353 } `json:"bypassNetworkLists,omitempty"` 354 } `json:"apiTargets,omitempty"` 355 WebsiteTargets []struct { 356 Type string `json:"type"` 357 BypassNetworkLists []struct { 358 ID string `json:"id"` 359 Name string `json:"name"` 360 } `json:"bypassNetworkLists,omitempty"` 361 DefaultFile string `json:"defaultFile"` 362 FilePaths []string `json:"filePaths,omitempty"` 363 FileExtensions []string `json:"fileExtensions,omitempty"` 364 Hostnames []string `json:"hostnames,omitempty"` 365 ID int `json:"id"` 366 IsNegativeFileExtensionMatch bool `json:"isNegativeFileExtensionMatch"` 367 IsNegativePathMatch bool `json:"isNegativePathMatch"` 368 SecurityPolicy struct { 369 PolicyID string `json:"policyId"` 370 } `json:"securityPolicy"` 371 Sequence int `json:"-"` 372 } `json:"websiteTargets"` 373 } `json:"matchTargets"` 374 SecurityPolicies []struct { 375 ID string `json:"id"` 376 Name string `json:"name"` 377 HasRatePolicyWithAPIKey bool `json:"hasRatePolicyWithApiKey"` 378 SecurityControls struct { 379 ApplyAPIConstraints bool `json:"applyApiConstraints"` 380 ApplyApplicationLayerControls bool `json:"applyApplicationLayerControls"` 381 ApplyBotmanControls bool `json:"applyBotmanControls"` 382 ApplyNetworkLayerControls bool `json:"applyNetworkLayerControls"` 383 ApplyRateControls bool `json:"applyRateControls"` 384 ApplyReputationControls bool `json:"applyReputationControls"` 385 ApplySlowPostControls bool `json:"applySlowPostControls"` 386 ApplyMalwareControls bool `json:"applyMalwareControls"` 387 } `json:"securityControls"` 388 WebApplicationFirewall struct { 389 RuleActions []struct { 390 Action string `json:"action"` 391 ID int `json:"id"` 392 RulesetVersionID int `json:"rulesetVersionId"` 393 Conditions *RuleConditions `json:"conditions,omitempty"` 394 Exception *RuleException `json:"exception,omitempty"` 395 } `json:"ruleActions,omitempty"` 396 AttackGroupActions []struct { 397 Action string `json:"action"` 398 Group string `json:"group"` 399 RulesetVersionID int `json:"rulesetVersionId"` 400 AdvancedExceptionsList *AttackGroupAdvancedExceptions `json:"advancedExceptions,omitempty"` 401 Exception *AttackGroupException `json:"exception,omitempty"` 402 } `json:"attackGroupActions,omitempty"` 403 Evaluation *WebApplicationFirewallEvaluation `json:"evaluation,omitempty"` 404 ThreatIntel string `json:"threatIntel"` 405 } `json:"webApplicationFirewall"` 406 CustomRuleActions []struct { 407 Action string `json:"action"` 408 ID int `json:"id"` 409 } `json:"customRuleActions,omitempty"` 410 APIRequestConstraints *APIRequestConstraintsexp `json:"apiRequestConstraints,omitempty"` 411 ClientReputation struct { 412 ReputationProfileActions *ClientReputationReputationProfileActions `json:"reputationProfileActions,omitempty"` 413 } `json:"clientReputation"` 414 RatePolicyActions *SecurityPoliciesRatePolicyActions `json:"ratePolicyActions,omitempty"` 415 IPGeoFirewall struct { 416 Block string `json:"block"` 417 GeoControls struct { 418 BlockedIPNetworkLists struct { 419 NetworkList []string `json:"networkList,omitempty"` 420 } `json:"blockedIPNetworkLists"` 421 } `json:"geoControls"` 422 IPControls struct { 423 AllowedIPNetworkLists struct { 424 NetworkList []string `json:"networkList,omitempty"` 425 } `json:"allowedIPNetworkLists"` 426 BlockedIPNetworkLists struct { 427 NetworkList []string `json:"networkList,omitempty"` 428 } `json:"blockedIPNetworkLists"` 429 } `json:"ipControls"` 430 } `json:"ipGeoFirewall,omitempty"` 431 PenaltyBox *SecurityPoliciesPenaltyBox `json:"penaltyBox,omitempty"` 432 EvaluationPenaltyBox *SecurityPoliciesPenaltyBox `json:"evaluationPenaltyBox,omitempty"` 433 SlowPost *SlowPostexp `json:"slowPost,omitempty"` 434 LoggingOverrides *LoggingOverridesexp `json:"loggingOverrides,omitempty"` 435 AttackPayloadLoggingOverrides *AttackPayloadLoggingOverrides `json:"attackPayloadLoggingOverrides,omitempty"` 436 PragmaHeader *GetAdvancedSettingsPragmaResponse `json:"pragmaHeader,omitempty"` 437 EvasivePathMatch *EvasivePathMatchexp `json:"evasivePathMatch,omitempty"` 438 } `json:"securityPolicies"` 439 Siem *Siemexp `json:"siem,omitempty"` 440 AdvancedOptions *AdvancedOptionsexp `json:"advancedOptions,omitempty"` 441 CustomDenyList *CustomDenyListexp `json:"customDenyList,omitempty"` 442 Evaluating struct { 443 SecurityPolicies []struct { 444 EffectiveSecurityControls struct { 445 ApplyApplicationLayerControls bool `json:"applyApplicationLayerControls,omitempty"` 446 ApplyRateControls bool `json:"applyRateControls,omitempty"` 447 ApplySlowPostControls bool `json:"applySlowPostControls,omitempty"` 448 } 449 Hostnames []string `json:"hostnames,omitempty"` 450 SecurityPolicyID string `json:"id"` 451 } 452 } `json:"evaluating"` 453 } 454 455 // RatePoliciesPath is returned as part of GetExportConfigurationResponse. 456 RatePoliciesPath struct { 457 PositiveMatch bool `json:"positiveMatch"` 458 Values *RatePoliciesPathValues `json:"values,omitempty"` 459 } 460 461 // ReputationProfileActionsexp is returned as part of GetExportConfigurationResponse. 462 ReputationProfileActionsexp []struct { 463 Action string `json:"action"` 464 ID int `json:"id"` 465 } 466 467 // RatePolicyActionsexp is returned as part of GetExportConfigurationResponse. 468 RatePolicyActionsexp []struct { 469 ID int `json:"id"` 470 Ipv4Action string `json:"ipv4Action"` 471 Ipv6Action string `json:"ipv6Action"` 472 } 473 474 // SlowRateThresholdExp is returned as part of GetExportConfigurationResponse. 475 SlowRateThresholdExp struct { 476 Period int `json:"period"` 477 Rate int `json:"rate"` 478 } 479 480 // DurationThresholdExp is returned as part of GetExportConfigurationResponse. 481 DurationThresholdExp struct { 482 Timeout int `json:"timeout"` 483 } 484 485 // SlowPostexp is returned as part of GetExportConfigurationResponse. 486 SlowPostexp struct { 487 Action string `json:"action"` 488 SlowRateThreshold *SlowRateThresholdExp `json:"slowRateThreshold,omitempty"` 489 DurationThreshold *DurationThresholdExp `json:"durationThreshold,omitempty"` 490 } 491 492 // AdvancedOptionsexp is returned as part of GetExportConfigurationResponse. 493 AdvancedOptionsexp struct { 494 Logging *Loggingexp `json:"logging"` 495 AttackPayloadLogging *AttackPayloadLogging `json:"attackPayloadLogging"` 496 EvasivePathMatch *EvasivePathMatchexp `json:"evasivePathMatch,omitempty"` 497 Prefetch struct { 498 AllExtensions bool `json:"allExtensions"` 499 EnableAppLayer bool `json:"enableAppLayer"` 500 EnableRateControls bool `json:"enableRateControls"` 501 Extensions []string `json:"extensions,omitempty"` 502 } `json:"prefetch"` 503 PragmaHeader *GetAdvancedSettingsPragmaResponse `json:"pragmaHeader,omitempty"` 504 RequestBody *RequestBody `json:"requestBody,omitempty"` 505 } 506 507 // CustomDenyListexp is returned as part of GetExportConfigurationResponse. 508 CustomDenyListexp []struct { 509 Description string `json:"description,omitempty"` 510 Name string `json:"name"` 511 ID string `json:"id"` 512 Parameters []struct { 513 DisplayName string `json:"-"` 514 Name string `json:"name"` 515 Value string `json:"value"` 516 } `json:"parameters"` 517 } 518 519 // CustomRuleActionsexp is returned as part of GetExportConfigurationResponse. 520 CustomRuleActionsexp []struct { 521 Action string `json:"action"` 522 ID int `json:"id"` 523 } 524 525 // Siemexp is returned as part of GetExportConfigurationResponse. 526 Siemexp struct { 527 EnableForAllPolicies bool `json:"enableForAllPolicies,omitempty"` 528 EnableSiem bool `json:"enableSiem"` 529 EnabledBotmanSiemEvents bool `json:"enabledBotmanSiemEvents,omitempty"` 530 FirewallPolicyIds []string `json:"firewallPolicyIds,omitempty"` 531 SiemDefinitionID int `json:"siemDefinitionId,omitempty"` 532 } 533 534 // PenaltyBoxexp is returned as part of GetExportConfigurationResponse. 535 PenaltyBoxexp struct { 536 Action string `json:"action"` 537 PenaltyBoxProtection bool `json:"penaltyBoxProtection"` 538 } 539 540 // APIRequestConstraintsexp is returned as part of GetExportConfigurationResponse. 541 APIRequestConstraintsexp struct { 542 Action string `json:"action,omitempty"` 543 APIEndpoints []struct { 544 Action string `json:"action"` 545 ID int `json:"id"` 546 } `json:"apiEndpoints,omitempty"` 547 } 548 549 // Evaluationexp is returned as part of GetExportConfigurationResponse. 550 Evaluationexp struct { 551 AttackGroupActions []struct { 552 Action string `json:"action"` 553 Group string `json:"group"` 554 } `json:"attackGroupActions"` 555 EvaluationID int `json:"evaluationId"` 556 EvaluationVersion int `json:"evaluationVersion"` 557 RuleActions []struct { 558 Action string `json:"action"` 559 ID int `json:"id"` 560 Conditions *RuleConditions `json:"conditions,omitempty"` 561 Exception *RuleException `json:"exception,omitempty"` 562 } `json:"ruleActions"` 563 RulesetVersionID int `json:"rulesetVersionId"` 564 } 565 566 // ConditionReputationProfile is returned as part of GetExportConfigurationResponse. 567 ConditionReputationProfile struct { 568 AtomicConditions *AtomicConditionsexp `json:"atomicConditions,omitempty"` 569 CanDelete bool `json:"-"` 570 ConfigVersionID int `json:"-"` 571 ID int `json:"-"` 572 Name string `json:"-"` 573 PositiveMatch *json.RawMessage `json:"positiveMatch,omitempty"` 574 UUID string `json:"-"` 575 Version int64 `json:"-"` 576 } 577 578 // HeaderCookieOrParamValuesattackgroup is returned as part of GetExportConfigurationResponse. 579 HeaderCookieOrParamValuesattackgroup []struct { 580 Criteria []struct { 581 Hostnames []string `json:"hostnames,omitempty"` 582 Paths []string `json:"paths,omitempty"` 583 Values []string `json:"values,omitempty"` 584 } `json:"criteria"` 585 ValueWildcard bool `json:"valueWildcard,omitempty"` 586 Values []string `json:"values,omitempty"` 587 } 588 589 // SpecificHeaderCookieOrParamNameValueexp is returned as part of GetExportConfigurationResponse. 590 SpecificHeaderCookieOrParamNameValueexp struct { 591 Name *json.RawMessage `json:"name,omitempty"` 592 Selector string `json:"selector,omitempty"` 593 Value *json.RawMessage `json:"value,omitempty"` 594 } 595 596 // AtomicConditionsexp is returned as part of GetExportConfigurationResponse. 597 AtomicConditionsexp []struct { 598 CheckIps *json.RawMessage `json:"checkIps,omitempty"` 599 ClassName string `json:"className,omitempty"` 600 Index int `json:"index,omitempty"` 601 PositiveMatch *json.RawMessage `json:"positiveMatch,omitempty"` 602 Value []string `json:"value,omitempty"` 603 Name *json.RawMessage `json:"name,omitempty"` 604 NameCase bool `json:"nameCase,omitempty"` 605 NameWildcard *json.RawMessage `json:"nameWildcard,omitempty"` 606 ValueCase bool `json:"valueCase,omitempty"` 607 ValueWildcard *json.RawMessage `json:"valueWildcard,omitempty"` 608 Host []string `json:"host,omitempty"` 609 } 610 611 // Loggingexp is returned as part of GetExportConfigurationResponse. 612 Loggingexp struct { 613 AllowSampling bool `json:"allowSampling"` 614 Cookies struct { 615 Type string `json:"type"` 616 Values []string `json:"values,omitempty"` 617 } `json:"cookies"` 618 CustomHeaders struct { 619 Type string `json:"type"` 620 Values []string `json:"values,omitempty"` 621 } `json:"customHeaders"` 622 StandardHeaders struct { 623 Type string `json:"type"` 624 Values []string `json:"values,omitempty"` 625 } `json:"standardHeaders"` 626 } 627 628 // LoggingOverridesexp is returned as part of GetExportConfigurationResponse. 629 LoggingOverridesexp struct { 630 AllowSampling bool `json:"allowSampling"` 631 Cookies struct { 632 Type string `json:"type"` 633 Values []string `json:"values,omitempty"` 634 } `json:"cookies"` 635 CustomHeaders struct { 636 Type string `json:"type"` 637 Values []string `json:"values,omitempty"` 638 } `json:"customHeaders"` 639 Override bool `json:"override"` 640 StandardHeaders struct { 641 Type string `json:"type"` 642 Values []string `json:"values,omitempty"` 643 } `json:"standardHeaders"` 644 } 645 646 // AttackPayloadLogging is returned as part of GetExportConfigurationResponse. 647 AttackPayloadLogging struct { 648 Enabled bool `json:"enabled"` 649 RequestBody struct { 650 Type string `json:"type"` 651 } `json:"requestBody"` 652 ResponseBody struct { 653 Type string `json:"type"` 654 } `json:"responseBody"` 655 } 656 657 // AttackPayloadLoggingOverrides is returned as part of GetExportConfigurationResponse. 658 AttackPayloadLoggingOverrides struct { 659 Enabled bool `json:"enabled"` 660 RequestBody struct { 661 Type string `json:"type"` 662 } `json:"requestBody"` 663 ResponseBody struct { 664 Type string `json:"type"` 665 } `json:"responseBody"` 666 Override bool `json:"override"` 667 } 668 669 // EvasivePathMatchexp contains the EnablePathMatch setting 670 EvasivePathMatchexp struct { 671 EnablePathMatch bool `json:"enabled"` 672 } 673 674 // RequestBody is returned as part of GetExportConfigurationResponse. 675 RequestBody struct { 676 RequestBodyInspectionLimitInKB string `json:"requestBodyInspectionLimitInKB"` 677 } 678 679 // ConditionsExp is returned as part of GetExportConfigurationResponse. 680 ConditionsExp []struct { 681 Type string `json:"type"` 682 PositiveMatch bool `json:"positiveMatch"` 683 Name *json.RawMessage `json:"name,omitempty"` 684 NameCase *json.RawMessage `json:"nameCase,omitempty"` 685 NameWildcard *json.RawMessage `json:"nameWildcard,omitempty"` 686 Value *json.RawMessage `json:"value,omitempty"` 687 ValueCase *json.RawMessage `json:"valueCase,omitempty"` 688 ValueWildcard *json.RawMessage `json:"valueWildcard,omitempty"` 689 } 690 691 // RatePoliciesPathValues is returned as part of GetExportConfigurationResponse. 692 RatePoliciesPathValues []string 693 694 // RatePoliciesQueryParameters is returned as part of GetExportConfigurationResponse. 695 RatePoliciesQueryParameters []struct { 696 Name string `json:"name"` 697 PositiveMatch bool `json:"positiveMatch"` 698 ValueInRange bool `json:"valueInRange"` 699 Values *RatePoliciesQueryParametersValues `json:"values,omitempty"` 700 } 701 702 // RatePoliciesQueryParametersValues is returned as part of GetExportConfigurationResponse. 703 RatePoliciesQueryParametersValues []string 704 705 // SecurityPoliciesPenaltyBox is returned as part of GetExportConfigurationResponse. 706 SecurityPoliciesPenaltyBox struct { 707 Action string `json:"action,omitempty"` 708 PenaltyBoxProtection bool `json:"penaltyBoxProtection,omitempty"` 709 } 710 711 // WebApplicationFirewallEvaluation is returned as part of GetExportConfigurationResponse. 712 WebApplicationFirewallEvaluation struct { 713 AttackGroupActions []struct { 714 Action string `json:"action"` 715 Group string `json:"group"` 716 Exception *RuleException `json:"exception,omitempty"` 717 AdvancedExceptionsList *AdvancedExceptions `json:"advancedExceptions,omitempty"` 718 } `json:"attackGroupActions,omitempty"` 719 EvaluationID int `json:"evaluationId"` 720 EvaluationVersion int `json:"evaluationVersion"` 721 RuleActions []struct { 722 Action string `json:"action"` 723 ID int `json:"id"` 724 Conditions *RuleConditions `json:"conditions,omitempty"` 725 Exception *RuleException `json:"exception,omitempty"` 726 AdvancedExceptionsList *AdvancedExceptions `json:"advancedExceptions,omitempty"` 727 } `json:"ruleActions,omitempty"` 728 RulesetVersionID int `json:"rulesetVersionId"` 729 } 730 731 // RulesetsRules is returned as part of GetExportConfigurationResponse. 732 RulesetsRules []struct { 733 ID int `json:"id"` 734 InspectRequestBody bool `json:"inspectRequestBody"` 735 InspectResponseBody bool `json:"inspectResponseBody"` 736 Outdated bool `json:"outdated"` 737 RuleVersion int `json:"ruleVersion"` 738 Score int `json:"score"` 739 Tag string `json:"tag"` 740 Title string `json:"title"` 741 AttackGroups []string `json:"attackGroups,omitempty"` 742 } 743 744 // ClientReputationReputationProfileActions is returned as part of GetExportConfigurationResponse. 745 ClientReputationReputationProfileActions []struct { 746 Action string `json:"action"` 747 ID int `json:"id"` 748 } 749 750 // SecurityPoliciesRatePolicyActions is returned as part of GetExportConfigurationResponse. 751 SecurityPoliciesRatePolicyActions []struct { 752 ID int `json:"id"` 753 Ipv4Action string `json:"ipv4Action"` 754 Ipv6Action string `json:"ipv6Action"` 755 } 756 757 // AdvancedSettings is returned as part of GetExportConfigurationResponse 758 AdvancedSettings struct { 759 BotAnalyticsCookieSettings map[string]interface{} `json:"botAnalyticsCookieSettings,omitempty"` 760 ClientSideSecuritySettings map[string]interface{} `json:"clientSideSecuritySettings,omitempty"` 761 TransactionalEndpointProtectionSettings map[string]interface{} `json:"transactionalEndpointProtectionSettings,omitempty"` 762 } 763 764 // ResponseActions is returned as part of GetExportConfigurationResponse 765 ResponseActions struct { 766 ChallengeActions []map[string]interface{} `json:"challengeActions,omitempty"` 767 ConditionalActions []map[string]interface{} `json:"conditionalActions,omitempty"` 768 CustomDenyActions []map[string]interface{} `json:"customDenyActions,omitempty"` 769 ServeAlternateActions []map[string]interface{} `json:"serveAlternateActions,omitempty"` 770 ChallengeInterceptionRules map[string]interface{} `json:"challengeInterceptionRules,omitempty"` 771 } 772 773 // BotManagement is returned as part of GetExportConfigurationResponse 774 BotManagement struct { 775 AkamaiBotCategoryActions []map[string]interface{} `json:"akamaiBotCategoryActions,omitempty"` 776 BotDetectionActions []map[string]interface{} `json:"botDetectionActions,omitempty"` 777 BotManagementSettings map[string]interface{} `json:"botManagementSettings,omitempty"` 778 CustomBotCategoryActions []map[string]interface{} `json:"customBotCategoryActions,omitempty"` 779 JavascriptInjectionRules map[string]interface{} `json:"javascriptInjectionRules,omitempty"` 780 TransactionalEndpoints *TransactionalEndpoints `json:"transactionalEndpoints,omitempty"` 781 } 782 783 // TransactionalEndpoints is returned as port of GetExportConfigurationResponse 784 TransactionalEndpoints struct { 785 BotProtection []map[string]interface{} `json:"botProtection,omitempty"` 786 BotProtectionExceptions map[string]interface{} `json:"botProtectionExceptions,omitempty"` 787 } 788 ) 789 790 // UnmarshalJSON reads a ConditionsValue struct from its data argument. 791 func (c *ConditionsValue) UnmarshalJSON(data []byte) error { 792 var nums interface{} 793 err := json.Unmarshal(data, &nums) 794 if err != nil { 795 return err 796 } 797 798 items := reflect.ValueOf(nums) 799 switch items.Kind() { 800 case reflect.String: 801 *c = append(*c, items.String()) 802 803 case reflect.Slice: 804 *c = make(ConditionsValue, 0, items.Len()) 805 for i := 0; i < items.Len(); i++ { 806 item := items.Index(i) 807 switch item.Kind() { 808 case reflect.String: 809 *c = append(*c, item.String()) 810 case reflect.Interface: 811 *c = append(*c, item.Interface().(string)) 812 } 813 } 814 } 815 return nil 816 } 817 818 func (p *appsec) GetExportConfiguration(ctx context.Context, params GetExportConfigurationRequest) (*GetExportConfigurationResponse, error) { 819 logger := p.Log(ctx) 820 logger.Debug("GetExportConfiguration") 821 822 uri := fmt.Sprintf( 823 "/appsec/v1/export/configs/%d/versions/%d", 824 params.ConfigID, 825 params.Version) 826 827 req, err := http.NewRequestWithContext(ctx, http.MethodGet, uri, nil) 828 if err != nil { 829 return nil, fmt.Errorf("failed to create GetExportConfiguration request: %w", err) 830 } 831 832 var result GetExportConfigurationResponse 833 resp, err := p.Exec(req, &result) 834 if err != nil { 835 return nil, fmt.Errorf("get export configuration request failed: %w", err) 836 } 837 if resp.StatusCode != http.StatusOK { 838 return nil, p.Error(resp) 839 } 840 841 return &result, nil 842 } 843 844 // Deprecated: this method will be removed in a future release. 845 func (p *appsec) GetExportConfigurations(ctx context.Context, params GetExportConfigurationsRequest) (*GetExportConfigurationsResponse, error) { 846 logger := p.Log(ctx) 847 logger.Debug("GetExportConfigurations") 848 849 uri := fmt.Sprintf( 850 "/appsec/v1/export/configs/%d/versions/%d", 851 params.ConfigID, 852 params.Version) 853 854 req, err := http.NewRequestWithContext(ctx, http.MethodGet, uri, nil) 855 if err != nil { 856 return nil, fmt.Errorf("failed to create GetExportConfigurations request: %w", err) 857 } 858 859 var result GetExportConfigurationsResponse 860 resp, err := p.Exec(req, &result) 861 if err != nil { 862 return nil, fmt.Errorf("get export configurations request failed: %w", err) 863 } 864 if resp.StatusCode != http.StatusOK { 865 return nil, p.Error(resp) 866 } 867 868 return &result, nil 869 }