// 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).
import * as waas from "oci-waas";
import common = require("oci-common");
// Create a default authentication provider that uses the DEFAULT
// profile in the configuration file.
// Refer to <see href="https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File>the public documentation</see> on how to prepare a configuration file.
const provider: common.ConfigFileAuthenticationDetailsProvider = new common.ConfigFileAuthenticationDetailsProvider();
(async () => {
try {
// Create a service client
const client = new waas.WaasClient({ authenticationDetailsProvider: provider });
// Create a request and dependent object(s).
const updateWaasPolicyDetails = {
displayName: "EXAMPLE-displayName-Value",
additionalDomains: ["EXAMPLE--Value" ],
origins: {
EXAMPLE_KEY_YmoYu :{
uri: "EXAMPLE-uri-Value",
httpPort: 50067,
httpsPort: 30343,
customHeaders: [{
name: "EXAMPLE-name-Value",
value: "EXAMPLE-value-Value",
}
],
}
},
originGroups: {
EXAMPLE_KEY_rbdC8 :{
origins: [{
origin: "EXAMPLE-origin-Value",
weight: 6392,
}
],
}
},
policyConfig: {
certificateId: "ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value",
isHttpsEnabled: true,
isHttpsForced: false,
tlsProtocols: [waas.models.PolicyConfig.TlsProtocols.TlsV11 ],
isOriginCompressionEnabled: true,
isBehindCdn: false,
clientAddressHeader: waas.models.PolicyConfig.ClientAddressHeader.ClientIp,
isCacheControlRespected: false,
isResponseBufferingEnabled: false,
cipherGroup: waas.models.PolicyConfig.CipherGroup.Default,
loadBalancingMethod: {
method: "STICKY_COOKIE", name: "EXAMPLE-name-Value",
domain: "EXAMPLE-domain-Value",
expirationTimeInSeconds: 21836621
}
,
websocketPathPrefixes: ["EXAMPLE--Value" ],
isSniEnabled: true,
healthChecks: {
isEnabled: true,
method: waas.models.HealthCheck.Method.Head,
path: "EXAMPLE-path-Value",
headers: {
EXAMPLE_KEY_1xc9F :"EXAMPLE_VALUE_fjq6x2j9b8vB4lt5BUSC"
},
expectedResponseCodeGroup: [waas.models.HealthCheck.ExpectedResponseCodeGroup._4Xx ],
isResponseTextCheckEnabled: true,
expectedResponseText: "EXAMPLE-expectedResponseText-Value",
intervalInSeconds: 21,
timeoutInSeconds: 69,
healthyThreshold: 6,
unhealthyThreshold: 1,
}
,
}
,
wafConfig: {
accessRules: [{
name: "EXAMPLE-name-Value",
criteria: [{
condition: waas.models.AccessRuleCriteria.Condition.UserAgentIsNot,
value: "EXAMPLE-value-Value",
isCaseSensitive: true,
}
],
action: waas.models.AccessRule.Action.Block,
blockAction: waas.models.AccessRule.BlockAction.ShowErrorPage,
blockResponseCode: 152,
blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
bypassChallenges: [waas.models.AccessRule.BypassChallenges.HumanInteractionChallenge ],
redirectUrl: "EXAMPLE-redirectUrl-Value",
redirectResponseCode: waas.models.AccessRule.RedirectResponseCode.Found,
captchaTitle: "EXAMPLE-captchaTitle-Value",
captchaHeader: "EXAMPLE-captchaHeader-Value",
captchaFooter: "EXAMPLE-captchaFooter-Value",
captchaSubmitLabel: "EXAMPLE-captchaSubmitLabel-Value",
responseHeaderManipulation: [{
action: "REMOVE_HTTP_RESPONSE_HEADER", header: "EXAMPLE-header-Value"
}
],
}
],
addressRateLimiting: {
isEnabled: true,
allowedRatePerAddress: 7634,
maxDelayedCountPerAddress: 5131,
blockResponseCode: 178,
}
,
captchas: [{
url: "EXAMPLE-url-Value",
sessionExpirationInSeconds: 319332,
title: "EXAMPLE-title-Value",
headerText: "EXAMPLE-headerText-Value",
footerText: "EXAMPLE-footerText-Value",
failureMessage: "EXAMPLE-failureMessage-Value",
submitLabel: "EXAMPLE-submitLabel-Value",
}
],
deviceFingerprintChallenge: {
isEnabled: false,
action: waas.models.DeviceFingerprintChallenge.Action.Block,
failureThreshold: 485294,
actionExpirationInSeconds: 304704,
failureThresholdExpirationInSeconds: 139353,
maxAddressCount: 8814,
maxAddressCountExpirationInSeconds: 367066,
challengeSettings: {
blockAction: waas.models.BlockChallengeSettings.BlockAction.SetResponseCode,
blockResponseCode: 658,
blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
captchaTitle: "EXAMPLE-captchaTitle-Value",
captchaHeader: "EXAMPLE-captchaHeader-Value",
captchaFooter: "EXAMPLE-captchaFooter-Value",
captchaSubmitLabel: "EXAMPLE-captchaSubmitLabel-Value",
}
,
}
,
goodBots: [{
key: "EXAMPLE-key-Value",
name: "EXAMPLE-name-Value",
isEnabled: false,
description: "EXAMPLE-description-Value",
}
],
humanInteractionChallenge: {
isEnabled: true,
action: waas.models.HumanInteractionChallenge.Action.Detect,
failureThreshold: 218938,
actionExpirationInSeconds: 143277,
failureThresholdExpirationInSeconds: 164343,
interactionThreshold: 64,
recordingPeriodInSeconds: 1016,
setHttpHeader: {
name: "EXAMPLE-name-Value",
value: "EXAMPLE-value-Value",
}
,
challengeSettings: {
blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowErrorPage,
blockResponseCode: 730,
blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
captchaTitle: "EXAMPLE-captchaTitle-Value",
captchaHeader: "EXAMPLE-captchaHeader-Value",
captchaFooter: "EXAMPLE-captchaFooter-Value",
captchaSubmitLabel: "EXAMPLE-captchaSubmitLabel-Value",
}
,
isNatEnabled: false,
}
,
jsChallenge: {
isEnabled: false,
action: waas.models.JsChallenge.Action.Block,
failureThreshold: 983309,
actionExpirationInSeconds: 72019,
setHttpHeader: {
name: "EXAMPLE-name-Value",
value: "EXAMPLE-value-Value",
}
,
challengeSettings: {
blockAction: waas.models.BlockChallengeSettings.BlockAction.SetResponseCode,
blockResponseCode: 467,
blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
captchaTitle: "EXAMPLE-captchaTitle-Value",
captchaHeader: "EXAMPLE-captchaHeader-Value",
captchaFooter: "EXAMPLE-captchaFooter-Value",
captchaSubmitLabel: "EXAMPLE-captchaSubmitLabel-Value",
}
,
areRedirectsChallenged: false,
criteria: [{
condition: waas.models.AccessRuleCriteria.Condition.UrlRegex,
value: "EXAMPLE-value-Value",
isCaseSensitive: false,
}
],
isNatEnabled: true,
}
,
origin: "EXAMPLE-origin-Value",
cachingRules: [{
key: "EXAMPLE-key-Value",
name: "EXAMPLE-name-Value",
action: waas.models.CachingRule.Action.BypassCache,
cachingDuration: "EXAMPLE-cachingDuration-Value",
isClientCachingEnabled: false,
clientCachingDuration: "EXAMPLE-clientCachingDuration-Value",
criteria: [{
condition: waas.models.CachingRuleCriteria.Condition.UrlStartsWith,
value: "EXAMPLE-value-Value",
}
],
}
],
customProtectionRules: [{
id: "ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value",
action: waas.models.CustomProtectionRuleSetting.Action.Detect,
exclusions: [{
target: waas.models.ProtectionRuleExclusion.Target.RequestCookies,
exclusions: ["EXAMPLE--Value" ],
}
],
}
],
originGroups: ["EXAMPLE--Value" ],
protectionRules: [{
key: "EXAMPLE-key-Value",
modSecurityRuleIds: ["EXAMPLE--Value" ],
name: "EXAMPLE-name-Value",
description: "EXAMPLE-description-Value",
action: waas.models.ProtectionRule.Action.Detect,
labels: ["EXAMPLE--Value" ],
exclusions: [{
target: waas.models.ProtectionRuleExclusion.Target.RequestCookies,
exclusions: ["EXAMPLE--Value" ],
}
],
}
],
protectionSettings: {
blockAction: waas.models.ProtectionSettings.BlockAction.SetResponseCode,
blockResponseCode: 635,
blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
maxArgumentCount: 6393,
maxNameLengthPerArgument: 14768,
maxTotalNameLengthOfArguments: 273078,
recommendationsPeriodInDays: 8,
isResponseInspected: false,
maxResponseSizeInKiB: 708,
allowedHttpMethods: [waas.models.ProtectionSettings.AllowedHttpMethods.Get ],
mediaTypes: ["EXAMPLE--Value" ],
}
,
threatFeeds: [{
key: "EXAMPLE-key-Value",
name: "EXAMPLE-name-Value",
action: waas.models.ThreatFeed.Action.Block,
description: "EXAMPLE-description-Value",
}
],
whitelists: [{
name: "EXAMPLE-name-Value",
addresses: ["EXAMPLE--Value" ],
addressLists: ["EXAMPLE--Value" ],
}
],
}
,
freeformTags: {
EXAMPLE_KEY_Vqxjk :"EXAMPLE_VALUE_pKKd6Bmv5U4uYcgqxnqj"
},
definedTags: {
EXAMPLE_KEY_Puf4t :{
EXAMPLE_KEY_HZf4P :"EXAMPLE--Value"
}
},
}
const updateWaasPolicyRequest: waas.requests.UpdateWaasPolicyRequest = {
waasPolicyId: "ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value",
updateWaasPolicyDetails: updateWaasPolicyDetails,
opcRequestId: "7FBJF0W34W6C8MUKGCEL<unique_ID>",
opcRetryToken: "EXAMPLE-opcRetryToken-Value",
ifMatch: "EXAMPLE-ifMatch-Value",
};
// Send request to the Client.
const updateWaasPolicyResponse = await client.updateWaasPolicy(updateWaasPolicyRequest);
}
catch (error) {
console.log("updateWaasPolicy Failed with error " + error);
}
})();