[
  {
    "enabled": 1,
    "version_min": 300000,
    "title": "Testing XML request body parser - validateDTD (validate ok)",
    "resource": "libxml2",
    "client": {
      "ip": "200.249.12.31",
      "port": 123
    },
    "server": {
      "ip": "200.249.12.31",
      "port": 80
    },
    "request": {
      "headers": {
        "Host": "localhost",
        "User-Agent": "curl/7.38.0",
        "Accept": "*/*",
        "Cookie": "PHPSESSID=rAAAAAAA2t5uvjq435r4q7ib3vtdjq120",
        "Content-Type": "text/xml",
        "Content-Length": "234"
      },
      "uri": "/?key=value&key=other_value",
      "method": "POST",
      "body": [
        "<?xml version=\"1.0\" encoding=\"utf-8\"?>",
        "    <!DOCTYPE Envelope SYSTEM \"SoapEnvelope.dtd\">",
        "    <Envelope>",
        "        <Body>",
        "            <getInput>",
        "                <id type=\"string\">12123</id>",
        "            </getInput>",
        "        </Body>",
        "    </Envelope>"
      ]
    },
    "response": {
      "headers": {
        "Content-Length": "0"
      },
      "body": [
        ""
      ]
    },
    "expected": {
      "debug_log": "XML: Successfully validated payload against DTD: test-cases/data/SoapEnvelope.dtd",
      "http_code": 200
    },
    "rules": [
      "SecRuleEngine On",
      "SecRequestBodyAccess On",
      "SecXMLExternalEntity On",
      "SecRule REQUEST_HEADERS:Content-Type \"^text/xml$\" \"id:500008,phase:1,t:none,t:lowercase,nolog,pass,ctl:requestBodyProcessor=XML\"",
      "SecRule XML \"@validateDTD test-cases/data/SoapEnvelope.dtd\" \"id:500007,phase:3,deny\""
    ]
  },
  {
    "enabled": 1,
    "version_min": 300000,
    "title": "Testing XML request body parser - validateDTD (validation failed)",
    "resource": "libxml2",
    "client": {
      "ip": "200.249.12.31",
      "port": 123
    },
    "server": {
      "ip": "200.249.12.31",
      "port": 80
    },
    "request": {
      "headers": {
        "Host": "localhost",
        "User-Agent": "curl/7.38.0",
        "Accept": "*/*",
        "Cookie": "PHPSESSID=rAAAAAAA2t5uvjq435r4q7ib3vtdjq120",
        "Content-Type": "text/xml",
        "Content-Length": "264"
      },
      "uri": "/?key=value&key=other_value",
      "method": "POST",
      "body": [
        "<?xml version=\"1.0\" encoding=\"utf-8\"?>",
        "    <!DOCTYPE Envelope SYSTEM \"SoapEnvelope.dtd\">",
        "        <Envelope>",
        "            <xBody>",
        "                <getInput>",
        "                    <id type=\"string\">12123</id>",
        "                </getInput>",
        "            </xBody>",
        "        </Envelope>"
      ]
    },
    "response": {
      "headers": {
        "Content-Length": "0"
      },
      "body": [
        ""
      ]
    },
    "expected": {
      "debug_log": "XML Error: No declaration for element xBody",
      "http_code": 403
    },
    "rules": [
      "SecRuleEngine On",
      "SecRequestBodyAccess On",
      "SecXMLExternalEntity On",
      "SecRule REQUEST_HEADERS:Content-Type \"^text/xml$\" \"id:500008,phase:1,t:none,t:lowercase,nolog,pass,ctl:requestBodyProcessor=XML\"",
      "SecRule XML \"@validateDTD test-cases/data/SoapEnvelope.dtd\" \"id:500007,phase:3,deny\""
    ]
  },
  {
    "enabled": 1,
    "version_min": 300000,
    "title": "Testing XML request body parser - validateDTD (bad XML)",
    "resource": "libxml2",
    "client": {
      "ip": "200.249.12.31",
      "port": 123
    },
    "server": {
      "ip": "200.249.12.31",
      "port": 80
    },
    "request": {
      "headers": {
        "Host": "localhost",
        "User-Agent": "curl/7.38.0",
        "Accept": "*/*",
        "Cookie": "PHPSESSID=rAAAAAAA2t5uvjq435r4q7ib3vtdjq120",
        "Content-Type": "text/xml",
        "Content-Length": "229"
      },
      "uri": "/?key=value&key=other_value",
      "method": "POST",
      "body": [
        "<?xml version=\"1.0\" encoding=\"utf-8\"?>",
        "<!DOCTYPE Envelope SYSTEM \"SoapEnvelope.dtd\">",
        "    <Envelop>",
        "        <Body>",
        "            <getInput>",
        "                <id type=\"string\">12123</id>",
        "            </getInput>",
        "        </Body>",
        "    </Envelope>"
      ]
    },
    "response": {
      "headers": {
        "Content-Length": "0"
      },
      "body": [
        ""
      ]
    },
    "expected": {
      "debug_log": "XML: DTD validation failed because content is not well formed",
      "http_code": 403
    },
    "rules": [
      "SecRuleEngine On",
      "SecRequestBodyAccess On",
      "SecXMLExternalEntity On",
      "SecRule REQUEST_HEADERS:Content-Type \"^text/xml$\" \"id:500008,phase:1,t:none,t:lowercase,nolog,pass,ctl:requestBodyProcessor=XML\"",
      "SecRule XML \"@validateDTD test-cases/data/SoapEnvelope.dtd\" \"id:500007,phase:3,deny\""
    ]
  },
  {
    "enabled": 1,
    "version_min": 300000,
    "title": "Testing XML request body parser - validateDTD (bad DTD)",
    "resource": "libxml2",
    "client": {
      "ip": "200.249.12.31",
      "port": 123
    },
    "server": {
      "ip": "200.249.12.31",
      "port": 80
    },
    "request": {
      "headers": {
        "Host": "localhost",
        "User-Agent": "curl/7.38.0",
        "Accept": "*/*",
        "Cookie": "PHPSESSID=rAAAAAAA2t5uvjq435r4q7ib3vtdjq120",
        "Content-Type": "text/xml",
        "Content-Length": "262"
      },
      "uri": "/?key=value&key=other_value",
      "method": "POST",
      "body": [
        "<?xml version=\"1.0\" encoding=\"utf-8\"?>",
        "    <!DOCTYPE Envelope SYSTEM \"SoapEnvelope.dtd\">",
        "        <Envelope>",
        "            <Body>",
        "                <getInput>",
        "                    <id type=\"string\">12123</id>",
        "                </getInput>",
        "            </Body>",
        "        </Envelope>"
      ]
    },
    "response": {
      "headers": {
        "Content-Length": "0"
      },
      "body": [
        ""
      ]
    },
    "expected": {
      "debug_log": "Failed to load DTD: test-cases/data/SoapEnvelope-bad.dtd",
      "http_code": 403
    },
    "rules": [
      "SecRuleEngine On",
      "SecRequestBodyAccess On",
      "SecXMLExternalEntity On",
      "SecRule REQUEST_HEADERS:Content-Type \"^text/xml$\" \"id:500008,phase:1,t:none,t:lowercase,nolog,pass,ctl:requestBodyProcessor=XML\"",
      "SecRule XML \"@validateDTD test-cases/data/SoapEnvelope-bad.dtd\" \"id:500007,phase:3,deny\""
    ]
  }
]
