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/tools/checkdistro.php (25 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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 7 and the first side effect is on line 2.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
echo "<!DOCTYPE html>";
3
echo "<meta charset=\"UTF-8\">";
4
echo "<title> </title>";
5
echo "<body>";
6
7
define('APP_ROOT', dirname(__FILE__).'/..');
8
require_once APP_ROOT.'/includes/interface/class.PSI_Interface_OS.inc.php';
9
require_once APP_ROOT.'/includes/os/class.OS.inc.php';
10
require_once APP_ROOT.'/includes/to/class.System.inc.php';
11
require_once APP_ROOT.'/includes/os/class.Linux.inc.php';
12
define('PSI_USE_VHOST', false);
13
define('PSI_DEBUG', false);
14
define('PSI_LOAD_BAR', false);
15
16
$log_file = "";
17
$lsb = true; //enable detection lsb_release -a
18
$lsbfile = true; //enable detection /etc/lsb-release
19
20
class PSI_Error
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type PSI_Error has been defined more than once; this definition is ignored, only the first definition in phpsysinfo/includes/error/class.PSI_Error.inc.php (L26-290) is considered.

This check looks for classes that have been defined more than once.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
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...
21
{
22
    public static function singleton()
23
    {
24
    }
25
}
26
27
class Parser
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type Parser has been defined more than once; this definition is ignored, only the first definition in phpsysinfo/includes/class.Parser.inc.php (L26-271) is considered.

This check looks for classes that have been defined more than once.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
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
    public static function lspci()
30
    {
31
        return array();
32
    }
33
    public static function df()
34
    {
35
        return array();
36
    }
37
}
38
39
class CommonFunctions
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type CommonFunctions has been defined more than once; this definition is ignored, only the first definition in phpsysinfo/includes/class.CommonFunctions.inc.php (L26-563) is considered.

This check looks for classes that have been defined more than once.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
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...
40
{
41
    private static function _parse_log_file($string)
42
    {
43
        global $log_file;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
44
        if (file_exists($log_file)) {
45
            $contents = @file_get_contents($log_file);
46
            $contents = preg_replace("/\r\n/", "\n", $contents);
47 View Code Duplication
            if ($contents && preg_match("/^\-\-\-\-\-\-\-\-\-\-".preg_quote($string, '/')."\-\-\-\-\-\-\-\-\-\-\n/m", $contents, $matches, PREG_OFFSET_CAPTURE)) {
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...
48
                $findIndex = $matches[0][1];
49
                if (preg_match("/\n/m", $contents, $matches, PREG_OFFSET_CAPTURE, $findIndex)) {
50
                    $startIndex = $matches[0][1]+1;
51
                    if (preg_match("/^\-\-\-\-\-\-\-\-\-\-/m", $contents, $matches, PREG_OFFSET_CAPTURE, $startIndex)) {
52
                        $stopIndex = $matches[0][1];
53
54
                        return substr($contents, $startIndex, $stopIndex-$startIndex);
55
                    } else {
56
                        return substr($contents, $startIndex);
57
                    }
58
                }
59
            }
60
        }
61
62
        return false;
63
    }
64
65
    public static function rfts($strFileName, &$strRet, $intLines = 0, $intBytes = 4096, $booErrorRep = true)
0 ignored issues
show
The parameter $intBytes 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...
The parameter $booErrorRep 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...
66
    {
67
        global $lsb;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
68
        global $lsbfile;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
69
        if ($lsb || $lsbfile || ($strFileName != "/etc/lsb-release")) {
70
            $strRet=self::_parse_log_file($strFileName);
71
            if ($strRet && ($intLines == 1) && (strpos($strRet, "\n") !== false)) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $strRet of type string|false is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== false instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
72
                $strRet=trim(substr($strRet, 0, strpos($strRet, "\n")));
73
            }
74
75
            return $strRet;
76
        } else {
77
            return false;
78
        }
79
    }
80
81
    public static function executeProgram($strProgramname, $strArgs, &$strBuffer, $booErrorRep = true)
0 ignored issues
show
The parameter $strArgs 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...
The parameter $booErrorRep 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...
82
    {
83
        global $lsb;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
84
        $strBuffer = '';
85
        if ($strProgramname=='lsb_release') {
86
            return $lsb && ($strBuffer = self::_parse_log_file('lsb_release -a'));
87
        } else {
88
            return $strBuffer = self::_parse_log_file($strProgramname);
89
        }
90
    }
91
92
    public static function fileexists($strFileName)
