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/Adapter/ArgsFormatInputDefinition.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\Adapter;
13
14
use Symfony\Component\Console\Input\InputArgument;
15
use Symfony\Component\Console\Input\InputDefinition;
16
use Symfony\Component\Console\Input\InputOption;
17
use Webmozart\Console\Api\Args\Format\ArgsFormat;
18
use Webmozart\Console\Api\Args\Format\Argument;
19
use Webmozart\Console\Api\Args\Format\CommandName;
20
use Webmozart\Console\Api\Args\Format\CommandOption;
21
use Webmozart\Console\Api\Args\Format\Option;
22
23
/**
24
 * Adapts an {@link ArgsFormat} instance to Symfony's {@link InputDefinition}
25
 * API.
26
 *
27
 * @since  1.0
28
 *
29
 * @author Bernhard Schussek <[email protected]>
30
 */
31
class ArgsFormatInputDefinition extends InputDefinition
32
{
33
    /**
34
     * @var CommandName[]
35
     */
36
    private $commandNames = array();
37
38
    /**
39
     * Creates a new adapter.
40
     *
41
     * @param ArgsFormat $format The adapted format.
42
     */
43 322
    public function __construct(ArgsFormat $format)
44
    {
45 322
        parent::__construct();
46
47 322
        $i = 1;
48
49 322
        foreach ($format->getCommandNames() as $commandName) {
50
            do {
51 308
                $argName = 'cmd'.$i++;
52 308
            } while ($format->hasArgument($argName));
53
54 308
            $this->addArgument($argument = $this->adaptCommandName($commandName, $argName));
55
56 308
            $this->commandNames[$argument->getName()] = $commandName;
57
        }
58
59 322
        foreach ($format->getCommandOptions() as $commandOption) {
60 87
            $this->addOption($this->adaptCommandOption($commandOption));
61
        }
62
63 322
        foreach ($format->getOptions() as $option) {
64 272
            $this->addOption($this->adaptOption($option));
65
        }
66
67 322
        foreach ($format->getArguments() as $argument) {
68 269
            $this->addArgument($this->adaptArgument($argument));
69
        }
70 322
    }
71
72
    /**
73
     * Returns the command names indexed by their argument names.
74
     *
75
     * @return CommandName[] The command names.
76
     */
77 297
    public function getCommandNamesByArgumentName()
78
    {
79 297
        return $this->commandNames;
80
    }
81
82
    /**
83
     * Creates an input argument for the given command name.
84
     *
85
     * @param CommandName $commandName The command name.
86
     * @param string      $argName     The name of the added argument.
87
     *
88
     * @return InputArgument The created input argument.
89
     */
90 308
    private function adaptCommandName(CommandName $commandName, $argName)
0 ignored issues
show
The parameter $commandName is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
91
    {
92 308
        return new InputArgument($argName, InputArgument::REQUIRED);
93
    }
94
95
    /**
96
     * Creates an input option for the given command option.
97
     *
98
     * @param CommandOption $commandOption The command option.
99
     *
100
     * @return InputOption The created input option.
101
     */
102 87
    private function adaptCommandOption(CommandOption $commandOption)
103
    {
104 87
        return new InputOption($commandOption->getLongName(), $commandOption->getShortName());
105
    }
106
107
    /**
108
     * Creates an input option for the given option.
109
     *
110
     * @param Option $option The option.
111
     *
112
     * @return InputOption The created input option.
113
     */
114 272
    private function adaptOption(Option $option)
115
    {
116 272
        $mode = null;
117
118 272
        if ($option->isMultiValued()) {
119 1
            $mode |= InputOption::VALUE_IS_ARRAY;
120
        }
121
122 272
        if ($option->isValueOptional()) {
123 264
            $mode |= InputOption::VALUE_OPTIONAL;
124
        }
125
126 272
        if ($option->isValueRequired()) {
127 4
            $mode |= InputOption::VALUE_REQUIRED;
128
        }
129
130 272
        return new InputOption($option->getLongName(), $option->getShortName(), $mode, $option->getDescription(), $option->getDefaultValue());
131
    }
132
133
    /**
134
     * Creates an input argument for the given argument.
135
     *
136
     * @param Argument $argument The argument.
137
     *
138
     * @return InputArgument The created input argument.
139
     */
140 269
    private function adaptArgument(Argument $argument)
141
    {
142 269
        $mode = null;
143
144 269
        if ($argument->isMultiValued()) {
145 5
            $mode |= InputArgument::IS_ARRAY;
146
        }
147
148 269
        if ($argument->isOptional()) {
149 261
            $mode |= InputArgument::OPTIONAL;
150
        }
151
152 269
        if ($argument->isRequired()) {
153 8
            $mode |= InputArgument::REQUIRED;
154
        }
155
156 269
        return new InputArgument($argument->getName(), $mode, $argument->getDescription(), $argument->getDefaultValue());
157
    }
158
}
159