Issues (431)

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.

include/classes/debug.class.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
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
3
4
/**
5
 * This file defines the debug class used in this site to enable
6
 * verbose deugging outout.
7
 * @package debug
8
 * @author Sebastian 'Seraph' Grewe
9
 * @copyright Sebastian Grewe
10
 * @version 1.0
11
 * */
12
class Debug {
13
14
    /**
15
     * @var integer $DEBUG enable (1) or disable (0) debugging
16
     */
17
    private $DEBUG;
18
19
    /**
20
     * @var array $debugInfo Data array with debugging information
21
     */
22
    private $arrDebugInfo;
23
24
    /**
25
     * @var float $startTime Start time of our debugger
26
     */
27
    private $floatStartTime;
28
29
    /**
30
     * Construct our class
31
     * @param integer $DEBUG [optional] Enable (>=1) or disable (0) debugging
32
     * @return none
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
33
     */
34
    function __construct($log, $DEBUG=0) {
35
      $this->log = $log;
36
        $this->DEBUG = $DEBUG;
37
        if ($DEBUG >= 1) {
38
            $this->floatStartTime = microtime(true);
39
            $this->append("Debugging enabled", 1);
40
        }
41
    }
42
43
    /**
44
     * If we want to set our debugging level in a child class this allows us to do so
45
     * @param integer $DEBUG our debugging level
46
     */
47
    function setDebug($DEBUG) {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
48
        $this->DEBUG = $DEBUG;
49
    }
50
    
51
    /**
52
     * Return a backtrace strin
53
     * @return string Full backtrace <file>:<line> but no refereces to debug class 
54
     */
55
    public function getBacktrace() {
56
        $bth = debug_backtrace();
57
        while (strpos($bth[0]['file'], "classes/debug") != false) array_shift($bth);
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing strpos($bth[0]['file'], 'classes/debug') of type integer to the boolean false. If you are specifically checking for non-zero, consider using something more explicit like > 0 or !== 0 instead.
Loading history...
58
        foreach ($bth as $x) {
59
            $backtrace[] = array(
0 ignored issues
show
Coding Style Comprehensibility introduced by
$backtrace was never initialized. Although not strictly required by PHP, it is generally a good practice to add $backtrace = 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...
60
                    'file' => substr($x['file'], strrpos($x['file'], '/') + 1),
61
                    'line' => $x['line'],
62
                    'function' => $x['function'],
63
                );
64
        }
65
        return $backtrace;
0 ignored issues
show
The variable $backtrace 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...
66
    }
67
68
    /**
69
     * We fill our data array here
70
     * @param string $msg Debug Message
71
     * @param string $file [optional] File name
72
     * @param integer $line [optional] Line inside the $file
0 ignored issues
show
There is no parameter named $line. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
73
     * @param integer $debug [optional] Debugging level, default 1
74
     * @param string $class [optional] Class this is called from
75
     * @param string $method [optional] Method this is called from
0 ignored issues
show
There is no parameter named $method. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
76
     * @return none
77
     */
78
    function append($msg, $debug=1) {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
79
        if ($this->DEBUG >= $debug) {
80
            $this->arrDebugInfo[] = array(
81
                'level' => $debug,
82
                'time' => round((microtime(true) - $this->floatStartTime) * 1000, 2),
83
                'backtrace' => $this->getBacktrace(),
84
                'message' => $msg,
85
            );
86
            $this->log->log("debug", $msg);
87
        }
88
    }
89
90
    /**
91
     * Return the created strDebugInfo array
92
     * @return none
93
     */
94
    public function getDebugInfo() {
95
        return $this->arrDebugInfo;
96
    }
97
98
    /**
99
     * Directly print the debugging information, table formatted
100
     * @return none
101
     */
102
    function printDebugInfo() {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
103
        echo "<table><tr><td>Timestamp</td><td>File</td><td>Line</td><td>Class</td><td>Method</td><td>Message</td></tr>";
104
        foreach ($this->getDebugInfo() as $content) {
105
            echo "<tr><td>" . $content['time'] . "</td><td>" . $content['backtrace'] . "</td><td>" . $content['message'] . "</td></tr>";
106
        }
107
        echo "</table>";
108
    }
109
110
}
111
112
// Instantiate this class
113
$debug = new Debug($log, $config['DEBUG']);
114