Issues (195)

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.

Alpha/View/Widget/DateBox.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
namespace Alpha\View\Widget;
4
5
use Alpha\Exception\IllegalArguementException;
6
use Alpha\Model\Type\Date;
7
use Alpha\Model\Type\Timestamp;
8
use Alpha\Util\Security\SecurityUtils;
9
use Alpha\Util\Config\ConfigProvider;
10
11
/**
12
 * A HTML widget for rendering a text box with calendar icon for Date/Timestamp types.
13
 *
14
 * @since 1.0
15
 *
16
 * @author John Collins <[email protected]>
17
 * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
18
 * @copyright Copyright (c) 2018, John Collins (founder of Alpha Framework).
19
 * All rights reserved.
20
 *
21
 * <pre>
22
 * Redistribution and use in source and binary forms, with or
23
 * without modification, are permitted provided that the
24
 * following conditions are met:
25
 *
26
 * * Redistributions of source code must retain the above
27
 *   copyright notice, this list of conditions and the
28
 *   following disclaimer.
29
 * * Redistributions in binary form must reproduce the above
30
 *   copyright notice, this list of conditions and the
31
 *   following disclaimer in the documentation and/or other
32
 *   materials provided with the distribution.
33
 * * Neither the name of the Alpha Framework nor the names
34
 *   of its contributors may be used to endorse or promote
35
 *   products derived from this software without specific
36
 *   prior written permission.
37
 *
38
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
39
 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
40
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
41
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
42
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
43
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
48
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
49
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
50
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51
 * </pre>
52
 */
53
class DateBox
54
{
55
    /**
56
     * The date or timestamp object for the widget.
57
     *
58
     * @var \Alpha\Model\Type\Date or Alpha\Model\Type\Timestamp
59
     *
60
     * @since 1.0
61
     */
62
    private $dateObject = null;
63
64
    /**
65
     * The data label for the object.
66
     *
67
     * @var string
68
     *
69
     * @since 1.0
70
     */
71
    private $label;
72
73
    /**
74
     * The name of the HTML input box.
75
     *
76
     * @var string
77
     *
78
     * @since 1.0
79
     */
80
    private $name;
81
82
    /**
83
     * The constructor.
84
     *
85
     * @param \Alpha\Model\Type\Date or Alpha\Model\Type\Timestamp $object The date or timestamp object that will be edited by this widget.
86
     * @param string                                              $label  The data label for the object.
87
     * @param string                                              $name   The name of the HTML input box.
88
     *
89
     * @since 1.0
90
     *
91
     * @throws \Alpha\Exception\IllegalArguementException
92
     */
93
    public function __construct($object, $label = '', $name = '')
94
    {
95
        $config = ConfigProvider::getInstance();
96
97
        // check the type of the object passed
98
        if ($object instanceof Date || $object instanceof Timestamp) {
99
            $this->dateObject = $object;
0 ignored issues
show
Documentation Bug introduced by
It seems like $object can also be of type object<Alpha\Model\Type\Timestamp>. However, the property $dateObject is declared as type object<Alpha\Model\Type\Date>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
100
        } else {
101
            throw new IllegalArguementException('DateBox widget can only accept a Date or Timestamp object!');
102
        }
103
104
        $this->label = $label;
105
106
        if ($config->get('security.encrypt.http.fieldnames')) {
107
            $this->name = base64_encode(SecurityUtils::encrypt($name));
108
        } else {
109
            $this->name = $name;
110
        }
111
    }
112
113
    /**
114
     * Renders the text box and icon to open the calendar pop-up.
115
     *
116
     * @return string
117
     *
118
     * @since 1.0
119
     */
120
    public function render()
121
    {
122
        $value = $this->dateObject->getValue();
123
124
        if ($value == '0000-00-00') {
125
            $value = '';
126
        }
127
128
        $html = '<div class="form-group">';
129
        $html .= '  <label for="'.$this->name.'">'.$this->label.'</label>';
130
        $html .= '  <div class="input-group date">';
131
        $html .= '    <input type="text" class="form-control" name="'.$this->name.'" id="'.$this->name.'" value="'.$value.'" readonly/>';
132
        $html .= '    <span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>';
133
        $html .= '  </div>';
134
        $html .= '</div>';
135
136
        $html .= '<script language="javascript">';
137
        $html .= 'if(window.jQuery) {';
138
        $html .= '  $(\'[Id="'.$this->name.'"]\').parent().datepicker({';
139
        $html .= '      format: "yyyy-mm-dd",';
140
        $html .= '      todayBtn: "linked",';
141
        $html .= '      todayHighlight: true,';
142
        $html .= '      autoclose: true';
143
        $html .= '  });';
144
        $html .= '}';
145
        $html .= '</script>';
146
147
        return $html;
148
    }
149
}
150