Issues (42)

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/RichParam/Parser.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 Macroparts\Vortex\RichParam;
4
5
/**
6
 * Created by PhpStorm.
7
 * User: daniel.jurkovic
8
 * Date: 14.06.17
9
 * Time: 18:02
10
 */
11
class Parser
12
{
13 39
    public function parseRichParam($param)
14
    {
15 39
        $interpretation = [];
16 39
        foreach ($this->parseElements($param) as $element) {
17 21
            list($fieldname, $modifiersStr) = array_pad(explode(':', $element, 2), 2, null);
18
19 21
            if ($modifiersStr === null) {
20 3
                if (!isset($interpretation[$fieldname])) {
21 3
                    $interpretation[$fieldname] = [];
22 2
                }
23 3
                continue;
24
            }
25
26 18
            $modifierArr = $this->parseModifiers($modifiersStr);
27
28 18
            if (isset($interpretation[$fieldname])) {
29 3
                $interpretation[$fieldname] = $interpretation[$fieldname] + $modifierArr;
30 2
            } else {
31 18
                $interpretation[$fieldname] = $modifierArr;
32
            }
33 26
        }
34
35 39
        return $interpretation;
36
    }
37
38
    /**
39
     * creates an array out of string in this format:
40
     *
41
     * modifierName1(modifierParam1|modifierParam2):modifierName2(modifierParam3))
42
     *
43
     * Can also handle modifier params that contain other modifier with params
44
     *
45
     * @param string $modifiersStr
46
     * @return array
47
     */
48 18 View Code Duplication
    private function parseModifiers($modifiersStr)
0 ignored issues
show
This method seems to be duplicated in 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...
49
    {
50 18
        $interpretation = [];
51 18
        $modifierName = '';
52 18
        $modifierParamStr = '';
53
54 18
        $depth = 0;
55 18
        for ($i = 0; $i < strlen($modifiersStr); $i++) {
56 18
            switch ($modifiersStr[$i]) {
57 18
                case '(':
58 15
                    if ($depth) {
59 9
                        $modifierParamStr .= $modifiersStr[$i];
60 6
                    }
61 15
                    $depth++;
62 15
                    break;
63
64 18
                case ')':
65 15
                    $depth--;
66 15
                    if ($depth) {
67 9
                        $modifierParamStr .= $modifiersStr[$i];
68 6
                    }
69 15
                    break;
70 18
                case ':':
71 9
                    if ($depth) {
72 9
                        $modifierParamStr .= $modifiersStr[$i];
73 6
                    } else {
74 3
                        $interpretation[$modifierName] = $this->parseArguments($modifierParamStr);
75 3
                        $modifierName = '';
76 3
                        $modifierParamStr = '';
77
                    }
78 9
                    break;
79 12
                default:
80 18
                    if ($depth) {
81 15
                        $modifierParamStr .= $modifiersStr[$i];
82 10
                    } else {
83 18
                        $modifierName .= $modifiersStr[$i];
84
                    }
85 12
            }
86 12
        }
87
88 18
        if ($modifierName) {
89 18
            $interpretation[$modifierName] = $this->parseArguments($modifierParamStr);
90 12
        }
91
92 18
        return $interpretation;
93
    }
94
95
    /**
96
     * Can make an array out of parameter string that looks like this:
97
     *
98
     * param1|param2|param3
99
     *
100
     * Can also handle params that contain other modifiers with params like this:
101
     * param1|modifier(innerParam1|innerParam2)|param3
102
     *
103
     * @param string $argumentsStr
104
     * @return array
105
     */
106 18
    private function parseArguments($argumentsStr)
107
    {
108 18
        $paramArr = [];
109 18
        $tmpStr = '';
110
111 18
        $depth = 0;
112 18
        for ($i = 0; $i < strlen($argumentsStr); $i++) {
113 15
            switch ($argumentsStr[$i]) {
114 15
                case '(':
115 9
                    $tmpStr .= $argumentsStr[$i];
116 9
                    $depth++;
117 9
                    break;
118
119 15
                case ')':
120 9
                    $tmpStr .= $argumentsStr[$i];
121 9
                    $depth--;
122 9
                    break;
123
124 15
                case '|':
125 6
                    if ($depth) {
126 6
                        $tmpStr .= $argumentsStr[$i];
127 4
                    } else {
128 6
                        $paramArr[] = $tmpStr;
129 6
                        $tmpStr = '';
130
                    }
131 6
                    break;
132
133 10
                default:
134 15
                    $tmpStr .= $argumentsStr[$i];
135 10
            }
136 10
        }
137
138 18
        if (strlen($tmpStr)) {
139 15
            $paramArr[] = $tmpStr;
140 10
        }
141
142 18
        return $paramArr;
143
    }
144
145 39
    private function parseElements($richParam)
146
    {
147 39
        if ($richParam === '' || !is_string($richParam)) {
148 18
            return [];
149
        }
150
151 21
        $fields = explode(',', $richParam);
152
153 21
        return is_array($fields) ? $fields : [];
154
    }
155
}
156