XML Threat Protection
XML Threat Protection é um interceptor que valida o conteúdo de um XML a partir de limites pré-definidos para uma série de componentes. Assim, ele evita que ataques maliciosos que enviam informações fora do padrão esperado sejam bem-sucedidos.
Para configurar o interceptor, temos que preencher os campos da imagem abaixo com os valores esperados. Você pode ler a respeito de cada uma das informações requisitadas nas próximas subseções.
 
Campo: Name Limits
Element
Especifica o tamanho máximo do nome de qualquer elemento no XML.
<Customers>
<Customer CustomerID="6s695dp84">
  <CompanyName>Sensedia</CompanyName>
  <ContactName>Howard Snyder</ContactName>
  <ContactTitle>Marketing Manager</ContactTitle>
  <Phone>(19) 555-7555</Phone>
  <FullAddress>
    <Address>Rua Dr. Ricardo Benetton Martins.</Address>
    <City>Campinas</City>
    <Region>SP</Region>
    <PostalCode>13086-902</PostalCode>
    <Country>BR</Country>
  </FullAddress>
</Customer>
</Customers>No exemplo acima, podemos configurar como 12. Então, o interceptor verificará se nenhum elemento excede 12 caracteres.
Attribute
Especifica o tamanho máximo para qualquer atributo no XML.
<Customer CustomerID="6s695dp84">
  <CompanyName>Sensedia</CompanyName>
  <ContactName>Howard Snyder</ContactName>
  <ContactTitle>Marketing Manager</ContactTitle>
  <Phone>(19) 555-7555</Phone>
</Customer>Para o exemplo acima, o interceptor verificará se o tamanho do atributo CustomerID não excede a quantidade permitida de caracteres definida na configuração.
Namespace prefix
Especifica o tamanho máximo de caracteres para qualquer prefixo no XML.
<sensedia:gateway xmlns:sensedia="http://sensedia.com" xmlns:manager="http:sensedia.com/api-manager"Nesse exemplo, ele verificará o tamanho do namespace sensedia, que, no caso, tem oito caracteres.
Processing Instruction Target
Especifica o tamanho máximo de caracteres para processing instruction target no XML.
<?xml-sensedia version="1.0" encoding="utf-8"?>Nesse exemplo, o interceptor verificará se xml-sensedia não excede a quantidade máxima de caracteres.
Nesse caso, xml-sensedia tem 12 caracteres.
Campo: Structure Limits
Node depth
Especifica a profundidade máxima permitida no XML.
<Customers>
   <Customer CustomerID="6s695dp84">
     <CompanyName>Sensedia</CompanyName>
     <ContactName>Howard Snyder</ContactName>
     <ContactTitle>Marketing Manager</ContactTitle>
     <Phone>(19) 555-7555</Phone>
     <FullAddress>
       <Address>Rua Dr. Ricardo Benetton Martins.</Address>
       <City>Campinas</City>
       <Region>SP</Region>
       <PostalCode>13086-902</PostalCode>
       <Country>BR</Country>
     </FullAddress>
   </Customer>
 </Customers>Nesse exemplo, o xml tem a profundidade igual a 4.
Attribute count per element
Especifica a quantidade de atributos por elemento em um documento XML.
<Customer CustomerID="3" CustomerID_web="s3ko05456sdsl">O exemplo acima, o elemento tem dois atributos: customerID e CustomerID_web.
Namespace count per element
Especifica a quantidade de namespaces por elemento em um documento XML.
<sensedia:gateway xmlns:sensedia="http://sensedia.com" xmlns:manager="http:sensedia.com/api-manager"
             manager:sensedia="sensedia">Nesse exemplo, há três namespaces: xmlns:sensedia, xmlns:manager e manager:sensedia.
Child count
Especifica a quantidade de filhos de qualquer elemento em um documento XML.
<Customers>
    <Customer CustomerID="6s695dp84">
      <CompanyName>Sensedia</CompanyName>
      <ContactName>Howard Snyder</ContactName>
      <ContactTitle>Marketing Manager</ContactTitle>
      <Phone>(19) 555-7555</Phone>
      <FullAddress>
        <Address>Rua Dr. Ricardo Benetton Martins.</Address>
        <City>Campinas</City>
        <Region>SP</Region>
        <PostalCode>13086-902</PostalCode>
        <Country>BR</Country>
      </FullAddress>
    </Customer>
  </Customers>Neste exemplo, o elemento Customer tem cinco filhos: CompanyName, ContactName, ContactTitle, Phone e FullAddress
Field: Value Limits
Text
Especifica a quantidade máxima de caracteres do valor de qualquer elemento.
<ContactTitle>Marketing Manager</ContactTitle>Nesse exemplo, o valor Marketing Manager tem 17 caracteres.
Attribute
Especifica a quantidade máxima de caracteres do valor de qualquer atributo.
<Customer CustomerID="6s695dp84">No exemplo acima, o valor 6s695dp84 do atributo CustomerID tem nove caracteres.
Namespace URI
Especifica a quantidade máxima de caracteres do valor de qualquer namespace.
 <sensedia:gateway xmlns:sensedia="http://sensedia.com">Nesse exemplo, http://sensedia.com tem 19 caracteres.
Erros
Here are the errors that can be returned when the interceptor finds any irregularity regarding the specifications above.
| Erro | Cód. HTTP Requisição | Cód. HTTP Resposta | |
|---|---|---|---|
| XML | XML format invalid | 400 | 500 | 
| Name Limits/Element | Name limits element exceeds the maximum allowed for this API (n) | 400 | 500 | 
| Name Limits/Attribute | Name limits attribute exceeds the maximum allowed for this API (n) | 400 | 500 | 
| Name Limits/Namespace prefix | Name limits namespace prefix exceeds the maximum allowed for this API (n) | 400 | 500 | 
| Name Limits/Processing Instruction Target | Name limits processing instruction target exceeds the maximum allowed for this API (n) | 400 | 500 | 
| Structure Limits/Node depth | Structure limits node depth element exceeds the maximum allowed for this API (n) | 400 | 500 | 
| Structure Limits/Attribute count per element | Structure limits attribute count per element exceeds the maximum allowed for this API (n) | 400 | 500 | 
| Structure Limits/Namespace count per element | Structure limits namespace count per element exceeds the maximum allowed for this API (n) | 400 | 500 | 
| Structure Limits/Child count | Structure limits child count exceeds the maximum allowed for this API (n) | 400 | 500 | 
| Value Limits/Text | Value limits text exceeds the maximum allowed for this API (n) | 400 | 500 | 
| Value Limits/Attribute | Value limits attribute exceeds the maximum allowed for this API (n) | 400 | 500 | 
| Value Limits/Namespace URI | Value limits namespace URI exceeds the maximum allowed for this API (n) | 400 | 500 | 
| Value Limits/Comment | Value limits comment exceeds the maximum allowed for this API (n) | 400 | 500 | 
| Value Limits/Processing Instruction Data | Value limits processing instruction data exceeds the maximum allowed for this API (n) | 400 | 500 | 
| Invalid Content-Type | XML threat protection validation failed: Invalid Content-Type in Header → (Content type) | 415 | 415 | 
| Content-Type not found | XML threat protection validation failed: Content-Type not found in Header | 415 | 415 | 
Share your suggestions with us!
          Click here and then [+ Submit idea]