Issues (555)

Branch: main

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
    #[\PHPUnit\Framework\Attributes\DataProvider('setDependsValidDataProvider')]
71
    public function testSetDependsValid(array $expectedDepends, string $depends): void
72
    {
73
        $this->target->setDepends($depends);
74
75
        $this->assertEquals($expectedDepends, $this->target->getDependencies());
76
    }
77
78
    public static function setDependsValidDataProvider(): array
79
    {
80
        return [
81
            [['target1'], 'target1'],
82
            [['target1', 'target2'], 'target1,target2'],
83
        ];
84
    }
85
86
    /**
87
     * @dataProvider setDependsInvalidDataProvider
88
     */
89
    #[\PHPUnit\Framework\Attributes\DataProvider('setDependsInvalidDataProvider')]
90
    public function testSetDependsInvalid(string $depends): void
91
    {
92
        $this->expectException(BuildException::class);
93
        $this->expectExceptionMessage('Syntax Error: Depend attribute for target MyTarget is malformed.');
94
95
        $this->target->setDepends($depends);
96
    }
97
98
    public static function setDependsInvalidDataProvider(): array
99
    {
100
        return [
101
            [''],
102
            ['target1,'],
103
        ];
104
    }
105
106
    public function testGetTasksReturnsCorrectTasks(): void
107
    {
108
        $task = new EchoTask();
109
        $task->setMessage('Hello World');
110
        $this->target->addTask($task);
111
        $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

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