Issues (3)

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/SymfonyToPsr15Bridge.php (2 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 TheCodingMachine\Psr15Bridge;
4
5
use Psr\Http\Server\MiddlewareInterface;
6
use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
7
use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;
8
use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface;
9
use Symfony\Component\HttpFoundation\Request;
10
use Symfony\Component\HttpFoundation\Response;
11
use Symfony\Component\HttpKernel\HttpKernelInterface;
12
13
/**
14
 * A Symfony middleware that can be used to access psr15 middlewares.
15
 */
16
class SymfonyToPsr15Bridge implements HttpKernelInterface
17
{
18
    /**
19
     * The psr15 middleware we bridge to.
20
     *
21
     * @var MiddlewareInterface
22
     */
23
    private $psr15Middleware;
24
25
    /**
26
     * @var HttpMessageFactoryInterface
27
     */
28
    private $httpMessageFactory;
29
    /**
30
     * @var HttpKernelInterface
31
     */
32
    private $nextSymfonyMiddleware;
33
    /**
34
     * @var HttpFoundationFactoryInterface
35
     */
36
    private $httpFoundationFactory;
37
38
    /**
39
     * @param HttpKernelInterface            $nextSymfonyMiddleware The next Symfony middleware to be called (after the psr15 middleware.
40
     * @param MiddlewareInterface            $psr15Middleware The psr15 middleware we bridge to.
41
     * @param HttpFoundationFactoryInterface $httpFoundationFactory The class in charge of translating PSR-7 request/response objects to Symfony objects. Defaults to Symfony default implementation
42
     * @param HttpMessageFactoryInterface    $httpMessageFactory    The class in charge of translating Symfony request/response objects to PSR-7 objects. Defaults to Symfony default implementation (that uses Diactoros)
43
     */
44
    public function __construct(HttpKernelInterface $nextSymfonyMiddleware, MiddlewareInterface $psr15Middleware, HttpFoundationFactoryInterface $httpFoundationFactory = null, HttpMessageFactoryInterface $httpMessageFactory = null)
45
    {
46
        $this->nextSymfonyMiddleware = $nextSymfonyMiddleware;
47
        $this->psr15Middleware = $psr15Middleware;
48
        $this->httpFoundationFactory = $httpFoundationFactory ?: new HttpFoundationFactory();
0 ignored issues
show
Documentation Bug introduced by
It seems like $httpFoundationFactory ?...HttpFoundationFactory() can also be of type object<Symfony\Bridge\Ps...\HttpFoundationFactory>. However, the property $httpFoundationFactory is declared as type object<TheCodingMachine\...dationFactoryInterface>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
49
        $this->httpMessageFactory = $httpMessageFactory ?: new DiactorosFactory();
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Bridge\PsrHttpMe...actory\DiactorosFactory has been deprecated with message: since symfony/psr-http-message-bridge 1.2, use PsrHttpFactory instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
50
    }
51
52
    /**
53
     * Handles a Request to convert it to a Response.
54
     *
55
     * When $catch is true, the implementation must catch all exceptions
56
     * and do its best to convert them to a Response instance.
57
     *
58
     * @param Request $request A Request instance
59
     * @param int     $type    The type of the request
60
     *                         (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST)
61
     * @param bool    $catch   Whether to catch exceptions or not
62
     *
63
     * @return Response A Response instance
64
     *
65
     * @throws \Exception When an Exception occurs during processing
66
     */
67
    public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true): Response
68
    {
69
        $psr7Request = $this->httpMessageFactory->createRequest($request);
70
71
        $psr7Response = $this->psr15Middleware->process($psr7Request,
72
            new Psr15ToSymfonyBridge($this->nextSymfonyMiddleware, $this->httpFoundationFactory, $this->httpMessageFactory));
73
74
        return $this->httpFoundationFactory->createResponse($psr7Response);
75
    }
76
}
77