This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | require_once 'Intraface/Kernel.php'; |
||
3 | |||
4 | class FakeKernelIntranet |
||
5 | { |
||
6 | function hasModuleAccess() |
||
7 | { |
||
8 | return true; |
||
9 | } |
||
10 | } |
||
11 | |||
12 | class FakeKernelIntranetWithNoAccess |
||
13 | { |
||
14 | function hasModuleAccess() |
||
15 | { |
||
16 | return false; |
||
17 | } |
||
18 | } |
||
19 | |||
20 | class KernelTest extends PHPUnit_Framework_TestCase |
||
21 | { |
||
22 | |||
23 | function testRandomKey() |
||
24 | { |
||
25 | $this->assertTrue(strlen(Intraface_Kernel::randomKey(9)) == 9); |
||
26 | } |
||
27 | |||
28 | /* |
||
0 ignored issues
–
show
|
|||
29 | function testWebloginReturnsTrueOnValidLoginAndCreatesTheCorrectObjectsInsideKernel() |
||
30 | { |
||
31 | $db = MDB2::singleton(DB_DSN); |
||
32 | $db->exec('TRUNCATE intranet'); |
||
33 | |||
34 | $this->private_key = md5('private' . date('d-m-Y H:i:s') . 'test'); |
||
35 | $this->public_key = md5('public' . date('d-m-Y H:i:s') . 'test'); |
||
36 | $db->exec('TRUNCATE intranet'); |
||
37 | $db->exec('INSERT INTO intranet SET private_key = ' . $db->quote($this->private_key, 'text') . ', public_key = ' . $db->quote($this->public_key, 'text')); |
||
38 | |||
39 | $session_id = 'somerandomsession'; |
||
40 | $kernel = new Intraface_Kernel; |
||
41 | $this->assertFalse($kernel->weblogin('private', 'wrongkey', $session_id)); |
||
42 | $this->assertTrue($kernel->weblogin('private', $this->private_key, $session_id)); |
||
43 | $this->assertEquals(get_class($kernel->weblogin), 'Weblogin'); |
||
44 | $this->assertEquals(get_class($kernel->intranet), 'Intranet'); |
||
45 | $this->assertEquals(get_class($kernel->setting), 'Setting'); |
||
46 | $this->assertTrue($kernel->weblogin('public', $this->public_key, $session_id)); |
||
47 | $this->assertEquals(get_class($kernel->weblogin), 'Weblogin'); |
||
48 | $this->assertEquals(get_class($kernel->intranet), 'Intranet'); |
||
49 | $this->assertEquals(get_class($kernel->setting), 'Setting'); |
||
50 | } |
||
51 | */ |
||
52 | |||
53 | /* |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
54% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
54 | function testWebloginMakesSureThatSessionIssetInsideKernelAsTheSameAsTheOneWebloginGetsWhenUsingWeblogin() |
||
55 | { |
||
56 | $db = MDB2::singleton(DB_DSN); |
||
57 | $db->exec('TRUNCATE intranet'); |
||
58 | |||
59 | $this->private_key = md5('private' . date('d-m-Y H:i:s') . 'test'); |
||
60 | $this->public_key = md5('public' . date('d-m-Y H:i:s') . 'test'); |
||
61 | $db->exec('TRUNCATE intranet'); |
||
62 | $db->exec('INSERT INTO intranet SET private_key = ' . $db->quote($this->private_key, 'text') . ', public_key = ' . $db->quote($this->public_key, 'text')); |
||
63 | |||
64 | $session_id = 'somerandomsession'; |
||
65 | $kernel = new Intraface_Kernel; |
||
66 | $kernel->weblogin('private', $this->private_key, $session_id); |
||
67 | $this->assertEquals($session_id, $kernel->getSessionId()); |
||
68 | } |
||
69 | */ |
||
70 | |||
71 | View Code Duplication | function testModuleThrowsAnExceptionWhenNoIntranetIsset() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
72 | { |
||
73 | $kernel = new Intraface_Kernel; |
||
74 | try { |
||
75 | $kernel->module('intranetmaintenance'); |
||
76 | $this->assertFalse(true, 'Should have thrown an exception'); |
||
77 | } catch (Exception $e) { |
||
78 | $this->assertTrue(true); |
||
79 | } |
||
80 | } |
||
81 | |||
82 | function testModuleReturnsTheModuleAsAnObjectTrueWhenModuleIsAvailableAndSetsPrimaryModule() |
||
83 | { |
||
84 | $kernel = new Intraface_Kernel; |
||
85 | $kernel->intranet = new FakeKernelIntranet; |
||
86 | $this->assertFalse($kernel->getPrimaryModule()); |
||
87 | $this->assertTrue(is_object($kernel->module('intranetmaintenance'))); |
||
88 | $this->assertTrue(is_object($primary = $kernel->getPrimaryModule())); |
||
89 | $this->assertEquals('intranetmaintenance', $primary->getName()); |
||
90 | } |
||
91 | |||
92 | View Code Duplication | function testUseModuleThrowsAnExceptionIfIntranetHasNoAccess() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
93 | { |
||
94 | $kernel = new Intraface_Kernel; |
||
95 | $kernel->intranet = new FakeKernelIntranetWithNoAccess; |
||
96 | try { |
||
97 | $kernel->useModule('intranetmaintenance'); |
||
98 | $this->assertTrue(false); |
||
99 | } catch (Exception $e) { |
||
100 | $this->assertTrue(true); |
||
101 | } |
||
102 | } |
||
103 | |||
104 | View Code Duplication | function testUseModuleThrowsAnExceptionIfUserHasNoAccess() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
105 | { |
||
106 | $kernel = new Intraface_Kernel; |
||
107 | $kernel->intranet = new FakeKernelIntranet; |
||
108 | $kernel->user = new FakeKernelIntranetWithNoAccess; |
||
109 | try { |
||
110 | $kernel->useModule('intranetmaintenance'); |
||
111 | $this->assertTrue(false); |
||
112 | } catch (Exception $e) { |
||
113 | $this->assertTrue(true); |
||
114 | } |
||
115 | } |
||
116 | |||
117 | View Code Duplication | function testUseModuleThrowsAnExceptionWhenNoIntranetIssetAndNoUserIsset() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
118 | { |
||
119 | $kernel = new Intraface_Kernel; |
||
120 | try { |
||
121 | $kernel->useModule('intranetmaintenance'); |
||
122 | $this->assertFalse(true, 'Should have thrown an exception'); |
||
123 | } catch (Exception $e) { |
||
124 | $this->assertTrue(true); |
||
125 | } |
||
126 | } |
||
127 | |||
128 | View Code Duplication | function testUseModuleDoesNotThrowAnExceptionWhenNoIntranetIssetAndTheUserIsset() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
129 | { |
||
130 | $kernel = new Intraface_Kernel; |
||
131 | $kernel->user = new FakeKernelIntranet; |
||
132 | try { |
||
133 | $kernel->useModule('intranetmaintenance'); |
||
134 | $this->assertFalse(true, 'Should have thrown an exception'); |
||
135 | } catch (Exception $e) { |
||
136 | $this->assertTrue(true); |
||
137 | } |
||
138 | } |
||
139 | |||
140 | View Code Duplication | function testUseModuleReturnsTheModuleAsAnObjectTrueWhenModuleIsAvailable() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
141 | { |
||
142 | $kernel = new Intraface_Kernel; |
||
143 | $kernel->intranet = new FakeKernelIntranet; |
||
144 | $this->assertTrue(is_object($module = $kernel->useModule('intranetmaintenance'))); |
||
145 | $this->assertEquals('intranetmaintenance', $module->getName()); |
||
146 | } |
||
147 | |||
148 | View Code Duplication | function testGetModule() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
149 | { |
||
150 | $kernel = new Intraface_Kernel; |
||
151 | $kernel->intranet = new FakeKernelIntranet; |
||
152 | $this->assertTrue(is_object($kernel->useModule('intranetmaintenance'))); |
||
153 | $this->assertTrue(is_object($module = $kernel->getModule('intranetmaintenance'))); |
||
154 | $this->assertEquals('intranetmaintenance', $module->getName()); |
||
155 | } |
||
156 | |||
157 | function testGetModules() |
||
158 | { |
||
159 | $db = MDB2::singleton(DB_DSN); |
||
160 | $result = $db->query('SELECT * FROM module'); |
||
161 | if (PEAR::isError($result)) { |
||
162 | die($result->getMessage() . $result->getUserInfo()); |
||
0 ignored issues
–
show
The method
testGetModules() contains an exit expression.
An exit expression should only be used in rare cases. For example, if you write a short command line script. In most cases however, using an ![]() |
|||
163 | } |
||
164 | |||
165 | $kernel = new Intraface_Kernel; |
||
166 | $kernel->intranet = new FakeKernelIntranet; |
||
167 | $this->assertTrue(is_array($kernel->getModules())); |
||
168 | $this->assertEquals($result->numRows(), count($kernel->getModules())); |
||
169 | } |
||
170 | } |
||
171 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.