This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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
Bug
introduced
by
![]() |
|||||
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
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. ![]() |
|||||
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 |