Issues (287)

Security Analysis    no request data  

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

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

phing/tasks/GuzzlePearPharPackageTask.php (11 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 14 and the first side effect is on line 9.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * This file is part of Guzzle's build process.
4
 *
5
 * @copyright 2012 Clay Loveless <[email protected]>
6
 * @license   http://claylo.mit-license.org/2012/ MIT License
7
 */
8
9
require_once 'phing/Task.php';
10
require_once 'PEAR/PackageFileManager2.php';
11
require_once 'PEAR/PackageFileManager/File.php';
12
require_once 'PEAR/Packager.php';
13
14
class GuzzlePearPharPackageTask extends Task
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
15
{
16
    private $version;
17
    private $deploy = true;
18
    private $makephar = true;
19
20
    private $subpackages = array();
21
22
    public function setVersion($str)
23
    {
24
        $this->version = $str;
25
    }
26
27
    public function getVersion()
28
    {
29
        return $this->version;
30
    }
31
32
    public function setDeploy($deploy)
33
    {
34
        $this->deploy = (bool) $deploy;
35
    }
36
37
    public function getDeploy()
38
    {
39
        return $this->deploy;
40
    }
41
42
    public function setMakephar($makephar)
43
    {
44
        $this->makephar = (bool) $makephar;
45
    }
46
47
    public function getMakephar()
48
    {
49
        return $this->makephar;
50
    }
51
52
    private $basedir;
53
    private $guzzleinfo;
54
    private $changelog_release_date;
55
    private $changelog_notes = '-';
56
57
    public function main()
58
    {
59
        $this->basedir = $this->getProject()->getBasedir();
60
61
        if (!is_dir((string) $this->basedir.'/.subsplit')) {
62
            throw new BuildException('PEAR packaging requires .subsplit directory');
63
        }
64
65
        // main composer file
66
        $composer_file = file_get_contents((string) $this->basedir.'/.subsplit/composer.json');
67
        $this->guzzleinfo = json_decode($composer_file, true);
68
69
        // make sure we have a target
70
        $pearwork = (string) $this->basedir . '/build/pearwork';
71
        if (!is_dir($pearwork)) {
72
            mkdir($pearwork, 0777, true);
73
        }
74
        $pearlogs = (string) $this->basedir . '/build/artifacts/logs';
75
        if (!is_dir($pearlogs)) {
76
            mkdir($pearlogs, 0777, true);
77
        }
78
79
        $version = $this->getVersion();
80
        $this->grabChangelog();
81
        if ($version[0] == '2') {
82
            $this->log('building single PEAR package');
83
            $this->buildSinglePackage();
84
        } else {
85
            // $this->log("building PEAR subpackages");
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
86
            // $this->createSubPackages();
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
87
            // $this->log("building PEAR bundle package");
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
88
            $this->buildSinglePackage();
89
        }
90
91
        if ($this->getMakephar()) {
92
            $this->log("building PHAR");
93
            $this->getProject()->executeTarget('package-phar');
94
        }
95
96
        if ($this->getDeploy()) {
97
            $this->doDeployment();
98
        }
99
    }
100
101
    public function doDeployment()
102
    {
103
        $basedir = (string) $this->basedir;
104
        $this->log('beginning PEAR/PHAR deployment');
105
106
        chdir($basedir . '/build/pearwork');
107
        if (!is_dir('./channel')) {
108
            mkdir('./channel');
109
        }
110
111
        // Pull the PEAR channel down locally
112
        passthru('aws s3 sync s3://pear.guzzlephp.org ./channel');
113
114
        // add PEAR packages
115
        foreach (scandir('./') as $file) {
116
            if (substr($file, -4) == '.tgz') {
117
                passthru('pirum add ./channel ' . $file);
118
            }
119
        }
120
121
        // if we have a new phar, add it
122
        if ($this->getMakephar() && file_exists($basedir . '/build/artifacts/guzzle.phar')) {
123
            rename($basedir . '/build/artifacts/guzzle.phar', './channel/guzzle.phar');
124
        }
125
126
        // Sync up with the S3 bucket
127
        chdir($basedir . '/build/pearwork/channel');
128
        passthru('aws s3 sync . s3://pear.guzzlephp.org');
129
    }
130
131
    public function buildSinglePackage()
132
    {
133
        $v = $this->getVersion();
134
        $apiversion = $v[0] . '.0.0';
135
136
        $opts = array(
137
            'packagedirectory' => (string) $this->basedir . '/.subsplit/src/',
138
            'filelistgenerator' => 'file',
139
            'ignore' => array('*composer.json'),
140
            'baseinstalldir' => '/',
141
            'packagefile' => 'package.xml'
142
            //'outputdirectory' => (string) $this->basedir . '/build/pearwork/'
0 ignored issues
show
Unused Code Comprehensibility introduced by
47% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
143
        );
144
        $pfm = new PEAR_PackageFileManager2();
145
        $pfm->setOptions($opts);
146
        $pfm->addRole('md', 'doc');
147
        $pfm->addRole('pem', 'php');
148
        $pfm->setPackage('Guzzle');
149
        $pfm->setSummary("Object-oriented PHP HTTP Client for PHP 5.3+");
150
        $pfm->setDescription($this->guzzleinfo['description']);
151
        $pfm->setPackageType('php');
152
        $pfm->setChannel('guzzlephp.org/pear');
153
        $pfm->setAPIVersion($apiversion);
154
        $pfm->setReleaseVersion($this->getVersion());
155
        $pfm->setAPIStability('stable');
156
        $pfm->setReleaseStability('stable');
157
        $pfm->setNotes($this->changelog_notes);
158
        $pfm->setPackageType('php');
159
        $pfm->setLicense('MIT', 'http://github.com/guzzle/guzzle/blob/master/LICENSE');
160
        $pfm->addMaintainer('lead', 'mtdowling', 'Michael Dowling', '[email protected]', 'yes');
161
        $pfm->setDate($this->changelog_release_date);
162
        $pfm->generateContents();
163
164
        $phpdep = $this->guzzleinfo['require']['php'];
165
        $phpdep = str_replace('>=', '', $phpdep);
166
        $pfm->setPhpDep($phpdep);
167
        $pfm->addExtensionDep('required', 'curl');
168
        $pfm->setPearinstallerDep('1.4.6');
169
        $pfm->addPackageDepWithChannel('required', 'EventDispatcher', 'pear.symfony.com', '2.1.0');
170
        if (!empty($this->subpackages)) {
171
            foreach ($this->subpackages as $package) {
172
                $pkg = dirname($package);
173
                $pkg = str_replace('/', '_', $pkg);
174
                $pfm->addConflictingPackageDepWithChannel($pkg, 'guzzlephp.org/pear', false, $apiversion);
175
            }
176
        }
177
178
        ob_start();
179
        $startdir = getcwd();
180
        chdir((string) $this->basedir . '/build/pearwork');
181
182
        echo "DEBUGGING GENERATED PACKAGE FILE\n";
183
        $result = $pfm->debugPackageFile();
184 View Code Duplication
        if ($result) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
185
            $out = $pfm->writePackageFile();
186
            echo "\n\n\nWRITE PACKAGE FILE RESULT:\n";
187
            var_dump($out);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($out); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
188
            // load up package file and build package
189
            $packager = new PEAR_Packager();
190
            echo "\n\n\nBUILDING PACKAGE FROM PACKAGE FILE:\n";
191
            $dest_package = $packager->package($opts['packagedirectory'].'package.xml');
192
            var_dump($dest_package);
193
        } else {
194
            echo "\n\n\nDEBUGGING RESULT:\n";
195
            var_dump($result);
196
        }
197
        echo "removing package.xml";
198
        unlink($opts['packagedirectory'].'package.xml');
199
        $log = ob_get_clean();
200
        file_put_contents((string) $this->basedir . '/build/artifacts/logs/pear_package.log', $log);
201
        chdir($startdir);
202
    }
203
204
    public function createSubPackages()
205
    {
206
        $this->findComponents();
207
208
        foreach ($this->subpackages as $package) {
209
            $baseinstalldir = dirname($package);
210
            $dir = (string) $this->basedir.'/.subsplit/src/' . $baseinstalldir;
211
            $composer_file = file_get_contents((string) $this->basedir.'/.subsplit/src/'. $package);
212
            $package_info = json_decode($composer_file, true);
213
            $this->log('building ' . $package_info['target-dir'] . ' subpackage');
214
            $this->buildSubPackage($dir, $baseinstalldir, $package_info);
215
        }
216
    }
217
218
    public function buildSubPackage($dir, $baseinstalldir, $info)
219
    {
220
        $package = str_replace('/', '_', $baseinstalldir);
221
        $opts = array(
222
            'packagedirectory' => $dir,
223
            'filelistgenerator' => 'file',
224
            'ignore' => array('*composer.json', '*package.xml'),
225
            'baseinstalldir' => '/' . $info['target-dir'],
226
            'packagefile' => 'package.xml'
227
        );
228
        $pfm = new PEAR_PackageFileManager2();
229
        $pfm->setOptions($opts);
230
        $pfm->setPackage($package);
231
        $pfm->setSummary($info['description']);
232
        $pfm->setDescription($info['description']);
233
        $pfm->setPackageType('php');
234
        $pfm->setChannel('guzzlephp.org/pear');
235
        $pfm->setAPIVersion('3.0.0');
236
        $pfm->setReleaseVersion($this->getVersion());
237
        $pfm->setAPIStability('stable');
238
        $pfm->setReleaseStability('stable');
239
        $pfm->setNotes($this->changelog_notes);
240
        $pfm->setPackageType('php');
241
        $pfm->setLicense('MIT', 'http://github.com/guzzle/guzzle/blob/master/LICENSE');
242
        $pfm->addMaintainer('lead', 'mtdowling', 'Michael Dowling', '[email protected]', 'yes');
243
        $pfm->setDate($this->changelog_release_date);
244
        $pfm->generateContents();
245
246
        $phpdep = $this->guzzleinfo['require']['php'];
247
        $phpdep = str_replace('>=', '', $phpdep);
248
        $pfm->setPhpDep($phpdep);
249
        $pfm->setPearinstallerDep('1.4.6');
250
251
        foreach ($info['require'] as $type => $version) {
252
            if ($type == 'php') {
253
                continue;
254
            }
255
            if ($type == 'symfony/event-dispatcher') {
256
                $pfm->addPackageDepWithChannel('required', 'EventDispatcher', 'pear.symfony.com', '2.1.0');
257
            }
258
            if ($type == 'ext-curl') {
259
                $pfm->addExtensionDep('required', 'curl');
260
            }
261
            if (substr($type, 0, 6) == 'guzzle') {
262
                $gdep = str_replace('/', ' ', $type);
263
                $gdep = ucwords($gdep);
264
                $gdep = str_replace(' ', '_', $gdep);
265
                $pfm->addPackageDepWithChannel('required', $gdep, 'guzzlephp.org/pear', $this->getVersion());
266
            }
267
        }
268
269
        // can't have main Guzzle package AND sub-packages
270
        $pfm->addConflictingPackageDepWithChannel('Guzzle', 'guzzlephp.org/pear', false, $apiversion);
0 ignored issues
show
The variable $apiversion does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
271
272
        ob_start();
273
        $startdir = getcwd();
274
        chdir((string) $this->basedir . '/build/pearwork');
275
276
        echo "DEBUGGING GENERATED PACKAGE FILE\n";
277
        $result = $pfm->debugPackageFile();
278 View Code Duplication
        if ($result) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
279
            $out = $pfm->writePackageFile();
280
            echo "\n\n\nWRITE PACKAGE FILE RESULT:\n";
281
            var_dump($out);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($out); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
282
            // load up package file and build package
283
            $packager = new PEAR_Packager();
284
            echo "\n\n\nBUILDING PACKAGE FROM PACKAGE FILE:\n";
285
            $dest_package = $packager->package($opts['packagedirectory'].'/package.xml');
286
            var_dump($dest_package);
287
        } else {
288
            echo "\n\n\nDEBUGGING RESULT:\n";
289
            var_dump($result);
290
        }
291
        echo "removing package.xml";
292
        unlink($opts['packagedirectory'].'/package.xml');
293
        $log = ob_get_clean();
294
        file_put_contents((string) $this->basedir . '/build/artifacts/logs/pear_package_'.$package.'.log', $log);
295
        chdir($startdir);
296
    }
