Issues (131)

Security Analysis    not enabled

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.

Composer/ScriptHandler.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
2
3
namespace Admingenerator\GeneratorBundle\Composer;
4
5
use Symfony\Component\Process\Process;
6
use Symfony\Component\Process\PhpExecutableFinder;
7
use Composer\Script\CommandEvent;
8
9
/**
10
 * Class ScriptHandler
11
 *
12
 * Inspired from SensioDistributionBundle ScriptHandler
13
 *
14
 * @package Admingenerator\GeneratorBundle\Composer
15
 */
16
class ScriptHandler
17
{
18
    /**
19
     * Installs the assets under the admin/components directory into web root directory.
20
     *
21
     * @param $event CommandEvent A instance
22
     */
23
    public static function installAssets(CommandEvent $event)
24
    {
25
        $options = self::getOptions($event);
26
        $consoleDir = self::getConsoleDir($event, 'install Generator assets');
27
        if (null === $consoleDir) {
28
            return;
29
        }
30
        $webDir = $options['symfony-web-dir'];
31
        $symlink = '';
0 ignored issues
show
$symlink is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
32
33
        if (!self::hasDirectory($event, 'symfony-web-dir', $webDir, 'install Generator assets')) {
34
            return;
35
        }
36
        static::executeCommand($event, $consoleDir, 'admin:assets-install');
37
    }
38
39
    /**
40
     * @param string $configName
41
     * @param string $actionName
42
     */
43
    protected static function hasDirectory(CommandEvent $event, $configName, $path, $actionName)
44
    {
45
        if (!is_dir($path)) {
46
            $event->getIO()->write(sprintf('The %s (%s) specified in composer.json was not found in %s, can not %s.', $configName, $path, getcwd(), $actionName));
47
48
            return false;
49
        }
50
51
        return true;
52
    }
53
54
    /**
55
     * @param string $consoleDir
56
     * @param string $cmd
57
     */
58
    protected static function executeCommand(CommandEvent $event, $consoleDir, $cmd, $timeout = 300)
59
    {
60
        $php = escapeshellarg(self::getPhp(false));
61
        $phpArgs = implode(' ', array_map('escapeshellarg', self::getPhpArguments()));
62
        $console = escapeshellarg($consoleDir.'/console');
63
        if ($event->getIO()->isDecorated()) {
64
            $console .= ' --ansi';
65
        }
66
        $process = new Process($php.($phpArgs ? ' '.$phpArgs : '').' '.$console.' '.$cmd, null, null, null, $timeout);
67
        $process->run(function ($type, $buffer) use ($event) { $event->getIO()->write($buffer, false); });
68
        if (!$process->isSuccessful()) {
69
            throw new \RuntimeException(sprintf('An error occurred when executing the "%s" command.', escapeshellarg($cmd)));
70
        }
71
    }
72
73
    protected static function getOptions(CommandEvent $event)
74
    {
75
        $options = $event->getComposer()->getPackage()->getExtra();
76
        $options['process-timeout'] = $event->getComposer()->getConfig()->get('process-timeout');
77
78
        return $options;
79
    }
80
81
    protected static function getPhp($includeArgs = true)
82
    {
83
        $phpFinder = new PhpExecutableFinder();
84
        if (!$phpPath = $phpFinder->find($includeArgs)) {
85
            throw new \RuntimeException('The php executable could not be found, add it to your PATH environment variable and try again');
86
        }
87
88
        return $phpPath;
89
    }
90
91
    protected static function getPhpArguments()
92
    {
93
        $arguments = array();
94
        $phpFinder = new PhpExecutableFinder();
95
        if (method_exists($phpFinder, 'findArguments')) {
96
            $arguments = $phpFinder->findArguments();
97
        }
98
        if (false !== $ini = php_ini_loaded_file()) {
99
            $arguments[] = '--php-ini='.$ini;
100
        }
101
102
        return $arguments;
103
    }
104
105
    /**
106
     * Returns a relative path to the directory that contains the `console` command.
107
     *
108
     * @param CommandEvent $event      The command event.
109
     * @param string       $actionName The name of the action
110
     *
111
     * @return string|null The path to the console directory, null if not found.
112
     */
113
    protected static function getConsoleDir(CommandEvent $event, $actionName)
114
    {
115
        $options = self::getOptions($event);
116
        if (self::useNewDirectoryStructure($options)) {
117
            if (!self::hasDirectory($event, 'symfony-bin-dir', $options['symfony-bin-dir'], $actionName)) {
118
                return;
119
            }
120
121
            return $options['symfony-bin-dir'];
122
        }
123
        if (!self::hasDirectory($event, 'symfony-app-dir', $options['symfony-app-dir'], 'execute command')) {
124
            return;
125
        }
126
127
        return $options['symfony-app-dir'];
128
    }
129
130
    /**
131
     * Returns true if the new directory structure is used.
132
     *
133
     * @param array $options Composer options
134
     *
135
     * @return bool
136
     */
137
    protected static function useNewDirectoryStructure(array $options)
138
    {
139
        return isset($options['symfony-var-dir']) && is_dir($options['symfony-var-dir']);
140
    }
141
}
142