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.DragonFly.inc.php (8 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
 * DragonFly System Class
4
 *
5
 * PHP version 5
6
 *
7
 * @category  PHP
8
 * @package   PSI DragonFly OS class
9
 * @author    Michael Cramer <[email protected]>
10
 * @copyright 2009 phpSysInfo
11
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License
12
 * @version   SVN: $Id: class.DragonFly.inc.php 287 2009-06-26 12:11:59Z bigmichi1 $
13
 * @link      http://phpsysinfo.sourceforge.net
14
 */
15
 /**
16
 * DragonFly sysinfo class
17
 * get all the required information from DragonFly system
18
 *
19
 * @category  PHP
20
 * @package   PSI DragonFly OS class
21
 * @author    Michael Cramer <[email protected]>
22
 * @copyright 2009 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 DragonFly extends BSDCommon
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
     * define the regexp for log parser
31
     */
32 View Code Duplication
    public function __construct()
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...
33
    {
34
        parent::__construct();
35
        $this->setCPURegExp1("/^cpu(.*)\, (.*) MHz/");
36
        $this->setCPURegExp2("/^(.*) at scsibus.*: <(.*)> .*/");
37
        $this->setSCSIRegExp2("/^(da[0-9]+): (.*)MB /");
38
        $this->setPCIRegExp1("/(.*): <(.*)>(.*) (pci|legacypci)[0-9]+$/");
39
        $this->setPCIRegExp2("/(.*): <(.*)>.* at [0-9\.]+$/");
40
    }
41
42
    /**
43
     * UpTime
44
     * time the system is running
45
     *
46
     * @return void
47
     */
48
    private function _uptime()
49
    {
50
        $a = $this->grab_key('kern.boottime');
0 ignored issues
show
The method grab_key() does not exist on DragonFly. Did you maybe mean grabkey()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
51
        preg_match("/sec = ([0-9]+)/", $a, $buf);
52
        $this->sys->setUptime(time() - $buf[1]);
0 ignored issues
show
time() - $buf[1] is of type integer|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...
53
    }
54
55
    /**
56
     * get network information
57
     *
58
     * @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...
59
     */
60
    private function _network()
61
    {
62
        CommonFunctions::executeProgram('netstat', '-nbdi | cut -c1-25,44- | grep "^[a-z]*[0-9][ \t].*Link"', $netstat_b);
63
        CommonFunctions::executeProgram('netstat', '-ndi | cut -c1-25,44- | grep "^[a-z]*[0-9][ \t].*Link"', $netstat_n);
64
        $lines_b = preg_split("/\n/", $netstat_b, -1, PREG_SPLIT_NO_EMPTY);
65
        $lines_n = preg_split("/\n/", $netstat_n, -1, PREG_SPLIT_NO_EMPTY);
66
        for ($i = 0, $max = sizeof($lines_b); $i < $max; $i++) {
67
            $ar_buf_b = preg_split("/\s+/", $lines_b[$i]);
68
            $ar_buf_n = preg_split("/\s+/", $lines_n[$i]);
69
            if (!empty($ar_buf_b[0]) && (!empty($ar_buf_n[5]) || ($ar_buf_n[5] === "0"))) {
70
                $dev = new NetDevice();
71
                $dev->setName($ar_buf_b[0]);
72
                $dev->setTxBytes($ar_buf_b[8]);
73
                $dev->setRxBytes($ar_buf_b[5]);
74
                $dev->setErrors($ar_buf_n[4] + $ar_buf_n[6]);
75
                $dev->setDrops($ar_buf_n[8]);
76
                $this->sys->setNetDevices($dev);
77
            }
78
        }
79
    }
80
81
    /**
82
     * get the ide information
83
     *
84
     * @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...
85
     */
86
    protected function ide()
87
    {
88
        foreach ($this->readdmesg() as $line) {
89
            if (preg_match('/^(.*): (.*) <(.*)> at (ata[0-9]+\-(.*)) (.*)/', $line, $ar_buf)) {
90
                $dev = new HWDevice();
91
                $dev->setName($ar_buf[1]);
92
                if (!preg_match("/^acd[0-9]+(.*)/", $ar_buf[1])) {
93
                    $dev->setCapacity($ar_buf[2] * 1024);
94
                }
95
                $this->sys->setIdeDevices($dev);
96
            }
97
        }
98
    }
99
100
    /**
101
     * get icon name
102
     *
103
     * @return void
104
     */
105
    private function _distroicon()
106
    {
107
        $this->sys->setDistributionIcon('DragonFly.png');
108
    }
109
110
    /**
111
     * Processes
112
     *
113
     * @return void
114
     */
115 View Code Duplication
    protected function _processes()
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...
116
    {
117
        if (CommonFunctions::executeProgram('ps', 'aux', $bufr, PSI_DEBUG)) {
118
            $lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
119
            $processes['*'] = 0;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$processes was never initialized. Although not strictly required by PHP, it is generally a good practice to add $processes = 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...
120
            foreach ($lines as $line) {
121
                if (preg_match("/^\S+\s+\d+\s+\S+\s+\S+\s+\d+\s+\d+\s+\S+\s+(\w)/", $line, $ar_buf)) {
122
                    $processes['*']++;
123
                    $state = $ar_buf[1];
124
                    if ($state == 'I') $state = 'S'; //linux format
125
                    if (isset($processes[$state])) {
126
                        $processes[$state]++;
127
                    } else {
128
                        $processes[$state] = 1;
129
                    }
130
                }
131
            }
132
            if ($processes['*'] > 0) {
133
                $this->sys->setProcesses($processes);
134
            }
135
        }
136
    }
137
138
    /**
139
     * get the information
140
     *
141
     * @see BSDCommon::build()
142
     *
143
     * @return Void
144
     */
145
    public function build()
146
    {
147
        parent::build();
148
        $this->_distroicon();
149
        $this->_network();
150
        $this->_uptime();
151
        $this->_processes();
152
    }
153
}
154