Passed
Push — master ( 4319d9...01828b )
by Timothy
05:08
created

NoHtmlTest::dataOWASP()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

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