Issues (201)

Security Analysis    no request data  

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.

includes/Head/HeadAbstract.php (1 issue)

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
namespace Redaxscript\Head;
3
4
use Redaxscript\Singleton;
5
use function array_key_exists;
6
use function array_map;
7
use function array_splice;
8
use function array_unshift;
9
use function is_array;
10
use function strlen;
11
use function trim;
12
use function ucfirst;
13
14
/**
15
 * abstract class to create a head class
16
 *
17
 * @since 3.0.0
18
 *
19
 * @package Redaxscript
20
 * @category Head
21
 * @author Henry Ruhs
22
 */
23
24
abstract class HeadAbstract extends Singleton implements HeadInterface
25
{
26
	/**
27
	 * collection namespace
28
	 *
29
	 * @var string
30
	 */
31
32
	protected static $_namespace = 'Redaxscript\Head';
33
34
	/**
35
	 * collection of the head
36
	 *
37
	 * @var array
38
	 */
39
40
	protected static $_collectionArray = [];
41
42
	/**
43
	 * stringify the collection
44
	 *
45
	 * @since 3.0.0
46
	 *
47
	 * @return string
48
	 */
49 25
50
	public function __toString() : string
51 25
	{
52 25
		$render = $this->render();
53
		if ($render)
54 16
		{
55
			return $render;
56 9
		}
57
		return '<!-- ' . self::$_namespace . ' -->';
58
	}
59
60
	/**
61
	 * init the class
62
	 *
63
	 * @param string $namespace collection sub namespace
64
	 *
65
	 * @since 3.0.0
66
	 *
67
	 * @return self
68
	 */
69 26
70
	public function init(string $namespace = null) : self
71 26
	{
72 26
		self::$_namespace = static::class;
73
		if ($namespace)
0 ignored issues
show
Bug Best Practice introduced by
The expression $namespace of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
74 26
		{
75
			self::$_namespace .= '\\' . ucfirst($namespace);
76 26
		}
77
		return $this;
78
	}
79
80
	/**
81
	 * append to the collection
82
	 *
83
	 * @since 3.0.0
84
	 *
85
	 * @param string|array $attribute key or array of attributes
86
	 * @param string $value value of the attribute
87
	 *
88
	 * @return self
89
	 */
90 8
91
	public function append($attribute = null, string $value = null) : self
92 8
	{
93 8
		$collectionArray = $this->_getCollectionArray();
94
		if (is_array($attribute))
95 8
		{
96
			$collectionArray[] = array_map('trim', $attribute);
97 1
		}
98
		else if (strlen($attribute) && strlen($value))
99 1
		{
100
			$collectionArray[] =
101 1
			[
102
				trim($attribute) => trim($value)
103
			];
104 8
		}
105 8
		$this->_setCollectionArray($collectionArray);
106
		return $this;
107
	}
108
109
	/**
110
	 * prepend to the collection
111
	 *
112
	 * @since 3.0.0
113
	 *
114
	 * @param string|array $attribute key or array of attributes
115
	 * @param string $value value of the attribute
116
	 *
117
	 * @return self
118
	 */
119 4
120
	public function prepend($attribute = null, string $value = null) : self
121 4
	{
122 4
		$collectionArray = $this->_getCollectionArray();
123
		if (is_array($attribute))
124 4
		{
125
			array_unshift($collectionArray, array_map('trim', $attribute));
126 1
		}
127
		else if (strlen($attribute) && strlen($value))
128 1
		{
129
			array_unshift($collectionArray,
130 1
			[
131
				trim($attribute) => trim($value)
132
			]);
133 4
		}
134 4
		$this->_setCollectionArray($collectionArray);
135
		return $this;
136
	}
137
138
	/**
139
	 * remove from to the collection
140
	 *
141
	 * @since 3.0.0
142
	 *
143
	 * @param string $attribute name of attribute
144
	 * @param string $value value of the attribute
145
	 *
146
	 * @return self
147
	 */
148 2
149
	public function remove(string $attribute = null, string $value = null) : self
150 2
	{
151 2
		$collectionArray = $this->_getCollectionArray();
152
		if (is_array($collectionArray))
153 2
		{
154
			foreach ($collectionArray as $collectionKey => $collectionValue)
155 2
			{
156
				if ($collectionValue[$attribute] === $value)
157 2
				{
158
					array_splice($collectionArray, $collectionKey, 1);
159
				}
160 2
			}
161
			$this->_setCollectionArray($collectionArray);
162 2
		}
163
		return $this;
164
	}
165
166
	/**
167
	 * clear the collection
168
	 *
169
	 * @since 3.0.0
170
	 *
171
	 * @return self
172
	 */
173 25
174
	public function clear() : self
175 25
	{
176 25
		$this->_setCollectionArray();
177
		return $this;
178
	}
179
180
	/**
181
	 * get the collection array
182
	 *
183
	 * @since 3.0.0
184
	 *
185
	 * @return array
186
	 */
187 25
188
	protected function _getCollectionArray() : array
189 25
	{
190
		return array_key_exists(self::$_namespace, self::$_collectionArray) ? self::$_collectionArray[self::$_namespace] : [];
191
	}
192
193
	/**
194
	 * set the collection array
195
	 *
196
	 * @since 3.0.0
197
	 *
198
	 * @param array $collectionArray
199
	 */
200 25
201
	protected function _setCollectionArray(array $collectionArray = []) : void
202 25
	{
203 25
		self::$_collectionArray[self::$_namespace] = $collectionArray;
204
	}
205
}
206