Issues (1098)

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.

src/engine/debug.php (1 issue)

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
//------------------------------------------------------------------------------
4
//
5
//  eTraxis - Records tracking web-based system
6
//  Copyright (C) 2005-2011  Artem Rodygin
7
//
8
//  This program is free software: you can redistribute it and/or modify
9
//  it under the terms of the GNU General Public License as published by
10
//  the Free Software Foundation, either version 3 of the License, or
11
//  (at your option) any later version.
12
//
13
//  This program is distributed in the hope that it will be useful,
14
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
//  GNU General Public License for more details.
17
//
18
//  You should have received a copy of the GNU General Public License
19
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
//
21
//------------------------------------------------------------------------------
22
23
/**
24
 * Debugging
25
 *
26
 * This module implements debug logging to trace functions calls, values of parameters, performance, etc.
27
 * Module is configurable via {@link DEBUG_MODE} and {@link DEBUG_LOGS}.
28
 *
29
 * @package Engine
30
 * @subpackage Debugging
31
 */
32
33
//------------------------------------------------------------------------------
34
//  Definitions.
35
//------------------------------------------------------------------------------
36
37
/**#@+
38
 * Debug mode.
39
 */
40
define('DEBUG_MODE_OFF',   0);  // no debug logging
41
define('DEBUG_MODE_TRACE', 1);  // data-safe debug logging
42
define('DEBUG_MODE_FULL',  2);  // full debug logging
43
/**#@-*/
44
45
/**#@+
46
 * Type of debug message.
47
 */
48
define('DEBUG_LOG_OPENED',  1);  // log is opened
49
define('DEBUG_LOG_CLOSED',  2);  // log is closed
50
define('DEBUG_ERROR',       3);  // error
51
define('DEBUG_WARNING',     4);  // warning
52
define('DEBUG_NOTICE',      5);  // information notice
53
define('DEBUG_TRACE',       6);  // trace route
54
define('DEBUG_PERFORMANCE', 7);  // performance
55
define('DEBUG_DUMP',        8);  // user data dump
56
/**#@-*/
57
58
//------------------------------------------------------------------------------
59
//  Classes.
60
//------------------------------------------------------------------------------
61
62
/**
63
 * Debug logging, implemented via Singleton pattern.
64
 * @package Engine
65
 * @subpackage Debugging
66
 * @ignore
67
 */
68
class CDebugLog
69
{
70
    // Static object of itself.
71
    private static $object = NULL;
72
73
    // Handle of opened debug log.
74
    private $handle = FALSE;
75
76
    // Timestamp when page is started to execute.
77
    // Used to profile execution performance.
78
    private $timer = NULL;
79
80
    // If debugging is not disabled (see {@link DEBUG_MODE}),
81
    // creates debug log file (see {@link DEBUG_LOGS}) and opens it for appending.
82
    private function __construct ()
83
    {
84
        if (DEBUG_MODE != DEBUG_MODE_OFF)
85
        {
86
            $this->handle = fopen(DEBUG_LOGS . session_id() . '.log', 'a');
0 ignored issues
show
Documentation Bug introduced by
It seems like fopen(DEBUG_LOGS . session_id() . '.log', 'a') of type resource is incompatible with the declared type boolean of property $handle.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
87
88
            if ($this->handle !== FALSE)
89
            {
90
                list($msec, $sec) = explode(' ', microtime());
91
                $this->timer = (float)$msec + (float)$sec;
92
            }
93
        }
94
    }
95
96
    // Closes opened debug log file.
97
    public function __destruct()
98
    {
99
        if ($this->handle !== FALSE)
100
        {
101
            list($msec, $sec) = explode(' ', microtime());
102
103
            $timer = (float)$msec + (float)$sec;
104
            $timer -= $this->timer;
105
106
            self::write(DEBUG_PERFORMANCE, 'PHP time = ' . $timer);
107
            self::write(DEBUG_LOG_CLOSED);
108
109
            fclose($this->handle);
110
            $this->handle = FALSE;
111
        }
112
    }
113
114
    // Writes specified message to opened debug log.
115
    public static function write ($type, $str = NULL)
116
    {
117
        if (is_null(self::$object))
118
        {
119
            self::$object = new CDebugLog();
120
            self::write(DEBUG_LOG_OPENED, isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : NULL);
121
        }
122
123
        if ($type == DEBUG_DUMP && DEBUG_MODE != DEBUG_MODE_FULL)
124
        {
125
            return TRUE;
126
        }
127
128
        $res = FALSE;
129
130
        if (self::$object->handle !== FALSE)
131
        {
132
            $prefix = array
133
            (
134
                DEBUG_LOG_OPENED  => '[OPENED]   ',
135
                DEBUG_LOG_CLOSED  => "[CLOSED]\n",
136
                DEBUG_ERROR       => '[ERROR]    ',
137
                DEBUG_WARNING     => '[WARNING]  ',
138
                DEBUG_NOTICE      => '[NOTICE]   ',
139
                DEBUG_TRACE       => '[TRACE]    ',
140
                DEBUG_PERFORMANCE => '[PERFORM]  ',
141
                DEBUG_DUMP        => '[DUMP]     ',
142
            );
143
144
            $today = date('Y-m-d  H:i:s  ');
145
            $res = (fwrite(self::$object->handle, "{$today}{$prefix[$type]}{$str}\n") != -1);
146
147
            if ($type == DEBUG_ERROR)
148
            {
149
                error_log("eTraxis Error: {$str}");
150
            }
151
        }
152
153
        return $res;
154
    }
155
}
156
157
//------------------------------------------------------------------------------
158
//  Functions.
159
//------------------------------------------------------------------------------
160
161
/**
162
 * Writes specified message to debug log.
163
 *
164
 * @param int $type Type of debug message.
165
 * @param string $str The message to be written.
166
 * @return bool TRUE on success, FALSE otherwise.
167
 */
168
function debug_write_log ($type, $str = NULL)
169
{
170
    return CDebugLog::write($type, $str);
171
}
172
173
?>
174