Class: AWSCDK::WAFv2::CfnRuleGroup::ByteMatchStatementProperty

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
wa_fv2/cfn_rule_group.rb

Overview

A rule statement that defines a string match search for AWS WAF to apply to web requests.

The byte match statement provides the bytes to search for, the location in requests that you want AWS WAF to search, and other settings. The bytes to search for are typically a string that corresponds with ASCII characters. In the AWS WAF console and the developer guide, this is called a string match statement.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field_to_match:, positional_constraint:, text_transformations:, search_string: nil, search_string_base64: nil) ⇒ ByteMatchStatementProperty

Returns a new instance of ByteMatchStatementProperty.

Parameters:



886
887
888
889
890
891
892
893
894
895
896
897
# File 'wa_fv2/cfn_rule_group.rb', line 886

def initialize(field_to_match:, positional_constraint:, text_transformations:, search_string: nil, search_string_base64: nil)
  @field_to_match = field_to_match.is_a?(Hash) ? ::AWSCDK::WAFv2::CfnRuleGroup::FieldToMatchProperty.new(**field_to_match.transform_keys(&:to_sym)) : field_to_match
  Jsii::Type.check_type(@field_to_match, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImZxbiI6ImF3cy1jZGstbGliLmF3c193YWZ2Mi5DZm5SdWxlR3JvdXAuRmllbGRUb01hdGNoUHJvcGVydHkifV19fQ==")), "fieldToMatch")
  @positional_constraint = positional_constraint
  Jsii::Type.check_type(@positional_constraint, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "positionalConstraint")
  @text_transformations = text_transformations
  Jsii::Type.check_type(@text_transformations, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImNvbGxlY3Rpb24iOnsiZWxlbWVudHR5cGUiOnsidW5pb24iOnsidHlwZXMiOlt7ImZxbiI6ImF3cy1jZGstbGliLklSZXNvbHZhYmxlIn0seyJmcW4iOiJhd3MtY2RrLWxpYi5hd3Nfd2FmdjIuQ2ZuUnVsZUdyb3VwLlRleHRUcmFuc2Zvcm1hdGlvblByb3BlcnR5In1dfX0sImtpbmQiOiJhcnJheSJ9fV19fQ==")), "textTransformations")
  @search_string = search_string
  Jsii::Type.check_type(@search_string, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "searchString") unless @search_string.nil?
  @search_string_base64 = search_string_base64
  Jsii::Type.check_type(@search_string_base64, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "searchStringBase64") unless @search_string_base64.nil?
end

Instance Attribute Details

#field_to_matchAWSCDK::IResolvable, AWSCDK::WAFv2::CfnRuleGroup::FieldToMatchProperty (readonly)

The part of the web request that you want AWS WAF to inspect.



903
904
905
# File 'wa_fv2/cfn_rule_group.rb', line 903

def field_to_match
  @field_to_match
end

#positional_constraintString (readonly)

The area within the portion of the web request that you want AWS WAF to search for SearchString .

Valid values include the following:

CONTAINS

The specified part of the web request must include the value of SearchString , but the location doesn't matter.

CONTAINS_WORD

The specified part of the web request must include the value of SearchString , and SearchString must contain only alphanumeric characters or underscore (A-Z, a-z, 0-9, or _). In addition, SearchString must be a word, which means that both of the following are true:

  • SearchString is at the beginning of the specified part of the web request or is preceded by a character other than an alphanumeric character or underscore (_). Examples include the value of a header and ;BadBot .
  • SearchString is at the end of the specified part of the web request or is followed by a character other than an alphanumeric character or underscore (_), for example, BadBot; and -BadBot; .

EXACTLY

The value of the specified part of the web request must exactly match the value of SearchString .

STARTS_WITH

The value of SearchString must appear at the beginning of the specified part of the web request.

ENDS_WITH

The value of SearchString must appear at the end of the specified part of the web request.



933
934
935
# File 'wa_fv2/cfn_rule_group.rb', line 933

def positional_constraint
  @positional_constraint
end

#search_stringString? (readonly)

A string value that you want AWS WAF to search for.

AWS WAF searches only in the part of web requests that you designate for inspection in FieldToMatch . The maximum length of the value is 200 bytes. For alphabetic characters A-Z and a-z, the value is case sensitive.

Don't encode this string. Provide the value that you want AWS WAF to search for. AWS CloudFormation automatically base64 encodes the value for you.

For example, suppose the value of Type is HEADER and the value of Data is User-Agent . If you want to search the User-Agent header for the value BadBot , you provide the string BadBot in the value of SearchString .

You must specify either SearchString or SearchStringBase64 in a ByteMatchStatement .



953
954
955
# File 'wa_fv2/cfn_rule_group.rb', line 953

def search_string
  @search_string
end

#search_string_base64String? (readonly)

String to search for in a web request component, base64-encoded.

If you don't want to encode the string, specify the unencoded value in SearchString instead.

You must specify either SearchString or SearchStringBase64 in a ByteMatchStatement .



962
963
964
# File 'wa_fv2/cfn_rule_group.rb', line 962

def search_string_base64
  @search_string_base64
end

#text_transformationsAWSCDK::IResolvable, Array<AWSCDK::IResolvable, AWSCDK::WAFv2::CfnRuleGroup::TextTransformationProperty> (readonly)

Text transformations eliminate some of the unusual formatting that attackers use in web requests in an effort to bypass detection.

If you specify one or more transformations in a rule statement, AWS WAF performs all transformations on the content of the request component identified by FieldToMatch , starting from the lowest priority setting, before inspecting the content for a match.



940
941
942
# File 'wa_fv2/cfn_rule_group.rb', line 940

def text_transformations
  @text_transformations
end

Class Method Details

.jsii_propertiesObject



964
965
966
967
968
969
970
971
972
# File 'wa_fv2/cfn_rule_group.rb', line 964

def self.jsii_properties
  {
    :field_to_match => "fieldToMatch",
    :positional_constraint => "positionalConstraint",
    :text_transformations => "textTransformations",
    :search_string => "searchString",
    :search_string_base64 => "searchStringBase64",
  }
end

Instance Method Details

#to_jsiiObject



974
975
976
977
978
979
980
981
982
983
984
# File 'wa_fv2/cfn_rule_group.rb', line 974

def to_jsii
  result = {}
  result.merge!({
    "fieldToMatch" => @field_to_match,
    "positionalConstraint" => @positional_constraint,
    "textTransformations" => @text_transformations,
    "searchString" => @search_string,
    "searchStringBase64" => @search_string_base64,
  })
  result.compact
end