Issues (3)

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.

src/DownloadCommand.php (1 issue)

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 namespace Laravel\Installer\Console;
2
3
use GuzzleHttp\Client;
4
use GuzzleHttp\Event\ProgressEvent;
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Helper\ProgressBar;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use Symfony\Component\Console\Input\InputInterface;
9
10
class DownloadCommand extends Command {
11
12
    private $output;
13
14
    private $progress = 0;
15
16
    /**
17
     * Configure the command options.
18
     *
19
     * @return void
20
     */
21
    protected function configure()
22
    {
23
        $this->setName('download')
24
             ->setDescription('Download laravel builds.');
25
    }
26
27
    /**
28
     * Execute the command.
29
     *
30
     * @param  InputInterface  $input
31
     * @param  OutputInterface $output
32
     *
33
     * @return void
34
     */
35
    protected function execute(InputInterface $input, OutputInterface $output)
36
    {
37
        $this->output = $output;
38
39
        $output->writeln('<info>Downloading NukaCode application data...</info>');
40
41
        $this->download();
42
43
        $output->writeln('<comment>Application download complete! Ready to build something amazingly FAST!</comment>');
44
    }
45
46
    /**
47
     * Download the temporary Zip to the given file.
48
     *
49
     * @return $this
50
     */
51
    protected function download()
52
    {
53
        $md5HashLocation = 'http://builds.nukacode.com/files.php';
54
        $slimZipLocation = dirname(__FILE__) . '/laravel_slim.zip';
55
        $fullZipLocation = dirname(__FILE__) . '/laravel_full.zip';
56
        $lumenZipLocation = dirname(__FILE__) . '/lumen_full.zip';
57
58
        if ($this->checkIfServerHasNewerBuild($md5HashLocation, $slimZipLocation)) {
59
            $this->cleanUp($slimZipLocation);
60
            $this->downloadFileWithProgressBar('http://builds.nukacode.com/slim/latest.zip', $slimZipLocation);
61
        }
62
63
        if ($this->checkIfServerHasNewerBuild($md5HashLocation, $fullZipLocation)) {
64
            $this->cleanUp($fullZipLocation);
65
            $this->downloadFileWithProgressBar('http://builds.nukacode.com/full/latest.zip', $fullZipLocation);
66
        }
67
68
        if ($this->checkIfServerHasNewerBuild($md5HashLocation, $lumenZipLocation)) {
69
            $this->cleanUp($lumenZipLocation);
70
            $this->downloadFileWithProgressBar('http://builds.nukacode.com/lumen/latest.zip', $lumenZipLocation);
71
        }
72
73
        return $this;
74
    }
75
76
    /**
77
     * Clean-up the Zip file.
78
     *
79
     * @param the zip file to remove
80
     *
81
     * @return $this
82
     */
83
    protected function cleanUp($zipFile)
84
    {
85
        @chmod($zipFile, 0777);
86
        @unlink($zipFile);
87
88
        return $this;
89
    }
90
91
92
    /**
93
     * Download the nukacode build files and display progress bar.
94
     *
95
     * @param $buildUrl
96
     * @param $zipFile
97
     */
98 View Code Duplication
    protected function downloadFileWithProgressBar($buildUrl, $zipFile)
0 ignored issues
show
This method seems to be duplicated in 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...
99
    {
100
        $this->output->writeln('<info>Begin file download...</info>');
101
102
        $progressBar = new ProgressBar($this->output, 100);
103
        $progressBar->start();
104
105
        $client  = new Client();
106
        $request = $client->createRequest('GET', $buildUrl);
107
        $request->getEmitter()->on('progress', function (ProgressEvent $e) use ($progressBar) {
108
            if ($e->downloaded > 0) {
109
                $localProgress = floor(($e->downloaded / $e->downloadSize * 100));
110
111
                if ($localProgress != $this->progress) {
112
                    $this->progress = (integer)$localProgress;
113
                    $progressBar->advance();
114
                }
115
            }
116
        });
117
118
        $response = $client->send($request);
119
120
        $progressBar->finish();
121
122
        file_put_contents($zipFile, $response->getBody());
123
124
        $this->output->writeln("\n<info>File download complete...</info>");
125
    }
126
127
    /**
128
     * Check if the server has a newer version of the nukacode build.
129
     *
130
     * @param string $md5CheckPath The url to check for file md5 hash
131
     * @param string $zipFile      The zip file we are checking
132
     *
133
     * @return bool
134
     */
135
    protected function checkIfServerHasNewerBuild($md5CheckPath, $zipFile)
136
    {
137
        if (file_exists($zipFile)) {
138
            $client   = new Client();
139
            $response = $client->get($md5CheckPath);
140
141
            // The downloaded copy is the same as the one on the server.
142
            if (in_array(md5_file($zipFile), $response->json())) {
143
                return false;
144
            }
145
        }
146
147
        return true;
148
    }
149
}
150