297
298
    public function findComponents()
299
    {
300
        $ds = new DirectoryScanner();
301
        $ds->setBasedir((string) $this->basedir.'/.subsplit/src');
302
        $ds->setIncludes(array('**/composer.json'));
303
        $ds->scan();
304
        $files = $ds->getIncludedFiles();
305
        $this->subpackages = $files;
306
    }
307
308
    public function grabChangelog()
309
    {
310
        $cl = file((string) $this->basedir.'/.subsplit/CHANGELOG.md');
311
        $notes = '';
312
        $in_version = false;
313
        $release_date = null;
314
315
        foreach ($cl as $line) {
316
            $line = trim($line);
317
            if (preg_match('/^\* '.$this->getVersion().' \(([0-9\-]+)\)$/', $line, $matches)) {
318
                $release_date = $matches[1];
319
                $in_version = true;
320
                continue;
321
            }
322
            if ($in_version && empty($line) && empty($notes)) {
323
                continue;
324
            }
325
            if ($in_version && ! empty($line)) {
326
                $notes .= $line."\n";
327
            }
328
            if ($in_version && empty($line) && !empty($notes)) {
329
                $in_version = false;
330
            }
331
        }
332
        $this->changelog_release_date = $release_date;
333
334
        if (! empty($notes)) {
335
            $this->changelog_notes = $notes;
336
        }
337
    }
338
}
339