Issues (11)

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/ElderBrother/Action/PhpCsFixerOld.php (1 issue)

Labels
Severity

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 uuf6429\ElderBrother\Action;
4
5
use Symfony\Component\Console\Input\InputInterface;
6
use Symfony\Component\Console\Output\OutputInterface;
7
use Symfony\Component\Process\Process;
8
use uuf6429\ElderBrother\Change\FileList;
9
10
/**
11
 * @deprecated Use PhpCsFixer class instead
12
 */
13
class PhpCsFixerOld extends ActionAbstract
14
{
15
    /**
16
     * @var FileList
17
     */
18
    protected $files;
19
20
    /**
21
     * @var string|null
22
     */
23
    protected $binFile;
24
25
    /**
26
     * @var string|null
27
     */
28
    protected $configFile;
29
30
    /**
31
     * @var bool
32
     */
33
    protected $addAutomatically;
34
35
    /**
36
     * Runs all the provided files through PHP-CS-Fixer, fixing any code style issues.
37
     *
38
     * @param FileList    $files            The files to check
39
     * @param string|null $binFile          (Optional, default is from vendor) File path to PHP-CS-Fixer binary
40
     * @param string|null $configFile       (Optional, default is project root) File path to PHP-CS-Fixer config
41
     * @param bool        $addAutomatically (Optional, default is true) Whether to add modified files to commit or not
42
     */
43
    public function __construct(FileList $files, $binFile = null, $configFile = null, $addAutomatically = true)
44
    {
45
        $this->files = $files;
46
        $this->binFile = $binFile ?: $this->getBinFile();
47
        $this->configFile = $configFile;
48
        $this->addAutomatically = $addAutomatically;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function getName()
55
    {
56
        return 'PHP Code Style Fixer (PhpCsFixerOld)';
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    public function isSupported()
63
    {
64
        if (!file_exists($this->binFile)) {
65
            $this->logger->warning(
66
                sprintf(
67
                    'PHP-CS-Fixer could not be found in: %s',
68
                    $this->binFile
69
                )
70
            );
71
72
            return false;
73
        }
74
75
        return true;
76
    }
77
78
    /**
79
     * {@inheritdoc}
80
     */
81
    public function execute(InputInterface $input, OutputInterface $output)
82
    {
83
        $files = $this->files->toArray();
84
85
        if (empty($files)) {
86
            return;
87
        }
88
89
        $progress = $this->createProgressBar($input, $output);
90
        $progress->start(count($files));
91
92
        $failed = [];
93
94
        foreach ($files as $file) {
95
            $progress->setMessage('Checking <info>' . $file . '</info>...');
96
97
            $process = new Process(
98
                sprintf(
99
                    'php -f %s -- fix %s %s',
100
                    escapeshellarg($this->binFile),
101
                    escapeshellarg($file),
102
                    $this->configFile ? ('--config-file=' . escapeshellarg($this->configFile)) : ''
103
                )
104
            );
105
            $process->run();
106
107
            switch ($process->getExitCode()) {
108
                case 0:
0 ignored issues
show
It seems like you are loosely comparing $process->getExitCode() of type integer|null to 0; this is ambiguous as not only 0 == 0 is true, but null == 0 is true, too. Consider using a strict comparison ===.
Loading history...
109
                    // file has been changed
110
                    if ($this->addAutomatically) {
111
                        exec('git add ' . escapeshellarg($file));
112
                    }
113
                    break;
114
                case 1:
115
                    // file not changed
116
                    break;
117
                default:
118
                    // some sort of error
119
                    $failed[$file] = explode("\n", str_replace(PHP_EOL, "\n", $process->getOutput()));
120
                    break;
121
            }
122
123
            $progress->advance();
124
        }
125
126
        if (count($failed)) {
127
            $message = 'PhpCsFixerOld failed for the following file(s):';
128
            foreach ($failed as $file => $result) {
129
                $message .= PHP_EOL . '- ' . $file . ':';
130
                $message .= PHP_EOL . ' - ' . implode(PHP_EOL . ' - ', $result);
131
            }
132
            throw new \RuntimeException($message);
133
        }
134
135
        $progress->setMessage('Finished.');
136
        $progress->finish();
137
    }
138
139
    /**
140
     * @return string
141
     */
142
    protected function getBinFile()
143
    {
144
        return PROJECT_ROOT . 'vendor'
145
            . DIRECTORY_SEPARATOR . 'friendsofphp'
146
            . DIRECTORY_SEPARATOR . 'php-cs-fixer'
147
            . DIRECTORY_SEPARATOR . 'php-cs-fixer';
148
    }
149
}
150