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/subscriptions/subscription.php (4 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
//------------------------------------------------------------------------------
4
//
5
//  eTraxis - Records tracking web-based system
6
//  Copyright (C) 2010-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
 * @package eTraxis
25
 * @ignore
26
 */
27
28
/**#@+
29
 * Dependency.
30
 */
31
require_once('../engine/engine.php');
32
require_once('../dbo/projects.php');
33
require_once('../dbo/templates.php');
34
require_once('../dbo/subscriptions.php');
35
require_once('../dbo/events.php');
36
/**#@-*/
37
38
init_page(LOAD_TAB);
39
40
if (!EMAIL_NOTIFICATIONS_ENABLED)
41
{
42
    debug_write_log(DEBUG_NOTICE, 'Email Notifications functionality is disabled.');
43
    exit;
44
}
45
46
// check that requested subscription exists
47
48
$id           = ustr2int(try_request('id'));
49
$subscription = subscription_find($id);
50
51
if (!$subscription)
0 ignored issues
show
Bug Best Practice introduced by
The expression $subscription of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
52
{
53
    debug_write_log(DEBUG_NOTICE, 'Subscription cannot be found.');
54
    exit;
55
}
56
57
// local JS functions
58
59
$resTitle  = ustrprocess(get_js_resource(RES_SUBSCRIPTION_X_ID), ustr2js($subscription['subscribe_name']));
60
$resOK     = get_js_resource(RES_OK_ID);
61
$resCancel = get_js_resource(RES_CANCEL_ID);
62
63
$xml = <<<JQUERY
64
<script>
65
66
function subscriptionModify ()
67
{
68
    jqModal("{$resTitle}", "modify.php?id={$id}", "{$resOK}", "{$resCancel}", "$('#modifyform').submit()");
69
}
70
71
function subscriptionToggle ()
72
{
73
    $.post("disable.php?id={$id}", function () {
74
        reloadTab();
75
    });
76
}
77
78
</script>
79
JQUERY;
80
81
// generate buttons
82
83
$xml .= '<button url="index.php">' . get_html_resource(RES_BACK_ID) . '</button>'
84
      . '<buttonset>'
85
      . '<button action="subscriptionModify()">' . get_html_resource(RES_MODIFY_ID) . '</button>'
86
      . '<button url="delete.php?id=' . $id . '" prompt="' . get_html_resource(RES_CONFIRM_DELETE_SUBSCRIPTIONS_ID) . '">' . get_html_resource(RES_DELETE_ID) . '</button>'
87
      . '<button action="subscriptionToggle()">' . get_html_resource($subscription['is_activated'] ? RES_DISABLE_ID : RES_ENABLE_ID) . '</button>'
88
      . '</buttonset>';
89
90
// generate subscription information
91
92
$xml .= '<group>';
93
94
switch ($subscription['subscribe_type'])
95
{
96
    case SUBSCRIPTION_TYPE_ALL_PROJECTS:
97
98
        $xml .= '<text label="' . get_html_resource(RES_PROJECT_ID) . '">' . get_html_resource(RES_ALL_PROJECTS_ID) . '</text>';
99
100
        break;
101
102 View Code Duplication
    case SUBSCRIPTION_TYPE_ALL_TEMPLATES:
103
104
        $project = project_find($subscription['subscribe_param']);
105
106
        if (!$project)
0 ignored issues
show
Bug Best Practice introduced by
The expression $project of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
107
        {
108
            debug_write_log(DEBUG_WARNING, 'Project cannot be found.');
109
            exit;
110
        }
111
112
        $xml .= '<text label="' . get_html_resource(RES_PROJECT_ID)  . '">' . ustr2html($project['project_name'])     . '</text>';
113
        $xml .= '<text label="' . get_html_resource(RES_TEMPLATE_ID) . '">' . get_html_resource(RES_ALL_TEMPLATES_ID) . '</text>';
114
115
        break;
116
117 View Code Duplication
    case SUBSCRIPTION_TYPE_ONE_TEMPLATE:
118
119
        $template = template_find($subscription['subscribe_param']);
120
121
        if (!$template)
0 ignored issues
show
Bug Best Practice introduced by
The expression $template of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
122
        {
123
            debug_write_log(DEBUG_WARNING, 'Template cannot be found.');
124
            exit;
125
        }
126
127
        $xml .= '<text label="' . get_html_resource(RES_PROJECT_ID)  . '">' . ustr2html($template['project_name'])  . '</text>';
128
        $xml .= '<text label="' . get_html_resource(RES_TEMPLATE_ID) . '">' . ustr2html($template['template_name']) . '</text>';
129
130
        break;
131
132
    default:
133
134
        debug_write_log(DEBUG_WARNING, 'Unknown subscription type = ' . $subscription['subscribe_type']);
135
}
136
137
$xml .= '<text label="' . get_html_resource(RES_SUBSCRIPTION_NAME_ID) . '">' . ustr2html($subscription['subscribe_name']) . '</text>'
138
      . '<text label="' . get_html_resource(RES_CARBON_COPY_ID) . '">' . (is_null($subscription['carbon_copy']) ? get_html_resource(RES_NONE_ID) : ustr2html($subscription['carbon_copy'])) . '</text>'
139
      . '</group>'
140
      . '<group title="' . get_html_resource(RES_EVENTS_ID) . '">';
141
142
foreach ($notifications as $notification)
143
{
144
    $xml .= '<text label="' . get_html_resource($notification[NOTIFY_RESOURCE]) . '">'
145
          . get_html_resource(($subscription['subscribe_flags'] & $notification[NOTIFY_EVENT]) != 0 ? RES_YES_ID : RES_NO_ID)
146
          . '</text>';
147
}
148
149
$xml .= '</group>';
150
151
echo(xml2html($xml));
152
153
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
154