Issues (7)

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.

RoboFile.php (2 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
2
3
/**
4
 * RoboFile.php
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2016 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import-cli-magento
18
 * @link      http://www.techdivision.com
19
 */
20
21
use Lurker\Event\FilesystemEvent;
22
23
use Symfony\Component\Finder\Finder;
24
use AppserverIo\RoboTasks\AbstractRoboFile;
25
use Robo\Robo;
26
27
/**
28
 * Defines the available build tasks.
29
 *
30
 * @author    Tim Wagner <[email protected]>
31
 * @copyright 2016 TechDivision GmbH <[email protected]>
32
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
33
 * @link      https://github.com/techdivision/import-cli-magento
34
 * @link      http://www.techdivision.com
35
 *
36
 * @SuppressWarnings(PHPMD)
37
 */
38
class RoboFile extends AbstractRoboFile
39
{
40
41
    /**
42
     * Configuration key for the directories.
43
     *
44
     * @var string
45
     */
46
    const DIRS = 'dirs';
47
48
    /**
49
     * Configuration key for the source directory.
50
     *
51
     * @var string
52
     */
53
    const SRC = 'src';
54
55
    /**
56
     * Configuration key for the destination directory.
57
     *
58
     * @var string
59
     */
60
    const DEST = 'dest';
61
62
    /**
63
     * Configuration key for the deploy directory.
64
     *
65
     * @var string
66
     */
67
    const DEPLOY = 'deploy';
68
69
    /**
70
     * Configuration key for the docker configuration.
71
     *
72
     * @var string
73
     */
74
    const DOCKER = 'docker';
75
76
    /**
77
     * Configuration key for the docker target container name.
78
     *
79
     * @var string
80
     */
81
    const TARGET_CONTAINER = 'target-container';
82
83
    /**
84
     * Returns the deploy directory.
85
     *
86
     * @return string The directory to deploy the sources to
87
     */
88
    protected function getDeployDir()
89
    {
90
        return Robo::config()->get(sprintf('%s.%s', RoboFile::DIRS, RoboFile::DEPLOY));
91
    }
92
93
    /**
94
     * Returns the name of the docker target container.
95
     *
96
     * @return string The docker target container
97
     */
98
    protected function getTargetContainer()
99
    {
100
        return Robo::config()->get(sprintf('%s.%s', RoboFile::DOCKER, RoboFile::TARGET_CONTAINER));
101
    }
102
103
    /**
104
     * Returns the Magento 2 root directory inside the docker container.
105
     *
106
     * @return string The Magento 2 root directory
107
     */
108
    protected function getDockerMagentoRootDir()
109
    {
110
        return Robo::config()->get(sprintf('%s.%s.%s', RoboFile::DOCKER, RoboFile::DIRS, RoboFile::DEPLOY));
111
    }
112
113
    /**
114
     * Returns the synchronization source directory inside the docker container.
115
     *
116
     * @return string The synchronization source directory
117
     */
118
    protected function getDockerSyncSrcDir()
119
    {
120
        return Robo::config()->get(sprintf('%s.%s.%s', RoboFile::DOCKER, RoboFile::DIRS, RoboFile::SRC));
121
    }
122
123
    /**
124
     * Returns the synchronization destination directory inside the docker container.
125
     *
126
     * @return string The synchronization destination directory
127
     */
128
    protected function getDockerSyncDestDir()
129
    {
130
        return Robo::config()->get(sprintf('%s.%s.%s', RoboFile::DOCKER, RoboFile::DIRS, RoboFile::DEST));
131
    }
132
133
    /**
134
     * Run's the composer install command.
135
     *
136
     * @return void
137
     */
138
    public function composerInstall()
139
    {
140
        // optimize autoloader with custom path
141
        $this->taskComposerInstall()
142
             ->preferDist()
143
             ->optimizeAutoloader()
144
             ->run();
145
    }
146
147
    /**
148
     * Run's the composer update command.
149
     *
150
     * @return void
151
     */
152
    public function composerUpdate()
153
    {
154
        // optimize autoloader with custom path
155
        $this->taskComposerUpdate()
156
             ->preferDist()
157
             ->optimizeAutoloader()
158
             ->run();
159
    }
160
161
    /**
162
     * Clean up the environment for a new build.
163
     *
164
     * @return void
165
     */
166
    public function clean()
167
    {
168
        $this->taskDeleteDir($this->getTargetDir())->run();
169
    }
170
171
    /**
172
     * Prepare's the environment for a new build.
173
     *
174
     * @return void
175
     */
176
    public function prepare()
177
    {
178
        $this->taskFileSystemStack()
179
             ->mkdir($this->getTargetDir())
180
             ->mkdir($this->getReportsDir())
181
             ->run();
182
    }
183
184
    /**
185
     * Run's the PHPMD.
186
     *
187
     * @return void
188
     */
189
    public function runMd()
190
    {
191
192
        // run the mess detector
193
        $this->_exec(
194
            sprintf(
195
                '%s/bin/phpmd %s xml phpmd.xml --reportfile %s/reports/pmd.xml --ignore-violations-on-exit',
196
                $this->getVendorDir(),
197
                $this->getSrcDir(),
198
                $this->getTargetDir()
199
            )
200
        );
201
    }
202
203
    /**
204
     * Run's the PHPCPD.
205
     *
206
     * @return void
207
     */
208
    public function runCpd()
209
    {
210
211
        // run the copy past detector
212
        $this->_exec(
213
            sprintf(
214
                '%s/bin/phpcpd %s --log-pmd %s/reports/pmd-cpd.xml',
215
                $this->getVendorDir(),
216
                $this->getSrcDir(),
217
                $this->getTargetDir()
218
            )
219
        );
220
    }
221
222
    /**
223
     * Run's the PHPCodeSniffer.
224
     *
225
     * @return void
226
     */
227
    public function runCs()
228
    {
229
230
        // run the code sniffer
231
        $this->_exec(
232
            sprintf(
233
                '%s/bin/phpcs -n --report-full --extensions=php --standard=phpcs.xml --report-checkstyle=%s/reports/phpcs.xml %s',
234
                $this->getVendorDir(),
235
                $this->getTargetDir(),
236
                $this->getSrcDir()
237
            )
238
        );
239
    }
240
241
    /**
242
     * Run's the PHPUnit tests.
243
     *
244
     * @return void
245
     */
246
    public function runTests()
247
    {
248
249
        // run PHPUnit
250
        $this->taskPHPUnit(sprintf('%s/bin/phpunit', $this->getVendorDir()))
251
             ->configFile('phpunit.xml')
252
             ->run();
253
    }
254
255
    /**
256
     * Deploy's the extension to it's target directory.
257
     *
258
     * @return void
259
     */
260
    public function deploy()
261
    {
262
        $this->taskCopyDir(array($this->getSrcDir() => $this->getDeployDir()))->run();
263
    }
264
265
    /**
266
     * Deploy's the extension to it's target directory in the specified docker container.
267
     *
268
     * @return void
269
     */
270
    public function dockerDeploy()
271
    {
272
273
        // copy the file itself
274
        $this->taskExec('docker')
275
             ->arg('cp')
276
             ->arg(sprintf('%s/app', $this->getSrcDir()))
277
             ->arg(sprintf('%s:%s', $this->getTargetContainer(), $this->getDockerSyncDestDir()))
278
             ->run();
279
    }
280
281
    /**
282
     * Start's the synchronization between the local sources and the Magento 2 instance
283
     * inside the container.
284
     *
285
     * @return void
286
     */
287
    public function dockerSync()
288
    {
289
290
        // copy the sources to the container
291
        $this->dockerDeploy();
292
293
        // start syncing the sources
294
        $this->taskExec('docker')
295
             ->arg('exec')
296
             ->arg($this->getTargetContainer())
297
             ->arg('bash')
298
             ->arg('-c')
299
             ->arg(
300
                 sprintf(
301
                     'cd %s && vendor/bin/robo sync %s %s',
302
                     $this->getDockerMagentoRootDir(),
303
                     $this->getDockerSyncSrcDir(),
304
                     $this->getDockerSyncDestDir()
305
                 )
306
             )
307
             ->run();
308
    }
309
310
    /**
311
     * Invokes the Magento 2 setup:upgrade command inside the docker container.
312
     *
313
     * @params array $args The arguments to pass to the bin/magento script inside the docker container
314
     *
315
     * @return void
316
     */
317 View Code Duplication
    public function dockerMagento(array $args)
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...
318
    {
319
320
        // if not argument has been passed, execute the info command
321
        if (sizeof($args) === 0) {
322
            $args = array('help');
323
        }
324
325
        // start syncing the sources
326
        $this->taskExec('docker')
327
             ->arg('exec')
328
             ->arg($this->getTargetContainer())
329
             ->arg('bash')
330
             ->arg('-c')
331
             ->arg(sprintf('cd %s && chmod +x bin/magento && bin/magento %s', $this->getDockerMagentoRootDir(), implode(' ', $args)))
332
             ->run();
333
    }
334
335
    /**
336
     * Invokes the passed Composer command inside the Magento root directory of the docker container.
337
     *
338
     * @params array $args The arguments to pass to the composer script inside the docker container
339
     *
340
     * @return void
341
     */
342 View Code Duplication
    public function dockerComposer(array $args)
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...
343
    {
344
345
        // if not argument has been passed, execute the info command
346
        if (sizeof($args) === 0) {
347
            $args = array('help');
348
        }
349
350
        // start syncing the sources
351
        $this->taskExec('docker')
352
             ->arg('exec')
353
             ->arg($this->getTargetContainer())
354
             ->arg('bash')
355
             ->arg('-c')
356
             ->arg(sprintf('cd %s && composer %s', $this->getDockerMagentoRootDir(), implode(' ', $args)))
357
             ->run();
358
    }
359
360
    /**
361
     * The complete build process.
362
     *
363
     * @return void
364
     */
365
    public function build()
366
    {
367
        $this->clean();
368
        $this->prepare();
369
        $this->runCs();
370
        $this->runCpd();
371
        $this->runMd();
372
        $this->runTests();
373
    }
374
}
375