Issues (106)

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/PageElement.php (1 issue)

Labels
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
namespace AOE\Languagevisibility;
4
5
/***************************************************************
6
 * Copyright notice
7
 *
8
 * (c) 2016 AOE GmbH <[email protected]>
9
 * All rights reserved
10
 *
11
 * This script is part of the TYPO3 project. The TYPO3 project is
12
 * free software; you can redistribute it and/or modify
13
 * it under the terms of the GNU General Public License as published by
14
 * the Free Software Foundation; either version 2 of the License, or
15
 * (at your option) any later version.
16
 *
17
 * The GNU General Public License can be found at
18
 * http://www.gnu.org/copyleft/gpl.html.
19
 *
20
 * This script is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * This copyright notice MUST APPEAR in all copies of the script!
26
 ***************************************************************/
27
28
/**
29
 *
30
 * @author	Daniel Poetzinger <[email protected]>
31
 * @coauthor Tolleiv Nietsch <[email protected]>
32
 * @coauthor Timo Schmidt <[email protected]>
33
 */
34
class PageElement extends Element {
35
36
	/**
37
	 * Returns if this Element is a translation or not.
38
	 * Pages are always original records, because overlays are stored in the
39
	 * table pages_language_overlay
40
	 *
41
	 * @return boolean
42
	 */
43
	protected function isOrigElement() {
44
		return TRUE;
45
	}
46
47
	/**
48
	 * Returns a simple description of the element type.
49
	 *
50
	 * @return string
51
	 */
52
	public function getElementDescription() {
53
		return 'Page';
54
	}
55
56
	/**
57
	 * This method is used to determine if this element is an element
58
	 * in the default language. For pages this is always true, because
59
	 * the table pages does not contain translations.
60
	 *
61
	 * @return boolean
62
	 */
63
	public function isLanguageSetToDefault() {
64
		return TRUE;
65
	}
66
67
	/**
68
	 * Returns an Informative description of the element.
69
	 *
70
	 * @return string
71
	 */
72
	public function getInformativeDescription() {
73
		return 'this is a normal page element (translations are managed with seperate overlay records)';
74
	}
75
76
	/**
77
	 * Method to get an overlay of an element for a certain langugae
78
	 *
79
	 * @param int $lUid
80
	 * @internal param bool $onlyUid
81
	 * @return array return the database row
82
	 */
83
	protected function getOverLayRecordForCertainLanguageImplementation($lUid) {
84
		if ($lUid > 0) {
85
			$fieldArr = explode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields']);
86
			$page_id = $this->row['t3ver_oid']?$this->row['t3ver_oid']:$this->getUid();	// Was the whole record
87
			$fieldArr = array_intersect($fieldArr,array_keys($this->row));		// Make sure that only fields which exist in the incoming record are overlaid!
88
89
			if (count($fieldArr)) {
90
				$table = 'pages_language_overlay';
91
				if (is_object($GLOBALS['TSFE']->sys_page)) {
92
					$enableFields = $GLOBALS['TSFE']->sys_page->enableFields($table);
93
				} else {
94
					$enableFields = \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table);
95
				}
96
				$fieldArr[] = 'deleted';
97
				$fieldArr[] = 'hidden';
98
				$fieldArr[] = 'tx_languagevisibility_visibility';
99
100
					// Selecting overlay record:
101
				$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
102
					implode(',', $fieldArr),
103
					'pages_language_overlay',
104
					'pid=' . intval($page_id) . '
105
						AND sys_language_uid=' . intval($lUid) .
106
						$enableFields,
107
					'',
108
					'',
109
					'1'
110
				);
111
				$olrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
112
				$olrow = $this->getContextIndependentWorkspaceOverlay($table, $olrow);
113
				$GLOBALS['TYPO3_DB']->sql_free_result($res);
114
115
				if ($this->getEnableFieldResult($olrow)) {
116
					$overlayRecord = $olrow;
117
				}
118
			} else {
119
				$overlayRecord =  $this->row;
120
			}
121
		} else {
122
			$overlayRecord =  $this->row;
123
		}
124
		return $overlayRecord;
0 ignored issues
show
The variable $overlayRecord does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
125
	}
126
127
	/**
128
	 * Returns which field in the language should be used to read the default visibility
129
	 *
130
	 * @return string (blank=default / page=page)
131
	 */
132
	public function getFieldToUseForDefaultVisibility() {
133
		return 'page';
134
	}
135
136
	/**
137
	 * Method to determine if this element has any translations in any workspace.
138
	 *
139
	 * @return boolean
140
	 */
141
	public function hasOverLayRecordForAnyLanguageInAnyWorkspace() {
142
		//if we handle a workspace record, we need to get it's live version
143
		if ($this->row['pid'] == -1) {
144
			$useUid = $this->row['t3ver_oid'];
145
		} else {
146
			$useUid = $this->row['uid'];
147
		}
148
149
			// if a workspace record has an overlay, an overlay also exists in the livews with versionstate = 1
150
			// therefore we have to look for any undeleted overlays of the live version
151
		$fields = 'count(uid) as anz';
152
		$table = 'pages_language_overlay';
153
		$where = 'deleted = 0 AND pid=' . $useUid;
154
155
		$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($fields, $table, $where);
156
		$anz = $rows[0]['anz'];
157
158
		return ($anz > 0);
159
	}
160
161
	/**
162
	 * The page elements supports inheritance.
163
	 *
164
	 * @param void
165
	 * @return boolean
166
	 */
167
	public function supportsInheritance() {
168
		return TRUE;
169
	}
170
}
171