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/AuthorshipController.php (2 issues)

Labels
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Controller;
6
7
use App\Model\Authorship;
8
use App\Repository\AuthorshipRepository;
9
use Symfony\Component\HttpFoundation\RequestStack;
10
use Symfony\Component\HttpFoundation\Response;
11
use Symfony\Component\Routing\Annotation\Route;
12
13
/**
14
 * This controller serves the search form and results for the Authorship tool
15
 * @codeCoverageIgnore
16
 */
17
class AuthorshipController extends XtoolsController
18
{
19
    /**
20
     * @inheritDoc
21
     * @codeCoverageIgnore
22
     */
23
    public function getIndexRoute(): string
24
    {
25
        return 'Authorship';
26
    }
27
28
    /**
29
     * @inheritDoc
30
     * @codeCoverageIgnore
31
     */
32
    public function supportedProjects(): array
33
    {
34
        return Authorship::SUPPORTED_PROJECTS;
35
    }
36
37
    /**
38
     * The search form.
39
     * @Route("/authorship", name="Authorship")
40
     * @Route("/authorship/{project}", name="AuthorshipProject")
41
     * @return Response
42
     */
43
    public function indexAction(): Response
44
    {
45
        $this->params['target'] = $this->request->query->get('target', '');
46
47
        if (isset($this->params['project']) && isset($this->params['page'])) {
48
            return $this->redirectToRoute('AuthorshipResult', $this->params);
49
        }
50
51
        if (preg_match('/\d{4}-\d{2}-\d{2}/', $this->params['target'])) {
52
            $show = 'date';
53
        } elseif (is_numeric($this->params['target'])) {
54
            $show = 'id';
55
        } else {
56
            $show = 'latest';
57
        }
58
59
        return $this->render('authorship/index.html.twig', array_merge([
60
            'xtPage' => 'Authorship',
61
            'xtPageTitle' => 'tool-authorship',
62
            'xtSubtitle' => 'tool-authorship-desc',
63
            'project' => $this->project,
64
65
            // Defaults that will get overridden if in $params.
66
            'page' => '',
67
            'supportedProjects' => Authorship::SUPPORTED_PROJECTS,
68
        ], $this->params, [
69
            'project' => $this->project,
70
            'show' => $show,
71
            'target' => '',
72
        ]));
73
    }
74
75
    /**
76
     * @Route(
77
     *     "/articleinfo-authorship/{project}/{page}",
78
     *     name="AuthorshipResultLegacy",
79
     *     requirements={
80
     *         "page"="(.+?)",
81
     *         "target"="|latest|\d+|\d{4}-\d{2}-\d{2}",
82
     *     },
83
     *     defaults={"target"="latest"}
84
     * )
85
     * @Route(
86
     *     "/authorship/{project}/{page}/{target}",
87
     *     name="AuthorshipResult",
88
     *     requirements={
89
     *         "page"="(.+?)",
90
     *         "target"="|latest|\d+|\d{4}-\d{2}-\d{2}",
91
     *     },
92
     *     defaults={"target"="latest"}
93
     * )
94
     * @param string $target
95
     * @param AuthorshipRepository $authorshipRepo
96
     * @param RequestStack $requestStack
97
     * @return Response
98
     */
99
    public function resultAction(
100
        string $target,
101
        AuthorshipRepository $authorshipRepo,
102
        RequestStack $requestStack
103
    ): Response {
104
        if (0 !== $this->page->getNamespace()) {
0 ignored issues
show
The method getNamespace() 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

104
        if (0 !== $this->page->/** @scrutinizer ignore-call */ getNamespace()) {

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...
105
            $this->addFlashMessage('danger', 'error-authorship-non-mainspace');
106
            return $this->redirectToRoute('AuthorshipProject', [
107
                'project' => $this->project->getDomain(),
108
            ]);
109
        }
110
111
        // This action sometimes requires more memory. 256M should be safe.
112
        ini_set('memory_limit', '256M');
113
114
        $isSubRequest = $this->request->get('htmlonly') || null !== $requestStack->getParentRequest();
115
        $limit = $isSubRequest ? 10 : ($this->limit ?? 500);
116
117
        $authorship = new Authorship($authorshipRepo, $this->page, $target, $limit);
0 ignored issues
show
It seems like $this->page can also be of type null; however, parameter $page of App\Model\Authorship::__construct() does only seem to accept App\Model\Page, 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

117
        $authorship = new Authorship($authorshipRepo, /** @scrutinizer ignore-type */ $this->page, $target, $limit);
Loading history...
118
        $authorship->prepareData();
119
120
        return $this->getFormattedResponse('authorship/authorship', [
121
            'xtPage' => 'Authorship',
122
            'xtTitle' => $this->page->getTitle(),
123
            'authorship' => $authorship,
124
            'is_sub_request' => $isSubRequest,
125
        ]);
126
    }
127
}
128