Issues (557)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/Phing/Mapper/GlobMapper.php (2 issues)

Severity
1
<?php
2
3
/**
4
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
5
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
6
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
7
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
8
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
9
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
10
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
11
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
12
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
13
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
14
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15
 *
16
 * This software consists of voluntary contributions made by many individuals
17
 * and is licensed under the LGPL. For more information please see
18
 * <http://phing.info>.
19
 */
20
21
namespace Phing\Mapper;
22
23
use Phing\Exception\BuildException;
24
use Phing\Util\StringHelper;
25
26
/**
27
 * Uses glob patterns to perform filename transformations.
28
 *
29
 * @author  Andreas Aderhold, [email protected]
30
 */
31
class GlobMapper implements FileNameMapper
32
{
33
    /**
34
     * Part of &quot;from&quot; pattern before the <code>.*</code>.
35
     *
36
     * @var string
37
     */
38
    private $fromPrefix;
39
40
    /**
41
     * Part of &quot;from&quot; pattern after the <code>.*</code>.
42
     *
43
     * @var string
44
     */
45
    private $fromPostfix;
46
47
    /**
48
     * Length of the prefix (&quot;from&quot; pattern).
49
     *
50
     * @var int
51
     */
52
    private $prefixLength;
53
54
    /**
55
     * Length of the postfix (&quot;from&quot; pattern).
56
     *
57
     * @var int
58
     */
59
    private $postfixLength;
60
61
    /**
62
     * Part of &quot;to&quot; pattern before the <code>*.</code>.
63
     *
64
     * @var string
65
     */
66
    private $toPrefix;
67
68
    /**
69
     * Part of &quot;to&quot; pattern after the <code>*.</code>.
70
     *
71
     * @var string
72
     */
73
    private $toPostfix;
74
75
    private $fromContainsStar = false;
76
    private $toContainsStar = false;
77
    private $handleDirSep = false;
78
    private $caseSensitive = true;
79
80
    /**
81
     * Attribute specifying whether to ignore the difference
82
     * between / and \ (the two common directory characters).
83
     *
84
     * @param bool $handleDirSep a boolean, default is false
85
     */
86
    public function setHandleDirSep($handleDirSep)
87
    {
88
        $this->handleDirSep = $handleDirSep;
89
    }
90
91
    /**
92
     * Attribute specifying whether to ignore the difference
93
     * between / and \ (the two common directory characters).
94
     */
95
    public function getHandleDirSep()
96
    {
97
        return $this->handleDirSep;
98
    }
99
100
    /**
101
     * Attribute specifying whether to ignore the case difference
102
     * in the names.
103
     *
104
     * @param bool $caseSensitive a boolean, default is false
105
     */
106
    public function setCaseSensitive($caseSensitive)
107
    {
108
        $this->caseSensitive = $caseSensitive;
109
    }
110
111
    /**
112
     * {@inheritdoc}
113
     *
114
     * @return null|array
115
     */
116
    public function main($sourceFileName)
117
    {
118
        $modName = $this->modifyName($sourceFileName);
119
        if (
120
            null === $this->fromPrefix
121
            || (strlen($sourceFileName) < ($this->prefixLength + $this->postfixLength)
122
                || (!$this->fromContainsStar
123
                    && !$modName === $this->modifyName($this->fromPrefix)))
124
            || ($this->fromContainsStar
125
                && (!StringHelper::startsWith($this->modifyName($this->fromPrefix), $modName)
126
                    || !StringHelper::endsWith($this->modifyName($this->fromPostfix), $modName)))
127
        ) {
128
            return null;
129
        }
130
131
        return [
132
            $this->toPrefix . (
133
                $this->toContainsStar
134
                ? $this->extractVariablePart($sourceFileName) . $this->toPostfix
135
                : ''
136
            ),
137
        ];
138
    }
139
140
    /**
141
     * {@inheritdoc}
142
     *
143
     * @param string $from
144
     */
145
    public function setFrom($from)
146
    {
147
        if (null === $from) {
0 ignored issues
show
The condition null === $from is always false.
Loading history...
148
            throw new BuildException("this mapper requires a 'from' attribute");
149
        }
150
151
        $index = strrpos($from, '*');
152
153
        if (false === $index) {
154
            $this->fromPrefix = $from;
155
            $this->fromPostfix = '';
156
        } else {
157
            $this->fromPrefix = substr($from, 0, $index);
158
            $this->fromPostfix = substr($from, $index + 1);
159
            $this->fromContainsStar = true;
160
        }
161
        $this->prefixLength = strlen($this->fromPrefix);
162
        $this->postfixLength = strlen($this->fromPostfix);
163
    }
164
165
    /**
166
     * Sets the &quot;to&quot; pattern. Required.
167
     * {@inheritdoc}
168
     *
169
     * @param string $to
170
     */
171
    public function setTo($to)
172
    {
173
        if (null === $to) {
0 ignored issues
show
The condition null === $to is always false.
Loading history...
174
            throw new BuildException("this mapper requires a 'to' attribute");
175
        }
176
177
        $index = strrpos($to, '*');
178
        if (false === $index) {
179
            $this->toPrefix = $to;
180
            $this->toPostfix = '';
181
        } else {
182
            $this->toPrefix = substr($to, 0, $index);
183
            $this->toPostfix = substr($to, $index + 1);
184
            $this->toContainsStar = true;
185
        }
186
    }
187
188
    /**
189
     * Extracts the variable part.
190
     *
191
     * @param string $name
192
     *
193
     * @return string
194
     */
195
    private function extractVariablePart($name)
196
    {
197
        return StringHelper::substring($name, $this->prefixLength, strlen($name) - $this->postfixLength - 1);
198
    }
199
200
    /**
201
     * modify string based on dir char mapping and case sensitivity.
202
     *
203
     * @param string $name the name to convert
204
     *
205
     * @return string the converted name
206
     */
207
    private function modifyName($name)
208
    {
209
        if (!$this->caseSensitive) {
210
            $name = strtolower($name);
211
        }
212
        if ($this->handleDirSep) {
213
            if (false !== strpos('\\', $name)) {
214
                $name = str_replace('\\', '/', $name);
215
            }
216
        }
217
218
        return $name;
219
    }
220
}
221