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/Io/SourceFileScanner.php (1 issue)

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\Io;
22
23
use Phing\Mapper\FileNameMapper;
24
use Phing\Phing;
25
use Phing\Project;
26
use Phing\Task;
27
28
/**
29
 *  Utility class that collects the functionality of the various
30
 *  scanDir methods that have been scattered in several tasks before.
31
 *
32
 *  The only method returns an array of source files. The array is a
33
 *  subset of the files given as a parameter and holds only those that
34
 *  are newer than their corresponding target files.
35
 */
36
class SourceFileScanner
37
{
38
    /**
39
     * Instance of FileUtils.
40
     */
41
    private $fileUtils;
42
43
    /**
44
     * Task this class is working for -- for logging purposes.
45
     */
46
    private $task;
47
48
    /**
49
     * @param Task $task The task we should log messages through
50
     */
51
    public function __construct($task)
52
    {
53
        $this->task = $task;
54
        $this->fileUtils = new FileUtils();
55
    }
56
57
    /**
58
     * Restrict the given set of files to those that are newer than
59
     * their corresponding target files.
60
     *
61
     * @param iterable       $files   the original set of files
62
     * @param File           $srcDir  all files are relative to this directory
63
     * @param File           $destDir target files live here. if null file names
64
     *                                returned by the mapper are assumed to be
65
     *                                absolute.
66
     * @param FilenameMapper $mapper  knows how to construct a target file names from
67
     *                                source file names
68
     * @param bool           $force   bool that determines if the files should be
69
     *                                forced to be copied
70
     *
71
     * @return array
72
     */
73
    public function restrict(&$files, $srcDir, $destDir, $mapper, $force = false)
74
    {
75
        $now = time();
76
        $targetList = '';
0 ignored issues
show
The assignment to $targetList is dead and can be removed.
Loading history...
77
78
        /*
79
          If we're on Windows, we have to munge the time up to 2 secs to
80
          be able to check file modification times.
81
          (Windows has a max resolution of two secs for modification times)
82
        */
83
        $osname = strtolower(Phing::getProperty('os.name'));
84
85
        // indexOf()
86
        $index = ((($res = strpos($osname, 'win')) === false) ? -1 : $res);
87
        if ($index >= 0) {
88
            $now += 2000;
89
        }
90
91
        $v = [];
92
93
        for ($i = 0, $size = count($files); $i < $size; ++$i) {
94
            $targets = $mapper->main($files[$i]);
95
            if (empty($targets)) {
96
                $this->task->log($files[$i] . " skipped - don't know how to handle it", Project::MSG_VERBOSE);
97
98
                continue;
99
            }
100
101
            $src = null;
102
103
            try {
104
                if (null === $srcDir) {
105
                    $src = new File($files[$i]);
106
                } else {
107
                    $src = $this->fileUtils->resolveFile($srcDir, $files[$i]);
108
                }
109
110
                if ($src->lastModified() > $now) {
111
                    $this->task->log(
112
                        'Warning: ' . $files[$i] . ' modified in the future (' . $src->lastModified() . ' > ' . $now . ')',
113
                        Project::MSG_WARN
114
                    );
115
                }
116
            } catch (IOException $ioe) {
117
                $this->task->log('Unable to read file ' . $files[$i] . ' (skipping): ' . $ioe->getMessage());
118
119
                continue;
120
            }
121
122
            $added = false;
123
            $targetList = '';
124
125
            for ($j = 0, $_j = count($targets); (!$added && $j < $_j); ++$j) {
126
                $dest = null;
127
                if (null === $destDir) {
128
                    $dest = new File($targets[$j]);
129
                } else {
130
                    $dest = $this->fileUtils->resolveFile($destDir, $targets[$j]);
131
                }
132
133
                if (!$dest->exists()) {
134
                    $this->task->log(
135
                        ($files[$i] ?: '.') . ' added as ' . $dest->__toString() . " doesn't exist.",
136
                        Project::MSG_VERBOSE
137
                    );
138
                    $v[] = $files[$i];
139
                    $added = true;
140
                } elseif ($src->lastModified() > $dest->lastModified()) {
141
                    $this->task->log(
142
                        $files[$i] . ' added as ' . $dest->__toString() . ' is outdated.',
143
                        Project::MSG_VERBOSE
144
                    );
145
                    $v[] = $files[$i];
146
                    $added = true;
147
                } elseif (true === $force) {
148
                    $this->task->log(
149
                        $files[$i] . ' added as ' . $dest->__toString() . ' is forced to be overwritten.',
150
                        Project::MSG_VERBOSE
151
                    );
152
                    $v[] = $files[$i];
153
                    $added = true;
154
                } else {
155
                    if (strlen($targetList) > 0) {
156
                        $targetList .= ', ';
157
                    }
158
                    $targetList .= $dest->getAbsolutePath();
159
                }
160
            }
161
162
            if (!$added) {
163
                $this->task->log(
164
                    $files[$i] . ' omitted as ' . $targetList . ' ' . (1 === count(
165
                        $targets
166
                    ) ? ' is ' : ' are ') . 'up to date.',
167
                    Project::MSG_VERBOSE
168
                );
169
            }
170
        }
171
172
        return $v;
173
    }
174
175
    /**
176
     * Convenience layer on top of restrict that returns the source
177
     * files as PhingFile objects (containing absolute paths if srcDir is
178
     * absolute).
179
     *
180
     * @param  $files
181
     * @param  $srcDir
182
     * @param  $destDir
183
     * @param  $mapper
184
     *
185
     * @return array
186
     */
187
    public function restrictAsFiles(&$files, &$srcDir, &$destDir, &$mapper)
188
    {
189
        $res = $this->restrict($files, $srcDir, $destDir, $mapper);
190
        $result = [];
191
        for ($i = 0, $resultsCount = count($res); $i < $resultsCount; ++$i) {
192
            $result[$i] = new File($srcDir, $res[$i]);
193
        }
194
195
        return $result;
196
    }
197
}
198