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.

src/Intraface/Kernel.php (10 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
/**
3
 * Kernel - a registry
4
 *
5
 * @package Intraface
6
 * @author  Sune Jensen <[email protected]>
7
 * @author  Lars Olesen <[email protected]>
8
 * @since   0.1.0
9
 * @version @package-version@
10
 */
11
class Intraface_Kernel implements Intraface_Identity
12
{
13
    private $db;
14
    public $intranet;
15
    public $user;
16
    private $_session;
17
    public $session_id;
18
    /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% 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.

Loading history...
19
    public $modules = array();
20
    public $shared;
21
    private $primary_module_name;
22
    */
23
    public $translation;
24
    private $observers = array();
0 ignored issues
show
The property $observers is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
25
    private $modulehandler;
26
    public $setting;
27
28
    /**
29
     * Constructor
30
     *
31
     * @param string $session Session string
32
     *
33
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
34
     */
35 30
    function __construct($session = null)
36
    {
37 30
        if ($session == null) {
0 ignored issues
show
It seems like you are loosely comparing $session of type string|null against null; this is ambiguous if the string can be empty. Consider using a strict comparison === instead.
Loading history...
38 30
            $this->_session = md5(uniqid(rand(), true));
39 30
        } else {
40
            $this->_session = $session;
41
        }
42 30
        $this->db = MDB2:: singleton(DB_DSN);
43 30
        if (PEAR::isError($this->db)) {
44
            throw new Exception($this->db->getMessage() . $this->db->getUserInfo());
45
        }
46 30
    }
47
48
    /**
49
     * returns an unique user id for this login
50
     *
51
     * @todo: session_id is not the correct name, as this is not always session id.
52
     */
53 3
    function getSessionId()
54
    {
55 3
        return $this->_session;
56
    }
57
58 89
    function getModuleHandler()
59
    {
60 89
        if (!empty($this->modulehandler)) {
61 63
            return $this->modulehandler;
62
        }
63 89
        return ($this->modulehandler = new Intraface_ModuleHandler($this->intranet, $this->user));
0 ignored issues
show
$this->intranet is of type object<Intraface_Intrane...ect<FakeDebtorIntranet>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
$this->user is of type object<Intraface_User>|o...|object<FakeDebtorUser>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
64
    }
65
66
    /**
67
     * Sets primary module for a page
68
     *
69
     * @param string $module_name Name on module
70
     *
71
     * @return Module object
72
     */
73 27
    function module($module_name)
74
    {
75 27
        return $this->getModuleHandler()->setPrimaryModule($module_name);
76
    }
77
78
    /**
79
     * Returns the primary module
80
     *
81
     * Used for instance in Page to give the correct submenu.
82
     *
83
     * @return module object or false
84
     */
85 1
    function getPrimaryModule()
86
    {
87 1
        return $this->getModuleHandler()->getPrimaryModule();
88
    }
89
90
    /**
91
     * Gets a module
92
     *
93
     * @param string $name of the module
94
     *
95
     * @return module object or false
96
     */
97 1
    function getModule($name)
98
    {
99 1
        return $this->getModuleHandler()->getModule($name);
100
    }
101
102
    /**
103
     * Gets a list of modules - is used on frontpage and under rights
104
     *
105
     * @param string $order_by which index
106
     *
107
     * @return array with modules
108
     */
109 1
    function getModules($order_by = 'frontpage_index')
110
    {
111 1
        return $this->getModuleHandler()->getModules($this->db, $order_by);
112
    }
113
114
    /**
115
     * Use another module besides the primary
116
     *
117
     * @param string  $module_name        Navn p� det modullet der skal loades
118
     * @param boolean $ignore_user_access Ved true, tjekker den ikke om brugeren har adgang, men kun om intranettet har. Benyttes bla. til n�r der skal tr�kkes vare fra lageret fra gennem faktura.
119
     *
120
     * @return object or false Hvis man har adgang returnere den et object, ellers returnere den 0;
121
     */
122 63
    function useModule($module_name, $ignore_user_access = false)
0 ignored issues
show
The parameter $ignore_user_access is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
123
    {
124 63
        return $this->getModuleHandler()->useModule($module_name, $ignore_user_access = false);
125
    }
126
127
    /**
128
     * Public: Giv adgang til et shared
129
     *
130
     * @param string $shared_name Navn p� det shared der skal loades
131
     *
132
     * @return object or 0 Hvis man har adgang returnere den et object, ellers returnere den 0;
133
     */
134 20
    function useShared($shared_name)
135
    {
136 20
        return $this->getModuleHandler()->useShared($shared_name);
137
    }
138
139
    /**
140
     * Returns translation object and sets page_id
141
     * Could be moved when there is no more calls to the method.
142
     *
143
     * @param string $page_id Which specific translation object is needed
144
     *
145
     * @return Translation object
146
     */
147
    function getTranslation($page_id = 'common')
148
    {
149
        if (is_object($this->translation)) {
150
            if (!empty($page_id)) {
151
                $this->translation->setPageID($page_id);
152
            }
153
            return $this->translation;
154
        }
155
156
        if (isset($this->translation)) {
157
            $this->translation->setPageID($page_id);
158
        }
159
160
        return $this->translation;
161
    }
162
163
    /**
164
     * Function to make a random key - e.g. for passwords
165
     * This functions don't return any characters whick can be mistaken.
166
     * Won't return 0 (zero) or o (as in Ole) or 1 (one) or l (lars), because they can be mistaken on print.
167
     *
168
     * @param $count (integer) how many characters to return?
169
     *
170
     * @return  random key (string) only letters
171
     */
172 1
    function randomKey($length = 1)
173
    {
174 1
        $random = new Ilib_RandomKeyGenerator();
175 1
        return $random->generate($length);
176
    }
177
178
    function getIntranet()
179
    {
180
        return $this->intranet;
181
    }
182
183
    function getSetting()
184
    {
185
        // Very important to store setting, as getSetting is called many times in some scripts
186
        if (empty($this->setting)) {
187
            if (is_object($this->user)) {
188
                $user_id = $this->user->getId();
189
            } else {
190
                $user_id = 0;
191
            }
192
            $this->setting = new Intraface_Setting($this->intranet->getId(), $user_id);
0 ignored issues
show
The method getId does only exist in FakeDebtorIntranet and Intraface_Intranet, but not in FakeKernelIntranet and F...nelIntranetWithNoAccess.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
193
        }
194
195
        return $this->setting;
196
    }
197
198
    function getId()
199
    {
200
        return $this->user->getId();
0 ignored issues
show
The method getId does only exist in Intraface_User, but not in FakeDebtorUser and FakeK...nelIntranetWithNoAccess.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
201
    }
202
203
    function getActiveIntranetId()
204
    {
205
        return $this->user->getActiveIntranetId();
0 ignored issues
show
The method getActiveIntranetId does only exist in Intraface_User, but not in FakeDebtorUser and FakeK...nelIntranetWithNoAccess.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
206
    }
207
}
208