File tree Expand file tree Collapse file tree 4 files changed +131
-0
lines changed
Security/Tests/BadFunctions Expand file tree Collapse file tree 4 files changed +131
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * Paranoia mode = 0.
5+ */
6+
7+ // Base.
8+ include ( 'path/to/ ' . $ _GET ['filename ' ] ); // Error.
9+ include_once 'path/to/ ' . "$ filename " . '. ' . $ extension ;
10+ require getenv ('PATHTOFILE ' ); // Error.
11+
12+ // Drupal 7.
13+ require_once ( 'path/to/ ' . $ form ['filename ' ] );
14+ include arg (2 ) . drupal_get_query_parameters ()['param ' ];
15+
16+ // Prevent false positives on safe $_SERVER variables.
17+ include $ _SERVER ['DOCUMENT_ROOT ' ] . '/filename.php ' ;
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * Paranoia mode = 1.
5+ */
6+
7+ // Base.
8+ include ( 'path/to/ ' . $ _GET ['filename ' ] ); // Error.
9+ include 'path/to/ ' . "$ filename " . '. ' . $ extension ; // Warning x 2.
10+ include getenv ('PATHTOFILE ' ); // Error.
11+
12+ // Drupal 7.
13+ include ( 'path/to/ ' . $ form ['filename ' ] ); // Warning.
14+ include arg (2 ) . drupal_get_query_parameters ()['param ' ]; // Warning x 2.
15+
16+ // Prevent false positives on safe $_SERVER variables.
17+ include $ _SERVER ['DOCUMENT_ROOT ' ] . '/filename.php ' ; // Error.
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * Paranoia mode = 1, CmsFramework = Drupal7.
5+ */
6+
7+ // Base.
8+ include ( 'path/to/ ' . $ _GET ['filename ' ] ); // Error.
9+ include 'path/to/ ' . "$ filename " . '. ' . $ extension ; // Warning x 2.
10+ include getenv ('PATHTOFILE ' ); // Error.
11+
12+ // Drupal 7.
13+ include ( 'path/to/ ' . $ form ['filename ' ] ); // Error.
14+ include arg (2 ) . drupal_get_query_parameters ()['param ' ]; // Error x 2.
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace PHPCS_SecurityAudit \Security \Tests \BadFunctions ;
4+
5+ use PHPCS_SecurityAudit \Security \Tests \AbstractSecurityTestCase ;
6+
7+ /**
8+ * Unit test class for the EasyRFI sniff.
9+ *
10+ * @covers \PHPCS_SecurityAudit\Security\Sniffs\BadFunctions\EasyRFISniff
11+ */
12+ class EasyRFIUnitTest extends AbstractSecurityTestCase
13+ {
14+
15+ /**
16+ * Returns the lines where errors should occur.
17+ *
18+ * The key of the array should represent the line number and the value
19+ * should represent the number of errors that should occur on that line.
20+ *
21+ * @param string $testFile The name of the file being tested.
22+ *
23+ * @return array<int, int>
24+ */
25+ public function getErrorList ($ testFile = '' )
26+ {
27+ switch ($ testFile ) {
28+ case 'EasyRFIUnitTest.0.inc ' :
29+ return [
30+ 8 => 1 ,
31+ 10 => 1 ,
32+ ];
33+
34+ case 'EasyRFIUnitTest.1.inc ' :
35+ return [
36+ 8 => 1 ,
37+ 10 => 1 ,
38+ 17 => 1 ,
39+ ];
40+
41+ case 'EasyRFIUnitTest.Drupal7.1.inc ' :
42+ return [
43+ 8 => 1 ,
44+ 10 => 1 ,
45+ 13 => 1 ,
46+ 14 => 2 ,
47+ ];
48+
49+ default :
50+ return [];
51+ }
52+ }
53+
54+ /**
55+ * Returns the lines where warnings should occur.
56+ *
57+ * The key of the array should represent the line number and the value
58+ * should represent the number of warnings that should occur on that line.
59+ *
60+ * @param string $testFile The name of the file being tested.
61+ *
62+ * @return array<int, int>
63+ */
64+ public function getWarningList ($ testFile = '' )
65+ {
66+ switch ($ testFile ) {
67+ case 'EasyRFIUnitTest.1.inc ' :
68+ return [
69+ 9 => 2 ,
70+ 13 => 1 ,
71+ 14 => 2 ,
72+ ];
73+
74+ case 'EasyRFIUnitTest.Drupal7.1.inc ' :
75+ return [
76+ 9 => 2 ,
77+ ];
78+
79+ default :
80+ return [];
81+ }
82+ }
83+ }
You can’t perform that action at this time.
0 commit comments