Issues (30)

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

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
 * @author    jan huang <[email protected]>
4
 * @copyright 2016
5
 *
6
 * @see      https://www.github.com/janhuang
7
 * @see      https://fastdlabs.com
8
 */
9
10
namespace FastD;
11
12
use FastD\Http\Response;
13
use FastD\Testing\WebTestCase;
14
use PHPUnit_Extensions_Database_DataSet_ArrayDataSet;
15
use PHPUnit_Extensions_Database_DataSet_CompositeDataSet;
16
use PHPUnit_Extensions_Database_DataSet_IDataSet;
17
use Psr\Http\Message\ServerRequestInterface;
18
19
/**
20
 * Class TestCase.
21
 */
22
class TestCase extends WebTestCase
23
{
24
    protected $connection = 'default';
25
26
    /**
27
     * @var Application
28
     */
29
    protected $app;
30
31
    /**
32
     * Set up unit.
33
     */
34
    public function setUp()
35
    {
36
        $this->app = $this->createApplication();
37
        parent::setUp();
38
    }
39
40
    /**
41
     * @return Application
42
     */
43
    public function createApplication()
44
    {
45
        return new Application(getcwd());
46
    }
47
48
    /**
49
     * @param ServerRequestInterface $request
50
     * @param array                  $params
51
     * @param array                  $headers
52
     *
53
     * @return Response
54
     */
55
    public function handleRequest(ServerRequestInterface $request, array $params = [], array $headers = [])
56
    {
57
        if (!empty($params)) {
58
            if ('GET' === $request->getMethod()) {
59
                $request->withQueryParams($params);
60
            } elseif ('POST' === $request->getMethod()) {
61
                $request->withParsedBody($params);
62
            } else {
63
                $request->getBody()->write(http_build_query($params));
64
            }
65
        }
66
67
        if (!empty($headers)) {
68
            foreach ($headers as $name => $header) {
69
                $request->withAddedHeader($name, $header);
70
            }
71
        }
72
73
        return $this->app->handleRequest($request);
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->app->handleRequest($request); of type FastD\Http\Response|Symf...HttpFoundation\Response adds the type Symfony\Component\HttpFoundation\Response to the return on line 73 which is incompatible with the return type documented by FastD\TestCase::handleRequest of type FastD\Http\Response.
Loading history...
74
    }
75
76
    /**
77
     * Returns the test database connection.
78
     *
79
     * @return \PHPUnit_Extensions_Database_DB_IDatabaseConnection|null
80
     */
81
    protected function getConnection()
82
    {
83
        try {
84
            return $this->createDefaultDBConnection(database($this->connection)->pdo);
85
        } catch (\Exception $exception) {
86
            return null;
87
        }
88
    }
89
90
    /**
91
     * Returns the test dataset.
92
     *
93
     * @return PHPUnit_Extensions_Database_DataSet_IDataSet
94
     */
95
    protected function getDataSet()
96
    {
97
        $path = app()->getPath().'/database/dataset/'.$this->connection;
98
99
        if (!file_exists($path) && !empty($this->connection)) {
100
            $path = dirname($path);
101
        }
102
103
        $composite = new PHPUnit_Extensions_Database_DataSet_CompositeDataSet();
104
105
        foreach (glob($path.'/*') as $file) {
106
            $dataSet = load($file);
107
            if (empty($dataSet)) {
108
                $dataSet = [];
109
            }
110
            $tableName = pathinfo($file, PATHINFO_FILENAME);
111
            $composite->addDataSet(
112
                new PHPUnit_Extensions_Database_DataSet_ArrayDataSet(
113
                    [
114
                        $tableName => $dataSet,
115
                    ]
116
                )
117
            );
118
        }
119
120
        return $composite;
121
    }
122
}
123