Issues (213)

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.

lib/Command/ConvertToBigInt.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
 * @copyright Copyright (c) 2019 Julius Härtl <[email protected]>
4
 *
5
 * @author Julius Härtl <[email protected]>
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *
9
 * This program is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License as
11
 * published by the Free Software Foundation, either version 3 of the
12
 * License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
 * GNU Affero General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Affero General Public License
20
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 */
23
24
25
namespace OCA\RichDocuments\Command;
26
27
use Doctrine\DBAL\Platforms\SqlitePlatform;
28
use Doctrine\DBAL\Types\Type;
29
use OC\DB\Connection;
30
use OCP\DB\Types;
31
use OC\DB\SchemaWrapper;
32
use OCP\IDBConnection;
33
use Symfony\Component\Console\Command\Command;
34
use Symfony\Component\Console\Input\InputInterface;
35
use Symfony\Component\Console\Output\OutputInterface;
36
use Symfony\Component\Console\Question\ConfirmationQuestion;
37
38
class ConvertToBigInt extends Command {
39
40
	/** @var IDBConnection */
41
	private $connection;
42
43
	/**
44
	 * @param IDBConnection $connection
45
	 */
46
	public function __construct(Connection $connection) {
47
		$this->connection = $connection;
0 ignored issues
show
Documentation Bug introduced by
It seems like $connection of type object<OC\DB\Connection> is incompatible with the declared type object<OCP\IDBConnection> of property $connection.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
48
		parent::__construct();
49
	}
50
51
	protected function configure() {
52
		$this
53
			->setName('richdocuments:convert-bigint')
54
			->setDescription('Convert the ID columns of the richdocuments tables to BigInt');
55
	}
56
57
	protected function getColumnsByTable() {
58
		return [
59
			'richdocuments_wopi' => ['id', 'fileid', 'version', 'template_id', 'template_destination', 'expiry'],
60
			'richdocuments_direct' => ['id', 'fileid', 'template_id', 'template_destination', 'timestamp'],
61
			'richdocuments_assets' => ['id', 'fileid', 'timestamp'],
62
		];
63
	}
64
65
	protected function execute(InputInterface $input, OutputInterface $output): int {
66
		$schema = new SchemaWrapper($this->connection);
67
		$isSqlite = $this->connection->getDatabasePlatform() instanceof SqlitePlatform;
0 ignored issues
show
The class Doctrine\DBAL\Platforms\SqlitePlatform does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
68
		$updates = [];
69
70
		$tables = $this->getColumnsByTable();
71
		foreach ($tables as $tableName => $columns) {
72
			if (!$schema->hasTable($tableName)) {
73
				continue;
74
			}
75
76
			$table = $schema->getTable($tableName);
77
78
			foreach ($columns as $columnName) {
79
				$column = $table->getColumn($columnName);
80
				$isAutoIncrement = $column->getAutoincrement();
81
				$isAutoIncrementOnSqlite = $isSqlite && $isAutoIncrement;
82
				if ($column->getType()->getName() !== Types::BIGINT && !$isAutoIncrementOnSqlite) {
83
					$column->setType(Type::getType(Types::BIGINT));
84
					$column->setOptions(['length' => 20]);
85
					$column->setUnsigned(true);
86
87
					$updates[] = '* ' . $tableName . '.' . $columnName;
88
				}
89
			}
90
		}
91
92
		if (empty($updates)) {
93
			$output->writeln('<info>All tables already up to date!</info>');
94
			return 0;
95
		}
96
97
		$output->writeln('<comment>Following columns will be updated:</comment>');
98
		$output->writeln('');
99
		$output->writeln($updates);
100
		$output->writeln('');
101
		$output->writeln('<comment>This can take up to hours, depending on the number of Collabora WOPI tokens in your instance!</comment>');
102
103
		if ($input->isInteractive()) {
104
			$helper = $this->getHelper('question');
105
			$question = new ConfirmationQuestion('Continue with the conversion (y/n)? [n] ', false);
106
107
			if (!$helper->ask($input, $output, $question)) {
108
				return 1;
109
			}
110
		}
111
112
		$this->connection->migrateToSchema($schema->getWrappedSchema());
113
114
		return 0;
115
	}
116
}
117