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/Captcha.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
namespace Redaxscript;
3
4
use function is_numeric;
5
use function random_int;
6
7
/**
8
 * parent class to provide a mathematical task
9
 *
10
 * @since 2.0.0
11
 *
12
 * @package Redaxscript
13
 * @category Captcha
14
 * @author Henry Ruhs
15
 */
16
17
class Captcha
18
{
19
	/**
20
	 * captcha operator mode
21
	 *
22
	 * @var int
23
	 */
24
25
	protected int $_mode;
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
26
27
	/**
28
	 * task to be solved
29
	 *
30
	 * @var string
31
	 */
32
33
	protected string $_task;
34
35
	/**
36
	 * solution to the task
37
	 *
38
	 * @var int
39
	 */
40
41
	protected string $_solution;
42
43
	/**
44
	 * allowed range for the task
45
	 *
46
	 * @var array
47
	 */
48
49
	protected array $_rangeArray =
50
	[
51
		'min' => 1,
52
		'max' => 10
53
	];
54
55
	/**
56
	 * array of mathematical operators used for the task
57
	 *
58
	 * @var array
59
	 */
60
61
	protected array $_operatorArray =
62
	[
63
		1 => 'plus',
64
		-1 => 'minus'
65
	];
66
67
	/**
68
	 * constructor of the class
69
	 *
70
	 * @since 2.4.0
71
	 *
72
	 * @param Language $_language instance of the language class
73
	 */
74
75
	public function __construct(protected Language $_language)
76
	{
77
	}
78
79
	/**
80
	 * init the class
81
	 *
82
	 * @since 2.4.0
83 5
	 *
84
	 * @param int $mode captcha operator mode
85 5
	 */
86 5
87
	public function init(int $mode = null) : void
88
	{
89
		if (is_numeric($mode))
90
		{
91
			$this->_mode = $mode;
92
		}
93
		else
94
		{
95
			$settingModel = new Model\Setting();
96 5
			$this->_mode = $settingModel->get('captcha');
97
		}
98 5
		$this->_create();
99
	}
100 2
101
	/**
102
	 * get the task
103
	 *
104 3
	 * @since 2.0.0
105 3
	 *
106
	 * @return string
107 5
	 */
108 5
109
	public function getTask() : string
110
	{
111
		return $this->_task;
112
	}
113
114
	/**
115
	 * get the solution
116
	 *
117
	 * @since 2.6.0
118 1
	 *
119
	 * @return int
120 1
	 */
121
122
	public function getSolution() : int
123
	{
124
		return $this->_solution;
125
	}
126
127
	/**
128
	 * get the minimum range
129
	 *
130
	 * @since 2.6.0
131 3
	 *
132
	 * @return int
133 3
	 */
134
135
	public function getMin() : int
136
	{
137
		return $this->_rangeArray['min'];
138
	}
139
140
	/**
141
	 * get the maximum range
142
	 *
143
	 * @since 2.6.0
144 5
	 *
145
	 * @return int
146 5
	 */
147
148
	public function getMax() : int
149
	{
150
		return $this->_rangeArray['max'];
151
	}
152
153
	/**
154
	 * get the mathematical operator used for the task
155
	 *
156
	 * @since 2.0.0
157 5
	 *
158
	 * @return int
159 5
	 */
160
161
	protected function _getOperator() : int
162
	{
163
		if ($this->_mode === 2)
164
		{
165
			return 1;
166
		}
167
		if ($this->_mode === 3)
168
		{
169
			return -1;
170 5
		}
171
		return random_int(0, 1) * 2 - 1;
172 5
	}
173
174 1
	/**
175
	 * create a task of two numbers between allowable range
176 4
	 *
177
	 * @since 2.0.0
178 1
	 */
179
180 3
	protected function _create() : void
181
	{
182
		/* range */
183
184
		$min = $this->getMin();
185
		$max = $this->getMax();
186
187
		/* random numbers */
188
189 5
		$a = random_int($min + 1, $max);
190
		$b = random_int($min, $a - 1);
191
192
		/* operator */
193 5
194 5
		$c = $this->_getOperator();
195
		$operator = $this->_operatorArray[$c];
196
197
		/* solution and task */
198 5
199 5
		$this->_solution = $a + $b * $c;
200
		$this->_task = $this->_language->get('_number')[$a] . ' ' . $this->_language->get($operator) . ' ' . $this->_language->get('_number')[$b];
201
	}
202
}
203