Issues (166)

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.

src/Outline/TemplateBuilder.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
3
namespace SRF\Outline;
4
5
use SMW\Query\PrintRequest;
6
use SRF\Outline\OutlineTree;
7
8
/**
9
 * @license GNU GPL v2+
10
 * @since 3.1
11
 *
12
 * @author mwjames
13
 */
14
class TemplateBuilder {
15
16
	/**
17
	 * @var []
18
	 */
19
	private $params = [];
20
21
	/**
22
	 * @var Linker
23
	 */
24
	private $linker;
25
26
	/**
27
	 * @var string
28
	 */
29
	private $template = '';
30
31
	/**
32
	 * @param array $params
33
	 */
34 3
	public function __construct( array $params ) {
35 3
		$this->params = $params;
36 3
	}
37
38
	/**
39
	 * @since 3.1
40
	 *
41
	 * @param Linker|null|false $linker
42
	 */
43 1
	public function setLinker( $linker ) {
44 1
		$this->linker = $linker;
45 1
	}
46
47
	/**
48
	 * @since 3.1
49
	 *
50
	 * @param OutlineTree $tree
51
	 *
52
	 * @return string
53
	 */
54 2
	public function build( OutlineTree $outlineTree ) {
55 2
		$this->tree( $outlineTree );
56
57 2
		return $this->getIntroTemplate() . $this->template . $this->getOutroTemplate();
58
	}
59
60 2
	private function tree( $outlineTree, $level = 0 ) {
61
62 2
		if ( $outlineTree->items !== null ) {
63 2
			foreach ( $outlineTree->items as $i => $item ) {
64 1
				$this->template .= $this->item( $i, $item );
65
			}
66
		}
67
68 2
		foreach ( $outlineTree->tree as $key => $node ) {
69 1
			$property = $this->params['outlineproperties'][$level];
70 1
			$class = $this->params['template'] . '-section-' . strtolower( str_replace( ' ', '-', $property ) );
71
72 1
			$this->template .= "<div class='$class'>";
73 1
			$this->template .= $this->open( $this->params['template'] . "-header" );
74 1
			$this->template .= $this->parameter( $property, $key );
75 1
			$this->template .= $this->parameter( "#outlinelevel", $level );
76 1
			$this->template .= $this->parameter( "#itemcount",  $node->leafCount );
77 1
			$this->template .= $this->parameter( "#userparam", $this->params['userparam'] );
78 1
			$this->template .= $this->close();
79 1
			$this->template .= "<div class='" . $this->params['template'] . "-items'>";
80 1
			$this->tree( $node, $level + 1 );
81 1
			$this->template .= "</div>";
82 1
			$this->template .= "</div>";
83
		}
84 2
	}
85
86 1
	private function item( $i, $item ) {
87
88 1
		$first_col = true;
89 1
		$template = '';
90 1
		$linker = $this->params['link'] === 'all' ? $this->linker : null;
91 1
		$itemnumber = 0;
92
93 1
		foreach ( $item->row as $resultArray ) {
94
95 1
			$printRequest = $resultArray->getPrintRequest();
96 1
			$val = $printRequest->getText( SMW_OUTPUT_WIKI, null );
97
98 1
			if ( in_array( $val, $this->params['outlineproperties'] ) ) {
99 1
				continue;
100
			}
101
102 1
			while ( ( $dv = $resultArray->getNextDataValue() ) !== false ) {
103 1
				$template .= $this->open( $this->params['template'] . '-item' );
104 1
				$template .= $this->parameter( "#itemsection", $i );
105
106 1
				$template .= $this->parameter( "#itemnumber", $itemnumber );
107 1
				$template .= $this->parameter( "#userparam", $this->params['userparam'] );
108
109 1
				$template .= $this->itemRaw($dv);
110
111 1
				$template .= $this->itemText( $dv, $linker, $printRequest, $first_col );
112 1
				$template .= $this->close();
113
114 1
				$itemnumber++;
115
			}
116
		}
117
118 1
		return "<div class='" . $this->params['template'] . "-item'>" . $template . '</div>';
119
	}
120
121 1
	private function itemText( $dv, $linker, $printRequest, &$first_col ) {
122
123 1
		if ( $first_col && $printRequest->isMode( PrintRequest::PRINT_THIS ) ) {
124 1
			$first_col = false;
125
126 1
			if ( $linker === null && ( $caption = $dv->getDisplayTitle() ) !== '' ) {
127
				$dv->setCaption( $caption );
128
			}
129
130 1
			$text = $dv->getShortText(
131 1
				SMW_OUTPUT_WIKI,
132 1
				$this->params['link'] === 'subject' ? $this->linker : $linker
133
			);
134
135 1
			return $this->parameter( "#itemsubject", $text );
136
		}
137
138 1
		$text = $dv->getShortText(
139 1
			SMW_OUTPUT_WIKI,
140
			$linker
141
		);
142
143 1
		return $this->parameter( $printRequest->getLabel(), $text );
144
	}
145
146 1
	private function itemRaw( $dv ){
147 1
		$rawText = $dv->getShortText( SMW_OUTPUT_WIKI );
148
149 1
		return $this->parameter( "#itemsubjectraw", $rawText );
150
	}
151
152 2
	private function open( $v ) {
153 2
		return "{{" . $v;
154
	}
155
156 1
	private function parameter( $k, $v ) {
157 1
		return " |$k=$v";
158
	}
159
160 2
	private function close() {
161 2
		return "}}";
162
	}
163
164 2
	function getIntroTemplate(): string {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
165 2
		if ( $this->params['introtemplate'] === '' ) {
166 1
			return "";
167
		}
168 2
		return $this->open( $this->params['introtemplate'] ) . $this->close();
169
	}
170
171 2
	function getOutroTemplate(): string {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
172 2
		if ( $this->params['outrotemplate'] === '' ) {
173 1
			return "";
174
		}
175 2
		return $this->open( $this->params['outrotemplate'] ) . $this->close();
176
	}
177
178
}
179