93
    {
94
        global $log_file;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
95
        global $lsb;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
96
        global $lsbfile;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
97
        if (file_exists($log_file)
98
            && ($lsb || $lsbfile || ($strFileName != "/etc/lsb-release"))
99
            && ($contents = @file_get_contents($log_file))
100
            && preg_match("/^\-\-\-\-\-\-\-\-\-\-".preg_quote($strFileName, '/')."\-\-\-\-\-\-\-\-\-\-\r?\n/m", $contents)) {
101
            return true;
102
        }
103
104
        return false;
105
    }
106
107
    public static function gdc()
108
    {
109
        return array();
110
    }
111
}
112
113
class _Linux extends Linux
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
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...
114
{
115
    public function build()
116
    {
117
        parent::_distro();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (_distro() instead of build()). Are you sure this is correct? If so, you might want to change this to $this->_distro().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
118
    }
119
}
120
121
$system = new _Linux();
122
if ($handle = opendir(APP_ROOT.'/sample/distrotest')) {
123
    echo "<table cellpadding=\"2\" border=\"1\"  CELLSPACING=\"0\"";
124
    echo "<tr>";
125
    echo "<td>Distrotest sample</td>";
126
    echo "<td>Distro Name</td>";
127
    echo "<td>Distro Icon</td>";
128
    echo "<td>Distro Name (no lsb_release)</td>";
129
    echo "<td>Distro Icon (no lsb_release)</td>";
130
    echo "<td>Distro Name (no lsb_release and no /etc/lsb-release)</td>";
131
    echo "<td>Distro Icon (no lsb_release and no /etc/lsb-release)</td>";
132
    echo "</tr>";
133
    while (false !== ($entry = readdir($handle))) {
134
        if (($entry!=".")&&($entry!="..")) {
135
            if ($shandle = opendir(APP_ROOT."/sample/distrotest/$entry")) {
136
                while (false !== ($sentry = readdir($shandle))) {
137
                    if (($sentry!=".")&&($sentry!="..")) {
138
                        $log_file=APP_ROOT.'/sample/distrotest/'.$entry.'/'.$sentry;
139
                        echo "<tr>";
140
                        echo "<td>".$entry.'/'.$sentry."</td>";
141
142
                        $lsb = true;
143
                        $lsbfile = true;
144
                        $sys=$system->getSys();
145
                        $distro=$sys->getDistribution();
146
                        $icon=$sys->getDistributionIcon();
147
                        if ($icon == '') $icon="unknown.png";
148
                        if ($icon != $entry.'.png')
149
                            echo "<td style='color:red'>";
150
                        else
151
                            echo "<td>";
152
                        echo $distro."</td>";
153
                        if ($icon != $entry.'.png')
154
                            echo "<td style='color:red'>";
155
                        else
156
                            echo "<td>";
157
                        echo "<img src=\"../gfx/images/".$icon."\" height=\"16\" width=\"16\">";
158
                        echo $icon."</td>";
159
                        $sys->setDistribution("");
160
                        $sys->setDistributionIcon("");
161
162
                        $lsb = false;
163
                        $lsbfile = true;
164
                        $sys=$system->getSys();
165
                        $distro=$sys->getDistribution();
166
                        $icon=$sys->getDistributionIcon();
167
                        if ($icon == '') $icon="unknown.png";
168
                        if ($icon != $entry.'.png')
169
                            echo "<td style='color:red'>";
170
                        else
171
                            echo "<td>";
172
                        echo $distro."</td>";
173
                        if ($icon != $entry.'.png')
174
                            echo "<td style='color:red'>";
175
                        else
176
                            echo "<td>";
177
                        echo "<img src=\"../gfx/images/".$icon."\" height=\"16\" width=\"16\">";
178
                        echo $icon."</td>";
179
                        $sys->setDistribution("");
180
                        $sys->setDistributionIcon("");
181
182
                        $lsb = false;
183
                        $lsbfile = false;
184
                        $sys=$system->getSys();
185
                        $distro=$sys->getDistribution();
186
                        $icon=$sys->getDistributionIcon();
187
                        if ($icon == '') $icon="unknown.png";
188
                        if ($icon != $entry.'.png')
189
                            echo "<td style='color:red'>";
190
                        else
191
                            echo "<td>";
192
                        echo $distro."</td>";
193
                        if ($icon != $entry.'.png')
194
                            echo "<td style='color:red'>";
195
                        else
196
                            echo "<td>";
197
                        echo "<img src=\"../gfx/images/".$icon."\" height=\"16\" width=\"16\">";
198
                        echo $icon."</td>";
199
                        $sys->setDistribution("");
200
                        $sys->setDistributionIcon("");
201
202
                        echo "</tr>";
203
                    }
204
                }
205
                closedir($shandle);
206
            }
207
        }
208
    }
209
    echo "</table>";
210
    closedir($handle);
211
}
212
echo "</body>";
213