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/projects/screate.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
 * @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/states.php');
35
/**#@-*/
36
37
init_page(LOAD_INLINE);
38
39
$error = NO_ERROR;
40
41
if (get_user_level() != USER_LEVEL_ADMIN)
42
{
43
    debug_write_log(DEBUG_NOTICE, 'User must have admin rights to be allowed.');
44
    header('HTTP/1.1 307 index.php');
45
    exit;
46
}
47
48
// check that requested template exists
49
50
$id       = ustr2int(try_request('id'));
51
$template = template_find($id);
52
53
if (!$template)
54
{
55
    debug_write_log(DEBUG_NOTICE, 'Template cannot be found.');
56
    header('HTTP/1.1 307 index.php');
57
    exit;
58
}
59
60 View Code Duplication
if (!$template['is_locked'])
61
{
62
    debug_write_log(DEBUG_NOTICE, 'Template must be locked.');
63
    header('HTTP/1.1 307 sindex.php?id=' . $id);
64
    exit;
65
}
66
67
$is_final = ustr2int(try_request('final', 0), 0, 1);
68
69
// new state has been submitted
70
71
if (try_request('submitted') == 'createform')
72
{
73
    debug_write_log(DEBUG_NOTICE, 'Data are submitted.');
74
75
    $state_name    = ustrcut($_REQUEST['state_name'], MAX_STATE_NAME);
76
    $state_abbr    = ustrcut($_REQUEST['state_abbr'], MAX_STATE_ABBR);
77
    $next_state_id = ustr2int(try_request('next_state'), 0);
78
    $responsible   = ustr2int(try_request('responsible', STATE_RESPONSIBLE_REMOVE), 1, 3);
79
80
    $error = state_validate($state_name, $state_abbr);
81
82
    if ($error == NO_ERROR)
83
    {
84
        $error = state_create($id,
85
                              $state_name,
86
                              $state_abbr,
87
                              ($is_final ? STATE_TYPE_FINAL : STATE_TYPE_INTERMEDIATE),
88
                              ($next_state_id == 0 ? NULL : $next_state_id),
89
                              $responsible);
90
    }
91
92
    switch ($error)
93
    {
94
        case NO_ERROR:
95
            header('HTTP/1.0 200 OK');
96
            break;
97
98
        case ERROR_INCOMPLETE_FORM:
99
            send_http_error(get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID));
100
            break;
101
102
        case ERROR_ALREADY_EXISTS:
103
            send_http_error(get_html_resource(RES_ALERT_STATE_ALREADY_EXISTS_ID));
104
            break;
105
106
        default:
107
            send_http_error(get_html_resource(RES_ALERT_UNKNOWN_ERROR_ID));
108
    }
109
110
    exit;
111
}
112
else
113
{
114
    debug_write_log(DEBUG_NOTICE, 'Data are being requested.');
115
116
    $state_name    = NULL;
117
    $state_abbr    = NULL;
118
    $next_state_id = NULL;
119
    $responsible   = STATE_RESPONSIBLE_REMAIN;
120
}
121
122
// local JS functions
123
124
$resTitle = get_js_resource(RES_ERROR_ID);
125
$resOK    = get_js_resource(RES_OK_ID);
126
127
$xml = <<<JQUERY
128
<script>
129
130
function createSuccess ()
131
{
132
    closeModal();
133
    reloadTab();
134
}
135
136
function createError (XMLHttpRequest)
137
{
138
    jqAlert("{$resTitle}", XMLHttpRequest.responseText, "{$resOK}");
139
}
140
141
</script>
142
JQUERY;
143
144
// generate page
145
146
$xml .= '<form name="createform" action="screate.php?id=' . $id . '&amp;final=' . $is_final . '" success="createSuccess" error="createError">'
147
      . '<group>'
148
      . '<control name="state_name" required="' . get_html_resource(RES_REQUIRED3_ID) . '">'
149
      . '<label>' . get_html_resource(RES_STATE_NAME_ID) . '</label>'
150
      . '<editbox maxlen="' . MAX_STATE_NAME . '">' . ustr2html($state_name) . '</editbox>'
151
      . '</control>'
152
      . '<control name="state_abbr" required="' . get_html_resource(RES_REQUIRED3_ID) . '">'
153
      . '<label>' . get_html_resource(RES_STATE_ABBR_ID) . '</label>'
154
      . '<editbox maxlen="' . MAX_STATE_ABBR . '">' . ustr2html($state_abbr) . '</editbox>'
155
      . '</control>';
156
157
if (!$is_final)
158
{
159
    $states = dal_query('states/list.sql', $id, 'state_name asc');
160
161 View Code Duplication
    if ($states->rows != 0)
0 ignored issues
show
The property $rows is declared protected in CRecordset. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
162
    {
163
        $xml .= '<control name="next_state">'
164
              . '<label>' . get_html_resource(RES_NEXT_STATE_BY_DEFAULT_ID) . '</label>'
165
              . '<combobox>'
166
              . '<listitem value="0">' . get_html_resource(RES_NONE_ID) . '</listitem>';
167
168
        while (($row = $states->fetch()))
169
        {
170
            $xml .= ($row['state_id'] == $next_state_id
171
                        ? '<listitem value="' . $row['state_id'] . '" selected="true">'
172
                        : '<listitem value="' . $row['state_id'] . '">')
173
                  . ustr2html($row['state_name'])
174
                  . '</listitem>';
175
        }
176
177
        $xml .= '</combobox>'
178
              . '</control>';
179
    }
180
181
    $xml .= '<control name="responsible">'
182
          . '<label>' . get_html_resource(RES_RESPONSIBLE_ID) . '</label>'
183
          . '<radio value="' . STATE_RESPONSIBLE_REMAIN . ($responsible == STATE_RESPONSIBLE_REMAIN ? '" checked="true">' : '">') . get_html_resource(RES_REMAIN_ID) . '</radio>'
184
          . '<radio value="' . STATE_RESPONSIBLE_ASSIGN . ($responsible == STATE_RESPONSIBLE_ASSIGN ? '" checked="true">' : '">') . get_html_resource(RES_ASSIGN_ID) . '</radio>'
185
          . '<radio value="' . STATE_RESPONSIBLE_REMOVE . ($responsible == STATE_RESPONSIBLE_REMOVE ? '" checked="true">' : '">') . get_html_resource(RES_REMOVE_ID) . '</radio>'
186
          . '</control>';
187
}
188
189
$xml .= '</group>'
190
      . '<note>' . get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID) . '</note>'
191
      . '</form>';
192
193
echo(xml2html($xml));
194
195
?>
196