Issues (28)

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.

Classes/Service/BackendLayoutService.php (1 issue)

Severity

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
 *  Copyright notice
5
 *
6
 *  All rights reserved
7
 *
8
 *  This script is part of the TYPO3 project. The TYPO3 project is
9
 *  free software; you can redistribute it and/or modify
10
 *  it under the terms of the GNU General Public License as published by
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  (at your option) any later version.
13
 *
14
 *  The GNU General Public License can be found at
15
 *  http://www.gnu.org/copyleft/gpl.html.
16
 *
17
 *  This script is distributed in the hope that it will be useful,
18
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 *  GNU General Public License for more details.
21
 *
22
 *  This copyright notice MUST APPEAR in all copies of the script!
23
 ***************************************************************/
24
25
namespace SourceBroker\Hugo\Service;
26
27
use SourceBroker\Hugo\Utility\RootlineUtility;
28
use TYPO3\CMS\Backend\Utility\BackendUtility;
29
use TYPO3\CMS\Core\SingletonInterface;
30
use TYPO3\CMS\Core\TypoScript\TypoScriptService;
31
use TYPO3\CMS\Core\Utility\StringUtility;
32
33
/**
34
 * Class Typo3UrlService
35
 *
36
 */
37
class BackendLayoutService extends AbstractService implements SingletonInterface
38
{
39
    /**
40
     * @var array
41
     */
42
    protected static $localIdentifierCache = [];
43
44
    /**
45
     * @var array
46
     */
47
    protected static $localCache = [];
48
49
    /**
50
     * @param int $pageUid
51
     *
52
     * @return string
53
     */
54
    public function getIdentifierByPage(int $pageUid): string
55
    {
56
        if (!isset(self::$localIdentifierCache[$pageUid])) {
57
            $rootLine = ($this->objectManager->get(RootlineUtility::class, $pageUid))->get();
0 ignored issues
show
The call to ObjectManagerInterface::get() has too many arguments starting with $pageUid.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
58
59
            $identifier = '';
60
61
            krsort($rootLine);
62
            foreach ($rootLine as $key => $page) {
63
                if ($pageUid == $page['uid'] && !empty($page['backend_layout'])) {
64
                    $identifier = $page['backend_layout'];
65
                    break;
66
                }
67
                if (!empty($page['backend_layout_next_level'])) {
68
                    $identifier = $page['backend_layout_next_level'];
69
                    break;
70
                }
71
            }
72
73
            self::$localIdentifierCache[$pageUid] = $identifier;
74
        }
75
76
        return self::$localIdentifierCache[$pageUid];
77
    }
78
79
    /**
80
     * @param int $pageUid
81
     *
82
     * @return array
83
     */
84
    public function getByPage(int $pageUid): array
85
    {
86
        if (!isset(self::$localCache[$pageUid])) {
87
            $identifier = $this->getIdentifierByPage($pageUid);
88
89
            if (!StringUtility::beginsWith($identifier, 'pagets__')) {
90
                throw new \InvalidArgumentException('Only backend layouts from PageTSConfig are supported at the moment.', 1534620796);
91
            }
92
93
            $pageTsConfig = $this->objectManager->get(TypoScriptService::class)
94
                ->convertTypoScriptArrayToPlainArray(BackendUtility::getPagesTSconfig($pageUid));
95
96
            $pageTsConfigIdentifier = str_replace('pagets__', '', $identifier);
97
98
            self::$localCache[$pageUid] = $pageTsConfig['mod']['web_layout']['BackendLayouts'][$pageTsConfigIdentifier] ?? [];
99
        }
100
101
        return self::$localCache[$pageUid];
102
    }
103
104
    /**
105
     * @param int $pageUid
106
     *
107
     * @return array
108
     */
109
    public function getColPosesByPage(int $pageUid)
110
    {
111
        return array_unique(
112
            array_map('intval', array_column($this->getColumnsByPage($pageUid), 'colPos'))
113
        );
114
    }
115
116
    /**
117
     * @param int $pageUid
118
     * @param int $slideLevel
119
     *
120
     * @return array
121
     */
122
    public function getColPosesByPageAndSlideLevel(int $pageUid, int $slideLevel)
123
    {
124
        $colPoses = [];
125
126
        foreach ($this->getColumnsByPage($pageUid) as $col) {
127
            $hugoSlideLevel = (int)($col['txHugoSlide'] ?? 0);
128
129
            if (isset($col['colPos']) && ($hugoSlideLevel === -1 || $hugoSlideLevel >= $slideLevel)) {
130
                $colPoses[] = (int)$col['colPos'];
131
            }
132
        }
133
134
        return $colPoses;
135
    }
136
137
    /**
138
     * @param int $pageUid
139
     *
140
     * @return array
141
     */
142
    protected function getColumnsByPage(int $pageUid): array
143
    {
144
        $backendLayout = $this->getByPage($pageUid);
145
        $rows = $backendLayout['config']['backend_layout']['rows'] ?? [];
146
        $columns = [];
147
148
        foreach ($rows as $row) {
149
            $columns = array_merge($columns, ($row['columns'] ?? []));
150
        }
151
152
        return $columns;
153
    }
154
}
155