Issues (1401)

Security Analysis    no request data  

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.

repo/includes/ParserOutput/TermboxView.php (2 issues)

Labels

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 Wikibase\Repo\ParserOutput;
4
5
use Wikibase\DataModel\Entity\EntityDocument;
6
use Wikibase\DataModel\Entity\EntityId;
7
use Wikibase\DataModel\Term\AliasGroupList;
8
use Wikibase\DataModel\Term\TermList;
9
use Wikibase\Lib\LanguageFallbackChainFactory;
10
use Wikibase\Lib\Store\EntityRevision;
11
use Wikibase\View\CacheableEntityTermsView;
12
use Wikibase\View\EntityTermsView;
13
use Wikibase\View\LocalizedTextProvider;
14
use Wikibase\View\SpecialPageLinker;
15
use Wikibase\View\Termbox\Renderer\TermboxRenderer;
16
use Wikibase\View\Termbox\Renderer\TermboxRenderingException;
17
use Wikibase\View\ViewPlaceHolderEmitter;
18
19
/**
20
 * @license GPL-2.0-or-later
21
 */
22
class TermboxView implements CacheableEntityTermsView {
23
24
	public const TERMBOX_PLACEHOLDER = 'wb-ui';
25
26
	public const TERMBOX_MARKUP = 'termbox-markup';
27
28
	public const TERMBOX_VERSION = 2;
29
30
	public const CACHE_VERSION = 2;
31
32
	private $fallbackChainFactory;
33
	private $renderer;
34
	private $specialPageLinker;
35
	private $textInjector;
36
37
	/**
38
	 * @var LocalizedTextProvider
39
	 */
40
	private $textProvider;
41
42
	public function __construct(
43
		LanguageFallbackChainFactory $fallbackChainFactory,
44
		TermboxRenderer $renderer,
45
		LocalizedTextProvider $textProvider,
46
		SpecialPageLinker $specialPageLinker,
47
		TextInjector $textInjector
48
	) {
49
		$this->fallbackChainFactory = $fallbackChainFactory;
50
		$this->renderer = $renderer;
51
		$this->textProvider = $textProvider;
52
		$this->specialPageLinker = $specialPageLinker;
53
		$this->textInjector = $textInjector;
54
	}
55
56
	public function getHtml(
57
		$mainLanguageCode,
58
		TermList $labels,
59
		TermList $descriptions,
60
		AliasGroupList $aliasGroups = null,
61
		EntityId $entityId = null
62
	) {
63
		return $this->textInjector->newMarker( self::TERMBOX_PLACEHOLDER );
64
	}
65
66
	public function getTitleHtml( EntityId $entityId = null ) {
67
		return htmlspecialchars(
68
			$this->textProvider->get( 'parentheses', [ $entityId->getSerialization() ] )
0 ignored issues
show
It seems like $entityId is not always an object, but can also be of type null. Maybe add an additional type check?

If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe:

function someFunction(A $objectMaybe = null)
{
    if ($objectMaybe instanceof A) {
        $objectMaybe->doSomething();
    }
}
Loading history...
69
		);
70
	}
71
72
	/**
73
	 * @see \Wikibase\View\ViewPlaceHolderEmitter
74
	 */
75
	public function getPlaceholders(
76
		EntityDocument $entity,
77
		$revision,
78
		$languageCode
79
	) {
80
		return [
81
			'wikibase-view-chunks' => $this->textInjector->getMarkers(),
82
			self::TERMBOX_MARKUP => $this->renderTermbox(
83
				$entity->getId(),
0 ignored issues
show
It seems like $entity->getId() can be null; however, renderTermbox() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
84
				$revision,
85
				$languageCode
86
			),
87
		];
88
	}
89
90
	/**
91
	 * @param EntityId $entityId
92
	 * @param int $revision
93
	 * @param string $mainLanguageCode
94
	 *
95
	 * @return string|null
96
	 */
97
	private function renderTermbox( EntityId $entityId, $revision, $mainLanguageCode ) {
98
		if ( $revision === EntityRevision::UNSAVED_REVISION ) {
99
			return ViewPlaceHolderEmitter::ERRONEOUS_PLACEHOLDER_VALUE;
100
		}
101
102
		try {
103
			return $this->renderer->getContent(
104
				$entityId,
105
				$revision,
106
				$mainLanguageCode,
107
				$this->specialPageLinker->getLink(
108
					EntityTermsView::TERMS_EDIT_SPECIAL_PAGE,
109
					[ $entityId->getSerialization() ]
110
				),
111
				$this->fallbackChainFactory->newFromLanguageCode( $mainLanguageCode )
112
			);
113
		} catch ( TermboxRenderingException $exception ) {
114
			return ViewPlaceHolderEmitter::ERRONEOUS_PLACEHOLDER_VALUE;
115
		}
116
	}
117
118
}
119