Issues (1626)

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.

phpsysinfo/includes/os/class.QNX.inc.php (9 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
 * QNX System Class
4
 *
5
 * PHP version 5
6
 *
7
 * @category  PHP
8
 * @package   PSI QNX OS class
9
 * @author    Mieczyslaw Nalewaj <[email protected]>
10
 * @copyright 2012 phpSysInfo
11
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License
12
 * @version   SVN: $Id: class.QNX.inc.php 687 2012-09-06 20:54:49Z namiltd $
13
 * @link      http://phpsysinfo.sourceforge.net
14
 */
15
 /**
16
 * QNX sysinfo class
17
 * get all the required information from QNX system
18
 *
19
 * @category  PHP
20
 * @package   PSI QNX OS class
21
 * @author    Mieczyslaw Nalewaj <[email protected]>
22
 * @copyright 2012 phpSysInfo
23
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License
24
 * @version   Release: 3.0
25
 * @link      http://phpsysinfo.sourceforge.net
26
 */
27
class QNX extends OS
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
28
{
29
    /**
30
     * content of the syslog
31
     *
32
     * @var array
33
     */
34
    private $_dmesg = array();
0 ignored issues
show
The property $_dmesg 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...
35
36
    /**
37
     * call parent constructor
38
     */
39
    public function __construct()
40
    {
41
        parent::__construct();
42
    }
43
44
    /**
45
     * get the cpu information
46
     *
47
     * @return array
0 ignored issues
show
Should the return type not be array|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
48
     */
49
    protected function _cpuinfo()
50
    {
51
        if (CommonFunctions::executeProgram('pidin', 'info', $buf)
52
           && preg_match('/^Processor\d+: (.*)/m', $buf)) {
53
            $lines = preg_split("/\n/", $buf, -1, PREG_SPLIT_NO_EMPTY);
54
            foreach ($lines as $line) {
55
                if (preg_match('/^Processor\d+: (.+)/', $line, $proc)) {
56
                    $dev = new CpuDevice();
57
                    $dev->SetModel(trim($proc[1]));
58
                    if (preg_match('/(\d+)MHz/', $proc[1], $mhz)) {
59
                        $dev->setCpuSpeed($mhz[1]);
60
                    }
61
                    $this->sys->setCpus($dev);
0 ignored issues
show
$dev is of type object<CpuDevice>, but the function expects a object<Cpu>.

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...
62
                }
63
            }
64
        }
65
    }
66
67
    /**
68
     * QNX Version
69
     *
70
     * @return void
71
     */
72
    private function _kernel()
73
    {
74
        if (CommonFunctions::executeProgram('uname', '-rvm', $ret)) {
75
            $this->sys->setKernel($ret);
76
        }
77
    }
78
79
    /**
80
     * Distribution
81
     *
82
     * @return void
83
     */
84
    protected function _distro()
85
    {
86
        if (CommonFunctions::executeProgram('uname', '-sr', $ret))
87
            $this->sys->setDistribution($ret);
88
        else
89
            $this->sys->setDistribution('QNX');
90
91
        $this->sys->setDistributionIcon('QNX.png');
92
    }
93
94
    /**
95
     * UpTime
96
     * time the system is running
97
     *
98
     * @return void
99
     */
100
    private function _uptime()
101
    {
102
103
        if (CommonFunctions::executeProgram('pidin', 'info', $buf)
104
           && preg_match('/^.* BootTime:(.*)/', $buf, $bstart)
105
           && CommonFunctions::executeProgram('date', '', $bstop)) {
106
            /* default error handler */
107
            if (function_exists('errorHandlerPsi')) {
108
                restore_error_handler();
109
            }
110
            /* fatal errors only */
111
            $old_err_rep = error_reporting();
112
            error_reporting(E_ERROR);
113
114
            $uptime = strtotime($bstop)-strtotime($bstart[1]);
115
            if ($uptime > 0) $this->sys->setUptime($uptime);
0 ignored issues
show
$uptime is of type integer, but the function expects a object<Interger>.

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...
116
117
            /* restore error level */
118
            error_reporting($old_err_rep);
119
            /* restore error handler */
120
            if (function_exists('errorHandlerPsi')) {
121
                set_error_handler('errorHandlerPsi');
122
            }
123
        }
124
    }
125
126
    /**
127
     * Number of Users
128
     *
129
     * @return void
130
     */
131
    protected function _users()
132
    {
133
        $this->sys->setUsers(1);
134
    }
135
136
    /**
137
     * Virtual Host Name
138
     *
139
     * @return void
140
     */
141 View Code Duplication
    private function _hostname()
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...
142
    {
143
        if (PSI_USE_VHOST === true) {
144
            $this->sys->setHostname(getenv('SERVER_NAME'));
145
        } else {
146
            if (CommonFunctions::executeProgram('uname', '-n', $result, PSI_DEBUG)) {
147
                $ip = gethostbyname($result);
148
                if ($ip != $result) {
149
                    $this->sys->setHostname(gethostbyaddr($ip));
150
                }
151
            }
152
        }
153
    }
154
155
    /**
156
     *  Physical memory information and Swap Space information
157
     *
158
     *  @return void
159
     */
160
    private function _memory()
161
    {
162
        if (CommonFunctions::executeProgram('pidin', 'info', $buf)
163
           && preg_match('/^.* FreeMem:(\S+)Mb\/(\S+)Mb/', $buf, $memm)) {
164
            $this->sys->setMemTotal(1024*1024*$memm[2]);
165
            $this->sys->setMemFree(1024*1024*$memm[1]);
166
            $this->sys->setMemUsed(1024*1024*($memm[2]-$memm[1]));
167
        }
168
    }
169
170
    /**
171
     * filesystem information
172
     *
173
     * @return void
174
     */
175
    private function _filesystems()
176
    {
177
        $arrResult = Parser::df("-P 2>/dev/null");
178
        foreach ($arrResult as $dev) {
179
            $this->sys->setDiskDevices($dev);
180
        }
181
    }
182
183
    /**
184
     * network information
185
     *
186
     * @return void
187
     */
188
    private function _network()
189
    {
190
        if (CommonFunctions::executeProgram('ifconfig', '', $bufr, PSI_DEBUG)) {
191
            $lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
192
            $was = false;
193
            foreach ($lines as $line) {
194
                if (preg_match("/^([^\s:]+)/", $line, $ar_buf)) {
195
                    if ($was) {
196
                        $this->sys->setNetDevices($dev);
0 ignored issues
show
The variable $dev does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
197
                    }
198
                    $dev = new NetDevice();
199
                    $dev->setName($ar_buf[1]);
200
                    $was = true;
201
                } else {
202
                    if ($was) {
203 View Code Duplication
                        if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
0 ignored issues
show
This code seems to be duplicated across 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...
204
                            if (preg_match('/^\s+address:\s*(\S+)/i', $line, $ar_buf2)) {
205
                                    $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').preg_replace('/:/', '-', strtoupper($ar_buf2[1])));
206
                            } elseif (preg_match('/^\s+inet\s+(\S+)\s+netmask/i', $line, $ar_buf2))
207
                                $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
208
209
                        }
210
                    }
211
                }
212
            }
213
            if ($was) {
214
                $this->sys->setNetDevices($dev);
215
            }
216
        }
217
    }
218
219
    /**
220
     * get the information
221
     *
222
     * @return Void
223
     */
224 View Code Duplication
    public function build()
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...
225
    {
226
        $this->error->addError("WARN", "The QNX version of phpSysInfo is a work in progress, some things currently don't work");
227
        $this->_distro();
228
        $this->_hostname();
229
        $this->_kernel();
230
        $this->_uptime();
231
        $this->_users();
232
        $this->_cpuinfo();
233
        $this->_memory();
234
        $this->_filesystems();
235
        $this->_network();
236
    }
237
}
238