{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.WAFRegional.Types.XssMatchTuple where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(XssMatchTuple -> XssMatchTuple -> Bool)
-> (XssMatchTuple -> XssMatchTuple -> Bool) -> Eq XssMatchTuple
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]
(Int -> ReadS XssMatchTuple)
-> ReadS [XssMatchTuple]
-> ReadPrec XssMatchTuple
-> ReadPrec [XssMatchTuple]
-> Read 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
(Int -> XssMatchTuple -> ShowS)
-> (XssMatchTuple -> String)
-> ([XssMatchTuple] -> ShowS)
-> Show XssMatchTuple
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. XssMatchTuple -> Rep XssMatchTuple x)
-> (forall x. Rep XssMatchTuple x -> XssMatchTuple)
-> Generic XssMatchTuple
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' :: FieldToMatch -> TextTransformation -> XssMatchTuple
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 :: (FieldToMatch -> f FieldToMatch)
-> XssMatchTuple -> f XssMatchTuple
xssMatchTuple_fieldToMatch = (XssMatchTuple -> FieldToMatch)
-> (XssMatchTuple -> FieldToMatch -> XssMatchTuple)
-> Lens XssMatchTuple XssMatchTuple FieldToMatch 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 :: (TextTransformation -> f TextTransformation)
-> XssMatchTuple -> f XssMatchTuple
xssMatchTuple_textTransformation = (XssMatchTuple -> TextTransformation)
-> (XssMatchTuple -> TextTransformation -> XssMatchTuple)
-> Lens
     XssMatchTuple XssMatchTuple TextTransformation 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 Core.FromJSON XssMatchTuple where
  parseJSON :: Value -> Parser XssMatchTuple
parseJSON =
    String
-> (Object -> Parser XssMatchTuple)
-> Value
-> Parser XssMatchTuple
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"XssMatchTuple"
      ( \Object
x ->
          FieldToMatch -> TextTransformation -> XssMatchTuple
XssMatchTuple'
            (FieldToMatch -> TextTransformation -> XssMatchTuple)
-> Parser FieldToMatch
-> Parser (TextTransformation -> XssMatchTuple)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser FieldToMatch
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"FieldToMatch")
            Parser (TextTransformation -> XssMatchTuple)
-> Parser TextTransformation -> Parser XssMatchTuple
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser TextTransformation
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"TextTransformation")
      )

instance Prelude.Hashable XssMatchTuple

instance Prelude.NFData XssMatchTuple

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"FieldToMatch" Text -> FieldToMatch -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= FieldToMatch
fieldToMatch),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"TextTransformation" Text -> TextTransformation -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TextTransformation
textTransformation)
          ]
      )