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/Article.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 function array_filter;
5
use function implode;
6
use function is_array;
7
8
/**
9
 * parent class to provide the article model
10
 *
11
 * @since 3.3.0
12
 *
13
 * @package Redaxscript
14
 * @category Model
15
 * @author Henry Ruhs
16
 */
17
18
class Article extends ContentAbstract
19
{
20
	/**
21
	 * name of the table
22
	 *
23
	 * @var string
24
	 */
25
26
	protected $_table = 'articles';
27
28
	/**
29
	 * get the article by alias
30
	 *
31
	 * @since 4.0.0
32
	 *
33
	 * @param string $articleAlias alias of the article
34
	 *
35
	 * @return object|null
36
	 */
37
38 2
	public function getByAlias(string $articleAlias = null) : ?object
39
	{
40 2
		return $this->query()->where('alias', $articleAlias)->findOne() ? : null;
41
	}
42
43
	/**
44
	 * count the articles by category and language
45
	 *
46
	 * @since 4.0.0
47
	 *
48
	 * @param int $categoryId identifier of the category
49
	 * @param string $language
50
	 *
51
	 * @return int|null
52
	 */
53
54 3
	public function countByCategoryAndLanguage(int $categoryId = null, string $language = null) : ?int
55
	{
56
		return $this
57 3
			->query()
58 3
			->where(
59
			[
60 3
				'category' => $categoryId,
61 3
				'status' => 1
62
			])
63 3
			->whereLanguageIs($language)
64 3
			->count() ? : null;
65
	}
66
67
	/**
68
	 * get the siblings by category and language and order and step
69
	 *
70
	 * @since 4.0.0
71
	 *
72
	 * @param int $categoryId identifier of the category
73
	 * @param string $language
74
	 * @param string $orderColumn
75
	 * @param int $limitStep
76
	 *
77
	 * @return object|null
78
	 */
79
80 5
	public function getSiblingByCategoryAndLanguageAndOrderAndStep(int $categoryId = null, string $language = null, string $orderColumn = 'rank', int $limitStep = null) : ?object
81
	{
82 5
		$categoryModel = new Category();
83
		$query = $this
84 5
			->query()
85 5
			->whereIn('category', $categoryModel->getSiblingArrayById($categoryId))
86 5
			->where('status', 1)
87 5
			->whereLanguageIs($language)
88 5
			->orderBySetting($orderColumn);
89 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...
90
		{
91 1
			$query->limitBySetting($limitStep);
92
		}
93 5
		return $query->findMany() ? : null;
94
	}
95
96
	/**
97
	 * get the article route by id
98
	 *
99
	 * @since 3.3.0
100
	 *
101
	 * @param int $articleId identifier of the article
102
	 *
103
	 * @return string|null
104
	 */
105
106 6
	public function getRouteById(int $articleId = null) : ?string
107
	{
108 6
		if ($articleId)
0 ignored issues
show
Bug Best Practice introduced by
The expression $articleId 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...
109
		{
110
			$routeArray = $this
111 5
				->query()
112 5
				->tableAlias('article')
113 5
				->leftJoinPrefix('categories', 'article.category = category.id', 'category')
114 5
				->leftJoinPrefix('categories', 'category.parent = parent.id', 'parent')
115 5
				->select('parent.alias', 'parentAlias')
116 5
				->select('category.alias', 'categoryAlias')
117 5
				->select('article.alias', 'articleAlias')
118 5
				->where('article.id', $articleId)
119 5
				->findArray();
120
121
			/* handle route */
122
123 5
			if (is_array($routeArray[0]))
124
			{
125 5
				return implode('/', array_filter($routeArray[0]));
126
			}
127
		}
128 1
		return null;
129
	}
130
}
131