Issues (235)

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.

StructureBundle/Controller/StructureController.php (3 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 Starkerxp\StructureBundle\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6
use Symfony\Component\DependencyInjection\ContainerInterface;
7
use Symfony\Component\EventDispatcher\Event;
8
use Symfony\Component\HttpFoundation\Request;
9
use Symfony\Component\OptionsResolver\OptionsResolver;
10
11
12
class StructureController extends Controller
13
{
14
15
    /**
16
     * Retourne l'entity manager de la connexion defaut.
17
     *
18
     * @return \Doctrine\Common\Persistence\ObjectManager|object
19
     */
20
    protected function getEntityManager()
21
    {
22
        return $this->getDoctrine()->getManager();
23
    }
24
25
    /**
26
     * Retourne les messages d'erreur issu d'un formulaire.
27
     *
28
     * @param $form
29
     *
30
     * @return array
31
     */
32
    protected function getFormErrors($form)
33
    {
34
        $errors = $this->get("starkerxp_structure.services.form_errors")->getFormErrors($form);
35
36
        return $errors;
37
    }
38
39
    /**
40
     * Retourne un uuid.
41
     *
42
     * @return string
43
     */
44
    protected function getUuid()
45
    {
46
        return (\Ramsey\Uuid\Uuid::uuid4())->toString();
47
    }
48
49
    /**
50
     * Permet de traduire un message.
51
     *
52
     * @param $id
53
     * @param null $domain
54
     * @param array $parameters
55
     *
56
     * @return string
57
     */
58
    protected function translate($id, $domain = null, array $parameters = [])
59
    {
60
        return $this->get('translator')->trans($id, $parameters, $domain);
61
    }
62
63
    /**
64
     * Retourne des données envoyer en json ou POST/PUT.
65
     *
66
     * @param Request $request
67
     *
68
     * @return array|mixed
69
     */
70
    protected function getRequestData(Request $request)
71
    {
72
        $data = json_decode($request->getContent(), true);
73
        if (empty($data)) {
74
            $data = $request->request->all();
75
        }
76
77
        return $data;
78
    }
79
80
    /**
81
     * @return ContainerInterface|null
82
     */
83
    protected function getContainer()
84
    {
85
        return $this->container;
86
    }
87
88
    /**
89
     * Permet de gérer les paramètres par défaut pour la gestion de l'api.
90
     *
91
     * @return OptionsResolver
92
     */
93
    protected function resolveParams()
94
    {
95
        $resolver = new OptionsResolver();
96
        $resolver->setDefaults(
97
            [
98
                'offset' => 0,
99
                'limit' => 15,
100
                'fields' => "*",
101
                'sort' => "",
102
                //'filter' => "",
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
103
            ]
104
        );
105
106
        return $resolver;
107
    }
108
109
    /**
110
     * Génère un tableau d'orderBy afin d'afficher les résultats comme voulu.
111
     *
112
     * @param $sort
113
     *
114
     * @return array
115
     */
116
    protected function getOrderBy($sort)
117
    {
118
        if (empty($sort)) {
119
            return [];
120
        }
121
        $tableauSort = explode(',', $sort);
122
        $export = [];
123
        foreach ($tableauSort as $element) {
124
            $order = substr($element, 0, 1) == '-' ? 'DESC' : 'ASC';
125
            $export[$order == "DESC" ? substr($element, 1) : trim($element)] = $order;
126
        }
127
128
        return $export;
129
    }
130
131
    /**
132
     * Permet de gérer les champs quer l'api va retourner. Par défaut elle retournera tous les champs.
133
     *
134
     * @param $fields
135
     *
136
     * @return array
137
     */
138
    protected function getFields($fields)
139
    {
140
        if ($fields == "*") {
141
            return [];
142
        }
143
144
        return explode(",", $fields);
145
    }
146
147
    protected function dispatch($libelle, $entite)
148
    {
149
        $event = new Event();
150
        $event->entite = $entite;
0 ignored issues
show
The property entite does not seem to exist in Symfony\Component\EventDispatcher\Event.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
151
        $this->get("event_dispatcher")->dispatch($libelle, $event);
152
    }
153
154
}
0 ignored issues
show
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
155