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/math/SRF_Math.php (6 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
/**
4
 * Various mathematical functions - sum, product, average, min and max.
5
 *
6
 * @licence GNU GPL v3+
7
 *
8
 * @author Jeroen De Dauw < [email protected] >
9
 * @author Yaron Koren
10
 * @author Nathan Yergler
11
 */
12
class SRFMath extends SMWResultPrinter {
13
14
	/**
15
	 * (non-PHPdoc)
16
	 * @see SMWResultPrinter::getName()
17
	 */
18
	public function getName() {
19
		// Give grep a chance to find the usages:
20
		// srf_printername_max, srf_printername_min, srf_printername_sum,
21
		// srf_printername_product, srf_printername_average, srf_printername_median
22
		return wfMessage( 'srf_printername_' . $this->mFormat )->text();
23
	}
24
25
	/**
26
	 * @see SMWResultPrinter::buildResult
27
	 *
28
	 * @since 1.8
29
	 *
30
	 * @param SMWQueryResult $results
31
	 *
32
	 * @return string
33
	 */
34 1
	protected function buildResult( SMWQueryResult $results ) {
35
36 1
		$number = $this->getResultText( $results, SMW_OUTPUT_HTML );
37
38 1
		if ( count( $results->getPrintRequests() ) > 1 ) {
39
			$outputformat = $results->getPrintRequests()[1]->getOutputFormat();
40
		} else {
41
			// no mainlabel
42 1
			$outputformat = $results->getPrintRequests()[0]->getOutputFormat();
43
		}
44
45
		// if raw-format ("-") than skip formatNum()
46 1
		if ( $outputformat != "-" ) {
47 1
			$dataValue = \SMW\DataValueFactory::getInstance()->newDataValueByType( '_num' );
48 1
			$number = $dataValue->getLocalizedFormattedNumber( $number );
49
		}
50
51 1
		return (string)$number;
52
	}
53
54
	/**
55
	 * @see SMWResultPrinter::getResultText()
56
	 */
57 1
	protected function getResultText( SMWQueryResult $res, $outputmode ) {
58 1
		$numbers = $this->getNumbers( $res );
59
60 1
		if ( count( $numbers ) == 0 ) {
61
			return $this->params['default'];
62
		}
63
64 1
		switch ( $this->mFormat ) {
65 1
			case 'max':
66 1
				return max( $numbers );
67
				break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
68 1
			case 'min':
69 1
				return min( $numbers );
70
				break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
71 1
			case 'sum':
72 1
				return array_sum( $numbers );
73
				break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
74 1
			case 'product':
75 1
				return array_product( $numbers );
76
				break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
77 1
			case 'average':
78 1
				return array_sum( $numbers ) / count( $numbers );
79
				break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
80 1
			case 'median':
81 1
				sort( $numbers, SORT_NUMERIC );
82 1
				$position = ( count( $numbers ) + 1 ) / 2 - 1;
83 1
				return ( $numbers[ceil( $position )] + $numbers[floor( $position )] ) / 2;
84
				break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
85
		}
86
	}
87
88
	/**
89
	 * @param SMWQueryResult $res
90
	 *
91
	 * @return float[]
92
	 */
93 1
	private function getNumbers( SMWQueryResult $res ) {
94 1
		$numbers = [];
95
96 1
		while ( $row = $res->getNext() ) {
97 1
			foreach ( $row as $resultArray ) {
98 1
				foreach ( $resultArray->getContent() as $dataItem ) {
99 1
					self::addNumbersForDataItem( $dataItem, $numbers );
100
				}
101
			}
102
		}
103
104 1
		return $numbers;
105
	}
106
107
	/**
108
	 * @param SMWDataItem $dataItem
109
	 * @param float[] $numbers
110
	 */
111 1
	private function addNumbersForDataItem( SMWDataItem $dataItem, array &$numbers ) {
112 1
		switch ( $dataItem->getDIType() ) {
113
			case SMWDataItem::TYPE_NUMBER:
114 1
				$numbers[] = $dataItem->getNumber();
115 1
				break;
116
			case SMWDataItem::TYPE_CONTAINER:
117
				foreach ( $dataItem->getDataItems() as $di ) {
118
					self::addNumbersForDataItem( $di, $numbers );
119
				}
120
				break;
121
			default:
122
		}
123 1
	}
124
125
}
126