Issues (45)

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.

src/Output/HTML/Basic.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
/**
3
 * Class Basic
4
 *
5
 * @filesource   Basic.php
6
 * @created      26.04.2018
7
 * @package      chillerlan\BBCode\Output\HTML
8
 * @author       smiley <[email protected]>
9
 * @copyright    2018 smiley
10
 * @license      MIT
11
 */
12
13
namespace chillerlan\BBCode\Output\HTML;
14
15
class Basic extends HTMLModuleAbstract{
16
17
	/**
18
	 * @var array
19
	 */
20
	protected $tags = [
21
		'noparse', 'nobb', 'color', 'font', 'size','br', 'hr', 'clear','img', 'url', 'c', 'list',
22
		'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
23
		'strong', 'sub', 'sup', 'del', 'small', 'em', 's', 'b', 'u', 'i', 'tt',
24
	];
25
26
	/**
27
	 * @var array
28
	 */
29
	protected $singletags = ['br', 'hr', 'clear'];
30
31
	/**
32
	 * @var array
33
	 */
34
	protected $noparse = ['noparse', 'nobb', 'c'];
35
36
	/**
37
	 * @return string
38
	 */
39
	protected function transform():string{
40
41
		if(empty($this->content)){
42
			return '';
43
		}
44
45
		return '<'.$this->tag.' class="bb-text '.$this->tag.'">'.$this->content.'</'.$this->tag.'>';
46
	}
47
48
	/**
49
	 * @return string
50
	 */
51
	protected function nobb():string{
52
		return $this->noparse();
53
	}
54
55
	/**
56
	 * @return string
57
	 */
58
	protected function noparse():string{
59
		$this->clearPseudoClosingTags();
60
61
		return '<pre class="bb-noparse">'.$this->content.'</pre>'; // $this->match
62
	}
63
64
	/**
65
	 * @return string
66
	 */
67
	protected function c(){ // @todo
68
		$this->clearPseudoClosingTags();
69
		return '<code class="bb-inline-code" style="display: inline">'.$this->content.'</code>';
70
	}
71
72
	/**
73
	 * @return string
74
	 */
75
	protected function color(){
76
		// @todo: preg_match('/^#([a-f\d]{3}){1,2}$/i', $value)
77
		return '<span class="bb-text color" style="color: '.'; background-color: '.';">'.$this->content.'</span>';
78
	}
79
80
	/**
81
	 * @return string
82
	 */
83
	protected function font(){ // @todo: restrict fonts via classname
84
		return '<span class="bb-text font comic-sans">'.$this->content.'</span>';
85
	}
86
87
	/**
88
	 * @return string
89
	 */
90
	protected function size(){ // @todo: restrict sizes via css
91
		return '<span class="bb-text size extra-tiny">'.$this->content.'</span>';
92
	}
93
94
	/**
95
	 * @return string
96
	 */
97
	public function br():string{ // @todo: adjust padding-bottom
98
		return '<br class="bb-br"/>';
99
	}
100
101
	/**
102
	 * @return string
103
	 */
104
	public function hr():string{ // @todo line style
105
		return '<hr class="bb-hr"/>';
106
	}
107
108
	/**
109
	 * @return string
110
	 */
111
	protected function clear(){
112
		return '<br class="bb-clear '.$this->bbtagIn(['both', 'left', 'right'], 'both').'"/>';
113
	}
114
115
	/**
116
	 * @return string
117
	 */
118 View Code Duplication
	protected function img():string{
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...
119
		$url = filter_var($this->content, FILTER_VALIDATE_URL);// @todo
120
121
		if(!$url){
122
			return '';
123
		}
124
125
		return '<img src="'.$url.'" class="bb-img" alt />'; // @todo: alt, title
126
	}
127
128
	/**
129
	 * @return string
130
	 */
131
	protected function url():string{
132
133
		if(empty($this->content)){
134
			return '';
135
		}
136
137
		$url    = filter_var($this->bbtag() ?? $this->content, FILTER_VALIDATE_URL);// @todo
138
		$host   = parse_url($url, PHP_URL_HOST);
139
		$target = (!empty($host) && (isset($_SERVER['SERVER_NAME']) && $host === $_SERVER['SERVER_NAME'])) || empty($host) ? 'self' : 'blank';
140
141
		return '<a class="bb-url '.$target.'" '.($url ? ' href="'.$url.'" target="_'.$target.'"' : '').'>'.$this->content.'</a>'; // .$this->getTitle()
142
143
	}
144
145
	/**
146
	 * @return string
147
	 */
148
	protected function list():string{
149
150
		if(empty($this->content)){
151
			return '';
152
		}
153
154
		$ol    = ['0', '1', 'a', 'A', 'i', 'I'];
155
		$ul    = ['c', 'd', 's'];
156
		$types = [
157
			'0' => 'decimal-leading-zero',
158
			'1' => 'decimal',
159
			'a' => 'lower-alpha',
160
			'A' => 'upper-alpha',
161
			'i' => 'lower-roman',
162
			'I' => 'upper-roman',
163
			'c' => 'circle',
164
			's' => 'square',
165
			'd' => 'disc',
166
		];
167
168
		$start    = $this->bbtag();
169
		$list_tag = (count($this->attributes) === 0 || $this->attributeIn('type', $ul) ? 'ul' : 'ol');
170
171
		return '<'.$list_tag.' class="bb-list '.$this->attributeKeyIn('type', $types, 'disc').'" '
172
		       .(is_numeric($start) && $this->attributeIn('type', $ol) ? ' start="'.ceil($start).'"' : '')
173
		       .($this->getAttribute('reversed') && $this->attributeIn('type', $ol) ? ' reversed="true"' : '')
174
		       .'>'
175
		       .'<li>'.implode(array_slice(explode('[*]', $this->content), true), '</li><li>').'</li>' // nasty
176
		       .'</'.$list_tag.'>';
177
	}
178
179
}
180