Issues (4714)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

tests/unit/Common/UserTest.php (3 issues)

Upgrade to new PHP Analysis Engine

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/User.php';
3
require_once 'Intraface/modules/intranetmaintenance/ModuleMaintenance.php';
4
require_once 'Intraface/modules/intranetmaintenance/UserMaintenance.php';
5
require_once 'Intraface/modules/intranetmaintenance/IntranetMaintenance.php';
6
require_once 'Intraface/Validator.php';
7
8
class UserTest extends PHPUnit_Framework_TestCase
9
{
10
    private $user;
11
12
    function setUp()
13
    {
14
        $db = MDB2::singleton(DB_DSN);
15
        $db->exec('TRUNCATE user');
16
        $db->exec('TRUNCATE intranet');
17
        $db->exec('TRUNCATE modules');
18
        $db->exec('TRUNCATE permission');
19
20
        // @todo this has the notion with the standard database setup
21
        $u = new UserMaintenance();
22
        $u->update(array('email' => '[email protected]', 'password' => '123456', 'confirm_password' => '123456', 'disabled' => 0));
23
24
        $i = new IntranetMaintenance();
25
        $i->save(array('name' => 'intraface', 'identifier' => 'intraface'));
26
27
        $m = new ModuleMaintenance();
28
        $result = $m->register();
0 ignored issues
show
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
29
30
        $this->user = new Intraface_User(1);
31
    }
32
33
    function tearDown()
34
    {
35
        $this->user = null;
36
    }
37
38
    ////////////////////////////////////////////////////////////////////////////
39
40
    function testConstructionOfUser()
41
    {
42
        $this->assertTrue(is_object($this->user));
43
    }
44
45
    function testIntranetAccessReturnsTrueWhenTheUserHasIntranetAccessAndFalseIfNot()
46
    {
47
        $u = new UserMaintenance(1);
48
        $u->setIntranetAccess(1);
49
50
        $this->assertTrue($this->user->hasIntranetAccess(1));
51
        $this->assertFalse($this->user->hasIntranetAccess(2));
52
    }
53
54
    function testUserModuleAccessOnlyWorksWhenTheUserHasAnActiveIntranetId()
55
    {
56
        $u = new UserMaintenance(1);
57
        $u->setModuleAccess('intranetmaintenance', 1);
58
59
        // TODO how should we handle unknown modules
60
        // TODO and setup modules we can count on for the test
61
        $this->assertFalse($this->user->hasModuleAccess('intranetmaintenance'));
62
        $this->assertFalse($this->user->hasModuleAccess('todo'));
63
        $this->user->setIntranetId(1); // sp�rgsm�let er om man bare skal have en init i stedet?
64
        $this->assertTrue($this->user->hasModuleAccess('intranetmaintenance'));
65
        $this->assertFalse($this->user->hasModuleAccess('todo'));
66
    }
67
68
    function testSubAccessReturnsFalseOnANotInitializedSubAccess()
69
    {
70
        $u = new UserMaintenance(1);
71
        $u->setIntranetAccess(1);
72
        $this->assertFalse($this->user->hasSubAccess(1, 1));
73
    }
74
75
    function testSetActiveIntranetReturnsAValueLargerThanZero()
76
    {
77
        $u = new UserMaintenance(1);
78
        $u->setModuleAccess('intranetmaintenance', 1);
79
80
        $this->assertTrue($this->user->setActiveIntranetId(1) > 0);
81
    }
82
83
    function testGetPermissionsReturnsAnArray()
84
    {
85
        $this->assertTrue(is_array($this->user->getPermissions()));
86
    }
87
88
    function testHasModuleAccessReturnsTrueOnAccess()
89
    {
90
        $u = new UserMaintenance(1);
91
        $u->setModuleAccess('intranetmaintenance', 1);
92
93
        $this->user->setIntranetId(1);
94
        $this->assertTrue($this->user->hasModuleAccess('intranetmaintenance'));
95
    }
96
97
    function testHasModuleAccessReturnsFalseIfAccessIsNotGranted()
98
    {
99
        $u = new UserMaintenance(1);
100
        $u->setIntranetAccess(1);
101
        $this->user->setIntranetId(1);
102
        $this->assertFalse($this->user->hasModuleAccess('todo'));
103
    }
104
105
    function testClearCachedPermissionsEmptiesPermissionArrayAndSetsPermissionLoadedToFalse()
106
    {
107
        $u = new UserMaintenance(1);
108
        $u->setIntranetAccess(1);
109
110
        $this->user->setIntranetId(1);
111
        $this->user->clearCachedPermission();
112
        $this->assertEquals(0, count($this->user->getPermissions()));
113
    }
114
115
    function testGetAddressReturnsObject()
116
    {
117
        $this->assertTrue(is_object($this->user->getAddress()));
118
    }
119
120
    /**
121
     * @todo Is this correct?
122
     */
123
    function testGetActiveIntranetIdReturnsCorrectIntranetIdEvenBeforeItIsSpecificallySetBySetActiveIntranetId()
124
    {
125
        $u = new UserMaintenance(1);
126
        $u->setIntranetAccess(1);
127
        $this->assertEquals(1, $this->user->getActiveIntranetId());
128
    }
129
130
    function testGetActiveIntranetIdReturnsActiveIdWhenFirstSetBySetActiveIntranetId()
131
    {
132
        $u = new UserMaintenance(1);
133
        $u->setIntranetAccess(1);
134
135
        $this->user->setActiveIntranetId(1);
136
        $this->assertEquals(1, $this->user->getActiveIntranetId());
137
    }
138
139
    function testIsFilledInReturnsFalseWhenNothingHasBeenDoneToSetupTheUser()
140
    {
141
        $u = new UserMaintenance(1);
142
        $u->setIntranetAccess(1);
143
        $this->assertFalse($this->user->isFilledIn());
144
    }
145
146 View Code Duplication
    function testUpdatePasswordReturnsTrue()
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.

Loading history...
147
    {
148
        $u = new UserMaintenance(1);
149
        $u->setIntranetAccess(1);
150
151
        $old = '123456';
152
        $new = 'newpass';
153
154
        $this->assertTrue($this->user->updatePassword($old, $new, $new));
155
    }
156
157 View Code Duplication
    function testUpdatePasswordReturnsFalseIfNewPasswordsDoNotMatch()
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.

Loading history...
158
    {
159
        $u = new UserMaintenance(1);
160
        $u->setIntranetAccess(1);
161
162
        $old = '123456';
163
        $new = 'newpass';
164
        $new1 = 'nomatch';
165
166
        $this->assertFalse($this->user->updatePassword($old, $new, $new1));
167
    }
168
169
    function testGetIdReturnsTheIdOfTheUSer()
170
    {
171
        $this->assertEquals(1, $this->user->getId());
172
    }
173
}
174