GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (5)

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/Install.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 declare(strict_types = 1);
2
3
namespace ApiClients\Tools\Installer;
4
5
use InvalidArgumentException;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Symfony\Component\Console\Style\SymfonyStyle;
10
use Symfony\Component\Console\Terminal;
11
use Throwable;
12
use function Composed\package;
13
use function igorw\get_in;
14
15
final class Install extends Command
16
{
17
    const COMMAND = 'install';
18
19
    /**
20
     * @var array
21
     */
22
    private $yaml;
23
24
    public function setYaml(array $yaml): Install
25
    {
26
        $this->yaml = $yaml;
27
28
        return $this;
29
    }
30
31
    protected function execute(InputInterface $input, OutputInterface $output)
32
    {
33
        if ($this->yaml === null) {
34
            throw new InvalidArgumentException('Missing configuration');
35
        }
36
37
        $style = new SymfonyStyle($input, $output);
38
39
        $style->newLine(2);
40
        $this->asciiArt($style);
41
        $style->newLine(2);
42
43
        $style->title($this->yaml['text']['welcome']);
44
45
        /**
46
         * Launchpad, the retry goto point.
47
         */
48
        retry:
49
        $style->section('Please answer the following questions.');
50
51
        $replacements = [];
52
        $table = [];
53
54
        foreach ($this->yaml['questions'] as $identifier => $question) {
55
            $replacements[$identifier] = $style->ask(
56
                $question['question'],
57
                get_in($question, ['default'], '')
58
            );
59
60
            if (empty($replacements[$identifier]) ||
61
                (isset($question['validate']) && is_callable($question['validate']))
62
            ) {
63
                while (!$this->validate($question['validate'], $replacements[$identifier]) ||
64
                    empty($replacements[$identifier])
65
                ) {
66
                    $replacements[$identifier] = $style->ask(
67
                        'Invalid response please try again, ' . $question['question'],
68
                        get_in($question, ['default'], '')
69
                    );
70
                }
71
            }
72
73
            $table[] = [
74
                $question['description'],
75
                $replacements[$identifier],
76
            ];
77
        }
78
79
        $style->section('Summary:');
80
        $style->table(
81
            [
82
                'What',
83
                'Value',
84
            ],
85
            $table
86
        );
87
88
        $installNow = $style->choice(
89
            'All settings correct?',
90
            [
91
                'y' => 'Yes',
92
                'n' => 'Change settings',
93
                'q' => 'Cancel installation',
94
            ],
95
            'Yes'
96
        );
97
98
        switch (strtolower($installNow)) {
99
            case 'y':
100
            {
101
                $style->text('Creating your middleware package now.');
102
                /** @var callable $operation */
103
                foreach ($this->yaml['operations'] as $operation) {
104
                    $operation()->operate($replacements, $this->yaml['config'] ?? [], $style);
105
                }
106
                $style->section('Package creation has been successfully.');
107
                $style->text('Next up we\'re running composer update twice to ensure all traces of this installer are gone.');
108
                $style->text('(The first time to update composer.lock, and the second time to update the autoloader.)');
109
                $style->text('After which your new package is ready to be developed.');
110
                $style->success('Installer done.');
111
                break;
112
            }
113
114
            case 'n':
115
            {
116
                /**
117
                 * Retry, goto launchpad.
118
                 */
119
                goto retry;
120
                break;
0 ignored issues
show
break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
121
            }
122
123
            case 'q':
124
            {
125
                $style->error('Installation canceled.');
126
127
                return 9;
128
            }
129
        }
130
131
        return 0;
132
    }
133
134
    private function validate(callable $validator, $input): bool
135
    {
136
        try {
137
            return $validator($input);
138
        } catch (Throwable $t) {
139
            return false;
140
        }
141
    }
142
143
    private function asciiArt(SymfonyStyle $style)
144
    {
145
        if (!isset($this->yaml['text']['ascii_art_file'])) {
146
            return;
147
        }
148
149
        $package = $this->yaml['package'];
150
        if (isset($this->yaml['text']['ascii_art_package'])) {
151
            $package = $this->yaml['text']['ascii_art_package'];
152
        }
153
        $path = package($package)->getPath() . DIRECTORY_SEPARATOR;
154
155
        $files = $this->yaml['text']['ascii_art_file'];
156
        if (!is_array($files)) {
157
            $files = [$files];
158
        }
159
160
        $sortedFiles = [];
161
        foreach ($files as $file) {
162
            $artWidth = 0;
163
            $contents = file($path . $file);
164
            foreach ($contents as $line) {
165
                $line = strip_tags($line);
166
                $lineLength = mb_strlen($line);
167
                if ($lineLength > $artWidth) {
168
                    $artWidth = $lineLength;
169
                }
170
            }
171
            $sortedFiles[$artWidth] = $path . $file;
172
        }
173
174
        $width = (new Terminal())->getWidth();
175
        $sortedFiles = array_filter($sortedFiles, function ($artWidth) use ($width) {
176
            return $width >= $artWidth;
177
        }, ARRAY_FILTER_USE_KEY);
178
179
        krsort($sortedFiles);
180
        $file = current($sortedFiles);
181
182
        foreach (file($file) as $line) {
183
            $style->write($line);
184
        }
185
    }
186
}
187