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/IO/EntityIdReader.php (1 issue)

Labels
Severity

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\IO;
4
5
use Wikibase\DataModel\Entity\EntityId;
6
use Wikibase\DataModel\Entity\EntityIdParser;
7
use Wikibase\DataModel\Entity\EntityIdParsingException;
8
use Wikibase\DataModel\Services\EntityId\EntityIdPager;
9
use Wikibase\Lib\Reporting\ExceptionHandler;
10
use Wikibase\Lib\Reporting\RethrowingExceptionHandler;
11
12
/**
13
 * EntityIdReader reads entity IDs from a file, one per line.
14
 *
15
 * @license GPL-2.0-or-later
16
 * @author Daniel Kinzler
17
 */
18
class EntityIdReader implements EntityIdPager {
19
20
	/**
21
	 * @var LineReader
22
	 */
23
	private $reader;
24
25
	/**
26
	 * @var EntityIdParser
27
	 */
28
	private $parser;
29
30
	/**
31
	 * @var string|null
32
	 */
33
	private $entityType;
34
35
	/**
36
	 * @var ExceptionHandler
37
	 */
38
	private $exceptionHandler;
39
40
	/**
41
	 * @param LineReader $reader
42
	 * @param EntityIdParser $parser
43
	 * @param null|string $entityType The desired entity type, or null for any type.
44
	 */
45
	public function __construct( LineReader $reader, EntityIdParser $parser, $entityType = null ) {
46
		$this->reader = $reader;
47
		$this->parser = $parser;
48
		$this->entityType = $entityType;
49
50
		$this->exceptionHandler = new RethrowingExceptionHandler();
51
	}
52
53
	public function setExceptionHandler( ExceptionHandler $exceptionHandler ) {
54
		$this->exceptionHandler = $exceptionHandler;
55
	}
56
57
	/**
58
	 * @return ExceptionHandler
59
	 */
60
	public function getExceptionHandler() {
61
		return $this->exceptionHandler;
62
	}
63
64
	/**
65
	 * @param string $line
66
	 * @return EntityId|null
67
	 */
68
	protected function lineToId( $line ) {
69
		$line = trim( $line );
70
71
		try {
72
			$id = $this->parser->parse( $line );
73
		} catch ( EntityIdParsingException $ex ) {
74
			$this->exceptionHandler->handleException( $ex, 'bad-entity-id', "Failed to parse Entity ID $line" );
75
			$id = null;
76
		}
77
78
		return $id;
79
	}
80
81
	/**
82
	 * Closes the underlying input stream
83
	 */
84
	public function dispose() {
85
		$this->reader->dispose();
86
	}
87
88
	/**
89
	 * Returns the next ID (or null if there are no more ids).
90
	 *
91
	 * @return EntityId|null
92
	 */
93
	protected function next() {
94
		$id = null;
95
96
		while ( $id === null ) {
97
			$this->reader->next();
98
99
			if ( !$this->reader->valid() ) {
100
				break;
101
			}
102
103
			$line = trim( $this->reader->current() );
104
105
			if ( $line === '' ) {
106
				continue;
107
			}
108
109
			$id = $this->lineToId( $line );
0 ignored issues
show
Are you sure the assignment to $id is correct as $this->lineToId($line) (which targets Wikibase\Repo\IO\EntityIdReader::lineToId()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
110
111
			if ( !$id ) {
112
				continue;
113
			}
114
115
			if ( $this->entityType !== null && $id->getEntityType() !== $this->entityType ) {
116
				$id = null;
117
				continue;
118
			}
119
		}
120
121
		return $id;
122
	}
123
124
	/**
125
	 * Fetches the next batch of IDs. Calling this has the side effect of advancing the
126
	 * internal state of the page, typically implemented by some underlying resource
127
	 * such as a file pointer or a database connection.
128
	 *
129
	 * @note After some finite number of calls, this method should eventually return
130
	 * an empty list of IDs, indicating that no more IDs are available.
131
	 *
132
	 * @param int $limit The maximum number of IDs to return.
133
	 *
134
	 * @return EntityId[] A list of EntityIds matching the given parameters. Will
135
	 * be empty if there are no more entities to list from the given offset.
136
	 */
137
	public function fetchIds( $limit ) {
138
		$ids = [];
139
		while ( $limit > 0 ) {
140
			$id = $this->next();
141
142
			if ( $id === null ) {
143
				break;
144
			}
145
146
			$ids[] = $id;
147
			$limit--;
148
		}
149
150
		return $ids;
151
	}
152
153
}
154