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/EditSummaryController.php (3 issues)

Labels
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Controller;
6
7
use App\Model\EditSummary;
8
use App\Repository\EditSummaryRepository;
9
use OpenApi\Annotations as OA;
10
use Symfony\Component\HttpFoundation\JsonResponse;
11
use Symfony\Component\HttpFoundation\Response;
12
use Symfony\Component\Routing\Annotation\Route;
13
14
/**
15
 * This controller handles the Simple Edit Counter tool.
16
 */
17
class EditSummaryController extends XtoolsController
18
{
19
    /**
20
     * @inheritDoc
21
     * @codeCoverageIgnore
22
     */
23
    public function getIndexRoute(): string
24
    {
25
        return 'EditSummary';
26
    }
27
28
    /**
29
     * The Edit Summary search form.
30
     * @Route("/editsummary", name="EditSummary")
31
     * @Route("/editsummary/index.php", name="EditSummaryIndexPhp")
32
     * @Route("/editsummary/{project}", name="EditSummaryProject")
33
     * @return Response
34
     */
35
    public function indexAction(): Response
36
    {
37
        // If we've got a project, user, and namespace, redirect to results.
38
        if (isset($this->params['project']) && isset($this->params['username'])) {
39
            return $this->redirectToRoute('EditSummaryResult', $this->params);
40
        }
41
42
        // Show the form.
43
        return $this->render('editSummary/index.html.twig', array_merge([
44
            'xtPageTitle' => 'tool-editsummary',
45
            'xtSubtitle' => 'tool-editsummary-desc',
46
            'xtPage' => 'EditSummary',
47
48
            // Defaults that will get overridden if in $params.
49
            'username' => '',
50
            'namespace' => 0,
51
            'start' => '',
52
            'end' => '',
53
        ], $this->params, ['project' => $this->project]));
54
    }
55
56
    /**
57
     * Display the Edit Summary results
58
     * @Route(
59
     *     "/editsummary/{project}/{username}/{namespace}/{start}/{end}", name="EditSummaryResult",
60
     *     requirements={
61
     *         "username" = "(ipr-.+\/\d+[^\/])|([^\/]+)",
62
     *         "namespace"="|all|\d+",
63
     *         "start"="|\d{4}-\d{2}-\d{2}",
64
     *         "end"="|\d{4}-\d{2}-\d{2}",
65
     *     },
66
     *     defaults={"namespace"="all", "start"=false, "end"=false}
67
     * )
68
     * @param EditSummaryRepository $editSummaryRepo
69
     * @return Response
70
     * @codeCoverageIgnore
71
     */
72
    public function resultAction(EditSummaryRepository $editSummaryRepo): Response
73
    {
74
        // Instantiate an EditSummary, treating the past 150 edits as 'recent'.
75
        $editSummary = new EditSummary(
76
            $editSummaryRepo,
77
            $this->project,
78
            $this->user,
0 ignored issues
show
It seems like $this->user can also be of type null; however, parameter $user of App\Model\EditSummary::__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

78
            /** @scrutinizer ignore-type */ $this->user,
Loading history...
79
            $this->namespace,
80
            $this->start,
81
            $this->end,
82
            150
83
        );
84
        $editSummary->prepareData();
85
86
        return $this->getFormattedResponse('editSummary/result', [
87
            'xtPage' => 'EditSummary',
88
            '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

88
            '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...
89
            'es' => $editSummary,
90
        ]);
91
    }
92
93
    /************************ API endpoints ************************/
94
95
    /**
96
     * Get statistics on how many times a user has used edit summaries.
97
     * @Route(
98
     *     "/api/user/edit_summaries/{project}/{username}/{namespace}/{start}/{end}", name="UserApiEditSummaries",
99
     *     requirements={
100
     *         "username" = "(ipr-.+\/\d+[^\/])|([^\/]+)",
101
     *         "namespace"="|all|\d+",
102
     *         "start"="|\d{4}-\d{2}-\d{2}",
103
     *         "end"="|\d{4}-\d{2}-\d{2}",
104
     *     },
105
     *     defaults={"namespace"="all", "start"=false, "end"=false},
106
     *     methods={"GET"}
107
     * )
108
     * @OA\Tag(name="User API")
109
     * @OA\Get(description="Get edit summage usage statistics for the user, with a month-by-month breakdown.")
110
     * @OA\Parameter(ref="#/components/parameters/Project")
111
     * @OA\Parameter(ref="#/components/parameters/UsernameOrIp")
112
     * @OA\Parameter(ref="#/components/parameters/Namespace")
113
     * @OA\Parameter(ref="#/components/parameters/Start")
114
     * @OA\Parameter(ref="#/components/parameters/End")
115
     * @OA\Response(
116
     *     response=200,
117
     *     description="Edit summary usage statistics",
118
     *     @OA\JsonContent(
119
     *         @OA\Property(property="project", ref="#/components/parameters/Project/schema"),
120
     *         @OA\Property(property="username", ref="#/components/parameters/UsernameOrIp/schema"),
121
     *         @OA\Property(property="namespace", ref="#/components/schemas/Namespace"),
122
     *         @OA\Property(property="start", ref="#/components/parameters/Start/schema"),
123
     *         @OA\Property(property="end", ref="#/components/parameters/End/schema"),
124
     *         @OA\Property(property="recent_edits_minor", type="integer",
125
     *             description="Number of minor edits within the last 150 edits"),
126
     *         @OA\Property(property="recent_edits_major", type="integer",
127
     *             description="Number of non-minor edits within the last 150 edits"),
128
     *         @OA\Property(property="total_edits_minor", type="integer",
129
     *             description="Total number of minor edits"),
130
     *         @OA\Property(property="total_edits_major", type="integer",
131
     *             description="Total number of non-minor edits"),
132
     *         @OA\Property(property="total_edits", type="integer", description="Total number of edits"),
133
     *         @OA\Property(property="recent_summaries_minor", type="integer",
134
     *             description="Number of minor edits with summaries within the last 150 edits"),
135
     *         @OA\Property(property="recent_summaries_major", type="integer",
136
     *             description="Number of non-minor edits with summaries within the last 150 edits"),
137
     *     )
138
     * )
139
     * @OA\Response(response=404, ref="#/components/responses/404")
140
     * @OA\Response(response=501, ref="#/components/responses/501")
141
     * @OA\Response(response=503, ref="#/components/responses/503")
142
     * @OA\Response(response=504, ref="#/components/responses/504")
143
     * @param EditSummaryRepository $editSummaryRepo
144
     * @return JsonResponse
145
     * @codeCoverageIgnore
146
     */
147
    public function editSummariesApiAction(EditSummaryRepository $editSummaryRepo): JsonResponse
148
    {
149
        $this->recordApiUsage('user/edit_summaries');
150
151
        // Instantiate an EditSummary, treating the past 150 edits as 'recent'.
152
        $editSummary = new EditSummary(
153
            $editSummaryRepo,
154
            $this->project,
155
            $this->user,
0 ignored issues
show
It seems like $this->user can also be of type null; however, parameter $user of App\Model\EditSummary::__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

155
            /** @scrutinizer ignore-type */ $this->user,
Loading history...
156
            $this->namespace,
157
            $this->start,
158
            $this->end,
159
            150
160
        );
161
        $editSummary->prepareData();
162
163
        return $this->getFormattedApiResponse($editSummary->getData());
164
    }
165
}
166