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/ups/class.pmset.inc.php (5 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
 * Pmset class
4
 *
5
 * PHP version 5
6
 *
7
 * @category  PHP
8
 * @package   PSI_UPS
9
 * @author    Robert Pelletier <[email protected]>
10
 * @copyright 2014 phpSysInfo
11
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License
12
 * @version   SVN: $Id: class.nut.inc.php 661 2012-08-27 11:26:39Z namiltd $
13
 * @link      http://phpsysinfo.sourceforge.net
14
 */
15
 /**
16
 * getting ups information from pmset program
17
 *
18
 * @category  PHP
19
 * @package   PSI_UPS
20
 * @author    Robert Pelletier <[email protected]>
21
 * @copyright 2014 phpSysInfo
22
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License
23
 * @version   Release: 3.0
24
 * @link      http://phpsysinfo.sourceforge.net
25
 */
26
class Pmset extends UPS
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...
27
{
28
    /**
29
     * internal storage for all gathered data
30
     *
31
     * @var array
32
     */
33
    private $_output = array();
34
35
    /**
36
     * get all information from all configured ups and store output in internal array
37
     */
38 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...
39
    {
40
        parent::__construct();
41
        CommonFunctions::executeProgram('pmset', '-g batt', $temp);
42
        if (! empty($temp)) {
43
            $this->_output[] = $temp;
44
        }
45
    }
46
47
    /**
48
     * parse the input and store data in resultset for xml generation
49
     *
50
     * @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...
51
     */
52
   private function _info()
53
    {
54
        $model = array();
0 ignored issues
show
$model is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
55
        $percCharge = array();
0 ignored issues
show
$percCharge is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
56
        $lines = explode(PHP_EOL, implode($this->_output));
57
        $dev = new UPSDevice();
58
        $model = explode('FW:',  $lines[1]);
59
        if (strpos($model[0], 'InternalBattery') === false) {
60
            $percCharge = explode(';',  $lines[1]);
61
            $dev->setName('UPS');
62
            if ($model !== false) {
63
                $dev->setModel(substr(trim($model[0]), 1));
64
            }
65
            if ($percCharge !== false) {
66
                $dev->setBatterCharge(trim(substr($percCharge[0], -4, 3)));
67
                $dev->setStatus(trim($percCharge[1]));
68
                if (isset($percCharge[2])) {
69
                    $time = explode(':', $percCharge[2]);
70
                    $hours = $time[0];
71
                    $minutes = $hours*60+substr($time[1], 0, 2);
72
                    $dev->setTimeLeft($minutes);
73
                }
74
            }
75
            $this->upsinfo->setUpsDevices($dev);
76
        }
77
    }
78
79
    /**
80
     * get the information
81
     *
82
     * @see PSI_Interface_UPS::build()
83
     *
84
     * @return Void
85
     */
86
    public function build()
87
    {
88
        $this->_info();
89
    }
90
}
91