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/filtered/src/Filters/DistanceFilter.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
namespace SRF\Filtered\Filter;
4
5
/**
6
 * File holding the SRF_FF_Distance class
7
 *
8
 * @author Stephan Gambke
9
 * @file
10
 * @ingroup SemanticResultFormats
11
 */
12
13
use DataValues\Geo\Parsers\LatLongParser;
14
use Exception;
15
use SMWPropertyValue;
16
use SRF\Filtered\ResultItem;
17
18
/**
19
 * The SRF_FF_Distance class.
20
 *
21
 * Available parameters for this filter:
22
 *   distance filter origin: the point from which the distance is measured (address or geo coordinate)
23
 *   distance filter property: the property containing the point to which distance is measured - not implemented yet
24
 *   distance filter unit: the unit in which the distance is measured
25
 *
26
 * @ingroup SemanticResultFormats
27
 */
28
class DistanceFilter extends Filter {
29
30
	private $jsConfig;
31
32
	/**
33
	 * Returns the name (string) or names (array of strings) of the resource
34
	 * modules to load.
35
	 *
36
	 * @return string|array
37
	 */
38 1
	public function getResourceModules() {
39 1
		return 'ext.srf.filtered.distance-filter';
40
	}
41
42 1
	protected function buildJsConfig() {
43
44 1
		parent::buildJsConfig();
45
46 1
		if ( !array_key_exists( 'distance filter origin', $this->getActualParameters() ) ) {
47 1
			$label = $this->getPrintRequest()->getLabel();
48 1
			$this->getQueryPrinter()->addError( "Missing origin for distance filter on '$label'." );
49 1
			return [];
50
		}
51
52
		try {
53
54 1
			$geoCoordinateParser = new LatLongParser();
55
56 1
			$callback = function ( $value ) use ( $geoCoordinateParser ) {
57 1
				$latlng = $geoCoordinateParser->parse( $value );
58 1
				return [ 'lat' => $latlng->getLatitude(), 'lng' => $latlng->getLongitude() ];
59 1
			};
60
61 1
			$this->addValueToJsConfig( 'distance filter origin', 'origin', null, $callback );
62
63
		}
64
		catch ( Exception $exception ) {
65
			$label = $this->getPrintRequest()->getLabel();
66
			$this->getQueryPrinter()->addError( "Distance filter on $label: " . $exception->getMessage() );
67
			return [];
68
		}
69
70 1
		$this->addValueToJsConfig( 'distance filter collapsible', 'collapsible' );
71 1
		$this->addValueToJsConfig( 'distance filter initial value', 'initial value' );
72 1
		$this->addValueToJsConfig( 'distance filter max distance', 'max' );
73 1
		$this->addValueToJsConfig( 'distance filter unit', 'unit' );
74 1
		$this->addValueListToJsConfig( 'distance filter switches', 'switches' );
75
76 1
	}
77
78
	/**
79
	 * @param ResultItem $row
80
	 *
81
	 * @return array|null
82
	 */
83 1
	public function getJsDataForRow( ResultItem $row ) {
84
85 1
		$markerPositionPropertyName = $this->getPrintRequest()->getData()->getInceptiveProperty()->getKey();
86
87 1
		foreach ( $row->getValue() as $field ) {
88
89 1
			$printRequest = $field->getPrintRequest();
90 1
			$field->reset();
91
92 1
			$value = $field->getNextDataItem();
93 1
			if ( $printRequest->getData() instanceof SMWPropertyValue &&
0 ignored issues
show
The class SMWPropertyValue does not exist. Is this class maybe located in a folder that is not analyzed, or in a newer version of your dependencies than listed in your composer.lock/composer.json?
Loading history...
94 1
				$printRequest->getData()->getInceptiveProperty()->getKey() === $markerPositionPropertyName &&
95 1
				( $value instanceof \SMWDIGeoCoord || $value instanceof \SMWDIBlob )
96
			) {
97
				$values = []; // contains plain text
98
99
				if ( $value instanceof \SMWDIGeoCoord ) {
100
101
					while ( $value instanceof \SMWDIGeoCoord ) {
102
						$values[] = [ 'lat' => $value->getLatitude(), 'lng' => $value->getLongitude() ];
103
						$value = $field->getNextDataItem();
104
					}
105
106
				} else {
107
108
					$coordParser = new LatLongParser();
109
					while ( $value instanceof \SMWDataItem ) {
110
						try {
111
							$latlng = $coordParser->parse( $value->getSerialization() );
112
							$values[] = [ 'lat' => $latlng->getLatitude(), 'lng' => $latlng->getLongitude() ];
113
						}
114
						catch ( \Exception $exception ) {
115
							$this->getQueryPrinter()->addError( "Error on '$value': " . $exception->getMessage() );
116
						}
117
						$value = $field->getNextDataItem();
118
					}
119
120
				}
121
122
				return [ 'positions' => $values, ];
123
			}
124
		}
125
126 1
		return null;
127
	}
128
129
	/**
130
	 * @return bool
131
	 */
132 1
	public function isValidFilterForPropertyType() {
133 1
		return $this->getPrintRequest()->getTypeID() === '_geo' || $this->getPrintRequest()->getTypeID() === '_txt';
134
	}
135
}
136