Issues (48)

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/ClientBundle/Controller/ClientController.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 ClientBundle\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6
use Symfony\Component\HttpFoundation\Request;
7
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
8
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
9
use ClientBundle\Form\Type\ClientForm;
10
use ClientBundle\Form\Type\CategoriesForm;
11
use ClientBundle\Entity\Client;
12
use ClientBundle\Entity\Contact;
13
use Symfony\Component\HttpFoundation\Response;
14
15
/**
16
 * Class ClientController
17
 */
18
class ClientController extends Controller
19
{
20
    /**
21
     * @param int $id
22
     * @return \Symfony\Component\HttpFoundation\Response
23
     */
24
    public function checkAction($id)
25
    {
26
        return new Response('test '.$id);
27
    }
28
29
    /**
30
     * @param int     $id
31
     * @param Request $request
32
     * @Method({"GET", "POST"})
33
     * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
34
     */
35
    public function showAction($id, Request $request)
36
    {
37
        if (!$this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY')) {
38
            throw $this->createAccessDeniedException();
39
        }
40
        $em = $this->getDoctrine()->getManager();
41
        $client = $em->find('ClientBundle:Client', $id);
42
43
        if (!$client) {
44
            throw $this->createNotFoundException(sprintf('не знайдений об\'єкт з id : %s', $id));
45
        } else {
46
            $form = $this->createForm(ClientForm::class, $client, ['id' => $client->getId()]);
47
            // перенести в вьюв
48
            if ($this->isGranted('ROLE_ADMIN')) {
49
                $form->add('delete', SubmitType::class);
50
            }
51
52
            $form->handleRequest($request);
53
54
            if ($request->isMethod('POST') && $form->isSubmitted() && $form->isValid()) {
55
                $client = $form->getData();
56
57
                if ($this->isGranted('ROLE_ADMIN') && $form->get('delete')->isClicked()) {
0 ignored issues
show
The method isClicked() does not seem to exist on object<Symfony\Component\Form\Form>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
58
                    return $this->redirectToRoute('client_del', ['id' => $client->getId()]);
59
                } elseif ($form->get('addcontact')->isClicked()) {
0 ignored issues
show
The method isClicked() does not seem to exist on object<Symfony\Component\Form\Form>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
60
                    $contact = new Contact();
61
                    $clientForm = $request->request->get('client_form');
62
63
                    $contactType = $em->find('ClientBundle:ContactType', $clientForm['newtypecontact']);
64
                    if (!$contactType) {
65
                        throw $this->createNotFoundException(sprintf('не знайдений об\'єкт з id : %s', $clientForm['newtypecontact']));
66
                    } else {
67
                        $contact->setType($contactType);
68
                        $contact->setMean($clientForm['newmeancontact']);
69
                        $client->addContact($contact);
70
                        $em->persist($contact);
71
                    }
72
                } else {
73
                    $em->flush();
74
75
                    return $this->redirectToRoute('client_home');
76
                }
77
            }
78
79
            return $this->render('ClientBundle:Default:edit.html.twig', ['form' => $form->createView(), 'client' => $client]);
80
        }
81
    }
82
83
    /**
84
     * @Method("GET")
85
     * @return \Symfony\Component\HttpFoundation\Response
86
     */
87
    public function searchAction()
88
    {
89
         return $this->render('ClientBundle:Default:home.html.twig');
90
    }
91
92
    /**
93
     * @param Request $request
94
     * @param string  $ctg
95
     * @Method({"GET", "POST"})
96
     * @return \Symfony\Component\HttpFoundation\Response
97
     */
98
    public function homeAction(Request $request, $ctg = '')
99
    {
100
        $ctgRequest = $request->request->get('categories_form');
101
        if (null !== $ctgRequest && '' !== $ctgRequest['categories']) {
102
            $ctg = (int) $ctgRequest['categories'];
103
        }
104
        $em = $this->getDoctrine()->getManager();
105
        $categories = $em->getRepository('ClientBundle:Category')->findAll();
106
        $form = $this->createForm(CategoriesForm::class, $categories);
107
        $form->handleRequest($request);
108
        if (is_integer($ctg)) {
109
            $category = $em->getRepository('ClientBundle:Category')->find($ctg);
110
            $clients =  $category->getClients();
111
112
            return $this->render('ClientBundle:Default:home.html.twig', ['form' => $form->createView(), 'clients' => $clients]);
113
        } else {
114
            $clients = $em->getRepository('ClientBundle:Client')->findAll();
115
116
            return $this->render('ClientBundle:Default:home.html.twig', ['form' => $form->createView(), 'clients' => $clients]);
117
        }
118
    }
119
120
    /**
121
     * @param Request $request
122
     * @Method({"GET", "POST"})
123
     * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
124
     */
125
    public function addAction(Request $request)
126
    {
127
        $em = $this->getDoctrine()->getManager();
128
        $client = new Client();
129
        $form = $this->createForm(ClientForm::class, $client, array('id' => $client->getId()));
130
131
        $form->handleRequest($request);
132
133
        if ($request->isMethod('POST') && $form->isSubmitted() && $form->isValid()) {
134
            $client = $form->getData();
135
136
            if ($form->get('addcontact')->isClicked()) {
0 ignored issues
show
The method isClicked() does not seem to exist on object<Symfony\Component\Form\Form>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
137
                $contact = new Contact();
138
                $clientForm = $request->request->get('client_form');
139
                $contactType = $em->getRepository('ClientBundle:ContactType')->find($clientForm['newtypecontact']);
140
                if (!$contactType) {
141
                    throw $this->createNotFoundException(sprintf('не знайдений об\'єкт з id : %s', $clientForm['newtypecontact']));
142
                } else {
143
                    $contact->setType($contactType);
144
                    $contact->setMean($clientForm['newmeancontact']);
145
                    $client->addContact($contact);
146
                    $em->persist($contact);
147
                    $em->persist($client);
148
                    $em->flush();
149
150
                    return $this->redirectToRoute('client_show', ['id' => $client->getId()]);
151
                }
152
            }
153
            $em->persist($client);
154
            $em->flush();
155
156
            return $this->redirectToRoute('client_home');
157
        }
158
159
        return $this->render('ClientBundle:Default:edit.html.twig', ['form' => $form->createView(), 'client' => $client]);
160
    }
161
162
    /**
163
     * @param int $id
164
     * @Method({"GET", "POST"})
165
     * @return \Symfony\Component\HttpFoundation\RedirectResponse
166
     */
167
    public function delAction($id)
168
    {
169
        $em = $this->getDoctrine()->getManager();
170
        $client = $em->getRepository('ClientBundle:Client')->find($id);
171
        if (!$client) {
172
            throw $this->createNotFoundException(sprintf('не знайдений об\'єкт з id : %s', $id));
173
        } else {
174
            $em->remove($client);
175
            $em->flush();
176
        }
177
178
        return $this->redirectToRoute('client_home');
179
    }
180
}
181