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.

src/Outline/ListTreeBuilder.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
use SMWDataItem as DataItem;
8
9
/**
10
 * @license GNU GPL v2+
11
 * @since 3.1
12
 *
13
 * @author mwjames
14
 */
15
class ListTreeBuilder {
16
17
	/**
18
	 * @var []
19
	 */
20
	private $params = [];
21
22
	/**
23
	 * @var Linker
24
	 */
25
	private $linker;
26
27
	/**
28
	 * @param array $params
29
	 */
30 3
	public function __construct( array $params ) {
31 3
		$this->params = $params;
32 3
	}
33
34
	/**
35
	 * @since 3.1
36
	 *
37
	 * @param Linker|null|false $linker
38
	 */
39 1
	public function setLinker( $linker ) {
40 1
		$this->linker = $linker;
0 ignored issues
show
Documentation Bug introduced by mwjames
It seems like $linker can also be of type false. However, the property $linker is declared as type object<SRF\Outline\Linker>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
41 1
	}
42
43
	/**
44
	 * @since 3.1
45
	 *
46
	 * @param OutlineTree $tree
0 ignored issues
show
There is no parameter named $tree. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
47
	 *
48
	 * @return string
49
	 */
50 2
	public function build( OutlineTree $outlineTree ) {
51 2
		return $this->tree( $outlineTree );
52
	}
53
54 2
	private function tree( $outline_tree, $level = 0 ) {
55 2
		$text = "";
56
57 2
		if ( !is_null( $outline_tree->items ) ) {
58 2
			$text .= "<ul>\n";
59 2
			foreach ( $outline_tree->items as $item ) {
60 1
				$text .= "<li>{$this->item($item)}</li>\n";
61
			}
62 2
			$text .= "</ul>\n";
63
		}
64
65 2
		if ( $level > 0 ) {
66 1
			$text .= "<ul>\n";
67
		}
68
69 2
		$num_levels = count( $this->params['outlineproperties'] );
70
		// set font size and weight depending on level we're at
71 2
		$font_level = $level;
72
73 2
		if ( $num_levels < 4 ) {
74 2
			$font_level += ( 4 - $num_levels );
75
		}
76
77 2
		if ( $font_level == 0 ) {
78
			$font_size = 'x-large';
79 2
		} elseif ( $font_level == 1 ) {
80
			$font_size = 'large';
81 2
		} elseif ( $font_level == 2 ) {
82 1
			$font_size = 'medium';
83
		} else {
84 2
			$font_size = 'small';
85
		}
86
87 2
		if ( $font_level == 3 ) {
88 2
			$font_weight = 'bold';
89
		} else {
90 1
			$font_weight = 'regular';
91
		}
92
93 2
		foreach ( $outline_tree->tree as $key => $node ) {
94 1
			$text .= "<p style=\"font-size: $font_size; font-weight: $font_weight;\">$key</p>\n";
95 1
			$text .= $this->tree( $node, $level + 1 );
96
		}
97
98 2
		if ( $level > 0 ) {
99 1
			$text .= "</ul>\n";
100
		}
101
102 2
		return $text;
103
	}
104
105 1
	private function item( $item ) {
106 1
		$first_col = true;
107 1
		$found_values = false; // has anything but the first column been printed?
108 1
		$result = "";
109
110 1
		foreach ( $item->row as $resultArray ) {
111
112 1
			$printRequest = $resultArray->getPrintRequest();
113 1
			$val = $printRequest->getText( SMW_OUTPUT_WIKI, null );
114 1
			$first_value = true;
115
116 1
			if ( in_array( $val, $this->params['outlineproperties'] ) ) {
117 1
				continue;
118
			}
119
120 1
			$linker = $this->params['link'] === 'all' ? $this->linker : null;
121
122 1
			if ( $this->params['link'] === 'subject' && $printRequest->isMode( PrintRequest::PRINT_THIS ) ) {
123
				$linker = $this->linker;
124
			}
125
126 1
			while ( ( $dv = $resultArray->getNextDataValue() ) !== false ) {
127
128 1
				if ( !$first_col && !$found_values ) { // first values after first column
129 1
					$result .= ' (';
130 1
					$found_values = true;
131 1
				} elseif ( $found_values || !$first_value ) {
132
					// any value after '(' or non-first values on first column
133
					$result .= ', ';
134
				}
135
136 1
				if ( $first_value ) { // first value in any column, print header
137 1
					$first_value = false;
138 1
					if ( $this->params['showHeaders'] && ( '' != $printRequest->getLabel() ) ) {
139 1
						$result .= $printRequest->getText( SMW_OUTPUT_WIKI, $linker ) . ' ';
140
					}
141
				}
142
143 1
				$dataItem = $dv->getDataItem();
144
145 1
				if ( $linker === null && $dataItem->getDIType() === DataItem::TYPE_WIKIPAGE && ( $caption = $dv->getDisplayTitle() ) !== '' ) {
146
					$dv->setCaption( $caption );
147
				}
148
149 1
				$result .= $dv->getShortText( SMW_OUTPUT_WIKI, $linker );
150
			}
151
152 1
			$first_col = false;
153
		}
154
155 1
		if ( $found_values ) {
156 1
			$result .= ')';
157
		}
158
159 1
		return $result;
160
	}
161
162
}