# This is an automatically generated code sample.
# To make this code sample work in your Oracle Cloud tenancy,
# please replace the values for any parameters whose current values do not fit
# your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
# boolean, number, and enum parameters with values not fitting your use case).
require 'oci'
# Create a default config using DEFAULT profile in default location
# Refer to https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File for more info
config = OCI::ConfigFileLoader.load_config
# Initialize service client with default config file
waas_client = OCI::Waas::WaasClient.new(config: config)
# Send the request to service, some parameters are not required, see API doc for more info
update_waf_config_response =
waas_client.update_waf_config(
'ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value',
OCI::Waas::Models::WafConfig.new(
access_rules: [
OCI::Waas::Models::AccessRule.new(
name: 'EXAMPLE-name-Value',
criteria: [
OCI::Waas::Models::AccessRuleCriteria.new(
condition: 'URL_PART_DOES_NOT_CONTAIN',
value: 'EXAMPLE-value-Value',
is_case_sensitive: true
)
],
action: 'REDIRECT',
block_action: 'SET_RESPONSE_CODE',
block_response_code: 654,
block_error_page_message: 'EXAMPLE-blockErrorPageMessage-Value',
block_error_page_code: 'EXAMPLE-blockErrorPageCode-Value',
block_error_page_description:
'EXAMPLE-blockErrorPageDescription-Value',
bypass_challenges: %w[JS_CHALLENGE],
redirect_url: 'EXAMPLE-redirectUrl-Value',
redirect_response_code: 'MOVED_PERMANENTLY',
captcha_title: 'EXAMPLE-captchaTitle-Value',
captcha_header: 'EXAMPLE-captchaHeader-Value',
captcha_footer: 'EXAMPLE-captchaFooter-Value',
captcha_submit_label: 'EXAMPLE-captchaSubmitLabel-Value',
response_header_manipulation: [
OCI::Waas::Models::ExtendHttpResponseHeaderAction.new(
action: 'EXTEND_HTTP_RESPONSE_HEADER',
header: 'EXAMPLE-header-Value',
value: 'EXAMPLE-value-Value'
)
]
)
],
address_rate_limiting:
OCI::Waas::Models::AddressRateLimiting.new(
is_enabled: true,
allowed_rate_per_address: 8413,
max_delayed_count_per_address: 7117,
block_response_code: 208
),
captchas: [
OCI::Waas::Models::Captcha.new(
url: 'EXAMPLE-url-Value',
session_expiration_in_seconds: 318_071,
title: 'EXAMPLE-title-Value',
failure_message: 'EXAMPLE-failureMessage-Value',
submit_label: 'EXAMPLE-submitLabel-Value',
header_text: 'EXAMPLE-headerText-Value',
footer_text: 'EXAMPLE-footerText-Value'
)
],
device_fingerprint_challenge:
OCI::Waas::Models::DeviceFingerprintChallenge.new(
is_enabled: true,
action: 'DETECT',
failure_threshold: 342_942,
action_expiration_in_seconds: 105_209,
failure_threshold_expiration_in_seconds: 35_066,
max_address_count: 4337,
max_address_count_expiration_in_seconds: 102_731,
challenge_settings:
OCI::Waas::Models::BlockChallengeSettings.new(
block_action: 'SHOW_ERROR_PAGE',
block_response_code: 167,
block_error_page_message: 'EXAMPLE-blockErrorPageMessage-Value',
block_error_page_description:
'EXAMPLE-blockErrorPageDescription-Value',
block_error_page_code: 'EXAMPLE-blockErrorPageCode-Value',
captcha_title: 'EXAMPLE-captchaTitle-Value',
captcha_header: 'EXAMPLE-captchaHeader-Value',
captcha_footer: 'EXAMPLE-captchaFooter-Value',
captcha_submit_label: 'EXAMPLE-captchaSubmitLabel-Value'
)
),
good_bots: [
OCI::Waas::Models::GoodBot.new(
key: 'EXAMPLE-key-Value',
is_enabled: true,
name: 'EXAMPLE-name-Value',
description: 'EXAMPLE-description-Value'
)
],
human_interaction_challenge:
OCI::Waas::Models::HumanInteractionChallenge.new(
is_enabled: false,
action: 'DETECT',
failure_threshold: 960_397,
action_expiration_in_seconds: 139_000,
failure_threshold_expiration_in_seconds: 76_950,
interaction_threshold: 98,
recording_period_in_seconds: 7407,
set_http_header:
OCI::Waas::Models::Header.new(
name: 'EXAMPLE-name-Value', value: 'EXAMPLE-value-Value'
),
challenge_settings:
OCI::Waas::Models::BlockChallengeSettings.new(
block_action: 'SET_RESPONSE_CODE',
block_response_code: 185,
block_error_page_message: 'EXAMPLE-blockErrorPageMessage-Value',
block_error_page_description:
'EXAMPLE-blockErrorPageDescription-Value',
block_error_page_code: 'EXAMPLE-blockErrorPageCode-Value',
captcha_title: 'EXAMPLE-captchaTitle-Value',
captcha_header: 'EXAMPLE-captchaHeader-Value',
captcha_footer: 'EXAMPLE-captchaFooter-Value',
captcha_submit_label: 'EXAMPLE-captchaSubmitLabel-Value'
),
is_nat_enabled: true
),
js_challenge:
OCI::Waas::Models::JsChallenge.new(
is_enabled: false,
action: 'DETECT',
failure_threshold: 877_887,
action_expiration_in_seconds: 53_707,
set_http_header:
OCI::Waas::Models::Header.new(
name: 'EXAMPLE-name-Value', value: 'EXAMPLE-value-Value'
),
challenge_settings:
OCI::Waas::Models::BlockChallengeSettings.new(
block_action: 'SHOW_CAPTCHA',
block_response_code: 369,
block_error_page_message: 'EXAMPLE-blockErrorPageMessage-Value',
block_error_page_description:
'EXAMPLE-blockErrorPageDescription-Value',
block_error_page_code: 'EXAMPLE-blockErrorPageCode-Value',
captcha_title: 'EXAMPLE-captchaTitle-Value',
captcha_header: 'EXAMPLE-captchaHeader-Value',
captcha_footer: 'EXAMPLE-captchaFooter-Value',
captcha_submit_label: 'EXAMPLE-captchaSubmitLabel-Value'
),
are_redirects_challenged: true,
criteria: [
OCI::Waas::Models::AccessRuleCriteria.new(
condition: 'URL_PART_DOES_NOT_CONTAIN',
value: 'EXAMPLE-value-Value',
is_case_sensitive: true
)
],
is_nat_enabled: true
),
origin: 'EXAMPLE-origin-Value',
caching_rules: [
OCI::Waas::Models::CachingRule.new(
name: 'EXAMPLE-name-Value',
action: 'CACHE',
criteria: [
OCI::Waas::Models::CachingRuleCriteria.new(
condition: 'URL_IS', value: 'EXAMPLE-value-Value'
)
],
key: 'EXAMPLE-key-Value',
caching_duration: 'EXAMPLE-cachingDuration-Value',
is_client_caching_enabled: true,
client_caching_duration: 'EXAMPLE-clientCachingDuration-Value'
)
],
custom_protection_rules: [
OCI::Waas::Models::CustomProtectionRuleSetting.new(
id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value',
action: 'DETECT',
exclusions: [
OCI::Waas::Models::ProtectionRuleExclusion.new(
target: 'ARGS', exclusions: %w[EXAMPLE--Value]
)
]
)
],
origin_groups: %w[EXAMPLE--Value],
protection_rules: [
OCI::Waas::Models::ProtectionRule.new(
key: 'EXAMPLE-key-Value',
mod_security_rule_ids: %w[EXAMPLE--Value],
name: 'EXAMPLE-name-Value',
description: 'EXAMPLE-description-Value',
action: 'DETECT',
labels: %w[EXAMPLE--Value],
exclusions: [
OCI::Waas::Models::ProtectionRuleExclusion.new(
target: 'ARGS', exclusions: %w[EXAMPLE--Value]
)
]
)
],
protection_settings:
OCI::Waas::Models::ProtectionSettings.new(
block_action: 'SHOW_ERROR_PAGE',
block_response_code: 382,
block_error_page_message: 'EXAMPLE-blockErrorPageMessage-Value',
block_error_page_code: 'EXAMPLE-blockErrorPageCode-Value',
block_error_page_description:
'EXAMPLE-blockErrorPageDescription-Value',
max_argument_count: 8661,
max_name_length_per_argument: 49_190,
max_total_name_length_of_arguments: 195_950,
recommendations_period_in_days: 34,
is_response_inspected: true,
max_response_size_in_ki_b: 1274,
allowed_http_methods: %w[DELETE],
media_types: %w[EXAMPLE--Value]
),
threat_feeds: [
OCI::Waas::Models::ThreatFeed.new(
key: 'EXAMPLE-key-Value',
name: 'EXAMPLE-name-Value',
action: 'OFF',
description: 'EXAMPLE-description-Value'
)
],
whitelists: [
OCI::Waas::Models::Whitelist.new(
name: 'EXAMPLE-name-Value',
addresses: %w[EXAMPLE--Value],
address_lists: %w[EXAMPLE--Value]
)
]
)
)
# Get the data from response
puts "#{update_waf_config_response.headers}"