NoHtmlTest::testOWASP()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 12
rs 9.4285
cc 1
eloc 8
nc 1
nop 1
1
<?php
2
3
namespace PhpNoHtmlTest;
4
5
class NoHtmlTest extends \PHPUnit_Framework_TestCase
6
{
7
    /**
8
     * @source https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
9
     * @return array[]
10
     */
11
    public function dataOWASP()
12
    {
13
        $exploits = [];
14
        
15
        foreach (new \DirectoryIterator(__DIR__ . '/exploits') as $file) {
16
            if ($file->isFile()) {
17
                $exploits[$file->getBasename()] = [file_get_contents($file->getRealPath())];
18
            }
19
        }
20
        
21
        return $exploits;
22
    }
23
24
    /**
25
     * @dataProvider dataOWASP
26
     * @param mixed $value
27
     */
28
    public function testOWASP($value)
29
    {
30
        self::assertNotEmpty($value);
31
        
32
        $actual = \NoHtml\noHtml($value);
33
        
34
        self::assertNotEmpty($actual);
35
        self::assertNotContains('<', $actual);
36
        self::assertNotContains('>', $actual);
37
        self::assertNotContains('"', $actual);
38
        self::assertNotContains("'", $actual);
39
    }
40
}
41