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

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\Model;
3
4
use PDOException;
5
use function array_filter;
6
use function implode;
7
use function is_array;
8
9
/**
10
 * parent class to provide the comment model
11
 *
12
 * @since 3.3.0
13
 *
14
 * @package Redaxscript
15
 * @category Model
16
 * @author Henry Ruhs
17
 */
18
19
class Comment extends ContentAbstract
20
{
21
	/**
22
	 * name of the table
23
	 *
24
	 * @var string
25
	 */
26
27
	protected $_table = 'comments';
28
29
	/**
30
	 * count the comments by article and language
31
	 *
32
	 * @since 4.0.0
33
	 *
34
	 * @param int $articleId identifier of the article
35
	 * @param string $language
36
	 *
37
	 * @return int|null
38
	 */
39
40 4
	public function countByArticleAndLanguage(int $articleId = null, string $language = null) : ?int
41
	{
42
		return $this
43 4
			->query()
44 4
			->where(
45
			[
46 4
				'article' => $articleId,
47 4
				'status' => 1
48
			])
49 4
			->whereLanguageIs($language)
50 4
			->count() ? : null;
51
	}
52
53
	/**
54
	 * max id by article and language
55
	 *
56
	 * @since 4.5.0
57
	 *
58
	 * @param int $articleId identifier of the article
59
	 * @param string $language
60
	 *
61
	 * @return int|null
62
	 */
63
64
	public function maxIdByArticleAndLanguage(int $articleId = null, string $language = null) : ?int
65
	{
66
		return $this
67
			->query()
68
			->where(
69
			[
70
				'article' => $articleId,
71
				'status' => 1
72
			])
73
			->whereLanguageIs($language)
74
			->max('id') ? : null;
75
	}
76
77
	/**
78
	 * get the comments by article and language and order and step
79
	 *
80
	 * @since 4.0.0
81
	 *
82
	 * @param int $articleId identifier of the article
83
	 * @param string $language
84
	 * @param string $orderColumn
85
	 * @param int $limitStep
86
	 *
87
	 * @return object|null
88
	 */
89
90 5
	public function getByArticleAndLanguageAndOrderAndStep(int $articleId = null, string $language = null, string $orderColumn = 'rank', int $limitStep = null) : ?object
91
	{
92
		$query = $this
93 5
			->query()
94 5
			->where(
95
			[
96 5
				'article' => $articleId,
97 5
				'status' => 1
98
			])
99 5
			->whereLanguageIs($language)
100 5
			->orderBySetting($orderColumn);
101 5
		if ($limitStep)
0 ignored issues
show
Bug Best Practice introduced by
The expression $limitStep of type null|integer is loosely compared to true; this is ambiguous if the integer can be zero. 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 integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
102
		{
103 1
			$query->limitBySetting($limitStep);
104
		}
105 5
		return $query->findMany() ? : null;
106
	}
107
108
	/**
109
	 * get the comment route by id
110
	 *
111
	 * @since 3.3.0
112
	 *
113
	 * @param int $commentId identifier of the comment
114
	 *
115
	 * @return string|null
116
	 */
117
118 4
	public function getRouteById(int $commentId = null) : ?string
119
	{
120 4
		if ($commentId)
0 ignored issues
show
Bug Best Practice introduced by
The expression $commentId of type null|integer is loosely compared to true; this is ambiguous if the integer can be zero. 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 integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
121
		{
122
			$routeArray = $this
123 3
				->query()
124 3
				->tableAlias('comment')
125 3
				->leftJoinPrefix('articles', 'comment.article = article.id', 'article')
126 3
				->leftJoinPrefix('categories', 'article.category = category.id', 'category')
127 3
				->leftJoinPrefix('categories', 'category.parent = parent.id', 'parent')
128 3
				->select('parent.alias', 'parentAlias')
129 3
				->select('category.alias', 'categoryAlias')
130 3
				->select('article.alias', 'articleAlias')
131 3
				->where('comment.id', $commentId)
132 3
				->findArray();
133
134
			/* handle route */
135
136 3
			if (is_array($routeArray[0]))
137
			{
138 3
				return implode('/', array_filter($routeArray[0])) . '#comment-' . $commentId;
139
			}
140
		}
141 1
		return null;
142
	}
143
144
	/**
145
	 * create the comment by array
146
	 *
147
	 * @since 3.3.0
148
	 *
149
	 * @param array $createArray array of the create
150
	 *
151
	 * @return bool
152
	 */
153
154 2
	public function createByArray(array $createArray = []) : bool
155
	{
156
		try
157
		{
158
			return $this
159 2
				->query()
160 2
				->create()
161 2
				->set($createArray)
162 2
				->save();
163
		}
164 1
		catch (PDOException $exception)
165
		{
166 1
			return false;
167
		}
168
	}
169
}
170