diff options
| author | Ben Fuhrmannek | 2021-02-16 11:16:59 +0100 |
|---|---|---|
| committer | Ben Fuhrmannek | 2021-02-16 11:16:59 +0100 |
| commit | 5484bcb5eb2714e7438927e2566c86a74d7c51af (patch) | |
| tree | b78326d2999397be4c08e06b23209981f82a4ea9 /src/tests/xxe | |
| parent | 7ac1e3866ef4f146c6c93a5ca13b9aebb14e936a (diff) | |
| parent | cecfdd808da67be908dbe7144cc8c74dfb3f855e (diff) | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/tests/xxe')
| -rw-r--r-- | src/tests/xxe/disable_xxe_dom.phpt | 69 | ||||
| -rw-r--r-- | src/tests/xxe/disable_xxe_dom_disabled.phpt | 1 | ||||
| -rw-r--r-- | src/tests/xxe/disable_xxe_xml_parse.phpt | 1 |
3 files changed, 2 insertions, 69 deletions
diff --git a/src/tests/xxe/disable_xxe_dom.phpt b/src/tests/xxe/disable_xxe_dom.phpt deleted file mode 100644 index 58467f7..0000000 --- a/src/tests/xxe/disable_xxe_dom.phpt +++ /dev/null | |||
| @@ -1,69 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable XXE | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus") || !extension_loaded("dom")) print("skip"); ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disable_xxe.ini | ||
| 7 | --EXTENSIONS-- | ||
| 8 | dom | ||
| 9 | --FILE-- | ||
| 10 | <?php | ||
| 11 | $dir = __DIR__; | ||
| 12 | $content = 'WARNING, external entity loaded!'; | ||
| 13 | file_put_contents('content.txt', $content); | ||
| 14 | |||
| 15 | $xml = <<<EOD | ||
| 16 | <?xml version="1.0"?> | ||
| 17 | <!DOCTYPE root | ||
| 18 | [ | ||
| 19 | <!ENTITY foo SYSTEM "file://$dir/content.txt"> | ||
| 20 | ]> | ||
| 21 | <test><testing>&foo;</testing></test> | ||
| 22 | EOD; | ||
| 23 | |||
| 24 | file_put_contents('content.xml', $xml); | ||
| 25 | |||
| 26 | libxml_disable_entity_loader(true); | ||
| 27 | $dom = new DOMDocument('1.0'); | ||
| 28 | $dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD|LIBXML_NOENT); | ||
| 29 | printf("libxml_disable_entity to true: %s\n", $dom->getElementsByTagName('testing')->item(0)->nodeValue); | ||
| 30 | |||
| 31 | libxml_disable_entity_loader(false); | ||
| 32 | $dom = new DOMDocument('1.0'); | ||
| 33 | $dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD|LIBXML_NOENT); | ||
| 34 | printf("libxml_disable_entity to false: %s\n", $dom->getElementsByTagName('testing')->item(0)->nodeValue); | ||
| 35 | |||
| 36 | $xml = "<test><testing>foo</testing></test>"; | ||
| 37 | file_put_contents('content.xml', $xml); | ||
| 38 | |||
| 39 | libxml_disable_entity_loader(false); | ||
| 40 | $dom = new DOMDocument('1.0'); | ||
| 41 | $dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD|LIBXML_NOENT); | ||
| 42 | printf("without xxe: %s", $dom->getElementsByTagName('testing')->item(0)->nodeValue); | ||
| 43 | |||
| 44 | ?> | ||
| 45 | --EXPECTF-- | ||
| 46 | Warning: DOMDocument::loadXML(): I/O warning : failed to load external entity "file://%a/content.txt" in %a/disable_xxe_dom.php on line %d | ||
| 47 | |||
| 48 | Warning: DOMDocument::loadXML(): Failure to process entity foo in Entity, line: %d in %a/disable_xxe_dom.php on line %d | ||
| 49 | |||
| 50 | Warning: DOMDocument::loadXML(): Entity 'foo' not defined in Entity, line: %d in %a/disable_xxe_dom.php on line %d | ||
| 51 | |||
| 52 | Notice: Trying to get property %a in %a/disable_xxe_dom.php on line %d | ||
| 53 | libxml_disable_entity to true: | ||
| 54 | |||
| 55 | Warning: DOMDocument::loadXML(): I/O warning : failed to load external entity "file://%a/content.txt" in %a/disable_xxe_dom.php on line %d | ||
| 56 | |||
| 57 | Warning: DOMDocument::loadXML(): Failure to process entity foo in Entity, line: %d in %a/disable_xxe_dom.php on line %d | ||
| 58 | |||
| 59 | Warning: DOMDocument::loadXML(): Entity 'foo' not defined in Entity, line: %d in %a/disable_xxe_dom.php on line %d | ||
| 60 | |||
| 61 | Notice: Trying to get property %a in %a/disable_xxe_dom.php on line %d | ||
| 62 | libxml_disable_entity to false: | ||
| 63 | without xxe: foo | ||
| 64 | --CLEAN-- | ||
| 65 | <?php | ||
| 66 | $dir = __DIR__; | ||
| 67 | unlink($dir . "content.xml"); | ||
| 68 | unlink($dir . "content.txt"); | ||
| 69 | ?> | ||
diff --git a/src/tests/xxe/disable_xxe_dom_disabled.phpt b/src/tests/xxe/disable_xxe_dom_disabled.phpt index fe88d76..493f5a3 100644 --- a/src/tests/xxe/disable_xxe_dom_disabled.phpt +++ b/src/tests/xxe/disable_xxe_dom_disabled.phpt | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | Disable XXE | 2 | Disable XXE |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus") || !extension_loaded("dom")) print("skip"); ?> | 4 | <?php if (!extension_loaded("snuffleupagus") || !extension_loaded("dom")) print("skip"); ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 5 | --INI-- | 6 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/disable_xxe_disable.ini | 7 | sp.configuration_file={PWD}/config/disable_xxe_disable.ini |
| 7 | --EXTENSIONS-- | 8 | --EXTENSIONS-- |
diff --git a/src/tests/xxe/disable_xxe_xml_parse.phpt b/src/tests/xxe/disable_xxe_xml_parse.phpt index b6dec2d..6b48bea 100644 --- a/src/tests/xxe/disable_xxe_xml_parse.phpt +++ b/src/tests/xxe/disable_xxe_xml_parse.phpt | |||
| @@ -8,6 +8,7 @@ Disable XXE in xml_parse | |||
| 8 | echo "skip because the `xml` extension isn't loaded"; | 8 | echo "skip because the `xml` extension isn't loaded"; |
| 9 | } | 9 | } |
| 10 | ?> | 10 | ?> |
| 11 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 11 | --EXTENSIONS-- | 12 | --EXTENSIONS-- |
| 12 | xml | 13 | xml |
| 13 | --INI-- | 14 | --INI-- |
