Issues (283)

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/UI/Help/ApplicationHelp.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
/*
4
 * This file is part of the webmozart/console package.
5
 *
6
 * (c) Bernhard Schussek <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Webmozart\Console\UI\Help;
13
14
use Webmozart\Console\Api\Application\Application;
15
use Webmozart\Console\Api\Args\Format\ArgsFormat;
16
use Webmozart\Console\Api\Args\Format\Argument;
17
use Webmozart\Console\Api\Command\Command;
18
use Webmozart\Console\Api\Command\CommandCollection;
19
use Webmozart\Console\UI\Component\EmptyLine;
20
use Webmozart\Console\UI\Component\LabeledParagraph;
21
use Webmozart\Console\UI\Component\NameVersion;
22
use Webmozart\Console\UI\Component\Paragraph;
23
use Webmozart\Console\UI\Layout\BlockLayout;
24
25
/**
26
 * Renders the help of a console application.
27
 *
28
 * @since  1.0
29
 *
30
 * @author Bernhard Schussek <[email protected]>
31
 */
32
class ApplicationHelp extends AbstractHelp
33
{
34
    /**
35
     * @var Application
36
     */
37
    private $application;
38
39
    /**
40
     * Creates the help.
41
     *
42
     * @param Application $application The application to render.
43
     */
44 19
    public function __construct(Application $application)
45
    {
46 19
        $this->application = $application;
47 19
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52 19
    protected function renderHelp(BlockLayout $layout)
53
    {
54 19
        $help = $this->application->getConfig()->getHelp();
55 19
        $commands = $this->application->getNamedCommands();
56 19
        $globalArgsFormat = $this->application->getGlobalArgsFormat();
57
58 19
        $argsFormat = ArgsFormat::build()
59 19
            ->addArgument(new Argument('command', Argument::REQUIRED, 'The command to execute'))
60 19
            ->addArgument(new Argument('arg', Argument::MULTI_VALUED, 'The arguments of the command'))
61
            // Global arguments are rendered in the command usage only
62 19
            ->addOptions($globalArgsFormat->getOptions())
63 19
            ->getFormat();
64
65 19
        $this->renderName($layout, $this->application);
66 19
        $this->renderUsage($layout, $this->application, $argsFormat);
67 19
        $this->renderArguments($layout, $argsFormat->getArguments());
68
69 19
        if ($argsFormat->hasOptions()) {
70 14
            $this->renderGlobalOptions($layout, $argsFormat->getOptions());
71
        }
72
73 19
        if (!$commands->isEmpty()) {
74 13
            $this->renderCommands($layout, $commands);
75
        }
76
77 19
        if ($help) {
78 1
            $this->renderDescription($layout, $help);
79
        }
80 19
    }
81
82
    /**
83
     * Renders the application name.
84
     *
85
     * @param BlockLayout $layout      The layout.
86
     * @param Application $application The application.
87
     */
88 19
    protected function renderName(BlockLayout $layout, Application $application)
89
    {
90 19
        $layout->add(new NameVersion($application->getConfig()));
91 19
        $layout->add(new EmptyLine());
92 19
    }
93
94
    /**
95
     * Renders the "Usage" section.
96
     *
97
     * @param BlockLayout $layout      The layout.
98
     * @param Application $application The application to describe.
99
     * @param ArgsFormat  $argsFormat  The format of the console arguments.
100
     */
101 19
    protected function renderUsage(BlockLayout $layout, Application $application, ArgsFormat $argsFormat)
102
    {
103 19
        $appName = $application->getConfig()->getName();
104
105 19
        $layout->add(new Paragraph('<b>USAGE</b>'));
106 19
        $layout->beginBlock();
107
108 19
        $this->renderSynopsis($layout, $argsFormat, $appName);
109
110 19
        $layout->endBlock();
111 19
        $layout->add(new EmptyLine());
112 19
    }
113
114
    /**
115
     * Renders the "Commands" section.
116
     *
117
     * @param BlockLayout       $layout   The layout.
118
     * @param CommandCollection $commands The commands to describe.
119
     */
120 13 View Code Duplication
    protected function renderCommands(BlockLayout $layout, CommandCollection $commands)
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...
121
    {
122 13
        $layout->add(new Paragraph('<b>AVAILABLE COMMANDS</b>'));
123 13
        $layout->beginBlock();
124
125 13
        $commands = $commands->toArray();
126 13
        ksort($commands);
127
128 13
        foreach ($commands as $command) {
129 13
            $this->renderCommand($layout, $command);
130
        }
131
132 13
        $layout->endBlock();
133 13
        $layout->add(new EmptyLine());
134 13
    }
135
136
    /**
137
     * Renders a command in the "Commands" section.
138
     *
139
     * @param BlockLayout $layout  The layout.
140
     * @param Command     $command The command to describe.
141
     */
142 13
    protected function renderCommand(BlockLayout $layout, Command $command)
143
    {
144 13
        $description = $command->getConfig()->getDescription();
145 13
        $name = '<c1>'.$command->getName().'</c1>';
146
147 13
        $layout->add(new LabeledParagraph($name, $description));
148 13
    }
149
150
    /**
151
     * Renders the "Description" section.
152
     *
153
     * @param BlockLayout $layout The layout.
154
     * @param string      $help   The help text.
155
     */
156 1
    protected function renderDescription(BlockLayout $layout, $help)
157
    {
158
        $layout
159 1
            ->add(new Paragraph('<b>DESCRIPTION</b>'))
160 1
            ->beginBlock()
161 1
                ->add(new Paragraph($help))
162 1
            ->endBlock()
163 1
            ->add(new EmptyLine())
164
        ;
165 1
    }
166
}
167