Issues (141)

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.

formats/slideshow/SRF_SlideShowApi.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
use ParamProcessor\ParamDefinition;
4
use SMW\DataValueFactory;
5
6
/**
7
 * API module to retrieve formatted results for a given page, printouts and template.
8
 *
9
 * @author Stephan Gambke
10
 * @ingroup SemanticResultFormats
11
 */
12
class SRFSlideShowApi extends ApiBase {
13
14
	/**
15
	 * Evaluates the parameters, performs the query, and sets up the result.
16
	 *
17
	 * The result data is stored in the ApiResult object available through getResult().
18
	 */
19
	public function execute() {
20
21
		// get request parameters
22
		$requestParams = $this->extractRequestParams();
23
24
		$title = Title::newFromID( $requestParams['pageid'] )->getPrefixedText();
25
26
		$rp = new SMWListResultPrinter( 'template', true );
27
28
		// get defaults of parameters for the 'template' result format as array of ParamDefinition
29
		$paramDefinitions = ParamDefinition::getCleanDefinitions( $rp->getParamDefinitions( [] ) );
0 ignored issues
show
Deprecated Code introduced by kghbln
The method ParamProcessor\ParamDefi...::getCleanDefinitions() has been deprecated with message: since 1.7 - use ParamDefinitionFactory

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
30
31
		// transform into normal key-value array
32
		$queryParams = [];
33
34
		foreach ( $paramDefinitions as $def ) {
35
			$queryParams[$def->getName()] = $def->getDefault();
36
		}
37
38
		// add/set specific parameters for this call
39
		$queryParams = array_merge(
40
			$queryParams,
41
			[
42
				'format' => 'template',
43
				'template' => $requestParams['template'],
44
				'mainlabel' => '',
45
				'sort' => '',
46
				'order' => '',
47
				'intro' => null,
48
				'outro' => null,
49
				'searchlabel' => null,
50
				'link' => null,
51
				'default' => null,
52
				'headers' => null,
53
				'introtemplate' => '',
54
				'outrotemplate' => '',
55
			]
56
		);
57
58
		// A bit of a hack since the parser isn't run, avoids [[SMW::off]]/[[SMW::on]]
59
		$queryParams['import-annotation'] = 'true';
60
61
		// transform query parameters into format suitable for SMWQueryProcessor
62
		$queryParams = SMWQueryProcessor::getProcessedParams( $queryParams, [] );
63
64
		// build array of printouts
65
66
		$printoutsRaw = json_decode( $requestParams['printouts'], true );
67
		$printouts = [];
68
69
		foreach ( $printoutsRaw as $printoutData ) {
70
71
			// if printout mode is PRINT_PROP
72
			if ( $printoutData[0] == SMWPrintRequest::PRINT_PROP ) {
73
				// create property from property key
74
				$data = DataValueFactory::getInstance()->newPropertyValueByLabel( $printoutData[2] );
75
			} else {
76
				$data = null;
77
			}
78
79
			// create printrequest from request mode, label, property name, output format, parameters
80
			$printouts[] = new SMWPrintRequest(
81
				$printoutData[0],
82
				$printoutData[1],
83
				$data,
84
				$printoutData[3],
85
				$printoutData[4]
86
			);
87
		}
88
89
		// query SMWQueryProcessor and set query result as API call result
90
		$query = SMWQueryProcessor::createQuery(
91
			'[[' . $title . ']]',
92
			$queryParams,
93
			SMWQueryProcessor::INLINE_QUERY,
94
			'',
95
			$printouts
96
		);
97
98
		$this->getResult()->addValue(
99
			null,
100
			$requestParams['pageid'],
101
			SMWQueryProcessor::getResultFromQuery( $query, $queryParams, SMW_OUTPUT_HTML, SMWQueryProcessor::INLINE_QUERY )
102
		);
103
	}
104
105
	/**
106
	 * Returns the description string for this module
107
	 *
108
	 * @return mixed string or array of strings
109
	 */
110
	protected function getDescription() {
111
		return [
112
			'API module used by the SlideShow result printer to retrieve formatted results.',
113
			'This module is should not be called directly.'
114
		];
115
	}
116
117
	/**
118
	 * Returns usage examples for this module. Return false if no examples are available.
119
	 *
120
	 * @return bool|string|array
121
	 */
122
	protected function getExamples() {
123
		return false;
124
	}
125
126
	public function getHelpUrls() {
127
		return 'http://semantic-mediawiki.org/wiki/Help:Slideshow_format';
128
	}
129
130
	/**
131
	 * Returns an array of allowed parameters
132
	 *
133
	 * @return array|bool
134
	 */
135
	protected function getAllowedParams() {
136
		return [
137
			'pageid' => [
138
				ApiBase::PARAM_TYPE => 'integer',
139
				ApiBase::PARAM_ISMULTI => false,
140
				ApiBase::PARAM_REQUIRED => true,
141
			],
142
			'template' => [
143
				ApiBase::PARAM_TYPE => 'string',
144
				ApiBase::PARAM_ISMULTI => false,
145
				ApiBase::PARAM_REQUIRED => true,
146
			],
147
			'printouts' => [
148
				ApiBase::PARAM_TYPE => 'string',
149
				ApiBase::PARAM_ISMULTI => false,
150
				ApiBase::PARAM_REQUIRED => false,
151
				ApiBase::PARAM_DFLT => '[]',
152
			],
153
		];
154
	}
155
156
	/**
157
	 * Returns an array of parameter descriptions.
158
	 * Don't call this function directly: use getFinalParamDescription() to
159
	 * allow hooks to modify descriptions as needed.
160
	 *
161
	 * @return array|bool False on no parameter descriptions
162
	 */
163
	protected function getParamDescription() {
164
		return [
165
			'pageid' => 'Id of the page (subject) to be displayed',
166
			'template' => 'Template to use for formatting',
167
			'printouts' => 'Printouts to send to the template',
168
		];
169
	}
170
171
	/**
172
	 * Returns a string that identifies the version of the extending class.
173
	 * Typically includes the class name, the svn revision, timestamp, and
174
	 * last author. Usually done with SVN's Id keyword
175
	 *
176
	 * @return string
177
	 */
178
	public function getVersion() {
179
		global $srfgIP;
180
		$gitSha1 = SpecialVersion::getGitHeadSha1( $srfgIP );
181
		return __CLASS__ . '-' . SRF_VERSION . ( $gitSha1 !== false ) ? ' (' . substr( $gitSha1, 0, 7 ) . ')' : '';
182
	}
183
184
}
185