Como faço para criar regras JSON complexas personalizadas no AWS WAF?
Quero criar regras JSON complexas personalizadas no AWS WAF.
Resolução
Crie uma regra personalizada complexa
Conclua as etapas a seguir:
- Abra o console do AWS WAF.
- No painel de navegação, escolha Grupos de regras.
- Escolha seu grupo de regras.
- Escolha Gerenciar regras e, em seguida, Adicionar regra.
- Escolha Regra personalizada e, em seguida, escolha Avançar.
- Escolha JSON para abrir o editor de regras JSON.
- Atualize o editor de regras JSON com sua regra personalizada.
- Selecione Adicionar regra.
Observação: Para criar regras personalizadas que usam instruções aninhadas, você deve usar o editor JSON. Instruções aninhadas combinam as lógicas E, OU, ou NÃO. Para obter mais informações, consulte Usando declarações de regras em AWS WAF.
Use os exemplos a seguir como referência para criar sua própria lógica de regra personalizada.
Exemplo 1
Use a seguinte instrução de regra personalizada para permitir uma solicitação quando ela for originária dos Estados Unidos - EUA e tiver o URI /wp-admin/ ou /wp-login/:
{ "Name": "test", "Priority": 100, "Statement": { "AndStatement": { "Statements": [ { "GeoMatchStatement": { "CountryCodes": [ "US" ] } }, { "OrStatement": { "Statements": [ { "ByteMatchStatement": { "SearchString": "/wp-admin/", "FieldToMatch": { "UriPath": {} }, "TextTransformations": [ { "Priority": 0, "Type": "NONE" } ], "PositionalConstraint": "CONTAINS" } }, { "ByteMatchStatement": { "SearchString": "/wp-login/", "FieldToMatch": { "UriPath": {} }, "TextTransformations": [ { "Priority": 0, "Type": "NONE" } ], "PositionalConstraint": "CONTAINS" } } ] } } ] } }, "Action": { "Allow": {} }, "VisibilityConfig": { "SampledRequestsEnabled": true, "CloudWatchMetricsEnabled": true, "MetricName": "test" } }
Lógica da regra: A solicitação é (dos EUA) E o URI é ( /a OU /b ).
Exemplo 2
Use a seguinte instrução de regra personalizada para bloquear uma solicitação quando ela tiver assinaturas XSS no corpo. A regra exclui os URIs /test, /login e /admin da inspeção:
{ "Name": "XSS_Block_Allow_Uploads", "Priority": 100, "Statement": { "AndStatement": { "Statements": [ { "XssMatchStatement": { "FieldToMatch": { "Body": {} }, "TextTransformations": [ { "Priority": 0, "Type": "NONE" } ] } }, { "NotStatement": { "Statement": { "OrStatement": { "Statements": [ { "ByteMatchStatement": { "SearchString": "/test", "FieldToMatch": { "UriPath": {} }, "TextTransformations": [ { "Priority": 0, "Type": "NONE" } ], "PositionalConstraint": "EXACTLY" } }, { "ByteMatchStatement": { "SearchString": "/admin", "FieldToMatch": { "UriPath": {} }, "TextTransformations": [ { "Priority": 0, "Type": "NONE" } ], "PositionalConstraint": "EXACTLY" } }, { "ByteMatchStatement": { "SearchString": "/login", "FieldToMatch": { "UriPath": {} }, "TextTransformations": [ { "Priority": 0, "Type": "NONE" } ], "PositionalConstraint": "EXACTLY" } } ] } } } } ] } }, "Action": { "Block": {} }, "VisibilityConfig": { "SampledRequestsEnabled": true, "CloudWatchMetricsEnabled": true, "MetricName": "XSS_Block_Allow_Uploads" } }
Lógica da regra: A solicitação possui (assinatura XSS no corpo) E o URI é NÃO ( /a OU /b, OU /c ).
Exemplo 3
Use a seguinte instrução de regra personalizada para bloquear uma solicitação quando ela tiver a etiqueta interno personalizada. As solicitações também não podem ter uma combinação específica para host, endereço IP e URI:
{ "Name": "Block_internal_unauthorized", "Priority": 100, "Statement": { "AndStatement": { "Statements": [ { "LabelMatchStatement": { "Scope": "LABEL", "Key": "internal" } }, { "NotStatement": { "Statement": { "AndStatement": { "Statements": [ { "ByteMatchStatement": { "FieldToMatch": { "UriPath": {} }, "PositionalConstraint": "EXACTLY", "SearchString": "/test", "TextTransformations": [{ "Type": "NONE", "Priority": 0 }] } }, { "IPSetReferenceStatement": { "ARN": "arn:aws:wafv2:us-east-1:555555555555:regional/ipset/internal_IPs/###-##-###" } }, { "ByteMatchStatement": { "FieldToMatch": { "SingleHeader": { "Name": "host" } }, "PositionalConstraint": "EXACTLY", "SearchString": "example.com", "TextTransformations": [{ "Type": "NONE", "Priority": 0 }] } } ] } } } } ] } }, "Action": { "Block": {} }, "VisibilityConfig": { "SampledRequestsEnabled": true, "CloudWatchMetricsEnabled": true, "MetricName": "Block_internal_unauthorized" } }
Lógica da regra: Se a solicitação (contiver a etiqueta) E não (URI e IP e host), bloqueie.
- Tags
- AWS WAF
- Idioma
- Português

Conteúdo relevante
feita há 2 anos
feita há um ano
AWS OFICIALAtualizada há 7 meses