Issues (273)

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

Labels
Severity

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
 * This file contains functionality relating Symfony2 components such as the template engine, requests, and sessions
4
 *
5
 * @package    BZiON
6
 * @license    https://github.com/allejo/bzion/blob/master/LICENSE.md GNU General Public License Version 3
7
 */
8
9
use BZIon\Cache\ModelCache;
10
use Symfony\Component\DependencyInjection\ContainerInterface;
11
use Symfony\Component\EventDispatcher\EventDispatcher;
12
use Symfony\Component\Form\FormFactory;
13
use Symfony\Component\HttpFoundation\Request;
14
use Symfony\Component\HttpFoundation\Session\Session;
15
use Symfony\Component\HttpFoundation\Session\SessionInterface;
16
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
17
18
/**
19
 * Class Service
20
 */
21
abstract class Service
22
{
23
    /**
24
     * Symfony's URL Generator
25
     * @var UrlGeneratorInterface;
26
     */
27
    private static $generator;
28
29
    /**
30
     * Symfony's Request class
31
     * @var Request
32
     */
33
    private static $request;
34
35
    /**
36
     * Symfony's FormFactory
37
     * @var FormFactory
38
     */
39
    private static $formFactory;
40
41
    /**
42
     * The kernel's environment (prod, debug, profile or test)
43
     * @var string
44
     */
45
    private static $environment;
46
47
    /**
48
     * The model memory cache
49
     * @var ModelCache
50
     */
51
    private static $modelCache;
52
53
    /**
54
     * The AppKernel's container
55
     * @var AppKernel
56
     */
57
    private static $kernel;
58
59
    /**
60
     * @param Request $request
61
     */
62 23
    public static function setRequest($request)
0 ignored issues
show
You have injected the Request via parameter $request. This is generally not recommended as there might be multiple instances during a request cycle (f.e. when using sub-requests). Instead, it is recommended to inject the RequestStack and retrieve the current request each time you need it via getCurrentRequest().
Loading history...
63
    {
64 23
        self::$request = $request;
65 23
    }
66
67
    /**
68
     * @return Request
69
     */
70 23
    public static function getRequest()
71
    {
72 23
        if (!self::$request) {
73
            $request = Request::createFromGlobals();
74
            $request->setSession(self::getNewSession());
75
            self::setRequest($request);
76
        }
77
78 23
        return self::$request;
79
    }
80
81
    /**
82
     * Sets the URL Generator.
83
     * @param  UrlGeneratorInterface $generator
84
     * @return void
85
     */
86 1
    public static function setGenerator($generator)
87
    {
88 1
        self::$generator = $generator;
89 1
    }
90
91
    /**
92
     * @return UrlGeneratorInterface
93
     */
94 1
    public static function getGenerator()
95
    {
96 1
        return self::$generator;
97
    }
98
99
    /**
100
     * Gets a parameter
101
     *
102
     * @param  string $name The parameter name
103
     * @return mixed  The parameter value
104
     */
105 76
    public static function getParameter($name)
106
    {
107 76
        return self::getContainer()->getParameter($name);
108
    }
109
110
    /**
111
     * @param SessionInterface $session
112
     */
113
    public static function setSession($session)
114
    {
115
        self::getRequest()->setSession($session);
116
    }
117
118
    /**
119
     * @return SessionInterface
120
     */
121
    public static function getSession()
122
    {
123
        return self::getRequest()->getSession();
124
    }
125
126
    /**
127
     * Create a new session
128
     * @return Session
129
     */
130
    public static function getNewSession()
131
    {
132
        $newSession = new Session();
133
        $newSession->start();
134
135
        return $newSession;
136
    }
137
138
    /**
139
     * @return FormFactory
140
     */
141 1
    public static function getFormFactory()
142
    {
143 1
        return self::$formFactory;
144
    }
145
146
    /**
147
     * @param FormFactory $formFactory
148
     */
149 23
    public static function setFormFactory($formFactory)
150
    {
151 23
        self::$formFactory = $formFactory;
152 23
    }
153
154
    /**
155
     * @return string
156
     */
157 1
    public static function getEnvironment()
158
    {
159 1
        return self::$environment;
160
    }
161
162
    /**
163
     * @param string $environment
164
     */
165 1
    public static function setEnvironment($environment)
166
    {
167 1
        self::$environment = $environment;
168 1
    }
169
170
    /**
171
     * @return ModelCache
172
     */
173 76
    public static function getModelCache()
174
    {
175 76
        return self::$modelCache;
176
    }
177
178
    /**
179
     * @param ModelCache $modelCache
180
     */
181 1
    public static function setModelCache($modelCache)
182
    {
183 1
        self::$modelCache = $modelCache;
184 1
    }
185
186
    /**
187
     * @return string[][]
188
     */
189 76
    public static function getSiteThemes()
190
    {
191 76
        return self::getParameter('bzion.site.themes');
192
    }
193
194
    /**
195
     * @return string
196
     */
197 1
    public static function getDefaultSiteTheme()
198
    {
199 1
        $themes = self::getSiteThemes();
200 1
201
        return $themes[0]['slug'];
202
    }
203
204
    /**
205 1
     * @return ContainerInterface
206
     */
207 1
    public static function getContainer()
208
    {
209
        return self::$kernel->getContainer();
210
    }
211
212
    /**
213 76
     * @param $kernel
214
     */
215 76
    public static function setKernel($kernel)
216
    {
217
        self::$kernel = $kernel;
218
    }
219
220
    /**
221
     * @return EventDispatcher
222
     */
223
    public static function getDispatcher()
224
    {
225
        return self::getContainer()->get('event_dispatcher');
226
    }
227
228
    /**
229
     * @return bool
230
     */
231
    public static function isDebug()
232
    {
233
        return self::getParameter('kernel.debug');
234
    }
235
}
236