Class: OCI::Waas::Models::ProtectionSettings

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/waas/models/protection_settings.rb

Overview

The settings used for protection rules.

Constant Summary collapse

BLOCK_ACTION_ENUM =

rubocop:disable Metrics/LineLength

[
  BLOCK_ACTION_SHOW_ERROR_PAGE = 'SHOW_ERROR_PAGE'.freeze,
  BLOCK_ACTION_SET_RESPONSE_CODE = 'SET_RESPONSE_CODE'.freeze,
  BLOCK_ACTION_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze
ALLOWED_HTTP_METHODS_ENUM =
[
  ALLOWED_HTTP_METHODS_OPTIONS = 'OPTIONS'.freeze,
  ALLOWED_HTTP_METHODS_GET = 'GET'.freeze,
  ALLOWED_HTTP_METHODS_HEAD = 'HEAD'.freeze,
  ALLOWED_HTTP_METHODS_POST = 'POST'.freeze,
  ALLOWED_HTTP_METHODS_PUT = 'PUT'.freeze,
  ALLOWED_HTTP_METHODS_DELETE = 'DELETE'.freeze,
  ALLOWED_HTTP_METHODS_TRACE = 'TRACE'.freeze,
  ALLOWED_HTTP_METHODS_CONNECT = 'CONNECT'.freeze,
  ALLOWED_HTTP_METHODS_PATCH = 'PATCH'.freeze,
  ALLOWED_HTTP_METHODS_PROPFIND = 'PROPFIND'.freeze,
  ALLOWED_HTTP_METHODS_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ProtectionSettings

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash

Options Hash (attributes):



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
# File 'lib/oci/waas/models/protection_settings.rb', line 168

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  self.block_action = attributes[:'blockAction'] if attributes[:'blockAction']

  raise 'You cannot provide both :blockAction and :block_action' if attributes.key?(:'blockAction') && attributes.key?(:'block_action')

  self.block_action = attributes[:'block_action'] if attributes[:'block_action']

  self.block_response_code = attributes[:'blockResponseCode'] if attributes[:'blockResponseCode']

  raise 'You cannot provide both :blockResponseCode and :block_response_code' if attributes.key?(:'blockResponseCode') && attributes.key?(:'block_response_code')

  self.block_response_code = attributes[:'block_response_code'] if attributes[:'block_response_code']

  self.block_error_page_message = attributes[:'blockErrorPageMessage'] if attributes[:'blockErrorPageMessage']

  raise 'You cannot provide both :blockErrorPageMessage and :block_error_page_message' if attributes.key?(:'blockErrorPageMessage') && attributes.key?(:'block_error_page_message')

  self.block_error_page_message = attributes[:'block_error_page_message'] if attributes[:'block_error_page_message']

  self.block_error_page_code = attributes[:'blockErrorPageCode'] if attributes[:'blockErrorPageCode']

  raise 'You cannot provide both :blockErrorPageCode and :block_error_page_code' if attributes.key?(:'blockErrorPageCode') && attributes.key?(:'block_error_page_code')

  self.block_error_page_code = attributes[:'block_error_page_code'] if attributes[:'block_error_page_code']

  self.block_error_page_description = attributes[:'blockErrorPageDescription'] if attributes[:'blockErrorPageDescription']

  raise 'You cannot provide both :blockErrorPageDescription and :block_error_page_description' if attributes.key?(:'blockErrorPageDescription') && attributes.key?(:'block_error_page_description')

  self.block_error_page_description = attributes[:'block_error_page_description'] if attributes[:'block_error_page_description']

  self.max_argument_count = attributes[:'maxArgumentCount'] if attributes[:'maxArgumentCount']

  raise 'You cannot provide both :maxArgumentCount and :max_argument_count' if attributes.key?(:'maxArgumentCount') && attributes.key?(:'max_argument_count')

  self.max_argument_count = attributes[:'max_argument_count'] if attributes[:'max_argument_count']

  self.max_name_length_per_argument = attributes[:'maxNameLengthPerArgument'] if attributes[:'maxNameLengthPerArgument']

  raise 'You cannot provide both :maxNameLengthPerArgument and :max_name_length_per_argument' if attributes.key?(:'maxNameLengthPerArgument') && attributes.key?(:'max_name_length_per_argument')

  self.max_name_length_per_argument = attributes[:'max_name_length_per_argument'] if attributes[:'max_name_length_per_argument']

  self.max_total_name_length_of_arguments = attributes[:'maxTotalNameLengthOfArguments'] if attributes[:'maxTotalNameLengthOfArguments']

  raise 'You cannot provide both :maxTotalNameLengthOfArguments and :max_total_name_length_of_arguments' if attributes.key?(:'maxTotalNameLengthOfArguments') && attributes.key?(:'max_total_name_length_of_arguments')

  self.max_total_name_length_of_arguments = attributes[:'max_total_name_length_of_arguments'] if attributes[:'max_total_name_length_of_arguments']

  self.recommendations_period_in_days = attributes[:'recommendationsPeriodInDays'] if attributes[:'recommendationsPeriodInDays']

  raise 'You cannot provide both :recommendationsPeriodInDays and :recommendations_period_in_days' if attributes.key?(:'recommendationsPeriodInDays') && attributes.key?(:'recommendations_period_in_days')

  self.recommendations_period_in_days = attributes[:'recommendations_period_in_days'] if attributes[:'recommendations_period_in_days']

  self.is_response_inspected = attributes[:'isResponseInspected'] unless attributes[:'isResponseInspected'].nil?

  raise 'You cannot provide both :isResponseInspected and :is_response_inspected' if attributes.key?(:'isResponseInspected') && attributes.key?(:'is_response_inspected')

  self.is_response_inspected = attributes[:'is_response_inspected'] unless attributes[:'is_response_inspected'].nil?

  self.max_response_size_in_ki_b = attributes[:'maxResponseSizeInKiB'] if attributes[:'maxResponseSizeInKiB']

  raise 'You cannot provide both :maxResponseSizeInKiB and :max_response_size_in_ki_b' if attributes.key?(:'maxResponseSizeInKiB') && attributes.key?(:'max_response_size_in_ki_b')

  self.max_response_size_in_ki_b = attributes[:'max_response_size_in_ki_b'] if attributes[:'max_response_size_in_ki_b']

  self.allowed_http_methods = attributes[:'allowedHttpMethods'] if attributes[:'allowedHttpMethods']

  raise 'You cannot provide both :allowedHttpMethods and :allowed_http_methods' if attributes.key?(:'allowedHttpMethods') && attributes.key?(:'allowed_http_methods')

  self.allowed_http_methods = attributes[:'allowed_http_methods'] if attributes[:'allowed_http_methods']

  self.media_types = attributes[:'mediaTypes'] if attributes[:'mediaTypes']

  raise 'You cannot provide both :mediaTypes and :media_types' if attributes.key?(:'mediaTypes') && attributes.key?(:'media_types')

  self.media_types = attributes[:'media_types'] if attributes[:'media_types']
end

Instance Attribute Details

#allowed_http_methodsArray<String>

The list of allowed HTTP methods. If unspecified, default to ‘[OPTIONS, GET, HEAD, POST]`.

Returns:

  • (Array<String>)


80
81
82
# File 'lib/oci/waas/models/protection_settings.rb', line 80

def allowed_http_methods
  @allowed_http_methods
end

#block_actionString

If ‘action` is set to `BLOCK`, this specifies how the traffic is blocked when detected as malicious by a protection rule. If unspecified, defaults to `SET_RESPONSE_CODE`.

Returns:

  • (String)


32
33
34
# File 'lib/oci/waas/models/protection_settings.rb', line 32

def block_action
  @block_action
end

#block_error_page_codeString

The error code to show on the error page when ‘action` is set to `BLOCK`, `blockAction` is set to `SHOW_ERROR_PAGE`, and the traffic is detected as malicious by a protection rule. If unspecified, defaults to `403`.

Returns:

  • (String)


44
45
46
# File 'lib/oci/waas/models/protection_settings.rb', line 44

def block_error_page_code
  @block_error_page_code
end

#block_error_page_descriptionString

The description text to show on the error page when ‘action` is set to `BLOCK`, `blockAction` is set to `SHOW_ERROR_PAGE`, and the traffic is detected as malicious by a protection rule. If unspecified, defaults to `Access blocked by website owner. Please contact support.`

Returns:

  • (String)


48
49
50
# File 'lib/oci/waas/models/protection_settings.rb', line 48

def block_error_page_description
  @block_error_page_description
end

#block_error_page_messageString

The message to show on the error page when ‘action` is set to `BLOCK`, `blockAction` is set to `SHOW_ERROR_PAGE`, and the traffic is detected as malicious by a protection rule. If unspecified, defaults to ’Access to the website is blocked.‘

Returns:

  • (String)


40
41
42
# File 'lib/oci/waas/models/protection_settings.rb', line 40

def block_error_page_message
  @block_error_page_message
end

#block_response_codeInteger

The response code returned when ‘action` is set to `BLOCK`, `blockAction` is set to `SET_RESPONSE_CODE`, and the traffic is detected as malicious by a protection rule. If unspecified, defaults to `403`.

Returns:

  • (Integer)


36
37
38
# File 'lib/oci/waas/models/protection_settings.rb', line 36

def block_response_code
  @block_response_code
end

#is_response_inspectedBOOLEAN

Inspects the response body of origin responses. Can be used to detect leakage of sensitive data. If unspecified, defaults to ‘false`.

Note: Only origin responses with a Content-Type matching a value in ‘mediaTypes` will be inspected.

Returns:

  • (BOOLEAN)


72
73
74
# File 'lib/oci/waas/models/protection_settings.rb', line 72

def is_response_inspected
  @is_response_inspected
end

#max_argument_countInteger

The maximum number of arguments allowed to be passed to your application before an action is taken. If unspecified, defaults to ‘255`.

Returns:

  • (Integer)


52
53
54
# File 'lib/oci/waas/models/protection_settings.rb', line 52

def max_argument_count
  @max_argument_count
end

#max_name_length_per_argumentInteger

The maximum length allowed for each argument name, in characters. If unspecified, defaults to ‘400`.

Returns:

  • (Integer)


56
57
58
# File 'lib/oci/waas/models/protection_settings.rb', line 56

def max_name_length_per_argument
  @max_name_length_per_argument
end

#max_response_size_in_ki_bInteger

The maximum response size to be fully inspected, in binary kilobytes (KiB). Anything over this limit will be partially inspected. If unspecified, defaults to ‘1024`.

Returns:

  • (Integer)


76
77
78
# File 'lib/oci/waas/models/protection_settings.rb', line 76

def max_response_size_in_ki_b
  @max_response_size_in_ki_b
end

#max_total_name_length_of_argumentsInteger

The maximum length allowed for the sum of all argument names, in characters. If unspecified, defaults to ‘64000`.

Returns:

  • (Integer)


60
61
62
# File 'lib/oci/waas/models/protection_settings.rb', line 60

def max_total_name_length_of_arguments
  @max_total_name_length_of_arguments
end

#media_typesArray<String>

The list of media types to allow for inspection, if ‘isResponseInspected` is enabled. Only responses with MIME types in this list will be inspected. If unspecified, defaults to `[`text/html`, `text/plain`, `text/xml`]`.

Supported MIME types include:

- text/html
- text/plain
- text/asp
- text/css
- text/x-script
- application/json
- text/webviewhtml
- text/x-java-source
- application/x-javascript
- application/javascript
- application/ecmascript
- text/javascript
- text/ecmascript
- text/x-script.perl
- text/x-script.phyton
- application/plain
- application/xml
- text/xml

Returns:

  • (Array<String>)


105
106
107
# File 'lib/oci/waas/models/protection_settings.rb', line 105

def media_types
  @media_types
end

#recommendations_period_in_daysInteger

The length of time to analyze traffic traffic, in days. After the analysis period, ‘WafRecommendations` will be populated. If unspecified, defaults to `10`.

Use ‘GET /waasPolicies/waasPolicyId/wafRecommendations` to view WAF recommendations.

Returns:

  • (Integer)


66
67
68
# File 'lib/oci/waas/models/protection_settings.rb', line 66

def recommendations_period_in_days
  @recommendations_period_in_days
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/oci/waas/models/protection_settings.rb', line 108

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'block_action': :'blockAction',
    'block_response_code': :'blockResponseCode',
    'block_error_page_message': :'blockErrorPageMessage',
    'block_error_page_code': :'blockErrorPageCode',
    'block_error_page_description': :'blockErrorPageDescription',
    'max_argument_count': :'maxArgumentCount',
    'max_name_length_per_argument': :'maxNameLengthPerArgument',
    'max_total_name_length_of_arguments': :'maxTotalNameLengthOfArguments',
    'recommendations_period_in_days': :'recommendationsPeriodInDays',
    'is_response_inspected': :'isResponseInspected',
    'max_response_size_in_ki_b': :'maxResponseSizeInKiB',
    'allowed_http_methods': :'allowedHttpMethods',
    'media_types': :'mediaTypes'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/oci/waas/models/protection_settings.rb', line 129

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'block_action': :'String',
    'block_response_code': :'Integer',
    'block_error_page_message': :'String',
    'block_error_page_code': :'String',
    'block_error_page_description': :'String',
    'max_argument_count': :'Integer',
    'max_name_length_per_argument': :'Integer',
    'max_total_name_length_of_arguments': :'Integer',
    'recommendations_period_in_days': :'Integer',
    'is_response_inspected': :'BOOLEAN',
    'max_response_size_in_ki_b': :'Integer',
    'allowed_http_methods': :'Array<String>',
    'media_types': :'Array<String>'
    # rubocop:enable Style/SymbolLiteral
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • other (Object)

    the other object to be compared



297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
# File 'lib/oci/waas/models/protection_settings.rb', line 297

def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    block_action == other.block_action &&
    block_response_code == other.block_response_code &&
    block_error_page_message == other.block_error_page_message &&
    block_error_page_code == other.block_error_page_code &&
    block_error_page_description == other.block_error_page_description &&
    max_argument_count == other.max_argument_count &&
    max_name_length_per_argument == other.max_name_length_per_argument &&
    max_total_name_length_of_arguments == other.max_total_name_length_of_arguments &&
    recommendations_period_in_days == other.recommendations_period_in_days &&
    is_response_inspected == other.is_response_inspected &&
    max_response_size_in_ki_b == other.max_response_size_in_ki_b &&
    allowed_http_methods == other.allowed_http_methods &&
    media_types == other.media_types
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
# File 'lib/oci/waas/models/protection_settings.rb', line 339

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)

  self.class.swagger_types.each_pair do |key, type|
    if type =~ /^Array<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        public_method("#{key}=").call(
          attributes[self.class.attribute_map[key]]
            .map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
        )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      public_method("#{key}=").call(
        OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]])
      )
    end
    # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(other) ⇒ Boolean

Parameters:

  • other (Object)

    the other object to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


319
320
321
# File 'lib/oci/waas/models/protection_settings.rb', line 319

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



328
329
330
# File 'lib/oci/waas/models/protection_settings.rb', line 328

def hash
  [block_action, block_response_code, block_error_page_message, block_error_page_code, block_error_page_description, max_argument_count, max_name_length_per_argument, max_total_name_length_of_arguments, recommendations_period_in_days, is_response_inspected, max_response_size_in_ki_b, allowed_http_methods, media_types].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



372
373
374
375
376
377
378
379
380
381
# File 'lib/oci/waas/models/protection_settings.rb', line 372

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = public_method(attr).call
    next if value.nil? && !instance_variable_defined?("@#{attr}")

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



366
367
368
# File 'lib/oci/waas/models/protection_settings.rb', line 366

def to_s
  to_hash.to_s
end