{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.WAFRegional.Types.XssMatchTuple
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.WAFRegional.Types.XssMatchTuple where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.WAFRegional.Types.FieldToMatch
import Amazonka.WAFRegional.Types.TextTransformation

-- | This is __AWS WAF Classic__ documentation. For more information, see
-- <https://docs.aws.amazon.com/waf/latest/developerguide/classic-waf-chapter.html AWS WAF Classic>
-- in the developer guide.
--
-- __For the latest version of AWS WAF__, use the AWS WAFV2 API and see the
-- <https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html AWS WAF Developer Guide>.
-- With the latest version, AWS WAF has a single set of endpoints for
-- regional and global use.
--
-- Specifies the part of a web request that you want AWS WAF to inspect for
-- cross-site scripting attacks and, if you want AWS WAF to inspect a
-- header, the name of the header.
--
-- /See:/ 'newXssMatchTuple' smart constructor.
data XssMatchTuple = XssMatchTuple'
  { -- | Specifies where in a web request to look for cross-site scripting
    -- attacks.
    XssMatchTuple -> FieldToMatch
fieldToMatch :: FieldToMatch,
    -- | Text transformations eliminate some of the unusual formatting that
    -- attackers use in web requests in an effort to bypass AWS WAF. If you
    -- specify a transformation, AWS WAF performs the transformation on
    -- @FieldToMatch@ before inspecting it for a match.
    --
    -- You can only specify a single type of TextTransformation.
    --
    -- __CMD_LINE__
    --
    -- When you\'re concerned that attackers are injecting an operating system
    -- command line command and using unusual formatting to disguise some or
    -- all of the command, use this option to perform the following
    -- transformations:
    --
    -- -   Delete the following characters: \\ \" \' ^
    --
    -- -   Delete spaces before the following characters: \/ (
    --
    -- -   Replace the following characters with a space: , ;
    --
    -- -   Replace multiple spaces with one space
    --
    -- -   Convert uppercase letters (A-Z) to lowercase (a-z)
    --
    -- __COMPRESS_WHITE_SPACE__
    --
    -- Use this option to replace the following characters with a space
    -- character (decimal 32):
    --
    -- -   \\f, formfeed, decimal 12
    --
    -- -   \\t, tab, decimal 9
    --
    -- -   \\n, newline, decimal 10
    --
    -- -   \\r, carriage return, decimal 13
    --
    -- -   \\v, vertical tab, decimal 11
    --
    -- -   non-breaking space, decimal 160
    --
    -- @COMPRESS_WHITE_SPACE@ also replaces multiple spaces with one space.
    --
    -- __HTML_ENTITY_DECODE__
    --
    -- Use this option to replace HTML-encoded characters with unencoded
    -- characters. @HTML_ENTITY_DECODE@ performs the following operations:
    --
    -- -   Replaces @(ampersand)quot;@ with @\"@
    --
    -- -   Replaces @(ampersand)nbsp;@ with a non-breaking space, decimal 160
    --
    -- -   Replaces @(ampersand)lt;@ with a \"less than\" symbol
    --
    -- -   Replaces @(ampersand)gt;@ with @>@
    --
    -- -   Replaces characters that are represented in hexadecimal format,
    --     @(ampersand)#xhhhh;@, with the corresponding characters
    --
    -- -   Replaces characters that are represented in decimal format,
    --     @(ampersand)#nnnn;@, with the corresponding characters
    --
    -- __LOWERCASE__
    --
    -- Use this option to convert uppercase letters (A-Z) to lowercase (a-z).
    --
    -- __URL_DECODE__
    --
    -- Use this option to decode a URL-encoded value.
    --
    -- __NONE__
    --
    -- Specify @NONE@ if you don\'t want to perform any text transformations.
    XssMatchTuple -> TextTransformation
textTransformation :: TextTransformation
  }
  deriving (XssMatchTuple -> XssMatchTuple -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: XssMatchTuple -> XssMatchTuple -> Bool
$c/= :: XssMatchTuple -> XssMatchTuple -> Bool
== :: XssMatchTuple -> XssMatchTuple -> Bool
$c== :: XssMatchTuple -> XssMatchTuple -> Bool
Prelude.Eq, ReadPrec [XssMatchTuple]
ReadPrec XssMatchTuple
Int -> ReadS XssMatchTuple
ReadS [XssMatchTuple]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [XssMatchTuple]
$creadListPrec :: ReadPrec [XssMatchTuple]
readPrec :: ReadPrec XssMatchTuple
$creadPrec :: ReadPrec XssMatchTuple
readList :: ReadS [XssMatchTuple]
$creadList :: ReadS [XssMatchTuple]
readsPrec :: Int -> ReadS XssMatchTuple
$creadsPrec :: Int -> ReadS XssMatchTuple
Prelude.Read, Int -> XssMatchTuple -> ShowS
[XssMatchTuple] -> ShowS
XssMatchTuple -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [XssMatchTuple] -> ShowS
$cshowList :: [XssMatchTuple] -> ShowS
show :: XssMatchTuple -> String
$cshow :: XssMatchTuple -> String
showsPrec :: Int -> XssMatchTuple -> ShowS
$cshowsPrec :: Int -> XssMatchTuple -> ShowS
Prelude.Show, forall x. Rep XssMatchTuple x -> XssMatchTuple
forall x. XssMatchTuple -> Rep XssMatchTuple x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep XssMatchTuple x -> XssMatchTuple
$cfrom :: forall x. XssMatchTuple -> Rep XssMatchTuple x
Prelude.Generic)

-- |
-- Create a value of 'XssMatchTuple' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'fieldToMatch', 'xssMatchTuple_fieldToMatch' - Specifies where in a web request to look for cross-site scripting
-- attacks.
--
-- 'textTransformation', 'xssMatchTuple_textTransformation' - Text transformations eliminate some of the unusual formatting that
-- attackers use in web requests in an effort to bypass AWS WAF. If you
-- specify a transformation, AWS WAF performs the transformation on
-- @FieldToMatch@ before inspecting it for a match.
--
-- You can only specify a single type of TextTransformation.
--
-- __CMD_LINE__
--
-- When you\'re concerned that attackers are injecting an operating system
-- command line command and using unusual formatting to disguise some or
-- all of the command, use this option to perform the following
-- transformations:
--
-- -   Delete the following characters: \\ \" \' ^
--
-- -   Delete spaces before the following characters: \/ (
--
-- -   Replace the following characters with a space: , ;
--
-- -   Replace multiple spaces with one space
--
-- -   Convert uppercase letters (A-Z) to lowercase (a-z)
--
-- __COMPRESS_WHITE_SPACE__
--
-- Use this option to replace the following characters with a space
-- character (decimal 32):
--
-- -   \\f, formfeed, decimal 12
--
-- -   \\t, tab, decimal 9
--
-- -   \\n, newline, decimal 10
--
-- -   \\r, carriage return, decimal 13
--
-- -   \\v, vertical tab, decimal 11
--
-- -   non-breaking space, decimal 160
--
-- @COMPRESS_WHITE_SPACE@ also replaces multiple spaces with one space.
--
-- __HTML_ENTITY_DECODE__
--
-- Use this option to replace HTML-encoded characters with unencoded
-- characters. @HTML_ENTITY_DECODE@ performs the following operations:
--
-- -   Replaces @(ampersand)quot;@ with @\"@
--
-- -   Replaces @(ampersand)nbsp;@ with a non-breaking space, decimal 160
--
-- -   Replaces @(ampersand)lt;@ with a \"less than\" symbol
--
-- -   Replaces @(ampersand)gt;@ with @>@
--
-- -   Replaces characters that are represented in hexadecimal format,
--     @(ampersand)#xhhhh;@, with the corresponding characters
--
-- -   Replaces characters that are represented in decimal format,
--     @(ampersand)#nnnn;@, with the corresponding characters
--
-- __LOWERCASE__
--
-- Use this option to convert uppercase letters (A-Z) to lowercase (a-z).
--
-- __URL_DECODE__
--
-- Use this option to decode a URL-encoded value.
--
-- __NONE__
--
-- Specify @NONE@ if you don\'t want to perform any text transformations.
newXssMatchTuple ::
  -- | 'fieldToMatch'
  FieldToMatch ->
  -- | 'textTransformation'
  TextTransformation ->
  XssMatchTuple
newXssMatchTuple :: FieldToMatch -> TextTransformation -> XssMatchTuple
newXssMatchTuple FieldToMatch
pFieldToMatch_ TextTransformation
pTextTransformation_ =
  XssMatchTuple'
    { $sel:fieldToMatch:XssMatchTuple' :: FieldToMatch
fieldToMatch = FieldToMatch
pFieldToMatch_,
      $sel:textTransformation:XssMatchTuple' :: TextTransformation
textTransformation = TextTransformation
pTextTransformation_
    }

-- | Specifies where in a web request to look for cross-site scripting
-- attacks.
xssMatchTuple_fieldToMatch :: Lens.Lens' XssMatchTuple FieldToMatch
xssMatchTuple_fieldToMatch :: Lens' XssMatchTuple FieldToMatch
xssMatchTuple_fieldToMatch = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\XssMatchTuple' {FieldToMatch
fieldToMatch :: FieldToMatch
$sel:fieldToMatch:XssMatchTuple' :: XssMatchTuple -> FieldToMatch
fieldToMatch} -> FieldToMatch
fieldToMatch) (\s :: XssMatchTuple
s@XssMatchTuple' {} FieldToMatch
a -> XssMatchTuple
s {$sel:fieldToMatch:XssMatchTuple' :: FieldToMatch
fieldToMatch = FieldToMatch
a} :: XssMatchTuple)

-- | Text transformations eliminate some of the unusual formatting that
-- attackers use in web requests in an effort to bypass AWS WAF. If you
-- specify a transformation, AWS WAF performs the transformation on
-- @FieldToMatch@ before inspecting it for a match.
--
-- You can only specify a single type of TextTransformation.
--
-- __CMD_LINE__
--
-- When you\'re concerned that attackers are injecting an operating system
-- command line command and using unusual formatting to disguise some or
-- all of the command, use this option to perform the following
-- transformations:
--
-- -   Delete the following characters: \\ \" \' ^
--
-- -   Delete spaces before the following characters: \/ (
--
-- -   Replace the following characters with a space: , ;
--
-- -   Replace multiple spaces with one space
--
-- -   Convert uppercase letters (A-Z) to lowercase (a-z)
--
-- __COMPRESS_WHITE_SPACE__
--
-- Use this option to replace the following characters with a space
-- character (decimal 32):
--
-- -   \\f, formfeed, decimal 12
--
-- -   \\t, tab, decimal 9
--
-- -   \\n, newline, decimal 10
--
-- -   \\r, carriage return, decimal 13
--
-- -   \\v, vertical tab, decimal 11
--
-- -   non-breaking space, decimal 160
--
-- @COMPRESS_WHITE_SPACE@ also replaces multiple spaces with one space.
--
-- __HTML_ENTITY_DECODE__
--
-- Use this option to replace HTML-encoded characters with unencoded
-- characters. @HTML_ENTITY_DECODE@ performs the following operations:
--
-- -   Replaces @(ampersand)quot;@ with @\"@
--
-- -   Replaces @(ampersand)nbsp;@ with a non-breaking space, decimal 160
--
-- -   Replaces @(ampersand)lt;@ with a \"less than\" symbol
--
-- -   Replaces @(ampersand)gt;@ with @>@
--
-- -   Replaces characters that are represented in hexadecimal format,
--     @(ampersand)#xhhhh;@, with the corresponding characters
--
-- -   Replaces characters that are represented in decimal format,
--     @(ampersand)#nnnn;@, with the corresponding characters
--
-- __LOWERCASE__
--
-- Use this option to convert uppercase letters (A-Z) to lowercase (a-z).
--
-- __URL_DECODE__
--
-- Use this option to decode a URL-encoded value.
--
-- __NONE__
--
-- Specify @NONE@ if you don\'t want to perform any text transformations.
xssMatchTuple_textTransformation :: Lens.Lens' XssMatchTuple TextTransformation
xssMatchTuple_textTransformation :: Lens' XssMatchTuple TextTransformation
xssMatchTuple_textTransformation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\XssMatchTuple' {TextTransformation
textTransformation :: TextTransformation
$sel:textTransformation:XssMatchTuple' :: XssMatchTuple -> TextTransformation
textTransformation} -> TextTransformation
textTransformation) (\s :: XssMatchTuple
s@XssMatchTuple' {} TextTransformation
a -> XssMatchTuple
s {$sel:textTransformation:XssMatchTuple' :: TextTransformation
textTransformation = TextTransformation
a} :: XssMatchTuple)

