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.

tests/BaseTest.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
namespace Spiral\Tests;
4
5
use Monolog\Handler\NullHandler;
6
use PHPUnit\Framework\TestCase;
7
use Psr\Log\LoggerInterface;
8
use Psr\Log\LoggerTrait;
9
use Psr\Log\LogLevel;
10
use Spiral\Core\Core;
11
use Spiral\Core\Traits\SharedTrait;
12
use Spiral\Statistics\Database\Sources\OccurrenceSource;
13
use Spiral\Statistics\DatetimeConverter;
14
use Spiral\Statistics\Extract;
15
use Spiral\Statistics\Track;
16
17
/**
18
 * @property \Spiral\Core\MemoryInterface             $memory
19
 * @property \Spiral\Core\ContainerInterface          $container
20
 * @property \Spiral\Debug\LogsInterface              $logs
21
 * @property \Spiral\Http\HttpDispatcher              $http
22
 * @property \Spiral\Console\ConsoleDispatcher        $console
23
 * @property \Spiral\Console\ConsoleDispatcher        $commands
24
 * @property \Spiral\Files\FilesInterface             $files
25
 * @property \Spiral\Tokenizer\TokenizerInterface     $tokenizer
26
 * @property \Spiral\Tokenizer\ClassesInterface       $locator
27
 * @property \Spiral\Tokenizer\InvocationsInterface   $invocationLocator
28
 * @property \Spiral\Views\ViewManager                $views
29
 * @property \Spiral\Translator\Translator            $translator
30
 * @property \Spiral\Database\DatabaseManager         $dbal
31
 * @property \Spiral\ORM\ORM                          $orm
32
 * @property \Spiral\Encrypter\EncrypterInterface     $encrypter
33
 * @property \Spiral\Database\Entities\Database       $db
34
 * @property \Spiral\Http\Cookies\CookieQueue         $cookies
35
 * @property \Spiral\Http\Routing\RouterInterface     $router
36
 * @property \Spiral\Pagination\PaginatorsInterface   $paginators
37
 * @property \Psr\Http\Message\ServerRequestInterface $request
38
 * @property \Spiral\Http\Request\InputManager        $input
39
 * @property \Spiral\Http\Response\ResponseWrapper    $response
40
 * @property \Spiral\Http\Routing\RouteInterface      $route
41
 * @property \Spiral\Security\PermissionsInterface    $permissions
42
 * @property \Spiral\Security\RulesInterface          $rules
43
 * @property \Spiral\Security\ActorInterface          $actor
44
 * @property \Spiral\Session\SessionInterface         $session
45
 */
46
abstract class BaseTest extends TestCase
47
{
48
    use SharedTrait;
49
50
    /**
51
     * @var TestApplication|Core
52
     */
53
    protected $app;
54
55
    public function setUp()
56
    {
57
        $root = __DIR__ . '/-app-/';
58
        $this->app = TestApplication::init(
0 ignored issues
show
Documentation Bug introduced by
It seems like \Spiral\Tests\TestApplic.../'), null, null, false) of type object<self> is incompatible with the declared type object<Spiral\Tests\Test...bject<Spiral\Core\Core> of property $app.

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
                'root'        => $root,
61
                'libraries'   => dirname(__DIR__) . '/vendor/',
62
                'application' => $root,
63
                'framework'   => dirname(__DIR__) . '/source/',
64
                'runtime'     => $root . 'runtime/',
65
                'cache'       => $root . 'runtime/cache/',
66
            ],
67
            null,
68
            null,
69
            false
70
        );
71
72
        //Monolog love to write to CLI when no handler set
73
        $this->app->logs->debugHandler(new NullHandler());
74
        $this->app->container->bind('factory', $this->app->container);
75
76
        $files = $this->app->files;
77
78
        //Ensure runtime is clean
79
        foreach ($files->getFiles($this->app->directory('runtime')) as $filename) {
80
            //If exception is thrown here this will mean that application wasn't correctly
81
            //destructed and there is open resources kept
82
            $files->delete($filename);
83
        }
84
85
        $builder = $this->orm->schemaBuilder(true);
86
        $builder->renderSchema();
87
        $builder->pushSchema();
88
        $this->orm->setSchema($builder);
89
90
        if ($this->app->getEnvironment()->get('DEBUG')) {
91
            $this->app->db->getDriver()->setLogger(new class implements LoggerInterface
92
            {
93
                use LoggerTrait;
94
95
                public function log($level, $message, array $context = [])
96
                {
97
                    if ($level == LogLevel::ERROR) {
98
                        echo " \n! \033[31m" . $message . "\033[0m";
99
                    } elseif ($level == LogLevel::ALERT) {
100
                        echo " \n! \033[35m" . $message . "\033[0m";
101
                    } elseif (strpos($message, 'PRAGMA') === 0) {
102
                        echo " \n> \033[34m" . $message . "\033[0m";
103
                    } else {
104
                        if (strpos($message, 'SELECT') === 0) {
105
                            echo " \n> \033[32m" . $message . "\033[0m";
106
                        } else {
107
                            echo " \n> \033[33m" . $message . "\033[0m";
108
                        }
109
                    }
110
                }
111
            });
112
        }
113
114
        clearstatcache();
115
116
        //Open application scope
117
        TestApplication::shareContainer($this->app->container);
118
    }
119
120
    /**
121
     * This method performs full destroy of spiral environment.
122
     */
123
    public function tearDown()
124
    {
125
        \Mockery::close();
126
127
        TestApplication::shareContainer(null);
128
129
        //Forcing destruction
130
        $this->app = null;
131
132
        gc_collect_cycles();
133
        clearstatcache();
134
    }
135
136
    /**
137
     * @return \Spiral\Core\ContainerInterface
138
     */
139
    protected function iocContainer()
140
    {
141
        return $this->app->container;
142
    }
143
144
    /**
145
     * @return Track
146
     */
147
    protected function getTrack(): Track
148
    {
149
        return $this->container->get(Track::class);
150
    }
151
152
    /**
153
     * @return Extract
154
     */
155
    protected function getExtract(): Extract
156
    {
157
        return $this->container->get(Extract::class);
158
    }
159
160
    /**
161
     * @return DatetimeConverter
162
     */
163
    protected function getConverter(): DatetimeConverter
164
    {
165
        return $this->container->get(DatetimeConverter::class);
166
    }
167
168
    /**
169
     * @return OccurrenceSource
170
     */
171
    protected function getSource(): OccurrenceSource
172
    {
173
        return $this->container->get(OccurrenceSource::class);
174
    }
175
}