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.

tests/Phing/Test/TargetTest.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\Test;
22
23
use Phing\Exception\BuildException;
24
use Phing\RuntimeConfigurable;
25
use Phing\Target;
26
use Phing\Task;
27
use Phing\Task\System\EchoTask;
28
use Phing\Test\Support\BuildFileTest;
29
30
/**
31
 * UTs for Target component.
32
 *
33
 * @author Victor Farazdagi <[email protected]>
34
 * @author Daniel Holmes
35
 *
36
 * @internal
37
 */
38
class TargetTest extends BuildFileTest
39
{
40
    /** @var Target */
41
    private $target;
42
43
    public function setUp(): void
44
    {
45
        $this->configureProject(
46
            PHING_TEST_BASE
47
            . '/etc/components/Target/Target.xml'
48
        );
49
50
        $this->target = new Target();
51
        $this->target->setProject($this->project);
52
        $this->target->setName('MyTarget');
53
    }
54
55
    public function testHiddenTargets(): void
56
    {
57
        $phingExecutable = '"' . PHING_TEST_BASE . '/../bin/phing"';
58
        $buildFile = '"' . PHING_TEST_BASE . '/etc/components/Target/HiddenTargets.xml"';
59
        $cmd = $phingExecutable . ' -l -f ' . $buildFile;
60
        exec($cmd, $out);
61
        $out = implode("\n", $out);
62
        $offset = strpos($out, 'Subtargets:');
63
        $this->assertFalse(strpos($out, 'HideInListTarget', $offset));
64
        $this->assertTrue(false !== strpos($out, 'ShowInListTarget', $offset));
65
    }
66
67
    /**
68
     * @dataProvider setDependsValidDataProvider
69
     */
70
    public function testSetDependsValid(array $expectedDepends, string $depends): void
71
    {
72
        $this->target->setDepends($depends);
73
74
        $this->assertEquals($expectedDepends, $this->target->getDependencies());
75
    }
76
77
    public function setDependsValidDataProvider(): array
78
    {
79
        return [
80
            [['target1'], 'target1'],
81
            [['target1', 'target2'], 'target1,target2'],
82
        ];
83
    }
84
85
    /**
86
     * @dataProvider setDependsInvalidDataProvider
87
     */
88
    public function testSetDependsInvalid(string $depends): void
89
    {
90
        $this->expectException(BuildException::class);
91
        $this->expectExceptionMessage('Syntax Error: Depend attribute for target MyTarget is malformed.');
92
93
        $this->target->setDepends($depends);
94
    }
95
96
    public function setDependsInvalidDataProvider(): array
97
    {
98
        return [
99
            [''],
100
            ['target1,'],
101
        ];
102
    }
103
104
    public function testGetTasksReturnsCorrectTasks(): void
105
    {
106
        $task = new EchoTask();
107
        $task->setMessage('Hello World');
108
        $this->target->addTask($task);
109
        $this->target->addDataType('dataType');
0 ignored issues
show
'dataType' of type string is incompatible with the type Phing\RuntimeConfigurable expected by parameter $rtc of Phing\Target::addDataType(). ( Ignorable by Annotation )

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

109
        $this->target->addDataType(/** @scrutinizer ignore-type */ 'dataType');
Loading history...
110
111
        $tasks = $this->target->getTasks();
112
113
        $this->assertEquals([$task], $tasks);
114
    }
115
116
    public function testGetTasksClonesTasks(): void
117
    {
118
        $task = new EchoTask();
119
        $task->setMessage('Hello World');
120
        $this->target->addTask($task);
121
122
        $tasks = $this->target->getTasks();
123
124
        $this->assertNotSame($task, $tasks[0]);
125
    }
126
127
    public function testMainAppliesConfigurables(): void
128
    {
129
        $configurable = $this->getMockBuilder(RuntimeConfigurable::class)
130
            ->disableOriginalConstructor()
131
            ->getMock()
132
        ;
133
        $configurable->expects($this->once())->method('maybeConfigure')->with($this->project);
134
        $this->target->addDataType($configurable);
135
136
        $this->target->main();
137
    }
138
139
    public function testMainFalseIfDoesntApplyConfigurable(): void
140
    {
141
        $this->project->setProperty('ifProperty', null);
142
        $this->target->setIf('ifProperty');
143
144
        $configurable = $this->getMockBuilder(RuntimeConfigurable::class)
145
            ->disableOriginalConstructor()
146
            ->getMock()
147
        ;
148
        $configurable->expects($this->never())->method('maybeConfigure');
149
        $this->target->addDataType($configurable);
150
151
        $this->target->main();
152
    }
153
154
    public function testMainTrueUnlessDoesntApplyConfigurable(): void
155
    {
156
        $this->project->setProperty('unlessProperty', 'someValue');
157
        $this->target->setUnless('unlessProperty');
158
159
        $configurable = $this->getMockBuilder(RuntimeConfigurable::class)
160
            ->disableOriginalConstructor()
161
            ->getMock()
162
        ;
163
        $configurable->expects($this->never())->method('maybeConfigure');
164
        $this->target->addDataType($configurable);
165
166
        $this->target->main();
167
    }
168
169
    public function testMainPerformsTasks(): void
170
    {
171
        $task = $this->createMock(Task::class);
172
        $task->expects($this->once())->method('perform');
173
        $this->target->addTask($task);
174
175
        $this->target->main();
176
    }
177
178
    public function testMainFalseIfDoesntPerformTasks(): void
179
    {
180
        $this->project->setProperty('ifProperty', null);
181
        $this->target->setIf('ifProperty');
182
183
        $task = $this->createMock(Task::class);
184
        $task->expects($this->never())->method('perform');
185
        $this->target->addTask($task);
186
187
        $this->target->main();
188
    }
189
190
    public function testMainTrueUnlessDoesntPerformTasks(): void
191
    {
192
        $this->project->setProperty('unlessProperty', 'someValue');
193
        $this->target->setUnless('unlessProperty');
194
195
        $task = $this->createMock(Task::class);
196
        $task->expects($this->never())->method('perform');
197
        $this->target->addTask($task);
198
199
        $this->target->main();
200
    }
201
}
202