Issues (22)

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/Util/ArgumentProcessor.php (1 issue)

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
namespace Consolidation\SiteProcess\Util;
3
4
use Consolidation\SiteAlias\SiteAliasInterface;
5
use Symfony\Component\Process\Process;
6
use Consolidation\SiteProcess\Transport\TransportInterface;
7
8
/**
9
 * ArgumentProcessor takes a set of arguments and options from the caller
10
 * and processes them with the provided site alias to produce a final
11
 * executable command that will run either locally or on a remote system,
12
 * as applicable.
13
 */
14
class ArgumentProcessor
15
{
16
    /**
17
     * selectArgs selects the appropriate set of arguments for the command
18
     * to be executed and orders them as needed.
19
     *
20
     * @param SiteAliasInterface $siteAlias Description of
21
     * @param array $args Command and arguments to execute (source)
22
     * @param array $options key / value pair of option and value in include
23
     *   in final arguments
24
     * @param array $optionsPassedAsArgs key / value pair of option and value
25
     *   to include in final arguments after the '--' argument.
26
     * @return array Command and arguments to execute
27
     */
28
    public function selectArgs(SiteAliasInterface $siteAlias, $args, $options = [], $optionsPassedAsArgs = [])
0 ignored issues
show
The parameter $siteAlias 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...
29
    {
30
        // Split args into three arrays separated by the `--`
31
        list($leadingArgs, $dashDash, $remaingingArgs) = $this->findArgSeparator($args);
32
        $convertedOptions = $this->convertOptions($options);
33
        $convertedOptionsPassedAsArgs = $this->convertOptions($optionsPassedAsArgs);
34
35
        // If the caller provided options that should be passed as args, then we
36
        // always need a `--`, whether or not one existed to begin with in $args
37
        if (!empty($convertedOptionsPassedAsArgs)) {
38
            $dashDash = ['--'];
39
        }
40
41
        // Combine our separated args in the correct order. $dashDash will
42
        // always be `['--']` if $optionsPassedAsArgs or $remaingingArgs are
43
        // not empty, and otherwise will usually be empty.
44
        return array_merge(
45
            $leadingArgs,
46
            $convertedOptions,
47
            $dashDash,
48
            $convertedOptionsPassedAsArgs,
49
            $remaingingArgs
50
        );
51
    }
52
53
    /**
54
     * findArgSeparator finds the "--" argument in the provided arguments list,
55
     * if present, and returns the arguments in three sets.
56
     *
57
     * @return array of three arrays, leading, "--" and trailing
58
     */
59
    protected function findArgSeparator($args)
60
    {
61
        $pos = array_search('--', $args);
62
        if ($pos === false) {
63
            return [$args, [], []];
64
        }
65
66
        return [
67
            array_slice($args, 0, $pos),
68
            ['--'],
69
            array_slice($args, $pos + 1),
70
        ];
71
    }
72
73
    /**
74
     * convertOptions takes an associative array of options (key / value) and
75
     * converts it to an array of strings in the form --key=value.
76
     *
77
     * @param array $options in key => value form
78
     * @return array options in --option=value form
79
     */
80
    protected function convertOptions($options)
81
    {
82
        $result = [];
83
        foreach ($options as $option => $value) {
84
            if ($value === true || $value === null) {
85
                $result[] = "--$option";
86
            } elseif ($value === false) {
87
                // Ignore this option.
88
            } else {
89
                $result[] = "--{$option}={$value}";
90
            }
91
        }
92
93
        return $result;
94
    }
95
}
96