instance Data.FromJSON XssMatchTuple where
  parseJSON :: Value -> Parser XssMatchTuple
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"XssMatchTuple"
      ( \Object
x ->
          FieldToMatch -> TextTransformation -> XssMatchTuple
XssMatchTuple'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"FieldToMatch")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"TextTransformation")
      )

instance Prelude.Hashable XssMatchTuple where
  hashWithSalt :: Int -> XssMatchTuple -> Int
hashWithSalt Int
_salt XssMatchTuple' {FieldToMatch
TextTransformation
textTransformation :: TextTransformation
fieldToMatch :: FieldToMatch
$sel:textTransformation:XssMatchTuple' :: XssMatchTuple -> TextTransformation
$sel:fieldToMatch:XssMatchTuple' :: XssMatchTuple -> FieldToMatch
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` FieldToMatch
fieldToMatch
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` TextTransformation
textTransformation

instance Prelude.NFData XssMatchTuple where
  rnf :: XssMatchTuple -> ()
rnf XssMatchTuple' {FieldToMatch
TextTransformation
textTransformation :: TextTransformation
fieldToMatch :: FieldToMatch
$sel:textTransformation:XssMatchTuple' :: XssMatchTuple -> TextTransformation
$sel:fieldToMatch:XssMatchTuple' :: XssMatchTuple -> FieldToMatch
..} =
    forall a. NFData a => a -> ()
Prelude.rnf FieldToMatch
fieldToMatch
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf TextTransformation
textTransformation

instance Data.ToJSON XssMatchTuple where
  toJSON :: XssMatchTuple -> Value
toJSON XssMatchTuple' {FieldToMatch
TextTransformation
textTransformation :: TextTransformation
fieldToMatch :: FieldToMatch
$sel:textTransformation:XssMatchTuple' :: XssMatchTuple -> TextTransformation
$sel:fieldToMatch:XssMatchTuple' :: XssMatchTuple -> FieldToMatch
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"FieldToMatch" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= FieldToMatch
fieldToMatch),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"TextTransformation" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= TextTransformation
textTransformation)
          ]
      )