Issues (277)

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.

Ajax/common/html/HtmlCollection.php (4 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
3
namespace Ajax\common\html;
4
5
use Ajax\common\html\HtmlDoubleElement;
6
use Ajax\service\JArray;
7
use Ajax\JsUtils;
8
9
/**
10
 * Base class for Html collections
11
 * @author jc
12
 * @version 1.001
13
 */
14
abstract class HtmlCollection extends HtmlDoubleElement {
15
16
	public function __construct($identifier,$tagName="div"){
17
		parent::__construct($identifier,$tagName);
18
		$this->content=array();
19
	}
20
21 View Code Duplication
	public function addItems($items){
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
		if(JArray::isAssociative($items)){
23
			foreach ($items as $k=>$v){
24
				$this->addItem([$k,$v]);
0 ignored issues
show
array($k, $v) is of type array<integer,?,{"0":"integer|string","1":"?"}>, but the function expects a object<Ajax\common\html\HtmlDoubleElement>|string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
25
			}
26
		}else{
27
			foreach ($items as $item){
28
				$this->addItem($item);
29
			}
30
		}
31
		return $this;
32
	}
33
34
	public function setItems($items){
35
		$this->content=$items;
36
		return $this;
37
	}
38
39
	public function getItems(){
40
		return $this->content;
41
	}
42
43
	protected function getItemToAdd($item){
44
		$itemO=$item;
45
		if($this->createCondition($item)===true){
46
			$itemO=$this->createItem($item);
47
		}
48
		return $itemO;
49
	}
50
51
	/**
52
	 * adds and returns an item
53
	 * @param HtmlDoubleElement|string $item
54
	 * @return \Ajax\common\html\HtmlDoubleElement
55
	 */
56
	public function addItem($item){
57
		$itemO=$this->getItemToAdd($item);
58
		$this->addContent($itemO);
59
		return $itemO;
60
	}
61
62
	public function insertItem($item,$position=0){
63
		$itemO=$this->getItemToAdd($item);
64
		\array_splice( $this->content, $position, 0, array($itemO));
65
		return $itemO;
66
	}
67
68
	/**
69
	 * Return the item at index
70
	 * @param int|string $index the index or the item identifier
71
	 * @return \Ajax\common\html\HtmlDoubleElement
72
	 */
73 View Code Duplication
	public function getItem($index) {
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
74
		if (is_int($index))
75
			return $this->content[$index];
76
		else {
77
			$elm=$this->getElementById($index, $this->content);
78
			return $elm;
79
		}
80
	}
81
82
	public function setItem($index, $value) {
83
		$this->content[$index]=$value;
84
		return $this;
85
	}
86
87
	public function removeItem($index){
88
		return array_splice($this->content, $index, 1);
89
	}
90
91
	public function count(){
92
		return \sizeof($this->content);
93
	}
94
95
	/* (non-PHPdoc)
96
	 * @see \Ajax\bootstrap\html\base\BaseHtml::fromDatabaseObject()
97
	 */
98
	public function fromDatabaseObject($object, $function) {
99
		return $this->addItem($function($object));
100
	}
101
102
	public function apply($callBack){
103
		foreach ($this->content as $item){
104
			$callBack($item);
105
		}
106
		return $this;
107
	}
108
109
	/*
110
	 * (non-PHPdoc)
111
	 * @see \Ajax\bootstrap\html\HtmlSingleElement::fromArray()
112
	 */
113
	public function fromArray($array) {
114
		$this->addItems($array);
115
		return $this;
116
	}
117
	/**
118
	 * The item factory
119
	 * @param mixed $value
120
	 */
121
	protected abstract function createItem($value);
0 ignored issues
show
The abstract declaration must precede the visibility declaration
Loading history...
122
123
	protected function createCondition($value){
124
		return \is_object($value)===false;
125
	}
126
127
	protected function contentAs($tagName){
128
		foreach ($this->content as $item){
129
			$item->setTagName($tagName);
130
		}
131
		return $this;
132
	}
133
}