Issues (2)

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/Helpers/Arr.php (2 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
namespace zqhong\route\Helpers;
4
5
class Arr
6
{
7
    /**
8
     * Retrieves the value of an array element or object property with the given key or property name.
9
     * If the key does not exist in the array or object, the default value will be returned instead.
10
     *
11
     * The key may be specified in a dot format to retrieve the value of a sub-array or the property
12
     * of an embedded object. In particular, if the key is `x.y.z`, then the returned value would
13
     * be `$array['x']['y']['z']` or `$array->x->y->z` (if `$array` is an object). If `$array['x']`
14
     * or `$array->x` is neither an array nor an object, the default value will be returned.
15
     * Note that if the array already has an element `x.y.z`, then its value will be returned
16
     * instead of going through the sub-arrays. So it is better to be done specifying an array of key names
17
     * like `['x', 'y', 'z']`.
18
     *
19
     * Below are some usage examples,
20
     *
21
     * ```php
22
     * // working with array
23
     * $username = \yii\helpers\ArrayHelper::getValue($_POST, 'username');
24
     * // working with object
25
     * $username = \yii\helpers\ArrayHelper::getValue($user, 'username');
26
     * // working with anonymous function
27
     * $fullName = \yii\helpers\ArrayHelper::getValue($user, function ($user, $defaultValue) {
28
     *     return $user->firstName . ' ' . $user->lastName;
29
     * });
30
     * // using dot format to retrieve the property of embedded object
31
     * $street = \yii\helpers\ArrayHelper::getValue($users, 'address.street');
32
     * // using an array of keys to retrieve the value
33
     * $value = \yii\helpers\ArrayHelper::getValue($versions, ['1.0', 'date']);
34
     * ```
35
     *
36
     * @param array|object $array array or object to extract value from
37
     * @param string|\Closure|array $key key name of the array element, an array of keys or property name of the object,
38
     * or an anonymous function returning the value. The anonymous function signature should be:
39
     * `function($array, $defaultValue)`.
40
     * The possibility to pass an array of keys is available since version 2.0.4.
41
     * @param mixed $default the default value to be returned if the specified array key does not exist. Not used when
42
     * getting value from an object.
43
     * @return mixed the value of the element if found, default value otherwise
44
     */
45
    public static function getValue($array, $key, $default = null)
46
    {
47
        if ($key instanceof \Closure) {
48
            return $key($array, $default);
49
        }
50
51
        if (is_array($key)) {
52
            $lastKey = array_pop($key);
53
            foreach ($key as $keyPart) {
54
                $array = static::getValue($array, $keyPart);
55
            }
56
            $key = $lastKey;
57
        }
58
59 View Code Duplication
        if (is_array($array) && (isset($array[$key]) || array_key_exists($key, $array))) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
60
            return $array[$key];
61
        }
62
63
        if (($pos = strrpos($key, '.')) !== false) {
64
            $array = static::getValue($array, substr($key, 0, $pos), $default);
65
            $key = substr($key, $pos + 1);
66
        }
67
68
        if (is_object($array)) {
69
            // this is expected to fail if the property does not exist, or __get() is not implemented
70
            // it is not reliably possible to check whether a property is accessible beforehand
71
            return $array->$key;
72 View Code Duplication
        } elseif (is_array($array)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
73
            return (isset($array[$key]) || array_key_exists($key, $array)) ? $array[$key] : $default;
74
        } else {
75
            return $default;
76
        }
77
    }
78
}
79