Issues (196)

Security Analysis    6 potential vulnerabilities

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection (4)
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection (1)
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
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/Controller/SimpleEditCounterController.php (2 issues)

Labels
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Controller;
6
7
use App\Model\SimpleEditCounter;
8
use App\Repository\SimpleEditCounterRepository;
9
use OpenApi\Annotations as OA;
10
use Symfony\Component\HttpFoundation\Response;
11
use Symfony\Component\Routing\Annotation\Route;
12
13
/**
14
 * This controller handles the Simple Edit Counter tool.
15
 */
16
class SimpleEditCounterController extends XtoolsController
17
{
18
19
    /**
20
     * @inheritDoc
21
     * @codeCoverageIgnore
22
     */
23
    public function getIndexRoute(): string
24
    {
25
        return 'SimpleEditCounter';
26
    }
27
28
    /**
29
     * The Simple Edit Counter search form.
30
     * @Route("/sc", name="SimpleEditCounter")
31
     * @Route("/sc/index.php", name="SimpleEditCounterIndexPhp")
32
     * @Route("/sc/{project}", name="SimpleEditCounterProject")
33
     * @return Response
34
     */
35
    public function indexAction(): Response
36
    {
37
        // Redirect if project and username are given.
38
        if (isset($this->params['project']) && isset($this->params['username'])) {
39
            return $this->redirectToRoute('SimpleEditCounterResult', $this->params);
40
        }
41
42
        // Show the form.
43
        return $this->render('simpleEditCounter/index.html.twig', array_merge([
44
            'xtPageTitle' => 'tool-simpleeditcounter',
45
            'xtSubtitle' => 'tool-simpleeditcounter-desc',
46
            'xtPage' => 'SimpleEditCounter',
47
48
            // Defaults that will get overridden if in $params.
49
            'namespace' => 'all',
50
            'start' => '',
51
            'end' => '',
52
        ], $this->params, ['project' => $this->project]));
53
    }
54
55
    private function prepareSimpleEditCounter(SimpleEditCounterRepository $simpleEditCounterRepo): SimpleEditCounter
56
    {
57
        $sec = new SimpleEditCounter(
58
            $simpleEditCounterRepo,
59
            $this->project,
60
            $this->user,
0 ignored issues
show
It seems like $this->user can also be of type null; however, parameter $user of App\Model\SimpleEditCounter::__construct() does only seem to accept App\Model\User, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

60
            /** @scrutinizer ignore-type */ $this->user,
Loading history...
61
            $this->namespace,
62
            $this->start,
63
            $this->end
64
        );
65
        $sec->prepareData();
66
67
        if ($sec->isLimited()) {
68
            $this->addFlash('warning', $this->i18n->msg('simple-counter-limited-results'));
69
        }
70
71
        return $sec;
72
    }
73
74
    /**
75
     * Display the results.
76
     * @Route(
77
     *     "/sc/{project}/{username}/{namespace}/{start}/{end}",
78
     *     name="SimpleEditCounterResult",
79
     *     requirements={
80
     *         "username" = "(ipr-.+\/\d+[^\/])|([^\/]+)",
81
     *         "namespace" = "|all|\d+",
82
     *         "start" = "|\d{4}-\d{2}-\d{2}",
83
     *         "end" = "|\d{4}-\d{2}-\d{2}",
84
     *     },
85
     *     defaults={
86
     *         "start"=false,
87
     *         "end"=false,
88
     *         "namespace"="all",
89
     *     }
90
     * )
91
     * @param SimpleEditCounterRepository $simpleEditCounterRepo
92
     * @return Response
93
     * @codeCoverageIgnore
94
     */
95
    public function resultAction(SimpleEditCounterRepository $simpleEditCounterRepo): Response
96
    {
97
        $sec = $this->prepareSimpleEditCounter($simpleEditCounterRepo);
98
99
        return $this->getFormattedResponse('simpleEditCounter/result', [
100
            'xtPage' => 'SimpleEditCounter',
101
            'xtTitle' => $this->user->getUsername(),
0 ignored issues
show
The method getUsername() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

101
            'xtTitle' => $this->user->/** @scrutinizer ignore-call */ getUsername(),

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...
102
            'sec' => $sec,
103
        ]);
104
    }
105
106
    /************************ API endpoints ************************/
107
108
    /**
109
     * API endpoint for the Simple Edit Counter.
110
     * @Route(
111
     *     "/api/user/simple_editcount/{project}/{username}/{namespace}/{start}/{end}",
112
     *     name="SimpleEditCounterApi",
113
     *     requirements={
114
     *         "username" = "(ipr-.+\/\d+[^\/])|([^\/]+)",
115
     *         "start" = "|\d{4}-\d{2}-\d{2}",
116
     *         "end" = "|\d{4}-\d{2}-\d{2}",
117
     *         "namespace" = "|all|\d+"
118
     *     },
119
     *     defaults={
120
     *         "start"=false,
121
     *         "end"=false,
122
     *         "namespace"="all",
123
     *     },
124
     *     methods={"GET"}
125
     * )
126
     * @OA\Tag(name="User API")
127
     * @OA\Parameter(ref="#/components/parameters/Project")
128
     * @OA\Parameter(ref="#/components/parameters/UsernameOrIp")
129
     * @OA\Parameter(ref="#/components/parameters/Namespace")
130
     * @OA\Parameter(ref="#/components/parameters/Start")
131
     * @OA\Parameter(ref="#/components/parameters/End")
132
     * @OA\Response(
133
     *     response=200,
134
     *     description="Simple edit count, along with user groups and global user groups.",
135
     *     @OA\JsonContent(
136
     *         @OA\Property(property="project", ref="#/components/parameters/Project/schema"),
137
     *         @OA\Property(property="username", ref="#/components/parameters/UsernameOrIp/schema"),
138
     *         @OA\Property(property="namespace", ref="#/components/parameters/Namespace/schema"),
139
     *         @OA\Property(property="start", ref="#components/parameters/Start/schema"),
140
     *         @OA\Property(property="end", ref="#components/parameters/End/schema"),
141
     *         @OA\Property(property="user_id", type="integer"),
142
     *         @OA\Property(property="live_edit_count", type="integer"),
143
     *         @OA\Property(property="deleted_edit_count", type="integer"),
144
     *         @OA\Property(property="user_groups", type="array", @OA\Items(type="string")),
145
     *         @OA\Property(property="global_user_groups", type="array", @OA\Items(type="string")),
146
     *         @OA\Property(property="elapsed_time", ref="#/components/schemas/elapsed_time")
147
     *     )
148
     * )
149
     * @OA\Response(response=404, ref="#/components/responses/404")
150
     * @OA\Response(response=503, ref="#/components/responses/503")
151
     * @OA\Response(response=504, ref="#/components/responses/504")
152
     * @param SimpleEditCounterRepository $simpleEditCounterRepository
153
     * @return Response
154
     * @codeCoverageIgnore
155
     */
156
    public function simpleEditCounterApiAction(SimpleEditCounterRepository $simpleEditCounterRepository): Response
157
    {
158
        $this->recordApiUsage('user/simple_editcount');
159
        $sec = $this->prepareSimpleEditCounter($simpleEditCounterRepository);
160
        $data = $sec->getData();
161
        if ($this->user->isIpRange()) {
162
            unset($data['deleted_edit_count']);
163
        }
164
        return $this->getFormattedApiResponse($data);
165
    }
166
}
167