Issues (21)

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.

bootstrap.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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 18 and the first side effect is on line 18.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
declare(strict_types = 1);
3
4
use Common\Response;
5
use DerAlex\Silex\YamlConfigServiceProvider;
6
use Doctrine\Common\Annotations\AnnotationRegistry;
7
use SilexFriends\Cors\Cors as CorsServiceProvider;
8
use SilexFriends\Di\Container as DiContainerProvider;
9
use SilexFriends\Router\Router as RouterServiceProvider;
10
use Palma\Silex\Provider\DoctrineORMServiceProvider;
11
use Silex\Application as SilexApplication;
12
use Silex\Provider\MonologServiceProvider;
13
use Symfony\Component\HttpFoundation\Request;
14
15
/**
16
 * @const string DS
17
 */
18
defined('DS') || define('DS', DIRECTORY_SEPARATOR);
19
20
/**
21
 * @const string APPLICATION_ENV
22
 */
23
defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ?: 'production'));
24
25
/**
26
 * Auto loader
27
 *
28
 * @var \Composer\Autoload\ClassLoader $loader
29
 */
30
$loader = require 'vendor' . DS . 'autoload.php';
31
$loader->register();
32
33
// Fix to read JMS annotations
34
AnnotationRegistry::registerAutoloadNamespace(
35
    'JMS\Serializer\Annotation', __DIR__ . DS . 'vendor' . DS . 'jms' . DS . 'serializer' . DS . 'src'
36
);
37
38
/* @var $configs array */
39
$configs = [
40
    'config' . DS . 'global' . DS . 'database.yml',
41
    'config' . DS . 'global' . DS . 'services.yml',
42
    'config' . DS . 'global' . DS . 'logger.yml',
43
];
44
45
/**
46
 * Silex Application
47
 *
48
 * @var SilexApplication $app
49
 */
50
$app = new SilexApplication();
51
$app['exception_handler']->disable();
52
53
if (APPLICATION_ENV !== 'production') {
54
    $app['debug']   = true;
55
    $app['testing'] = true;
56
}
57
58
$configFile = __DIR__ . DS . 'tmp' . DS . 'config.yml';
59
$strConfig = '';
60
61
foreach ($configs as $config) {
62
    $strConfig .= file_get_contents($config) . PHP_EOL;
63
}
64
65
file_put_contents($configFile, $strConfig);
66
67
$app->register(new YamlConfigServiceProvider($configFile));
68
69
// Logger Service
70
$app->register(
71
    new MonologServiceProvider(),
72
    [
73
        'monolog.logfile' => $app['config']['log']['logfile'],
74
        'monolog.permission' => $app['config']['log']['permission'],
75
        'monolog.level' => $app['config']['log']['level'],
76
        'monolog.name' => $app['config']['log']['name'],
77
    ]
78
);
79
80
// ORM Service
81
$app->register(
82
    new DoctrineORMServiceProvider(),
83
    [
84
        'doctrine_orm.entities_path' => __DIR__ . DS . 'src',
85
        'doctrine_orm.proxies_path' => __DIR__ . DS . 'tmp' . DS . 'proxy',
86
        'doctrine_orm.proxies_namespace' => 'ApplicationPro',
87
        'doctrine_orm.connection_parameters' => $app['config']['database'][APPLICATION_ENV],
88
        'doctrine_orm.simple_annotation_reader' => false
89
    ]
90
);
91
92
// Loading service container
93
$app->register(new DiContainerProvider($app['config']['services']));
94
95
// CORS provider
96
$app->register(new CorsServiceProvider());
97
98
// Router Provider
99
$app->register(new RouterServiceProvider(__DIR__ . DS . 'config' . DS . 'routes' . DS . 'routes.yml'));
100
101
$app->before(function (Request $request) use ($app) {
102
    // Skipping OPTIONS requests
103
    if ($request->getMethod() === 'OPTIONS') {
104
        return;
105
    }
106
107
    // If body request is JSON, decode it!
108
    if (0 === strpos($request->headers->get('Content-Type', 'application/json'), 'application/json')) {
109
        $data = json_decode($request->getContent(), true);
110
111
        $request->request->replace(is_array($data) ? $data : []);
112
    }
113
});
114
115
$app->after(function (Request $request, Response $response, SilexApplication $app) {
116
    $app[CorsServiceProvider::HTTP_CORS]($request, $response);
117
});
118
119
$app->error(function (\Exception $e, $code = Response::HTTP_INTERNAL_SERVER_ERROR) {
120
    if ($e->getCode() !== 0) {
121
        $code = $e->getCode();
122
    }
123
124
    if ($code > 505 || $code < 100) {
125
        $code = 500;
126
    }
127
128
    return new Response(["exception" => $e->getMessage(), "status" => "error"], $code);
129
});
130
131
return $app;
132