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.AIX.inc.php (17 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
 * IBM AIX System Class
4
 *
5
 * PHP version 5
6
 *
7
 * @category  PHP
8
 * @package   PSI AIX OS class
9
 * @author    Krzysztof Paz ([email protected]) based on HPUX of Michael Cramer <[email protected]>
10
 * @copyright 2011 Krzysztof Paz
11
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License
12
 * @version   SVN: $Id: class.AIX.inc.php 287 2009-06-26 12:11:59Z Krzysztof Paz, IBM POLSKA
13
 * @link      http://phpsysinfo.sourceforge.net
14
 */
15
/**
16
* IBM AIX sysinfo class
17
* get all the required information from IBM AIX system
18
*
19
* @category  PHP
20
* @package   PSI AIX OS class
21
* @author    Krzysztof Paz ([email protected]) based on Michael Cramer <[email protected]>
22
* @copyright 2011 Krzysztof Paz
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 AIX 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
    private $_aixdata = array();
31
32
    /**
33
     * Virtual Host Name
34
     * @return void
35
     */
36
    private function _hostname()
37
    {
38
        /*   if (PSI_USE_VHOST === true) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% 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...
39
               $this->sys->setHostname(getenv('SERVER_NAME'));
40
           } else {
41
               if (CommonFunctions::executeProgram('hostname', '', $ret)) {
42
                   $this->sys->setHostname($ret);
43
               }
44
           } */
45
        $this->sys->setHostname(getenv('SERVER_NAME'));
46
47
    }
48
49
    /**
50
     * IBM AIX Version
51
     * @return void
52
     */
53
    private function _kernel()
54
    {
55
        if (CommonFunctions::executeProgram('oslevel', '', $ret1) && CommonFunctions::executeProgram('oslevel', '-s', $ret2)) {
56
            $this->sys->setKernel($ret1 . '   (' . $ret2 . ')');
57
        }
58
    }
59
60
    /**
61
     * UpTime
62
     * time the system is running
63
     * @return void
64
     */
65 View Code Duplication
    private function _uptime()
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...
66
    {
67
        if (CommonFunctions::executeProgram('uptime', '', $buf)) {
68
            if (preg_match("/up (\d+) days,\s*(\d+):(\d+),/", $buf, $ar_buf) || preg_match("/up (\d+) day,\s*(\d+):(\d+),/", $buf, $ar_buf)) {
69
                $min = $ar_buf[3];
70
                $hours = $ar_buf[2];
71
                $days = $ar_buf[1];
72
                $this->sys->setUptime($days * 86400 + $hours * 3600 + $min * 60);
0 ignored issues
show
$days * 86400 + $hours * 3600 + $min * 60 is of type double, 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...
73
            }
74
        }
75
    }
76
77
    /**
78
     * Processor Load
79
     * optionally create a loadbar
80
     * @return void
81
     */
82 View Code Duplication
    private function _loadavg()
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...
83
    {
84
        if (CommonFunctions::executeProgram('uptime', '', $buf)) {
85
            if (preg_match("/average: (.*), (.*), (.*)$/", $buf, $ar_buf)) {
86
                $this->sys->setLoad($ar_buf[1].' '.$ar_buf[2].' '.$ar_buf[3]);
87
            }
88
        }
89
    }
90
91
    /**
92
     * CPU information
93
     * All of the tags here are highly architecture dependant
94
     * @return void
95
     */
96
    private function _cpuinfo()
97
    {
98
        $ncpu = 0;
99
        $tcpu = "";
100
        $vcpu = "";
101
        $ccpu = "";
102
        $scpu = "";
103
        foreach ($this->readaixdata() as $line) {
104
            if (preg_match("/^Number Of Processors:\s+(\d+)/", $line, $ar_buf)) {
105
                $ncpu = $ar_buf[1];
106
            }
107
            if (preg_match("/^Processor Type:\s+(.+)/", $line, $ar_buf)) {
108
                $tcpu = $ar_buf[1];
109
            }
110
            if (preg_match("/^Processor Version:\s+(.+)/", $line, $ar_buf)) {
111
                $vcpu = $ar_buf[1];
112
            }
113
            if (preg_match("/^CPU Type:\s+(.+)/", $line, $ar_buf)) {
114
                $ccpu = $ar_buf[1];
115
            }
116
            if (preg_match("/^Processor Clock Speed:\s+(\d+)\s/", $line, $ar_buf)) {
117
                $scpu = $ar_buf[1];
118
            }
119
        }
120
        for ($i = 0; $i < $ncpu; $i++) {
121
            $dev = new CpuDevice();
122
            if (trim($tcpu) != "") {
123
                $cpu = trim($tcpu);
124
                if (trim($vcpu) != "") $cpu .= " ".trim($vcpu);
125
                if (trim($ccpu) != "") $cpu .= " ".trim($ccpu);
126
                $dev->setModel($cpu);
127
            }
128
            if (trim($scpu) != "") {
129
                $dev->setCpuSpeed(trim($scpu));
130
            }
131
            $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...
132
        }
133
    }
134
135
    /**
136
     * PCI devices
137
     * @return void
138
     */
139 View Code Duplication
    private function _pci()
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...
140
    {
141
        foreach ($this->readaixdata() as $line) {
142
            if (preg_match("/^[\*\+]\s\S+\s+\S+\s+(.*PCI.*)/", $line, $ar_buf)) {
143
                $dev = new HWDevice();
144
                $dev->setName(trim($ar_buf[1]));
145
                $this->sys->setPciDevices($dev);
146
            }
147
        }
148
    }
149
150
    /**
151
     * IDE devices
152
     * @return void
153
     */
154 View Code Duplication
    private function _ide()
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...
155
    {
156
        foreach ($this->readaixdata() as $line) {
157
            if (preg_match("/^[\*\+]\s\S+\s+\S+\s+(.*IDE.*)/", $line, $ar_buf)) {
158
                $dev = new HWDevice();
159
                $dev->setName(trim($ar_buf[1]));
160
                $this->sys->setIdeDevices($dev);
161
            }
162
        }
163
    }
164
165
    /**
166
     * SCSI devices
167
     * @return void
168
     */
169 View Code Duplication
    private function _scsi()
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...
170
    {
171
        foreach ($this->readaixdata() as $line) {
172
            if (preg_match("/^[\*\+]\s\S+\s+\S+\s+(.*SCSI.*)/", $line, $ar_buf)) {
173
                $dev = new HWDevice();
174
                $dev->setName(trim($ar_buf[1]));
175
                $this->sys->setScsiDevices($dev);
176
            }
177
        }
178
    }
179
180
    /**
181
     * USB devices
182
     * @return void
183
     */
184 View Code Duplication
    private function _usb()
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...
185
    {
186
        foreach ($this->readaixdata() as $line) {
187
            if (preg_match("/^[\*\+]\s\S+\s+\S+\s+(.*USB.*)/", $line, $ar_buf)) {
188
                $dev = new HWDevice();
189
                $dev->setName(trim($ar_buf[1]));
190
                $this->sys->setUsbDevices($dev);
191
            }
192
        }
193
    }
194
195
    /**
196
     * Network devices
197
     * includes also rx/tx bytes
198
     * @return void
199
     */
200 View Code Duplication
    private function _network()
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...
201
    {
202
        if (CommonFunctions::executeProgram('netstat', '-ni | tail -n +2', $netstat)) {
203
            $lines = preg_split("/\n/", $netstat, -1, PREG_SPLIT_NO_EMPTY);
204
            foreach ($lines as $line) {
205
                $ar_buf = preg_split("/\s+/", $line);
206
                if (! empty($ar_buf[0]) && ! empty($ar_buf[3])) {
207
                    $dev = new NetDevice();
208
                    $dev->setName($ar_buf[0]);
209
                    $dev->setRxBytes($ar_buf[4]);
210
                    $dev->setTxBytes($ar_buf[6]);
211
                    $dev->setErrors($ar_buf[5] + $ar_buf[7]);
212
                    //$dev->setDrops($ar_buf[8]);
0 ignored issues
show
Unused Code Comprehensibility introduced by
90% 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...
213
                    $this->sys->setNetDevices($dev);
214
                }
215
            }
216
        }
217
    }
218
219
    /**
220
     * Physical memory information and Swap Space information
221
     * @return void
222
     */
223
    private function _memory()
224
    {
225
        $mems = "";
226
        $tswap = "";
227
        $pswap = "";
228
        foreach ($this->readaixdata() as $line) {
229
            if (preg_match("/^Good Memory Size:\s+(\d+)\s+MB/", $line, $ar_buf)) {
230
                $mems = $ar_buf[1];
231
            }
232
            if (preg_match("/^\s*Total Paging Space:\s+(\d+)MB/", $line, $ar_buf)) {
233
                $tswap = $ar_buf[1];
234
            }
235
            if (preg_match("/^\s*Percent Used:\s+(\d+)%/", $line, $ar_buf)) {
236
                $pswap = $ar_buf[1];
237
            }
238
        }
239
        if (trim($mems) != "") {
240
            $mems = $mems*1024*1024;
241
            $this->sys->setMemTotal($mems);
242
            $memu = 0;
243
            $memf = 0;
244
            if (CommonFunctions::executeProgram('svmon', '-G', $buf)) {
245
                if (preg_match("/^memory\s+\d+\s+(\d+)\s+/", $buf, $ar_buf)) {
246
                    $memu = $ar_buf[1]*1024*4;
247
                    $memf = $mems - $memu;
248
                }
249
            }
250
            $this->sys->setMemUsed($memu);
251
            $this->sys->setMemFree($memf);
252
//            $this->sys->setMemApplication($mems);
0 ignored issues
show
Unused Code Comprehensibility introduced by
66% 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...
253
//            $this->sys->setMemBuffer($mems);
254
//            $this->sys->setMemCache($mems);
255
        }
256
        if (trim($tswap) != "") {
257
            $dev = new DiskDevice();
258
            $dev->setName("SWAP");
259
            $dev->setFsType('swap');
260
            $dev->setTotal($tswap * 1024 * 1024);
261
            if (trim($pswap) != "") {
262
                $dev->setUsed($dev->getTotal() * $pswap / 100);
263
            }
264
            $dev->setFree($dev->getTotal() - $dev->getUsed());
265
            $this->sys->setSwapDevices($dev);
266
        }
267
    }
268
269
    /**
270
     * filesystem information
271
     *
272
     * @return void
273
     */
274 View Code Duplication
    private function _filesystems()
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...
275
    {
276
        if (CommonFunctions::executeProgram('df', '-kP', $df, PSI_DEBUG)) {
277
            $mounts = preg_split("/\n/", $df, -1, PREG_SPLIT_NO_EMPTY);
278
            if (CommonFunctions::executeProgram('mount', '-v', $s, PSI_DEBUG)) {
279
                $lines = preg_split("/\n/", $s, -1, PREG_SPLIT_NO_EMPTY);
280
                while (list(, $line) = each($lines)) {
281
                    $a = preg_split('/ /', $line, -1, PREG_SPLIT_NO_EMPTY);
282
                    $fsdev[$a[0]] = $a[4];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$fsdev was never initialized. Although not strictly required by PHP, it is generally a good practice to add $fsdev = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
283
                }
284
            }
285
            foreach ($mounts as $mount) {
286
                $ar_buf = preg_split("/\s+/", $mount, 6);
287
                $dev = new DiskDevice();
288
                $dev->setName($ar_buf[0]);
289
                $dev->setTotal($ar_buf[1] * 1024);
290
                $dev->setUsed($ar_buf[2] * 1024);
291
                $dev->setFree($ar_buf[3] * 1024);
292
                $dev->setMountPoint($ar_buf[5]);
293
                if (isset($fsdev[$ar_buf[0]])) {
294
                    $dev->setFsType($fsdev[$ar_buf[0]]);
295
                }
296
                $this->sys->setDiskDevices($dev);
297
            }
298
        }
299
    }
300
301
    /**
302
     * Distribution
303
     *
304
     * @return void
305
     */
306
    private function _distro()
307
    {
308
        $this->sys->setDistribution('IBM AIX');
309
        $this->sys->setDistributionIcon('AIX.png');
310
    }
311
312
    /**
313
     * IBM AIX informations by K.PAZ
314
     * @return void
0 ignored issues
show
Should the return type not be array?

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...
315
     */
316
    private function readaixdata()
317
    {
318
        if (count($this->_aixdata) === 0) {
319
            if (CommonFunctions::executeProgram('prtconf', '', $bufr)) {
320
                $this->_aixdata = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
321
            }
322
        }
323
324
        return $this->_aixdata;
325
    }
326
327
    /**
328
     * get the information
329
     *
330
     * @see PSI_Interface_OS::build()
331
     *
332
     * @return Void
333
     */
334 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...
335
    {
336
        $this->error->addError("WARN", "The AIX version of phpSysInfo is a work in progress, some things currently don't work");
337
        $this->_distro();
338
        $this->_hostname();
339
        $this->_kernel();
340
        $this->_uptime();
341
        $this->_users();
342
        $this->_loadavg();
343
        $this->_cpuinfo();
344
        $this->_pci();
345
        $this->_ide();
346
        $this->_scsi();
347
        $this->_usb();
348
        $this->_network();
349
        $this->_memory();
350
        $this->_filesystems();
351
    }
352
}
353