Issues (51)

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.

Controller/ThreadController.php (7 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
/*
4
 * This file is part of Sulu.
5
 *
6
 * (c) MASSIVE ART WebServices GmbH
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Sulu\Bundle\CommentBundle\Controller;
13
14
use FOS\RestBundle\Controller\Annotations\Get;
15
use FOS\RestBundle\Routing\ClassResourceInterface;
16
use Sulu\Bundle\CommentBundle\Entity\ThreadInterface;
17
use Sulu\Component\Rest\Exception\EntityNotFoundException;
18
use Sulu\Component\Rest\ListBuilder\FieldDescriptorInterface;
19
use Sulu\Component\Rest\ListBuilder\ListRepresentation;
20
use Sulu\Component\Rest\RequestParametersTrait;
21
use Sulu\Component\Rest\RestController;
22
use Symfony\Component\HttpFoundation\Request;
23
use Symfony\Component\HttpFoundation\Response;
24
25
/**
26
 * Provides an api for threads.
27
 */
28
class ThreadController extends RestController implements ClassResourceInterface
29
{
30
    use RequestParametersTrait;
31
32
    /**
33
     * Returns list of field-descriptors.
34
     *
35
     * @Get("/threads/fields")
36
     *
37
     * @return Response
38
     */
39
    public function getFieldsAction()
40
    {
41
        return $this->handleView($this->view($this->getFieldDescriptors()));
0 ignored issues
show
$this->view($this->getFieldDescriptors()) is of type this<Sulu\Bundle\Comment...oller\ThreadController>, but the function expects a object<FOS\RestBundle\View\View>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
42
    }
43
44
    /**
45
     * Returns list of threads.
46
     *
47
     * @param Request $request
48
     *
49
     * @return Response
50
     */
51 3
    public function cgetAction(Request $request)
52
    {
53 3
        $restHelper = $this->get('sulu_core.doctrine_rest_helper');
54 3
        $factory = $this->get('sulu_core.doctrine_list_builder_factory');
55 3
        $listBuilder = $factory->create($this->getParameter('sulu.model.thread.class'));
56
57 3
        $fieldDescriptors = $this->getFieldDescriptors();
58 3
        $restHelper->initializeListBuilder($listBuilder, $fieldDescriptors);
59
60 3 View Code Duplication
        foreach ($request->query->all() as $filterKey => $filterValue) {
61 3
            if (isset($fieldDescriptors[$filterKey])) {
62 3
                $listBuilder->where($fieldDescriptors[$filterKey], $filterValue);
63
            }
64
        }
65
66 3
        $typeParameter = $request->get('types');
67 3
        if ($typeParameter) {
68 1
            $listBuilder->in($fieldDescriptors['type'], array_filter(explode(',', $typeParameter)));
69
        }
70
71 3
        $items = $listBuilder->execute();
72 3
        $list = new ListRepresentation(
73
            $items,
74 3
            'threads',
75 3
            'get_threads',
76 3
            $request->query->all(),
77 3
            $listBuilder->getCurrentPage(),
78 3
            $listBuilder->getLimit(),
79 3
            $listBuilder->count()
80
        );
81
82 3
        return $this->handleView($this->view($list, 200));
0 ignored issues
show
$this->view($list, 200) is of type this<Sulu\Bundle\Comment...oller\ThreadController>, but the function expects a object<FOS\RestBundle\View\View>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
83
    }
84
85
    /**
86
     * Returns single thread.
87
     *
88
     * @param int $id
89
     *
90
     * @return Response
91
     *
92
     * @throws EntityNotFoundException
93
     */
94 1
    public function getAction($id)
95
    {
96 1
        $thread = $this->get('sulu.repository.thread')->findThreadById($id);
97 1
        if (!$thread) {
98
            throw new EntityNotFoundException(ThreadInterface::class, $id);
99
        }
100
101 1
        return $this->handleView($this->view($thread));
0 ignored issues
show
$this->view($thread) is of type this<Sulu\Bundle\Comment...oller\ThreadController>, but the function expects a object<FOS\RestBundle\View\View>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
102
    }
103
104
    /**
105
     * Update thread.
106
     *
107
     * @param int $id
108
     * @param Request $request
109
     *
110
     * @return Response
111
     *
112
     * @throws EntityNotFoundException
113
     */
114 1 View Code Duplication
    public function putAction($id, Request $request)
115
    {
116
        /** @var ThreadInterface $thread */
117 1
        $thread = $this->get('sulu.repository.thread')->findThreadById($id);
118 1
        if (!$thread) {
119
            throw new EntityNotFoundException(ThreadInterface::class, $id);
120
        }
121
122 1
        $thread->setTitle($request->request->get('title'));
123
124 1
        $this->get('sulu_comment.manager')->updateThread($thread);
125 1
        $this->get('doctrine.orm.entity_manager')->flush();
126
127 1
        return $this->handleView($this->view($thread));
0 ignored issues
show
$this->view($thread) is of type this<Sulu\Bundle\Comment...oller\ThreadController>, but the function expects a object<FOS\RestBundle\View\View>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
128
    }
129
130
    /**
131
     * Delete thread identified by id.
132
     *
133
     * @param int $id
134
     *
135
     * @return Response
136
     */
137 1 View Code Duplication
    public function deleteAction($id)
138
    {
139 1
        $this->get('sulu_comment.manager')->deleteThreads([$id]);
140 1
        $this->get('doctrine.orm.entity_manager')->flush();
141
142 1
        return $this->handleView($this->view(null, 204));
0 ignored issues
show
$this->view(null, 204) is of type this<Sulu\Bundle\Comment...oller\ThreadController>, but the function expects a object<FOS\RestBundle\View\View>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
143
    }
144
145
    /**
146
     * Delete multiple threads identified by ids parameter.
147
     *
148
     * @param Request $request
149
     *
150
     * @return Response
151
     */
152 1 View Code Duplication
    public function cdeleteAction(Request $request)
153
    {
154 1
        $ids = array_filter(explode(',', $request->get('ids', '')));
155
156 1
        if (0 === count($ids)) {
157
            return $this->handleView($this->view(null, 204));
0 ignored issues
show
$this->view(null, 204) is of type this<Sulu\Bundle\Comment...oller\ThreadController>, but the function expects a object<FOS\RestBundle\View\View>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
158
        }
159
160 1
        $this->get('sulu_comment.manager')->deleteThreads($ids);
161 1
        $this->get('doctrine.orm.entity_manager')->flush();
162
163 1
        return $this->handleView($this->view(null, 204));
0 ignored issues
show
$this->view(null, 204) is of type this<Sulu\Bundle\Comment...oller\ThreadController>, but the function expects a object<FOS\RestBundle\View\View>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
164
    }
165
166
    /**
167
     * Returns array of field-descriptors.
168
     *
169
     * @return FieldDescriptorInterface[]
170
     */
171 3
    private function getFieldDescriptors()
172
    {
173 3
        return $this->get('sulu_core.list_builder.field_descriptor_factory')
174 3
            ->getFieldDescriptorForClass($this->getParameter('sulu.model.thread.class'));
175
    }
176
}
177