Issues (5)

Security Analysis    not enabled

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/Pipeline.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
2
3
namespace Imanghafoori\Middlewarize;
4
5
use InvalidArgumentException;
6
use Illuminate\Pipeline\Pipeline as CorePipe;
7
8
class Pipeline extends CorePipe
9
{
10
    /**
11
     * Set the array of pipes.
12
     *
13
     * @param  callable|array|string  $pipes
14
     * @return \Illuminate\Pipeline\Pipeline
15
     */
16 12
    public function through($pipes)
17
    {
18 12
        $pipes = is_callable($pipes) ? [$pipes] : $pipes;
19 12
        $this->pipes = is_array($pipes) ? $pipes : func_get_args();
20
21 12
        return $this;
22
    }
23
24
    /**
25
     * Get a Closure that represents a slice of the application onion.
26
     *
27
     * @return \Closure
28
     */
29 12
    protected function carry()
30
    {
31
        return function ($stack, $pipe) {
32
            return function ($passable) use ($stack, $pipe) {
33 12
                if (is_callable($pipe)) {
34
                    // If the pipe is an instance of a Closure, we will just call it directly but
35
                    // otherwise we'll resolve the pipes out of the container and call it with
36
                    // the appropriate method and arguments, returning the results back out.
37 3
                    return $pipe($passable, $stack);
38 10
                } elseif (is_string($pipe)) {
39 8
                    [$name, $parameters] = $this->parsePipeString($pipe);
0 ignored issues
show
The variable $name seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?

This error can happen if you refactor code and forget to move the variable initialization.

Let’s take a look at a simple example:

function someFunction() {
    $x = 5;
    echo $x;
}

The above code is perfectly fine. Now imagine that we re-order the statements:

function someFunction() {
    echo $x;
    $x = 5;
}

In that case, $x would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.

Loading history...
The variable $parameters seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?

This error can happen if you refactor code and forget to move the variable initialization.

Let’s take a look at a simple example:

function someFunction() {
    $x = 5;
    echo $x;
}

The above code is perfectly fine. Now imagine that we re-order the statements:

function someFunction() {
    echo $x;
    $x = 5;
}

In that case, $x would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.

Loading history...
40
41
                    // If the pipe is a string we will parse the string and resolve the class out
42
                    // of the dependency injection container. We can then build a callable and
43
                    // execute the pipe function giving in the parameters that are required.
44 8
                    $name = explode('@', $name);
0 ignored issues
show
The variable $name seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?

This error can happen if you refactor code and forget to move the variable initialization.

Let’s take a look at a simple example:

function someFunction() {
    $x = 5;
    echo $x;
}

The above code is perfectly fine. Now imagine that we re-order the statements:

function someFunction() {
    echo $x;
    $x = 5;
}

In that case, $x would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.

Loading history...
45 8
                    $pipe = $this->getContainer()->make($name[0]);
0 ignored issues
show
Consider using a different name than the imported variable $pipe, or did you forget to import by reference?

It seems like you are assigning to a variable which was imported through a use statement which was not imported by reference.

For clarity, we suggest to use a different name or import by reference depending on whether you would like to have the change visibile in outer-scope.

Change not visible in outer-scope

$x = 1;
$callable = function() use ($x) {
    $x = 2; // Not visible in outer scope. If you would like this, how
            // about using a different variable name than $x?
};

$callable();
var_dump($x); // integer(1)

Change visible in outer-scope

$x = 1;
$callable = function() use (&$x) {
    $x = 2;
};

$callable();
var_dump($x); // integer(2)
Loading history...
46
47 8
                    $parameters = array_merge([$passable, $stack], $parameters);
0 ignored issues
show
The variable $parameters seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?

This error can happen if you refactor code and forget to move the variable initialization.

Let’s take a look at a simple example:

function someFunction() {
    $x = 5;
    echo $x;
}

The above code is perfectly fine. Now imagine that we re-order the statements:

function someFunction() {
    echo $x;
    $x = 5;
}

In that case, $x would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.

Loading history...
48 2
                } elseif (is_object($pipe)) {
49
                    // If the pipe is already an object we'll just make a callable and pass it to
50
                    // the pipe as-is. There is no need to do any extra parsing and formatting
51
                    // since the object we're given was already a fully instantiated object.
52 1
                    $parameters = [$passable, $stack];
53
                } else {
54 1
                    throw new InvalidArgumentException(sprintf('A pipe must be an object, a string or a callable. %s given', gettype($pipe)));
55
                }
56
57 9
                $method = $name[1] ?? $this->method;
58
59 9
                return method_exists($pipe, $method)
60 9
                    ? $pipe->{$method}(...$parameters)
61 9
                    : $pipe(...$parameters);
62 12
            };
63 12
        };
64
    }
65
}
66