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/Parser/TargetHandler.php (1 issue)

Labels
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\Parser;
22
23
use Phing\Exception\BuildException;
24
use Phing\ExtensionPoint;
25
use Phing\Project;
26
use Phing\Target;
27
use Phing\Util\StringHelper;
28
29
/**
30
 * The target handler class.
31
 *
32
 * This class handles the occurrence of a <target> tag and it's possible
33
 * nested tags (datatypes and tasks).
34
 *
35
 * @author    Andreas Aderhold <[email protected]>
36
 * @copyright 2001,2002 THYRELL. All rights reserved
37
 */
38
class TargetHandler extends AbstractHandler
39
{
40
    /**
41
     * Reference to the target object that represents the currently parsed
42
     * target.
43
     *
44
     * @var Target the target instance
45
     */
46
    private $target;
47
48
    /**
49
     * The phing project configurator object.
50
     *
51
     * @var ProjectConfigurator
52
     */
53
    private $configurator;
54
55
    /**
56
     * @var XmlContext
57
     */
58
    private $context;
59
60
    /**
61
     * Constructs a new TargetHandler.
62
     *
63
     * @internal param the $object ExpatParser object
64
     * @internal param the $object parent handler that invoked this handler
65
     * @internal param the $object ProjectConfigurator object
66
     */
67
    public function __construct(
68
        AbstractSAXParser $parser,
69
        AbstractHandler $parentHandler,
70
        ProjectConfigurator $configurator,
71
        XmlContext $context
72
    ) {
73
        parent::__construct($parser, $parentHandler);
74
        $this->configurator = $configurator;
75
        $this->context = $context;
76
    }
77
78
    /**
79
     * Executes initialization actions required to setup the data structures
80
     * related to the tag.
81
     * <p>
82
     * This includes:
83
     * <ul>
84
     * <li>creation of the target object</li>
85
     * <li>calling the setters for attributes</li>
86
     * <li>adding the target to the project</li>
87
     * <li>adding a reference to the target (if id attribute is given)</li>
88
     * </ul>.
89
     *
90
     * @param $tag
91
     * @param $attrs
92
     *
93
     * @throws BuildException
94
     * @throws ExpatParseException
95
     *
96
     * @internal param the $string tag that comes in
97
     * @internal param attributes $array the tag carries
98
     */
99
    public function init($tag, $attrs)
100
    {
101
        $name = null;
102
        $depends = '';
103
        $extensionPoint = null; //'fail';
104
        $extensionPointMissing = null;
105
        $ifCond = null;
106
        $unlessCond = null;
107
        $id = null;
108
        $description = null;
109
        $isHidden = false;
110
        $logskipped = false;
111
112
        foreach ($attrs as $key => $value) {
113
            switch ($key) {
114
                case 'name':
115
                    $name = (string) $value;
116
117
                    break;
118
119
                case 'depends':
120
                    $depends = (string) $value;
121
122
                    break;
123
124
                case 'if':
125
                    $ifCond = (string) $value;
126
127
                    break;
128
129
                case 'unless':
130
                    $unlessCond = (string) $value;
131
132
                    break;
133
134
                case 'id':
135
                    $id = (string) $value;
136
137
                    break;
138
139
                case 'hidden':
140
                    $isHidden = StringHelper::booleanValue($value);
141
142
                    break;
143
144
                case 'description':
145
                    $description = (string) $value;
146
147
                    break;
148
149
                case 'logskipped':
150
                    $logskipped = $value;
151
152
                    break;
153
154
                case 'extensionof':
155
                    $extensionPoint = $value;
156
157
                    break;
158
159
                case 'onmissingextensionpoint':
160
                    if (!in_array($value, ['fail', 'warn', 'ignore'], true)) {
161
                        throw new BuildException('Invalid onMissingExtensionPoint ' . $value);
162
                    }
163
                    $extensionPointMissing = $value;
164
165
                    break;
166
167
                default:
168
                    throw new ExpatParseException("Unexpected attribute '{$key}'", $this->parser->getLocation());
0 ignored issues
show
The method getLocation() does not exist on Phing\Parser\AbstractSAXParser. Since it exists in all sub-types, consider adding an abstract or default implementation to Phing\Parser\AbstractSAXParser. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

168
                    throw new ExpatParseException("Unexpected attribute '{$key}'", $this->parser->/** @scrutinizer ignore-call */ getLocation());
Loading history...
169
            }
170
        }
171
172
        if (null === $name) {
173
            throw new ExpatParseException(
174
                'target element appears without a name attribute',
175
                $this->parser->getLocation()
176
            );
177
        }
178
179
        // shorthand
180
        $project = $this->configurator->project;
181
182
        // check to see if this target is a dup within the same file
183
        if (isset($this->context->getCurrentTargets()[$name])) {
184
            throw new BuildException(
185
                "Duplicate target: {$name}",
186
                $this->parser->getLocation()
187
            );
188
        }
189
190
        $this->target = 'target' === $tag ? new Target() : new ExtensionPoint();
191
        $this->target->setProject($project);
192
        $this->target->setLocation($this->parser->getLocation());
193
        $this->target->setHidden($isHidden);
194
        $this->target->setIf($ifCond);
195
        $this->target->setUnless($unlessCond);
196
        $this->target->setDescription($description);
197
        $this->target->setLogSkipped(StringHelper::booleanValue($logskipped));
198
        // take care of dependencies
199
        if ('' !== $depends) {
200
            $this->target->setDepends($depends);
201
        }
202
203
        // check to see if target with same name is already defined
204
        $projectTargets = $project->getTargets();
205
        if (isset($projectTargets[$name])) {
206
            if (
207
                $this->configurator->isIgnoringProjectTag()
208
                && null != $this->configurator->getCurrentProjectName()
209
                && 0 != strlen($this->configurator->getCurrentProjectName())
210
            ) {
211
                // In an impored file (and not completely
212
                // ignoring the project tag)
213
                $newName = $this->configurator->getCurrentProjectName() . '.' . $name;
214
                $project->log(
215
                    'Already defined in main or a previous import, ' .
216
                    "define {$name} as {$newName}",
217
                    Project::MSG_VERBOSE
218
                );
219
                $name = $newName;
220
            } else {
221
                $project->log(
222
                    'Already defined in main or a previous import, ' .
223
                    "ignore {$name}",
224
                    Project::MSG_VERBOSE
225
                );
226
                $name = null;
227
            }
228
        }
229
230
        if (null !== $name) {
231
            $this->target->setName($name);
232
            $project->addOrReplaceTarget($name, $this->target);
233
            if (null !== $id && '' !== $id) {
234
                $project->addReference($id, $this->target);
235
            }
236
        }
237
238
        if (null !== $extensionPointMissing && null === $extensionPoint) {
239
            throw new BuildException(
240
                'onMissingExtensionPoint attribute cannot ' .
241
                'be specified unless extensionOf is specified',
242
                $this->target->getLocation()
243
            );
244
        }
245
        if (null !== $extensionPoint) {
246
            foreach (Target::parseDepends($extensionPoint, $name, 'extensionof') as $extPointName) {
247
                if (null === $extensionPointMissing) {
248
                    $extensionPointMissing = 'fail';
249
                }
250
                $this->context->addExtensionPoint([
251
                    $extPointName,
252
                    $this->target->getName(),
253
                    $extensionPointMissing,
254
                    null,
255
                ]);
256
            }
257
        }
258
    }
259
260
    /**
261
     * Checks for nested tags within the current one. Creates and calls
262
     * handlers respectively.
263
     *
264
     * @param string $name  the tag that comes in
265
     * @param array  $attrs attributes the tag carries
266
     */
267
    public function startElement($name, $attrs)
268
    {
269
        $tmp = new ElementHandler($this->parser, $this, $this->configurator, null, null, $this->target);
270
        $tmp->init($name, $attrs);
271
    }
272
273
    /**
274
     * Checks if this target has dependencies and/or nested tasks.
275
     * If the target has neither, show a warning.
276
     */
277
    protected function finished()
278
    {
279
        if (!$this->target instanceof ExtensionPoint && !count($this->target->getDependencies()) && !count($this->target->getTasks())) {
280
            $this->configurator->project->log(
281
                "Warning: target '" . $this->target->getName() .
282
                "' has no tasks or dependencies",
283
                Project::MSG_WARN
284
            );
285
        }
286
    }
287
}
288