Issues (33)

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/Wrappers/MarshalDispatcher.php (3 issues)

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 Cerbero\Workflow\Wrappers;
4
5
use Exception;
6
use ArrayAccess;
7
use ReflectionClass;
8
use ReflectionParameter;
9
use Illuminate\Contracts\Bus\Dispatcher;
10
11
/**
12
 * Wrapper to marshal commands before dispatching them.
13
 *
14
 * @author	Andrea Marco Sartori
15
 */
16
class MarshalDispatcher implements DispatcherInterface
17
{
18
19
	/**
20
	 * @author	Andrea Marco Sartori
21
	 * @var		Illuminate\Contracts\Bus\Dispatcher	$dispatcher	Bus dispatcher.
22
	 */
23
	protected $dispatcher;
24
25
	/**
26
	 * @author	Andrea Marco Sartori
27
	 * @var		string  $command	Command to dispatch
28
	 */
29
	protected $command;
30
31
	/**
32
	 * @author	Andrea Marco Sartori
33
	 * @var		\ArrayAccess  $values	Parameters values
34
	 */
35
	protected $values;
36
	
37
	/**
38
	 * Set the dependencies.
39
	 *
40
	 * @author	Andrea Marco Sartori
41
	 * @param	Illuminate\Contracts\Bus\Dispatcher	$dispatcher
42
	 * @return	void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
43
	 */
44
	public function __construct(Dispatcher $dispatcher)
45
	{
46
		$this->dispatcher = $dispatcher;
0 ignored issues
show
Documentation Bug introduced by
It seems like $dispatcher of type object<Illuminate\Contracts\Bus\Dispatcher> is incompatible with the declared type object<Cerbero\Workflow\...ntracts\Bus\Dispatcher> of property $dispatcher.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
47
	}
48
49
	/**
50
     * Set the pipes commands should be piped through before dispatching.
51
     *
52
	 * @author	Andrea Marco Sartori
53
     * @param  array  $pipes
54
     * @return $this
55
     */
56
    public function pipeThrough(array $pipes)
57
    {
58
    	$this->dispatcher->pipeThrough($pipes);
59
60
    	return $this;
61
    }
62
63
    /**
64
     * Marshal a command and dispatch it.
65
     *
66
	 * @author	Andrea Marco Sartori
67
     * @param  mixed  $command
68
     * @param  \ArrayAccess  $source
69
     * @param  array  $extras
70
     * @return mixed
71
     */
72
    public function dispatchFrom($command, ArrayAccess $source, array $extras = [])
73
    {
74
    	$this->command = $command;
75
76
    	$this->values = array_merge((array) $source, $extras);
0 ignored issues
show
Documentation Bug introduced by
It seems like array_merge((array) $source, $extras) of type array is incompatible with the declared type object<ArrayAccess> of property $values.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
77
78
    	return $this->dispatcher->dispatch($this->marshal());
79
    }
80
81
    /**
82
     * Marshal the command to dispatch.
83
     *
84
	 * @author	Andrea Marco Sartori
85
     * @return mixed
86
     */
87
    protected function marshal()
88
    {
89
        $reflection = new ReflectionClass($this->command);
90
91
        $constructor = $reflection->getConstructor();
92
93
        $params = $this->getParamsToInject($constructor->getParameters());
94
95
        return $reflection->newInstanceArgs($params);
96
    }
97
98
    /**
99
     * Retrieve the arguments to inject into the command constructor.
100
     *
101
     * @author	Andrea Marco Sartori
102
     * @param	array	$parameters
103
     * @return	array
104
     */
105
    protected function getParamsToInject(array $parameters)
106
    {
107
        return array_map(function ($parameter)
108
        {
109
            return $this->grabParameter($parameter);
110
111
        }, $parameters);
112
    }
113
114
    /**
115
     * Get a parameter value for a marshaled command.
116
     *
117
	 * @author	Andrea Marco Sartori
118
     * @param  \ReflectionParameter  $parameter
119
     * @return mixed
120
     */
121
    protected function grabParameter(ReflectionParameter $parameter)
122
    {
123
        if (isset($this->values[$parameter->name]))
124
        {
125
            return $this->values[$parameter->name];
126
        }
127
128
        if ($parameter->isDefaultValueAvailable())
129
        {
130
            return $parameter->getDefaultValue();
131
        }
132
133
        throw new Exception("Unable to map parameter [{$parameter->name}] to command [{$this->command}]");
134
    }
135
136
}
137