Beispiel #1
0
def test_warning_false_postitives():
    assert find_warning_message((
        "<b>Warning</b>:  include() [<a href=function.include>function.include</a>]: Filename cannot be empty "
        "in <b>/www/index.php</b> on line <b>86</b><br/>\n<br/>\n"
        "<b>Warning</b>:  include() [<a href=function.include>function.include</a>]: Failed opening '' for "
        "inclusion (include_path='.:/usr/local/php/lib64/php') in <b>/www/index.php</b> on line <b>86</b><br/>"
    ), "/etc/passwd") is None

    pattern = (
        "<b>Warning</b>:  file_get_contents() expects parameter 1 to be a valid path, string given in "
        "<b>/home/blah/public_html/skin/blah/page-boatprice.php</b> on line <b>34</b><br />"
    )
    assert find_warning_message(pattern, "http://wapiti3.ovh/e.php\0") is None

    pattern = (
        "<b>Warning</b>:  file_get_contents(): Filename cannot be empty in "
        "<b>/www/doc/blah/www/extdocs/rssReader.php</b> on line <b>319</b><br />"
    )
    assert find_warning_message(pattern, "/etc/passwd") is None
Beispiel #2
0
def test_warning_postitives():
    pattern = (
        "Warning: include(): Failed opening 'application/config/tool_http://wapiti3.ovh/e.php.PPGUI.php' for "
        "inclusion (include_path='.:/home/blah/www:/usr/share/php:/usr/share/pear') in /home/blah/www/index.php on "
        "line <i>25</i>")
    assert find_warning_message(
        pattern, "http://wapiti3.ovh/e.php") == FileWarning(
            pattern=pattern,
            uri="application/config/tool_http://wapiti3.ovh/e.php.PPGUI.php",
            function="include()",
            path="/home/blah/www/index.php")

    pattern = (
        "Warning: readfile(bilder//etc/passwd): failed to open stream: No such file or directory "
        "in /home/httpd/vhosts/blah.tld/httpdocs/download.php on line 71")
    assert find_warning_message(pattern, "/etc/passwd") == FileWarning(
        pattern=pattern,
        uri="bilder//etc/passwd",
        function="readfile()",
        path="/home/httpd/vhosts/blah.tld/httpdocs/download.php")

    pattern = (
        "<b>Warning</b>:  include(specialSites/http://wapiti3.ovh/e.php.php): failed to open stream: "
        "No such file or directory in <b>/home/httpd/vhosts/blah/cgi-bin/includePage.php</b> on line <b>227</b>"
    )
    assert find_warning_message(
        pattern, "http://wapiti3.ovh/e.php") == FileWarning(
            pattern=pattern,
            uri="specialSites/http://wapiti3.ovh/e.php.php",
            function="include()",
            path="/home/httpd/vhosts/blah/cgi-bin/includePage.php")

    pattern = (
        "<b>Warning</b>:  file_get_contents(./http://wapiti3.ovh/e.php/http://wapiti3.ovh/e.php.php): "
        "failed to open stream: No such file or directory in <b>/www/doc/blah/www/index.php</b> on line <b>45</b>"
    )
    assert find_warning_message(
        pattern, "http://wapiti3.ovh/e.php") == FileWarning(
            pattern=pattern,
            uri="./http://wapiti3.ovh/e.php/http://wapiti3.ovh/e.php.php",
            function="file_get_contents()",
            path="/www/doc/blah/www/index.php")

    pattern = (
        "<b>Warning</b>:  include(blah/etc/services.html) [<a href='function.include'>function.include</a>]: "
        "failed to open stream: No such file or directory in <b>/www/doc/blah/www/page.php</b> on line <b>32</b>"
    )
    assert find_warning_message(pattern, "/etc/services") == FileWarning(
        pattern=pattern,
        uri="blah/etc/services.html",
        path="/www/doc/blah/www/page.php",
        function="include()")

    pattern = (
        "<b>Warning</b>:  include() [<a href='function.include'>function.include</a>]: "
        "Failed opening 'blah/etc/services.html' for inclusion (include_path='.:/usr/share/php') "
        "in <b>/www/doc/blah/www/page.php</b> on line <b>32</b>")
    assert find_warning_message(pattern, "/etc/services") == FileWarning(
        pattern=pattern,
        uri="blah/etc/services.html",
        path="/www/doc/blah/www/page.php",
        function="include()")