Issues (53)

Security Analysis    no request data  

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/Definitions/AbstractDefinition.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
 * Fwk
4
 *
5
 * Copyright (c) 2011-2012, Julien Ballestracci <[email protected]>.
6
 * All rights reserved.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
12
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
13
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
15
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
16
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
17
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
18
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
19
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
21
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
22
 * POSSIBILITY OF SUCH DAMAGE.
23
 *
24
 * PHP Version 5.3
25
 *
26
 * @category  DependencyInjection
27
 * @package   Fwk\Di
28
 * @author    Julien Ballestracci <[email protected]>
29
 * @copyright 2011-2014 Julien Ballestracci <[email protected]>
30
 * @license   http://www.opensource.org/licenses/bsd-license.php  BSD License
31
 * @link      http://www.nitronet.org/fwk
32
 */
33
namespace Fwk\Di\Definitions;
34
35
use Fwk\Di\Container;
36
use Fwk\Di\DefinitionInterface;
37
use Fwk\Di\InvokableInterface;
38
use Fwk\Di\Exceptions;
39
use Fwk\Di\Reference;
40
41
/**
42
 * Abstract Definition Utility
43
 *
44
 * @category Utilities
45
 * @package  Fwk\Di
46
 * @author   Julien Ballestracci <[email protected]>
47
 * @license  http://www.opensource.org/licenses/bsd-license.php  BSD License
48
 * @link     http://www.nitronet.org/fwk
49
 */
50
abstract class AbstractDefinition
51
{
52
    /**
53
     * Shared result/instance ?
54
     *
55
     * @var bool
56
     */
57
    protected $shared = false;
58
59
    /**
60
     * Definition's meta-data
61
     *
62
     * @var array
63
     */
64
    protected $data = array();
65
66
    /**
67
     * @param bool $bool
68
     *
69
     * @return DefinitionInterface
70
     */
71 39
    public function setShared($bool)
72
    {
73 39
        $this->shared = (bool)$bool;
74
75 39
        return $this;
76
    }
77
78
    /**
79
     * @return bool
80
     */
81 20
    public function isShared()
82
    {
83 20
        return $this->shared;
84
    }
85
86
    /**
87
     * Sets (erase) definition meta-data
88
     *
89
     * @param array $data The Definition's data
90
     *
91
     * @return DefinitionInterface
92
     */
93 7
    public function setData(array $data)
94
    {
95 7
        $this->data = $data;
96
97 7
        return $this;
98
    }
99
100
    /**
101
     * Returns all definition meta-data
102
     *
103
     * @return array
104
     */
105 3
    public function getData()
106
    {
107 3
        return $this->data;
108
    }
109
110
    /**
111
     * Returns a meta-data parameter ($param) or $default if not defined
112
     *
113
     * @param string     $param   Parameter key
114
     * @param null|mixed $default Default return value if not defined
115
     *
116
     * @return mixed
117
     */
118
    public function get($param, $default = null)
119
    {
120
        return (array_key_exists($param, $this->data) ? $this->data[$param] : $default);
121
    }
122
123
    /**
124
     * Defines a meta-data parameter
125
     *
126
     * @param string $param Parameter key
127
     * @param mixed  $value Parameter value
128
     *
129
     * @return DefinitionInterface
130
     */
131 5
    public function set($param, $value)
132
    {
133 5
        $this->data[$param] = $value;
134
135 5
        return $this;
136
    }
137
138
    /**
139
     * Tells if definition's meta-data matches $dataQuery
140
     *
141
     * @param array $query
142
     *
143
     * @return boolean
144
     */
145 1
    public function match(array $query, Container $container)
0 ignored issues
show
function match() does not seem to conform to the naming convention (^(?:is|has|should|may|su...ster|unregister|exists)).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
146
    {
147 1
        $queryValuesCache = array();
148 1
        foreach ($query as $key => $queryValue) {
149 1
            if (!array_key_exists($key, $this->data)) {
150 1
                continue;
151
            }
152
153 1
            if (!is_string($this->data[$key]) || !is_string($queryValue)) {
154 1
                return $this->data[$key] === $queryValue;
155
            }
156
157 1
            if (!isset($queryValuesCache[$key])) {
158 1
                $queryValuesCache[$key] = $this->searchQueryToRegex($queryValue, $container);
159
            }
160
161 1
            if (preg_match($queryValuesCache[$key], $this->data[$key])) {
162 1
                return true;
163
            }
164
        }
165
166 1
        return false;
167
    }
168
169
    /**
170
     * Transforms a wildcard to a regex
171
     *
172
     * @param string $value
173
     *
174
     * @return string
175
     * @throws Exceptions\SearchException
176
     */
177 1
    protected function searchQueryToRegex($value, Container $container)
178
    {
179 1
        $original = $value;
180 1
        $value = $container->propertizeString($value);
181 1
        if (!is_string($value)) {
182
            throw new Exceptions\SearchException("Invalid Query: '$original' because of a non-string value.");
183
        }
184
185 1
        if (empty($value)) {
186
            return "/(.+){1,}/";
187
        }
188
189 1
        return '/^'. str_replace(array('?', '*'), array('(.+){1}', '(.+){1,}'), $value) .'$/';
190
    }
191
}
192