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/Workflow.php (5 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 namespace Cerbero\Workflow;
2
3
use Cerbero\Workflow\Repositories\PipelineRepositoryInterface;
4
use Cerbero\Workflow\Inflectors\InflectorInterface;
5
use Cerbero\Workflow\Wrappers\DispatcherInterface;
6
use Illuminate\Contracts\Container\Container;
7
8
/**
9
 * Hub of the pipelines.
10
 *
11
 * @author	Andrea Marco Sartori
12
 */
13
class Workflow {
14
15
	/**
16
	 * @author	Andrea Marco Sartori
17
	 * @var		Cerbero\Workflow\Repositories\PipelineRepositoryInterface	$pipelines	Pipelines repository.
18
	 */
19
	protected $pipelines;
20
21
	/**
22
	 * @author	Andrea Marco Sartori
23
	 * @var		Cerbero\Workflow\Inflectors\InflectorInterface	$inflector	Inflector.
24
	 */
25
	protected $inflector;
26
27
	/**
28
	 * @author	Andrea Marco Sartori
29
	 * @var		Illuminate\Contracts\Container\Container	$container	Service container.
30
	 */
31
	protected $container;
32
33
	/**
34
	 * @author	Andrea Marco Sartori
35
	 * @var		Cerbero\Workflow\Wrappers\DispatcherInterface	$dispatcher	Bus dispatcher.
36
	 */
37
	protected $dispatcher;
38
	
39
	/**
40
	 * Set the dependencies.
41
	 *
42
	 * @author	Andrea Marco Sartori
43
	 * @param	Cerbero\Workflow\Repositories\PipelineRepositoryInterface	$pipelines
44
	 * @param	Cerbero\Workflow\Wrappers\DispatcherInterface	$dispatcher
45
	 * @param	Cerbero\Workflow\Inflectors\InflectorInterface	$inflector
46
	 * @param	Illuminate\Contracts\Container\Container	$container
47
	 * @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...
48
	 */
49
	public function __construct(
50
		PipelineRepositoryInterface $pipelines,
51
		InflectorInterface $inflector,
52
		Container $container,
53
		DispatcherInterface $dispatcher
54
	) {
55
		$this->pipelines  = $pipelines;
0 ignored issues
show
Documentation Bug introduced by
It seems like $pipelines of type object<Cerbero\Workflow\...ineRepositoryInterface> is incompatible with the declared type object<Cerbero\Workflow\...ineRepositoryInterface> of property $pipelines.

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...
56
		$this->inflector  = $inflector;
0 ignored issues
show
Documentation Bug introduced by
It seems like $inflector of type object<Cerbero\Workflow\...ors\InflectorInterface> is incompatible with the declared type object<Cerbero\Workflow\...ors\InflectorInterface> of property $inflector.

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...
57
		$this->container  = $container;
0 ignored issues
show
Documentation Bug introduced by
It seems like $container of type object<Illuminate\Contracts\Container\Container> is incompatible with the declared type object<Cerbero\Workflow\...ts\Container\Container> of property $container.

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...
58
		$this->dispatcher = $dispatcher;
0 ignored issues
show
Documentation Bug introduced by
It seems like $dispatcher of type object<Cerbero\Workflow\...rs\DispatcherInterface> is incompatible with the declared type object<Cerbero\Workflow\...rs\DispatcherInterface> 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...
59
	}
60
61
	/**
62
	 * Dynamically call pipelines.
63
	 *
64
	 * @author	Andrea Marco Sartori
65
	 * @param	string	$name
66
	 * @param	array	$arguments
67
	 * @return	mixed
68
	 */
69
	public function __call($name, $arguments)
70
	{
71
		$this->failIfNotExists($name);
72
73
		$this->inflector->of($name);
74
75
		return $this->dispatchWorkflow($name);
76
	}
77
78
	/**
79
	 * Throw an exception if the given workflow does not exist.
80
	 *
81
	 * @author	Andrea Marco Sartori
82
	 * @param	string	$workflow
83
	 * @return	void
84
	 */
85
	protected function failIfNotExists($workflow)
86
	{
87
		if( ! $this->pipelines->exists($workflow))
88
		{
89
			$error = "The workflow [$workflow] does not exist.";
90
91
			throw new \BadFunctionCallException($error);
92
		}
93
	}
94
95
	/**
96
	 * Dispatch the given workflow.
97
	 *
98
	 * @author	Andrea Marco Sartori
99
	 * @param	string	$workflow
100
	 * @return	mixed
101
	 */
102
	protected function dispatchWorkflow($workflow)
103
	{
104
		$job = $this->inflector->getJob();
105
106
		$request = $this->resolveRequest();
107
108
		$pipes = $this->pipelines->getPipesByPipeline($workflow);
109
110
		$parameters = $this->container->make('router')->current()->parameters();
111
112
		return $this->dispatcher->pipeThrough($pipes)->dispatchFrom($job, $request, $parameters);
113
	}
114
115
	/**
116
	 * Resolve the apter request.
117
	 *
118
	 * @author	Andrea Marco Sartori
119
	 * @return	Illuminate\Http\Request
120
	 */
121
	protected function resolveRequest()
122
	{
123
		if(class_exists($request = $this->inflector->getRequest()))
124
		{
125
			return $this->container->make($request);
126
		}
127
128
		return $this->container->make('Illuminate\Http\Request');
129
	}
130
131
}
132