Issues (5)

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.

lib/AppInfo/Application.php (4 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
declare(strict_types=1);
3
4
5
/**
6
 * Bookmarks_FullTextSearch - Indexing bookmarks
7
 *
8
 * This file is licensed under the Affero General Public License version 3 or
9
 * later. See the COPYING file.
10
 *
11
 * @author Maxence Lange <[email protected]>
12
 * @copyright 2018
13
 * @license GNU AGPL version 3 or any later version
14
 *
15
 * This program is free software: you can redistribute it and/or modify
16
 * it under the terms of the GNU Affero General Public License as
17
 * published by the Free Software Foundation, either version 3 of the
18
 * License, or (at your option) any later version.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU Affero General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU Affero General Public License
26
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
27
 *
28
 */
29
30
31
namespace OCA\Bookmarks_FullTextSearch\AppInfo;
32
33
34
use Exception;
35
use OCA\Bookmarks_FullTextSearch\Provider\BookmarksProvider;
36
use OCP\App\IAppManager;
37
use OCP\AppFramework\App;
38
use OCP\AppFramework\QueryException;
39
use OCP\FullTextSearch\IFullTextSearchManager;
40
use OCP\FullTextSearch\Model\IIndex;
41
use OCP\IUserSession;
42
use OCP\Util;
43
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
44
use Symfony\Component\EventDispatcher\GenericEvent;
45
46
47
class Application extends App {
48
49
50
	const APP_NAME = 'bookmarks_fulltextsearch';
51
52
53
	/** @var IFullTextSearchManager */
54
	private $fullTextSearchManager;
55
56
	/** @var EventDispatcherInterface */
57
	private $eventDispatcher;
58
59
60
	/**
61
	 * @param array $params
62
	 */
63
	public function __construct(array $params = []) {
64
		parent::__construct(self::APP_NAME, $params);
65
66
		$c = $this->getContainer();
67
68
		try {
69
			$this->fullTextSearchManager = $c->query(IFullTextSearchManager::class);
70
		} catch (QueryException $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
71
		}
72
	}
73
74
75
	/**
76
	 * Register Hooks
77
	 */
78
	public function registerHooks() {
79
		$this->eventDispatcher = \OC::$server->getEventDispatcher();
80
81
		$this->registerHookCreate();
82
		$this->registerHookUpdate();
83
		$this->registerHookDelete();
84
	}
85
86
87
	/**
88
	 *
89
	 */
90
	private function registerHookCreate() {
91
		$this->eventDispatcher->addListener(
92
			'\OCA\Bookmarks::onBookmarkCreate', function(GenericEvent $e) {
93
94
			$this->fullTextSearchManager->createIndex(
95
				BookmarksProvider::BOOKMARKS_PROVIDER_ID,
96
				(string)$e->getArgument('id'),
97
				$e->getArgument('userId')
98
			);
99
			$this->fullTextSearchManager->updateIndexStatus(
100
				BookmarksProvider::BOOKMARKS_PROVIDER_ID,
101
				(string)$e->getArgument('id'),
102
				IIndex::INDEX_FULL
103
			);
104
		}
105
		);
106
	}
107
108
109
	/**
110
	 *
111
	 */
112 View Code Duplication
	private function registerHookUpdate() {
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
113
		$this->eventDispatcher->addListener(
114
			'\OCA\Bookmarks::onBookmarkUpdate', function(GenericEvent $e) {
115
116
			$this->fullTextSearchManager->updateIndexStatus(
117
				BookmarksProvider::BOOKMARKS_PROVIDER_ID, (string)$e->getArgument('id'),
118
				IIndex::INDEX_FULL
119
			);
120
		}
121
		);
122
	}
123
124
125
	/**
126
	 *
127
	 */
128 View Code Duplication
	private function registerHookDelete() {
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
129
		$this->eventDispatcher->addListener(
130
			'\OCA\Bookmarks::onBookmarkDelete', function(GenericEvent $e) {
131
132
			$this->fullTextSearchManager->updateIndexStatus(
133
				BookmarksProvider::BOOKMARKS_PROVIDER_ID, (string)$e->getArgument('id'),
134
				IIndex::INDEX_REMOVE
135
			);
136
		}
137
		);
138
	}
139
140
141
	/**
142
	 *
143
	 * @throws QueryException
144
	 */
145
	public function registerBookmarksSearch() {
146
		$container = $this->getContainer();
147
148
		/** @var IUserSession $userSession */
149
		$userSession = $container->query(IUserSession::class);
150
151
		if (!$userSession->isLoggedIn()) {
152
			return;
153
		}
154
155
		$user = $userSession->getUser();
156
157
		try {
158
			$appManager = $container->query(IAppManager::class);
159
			if ($appManager->isEnabledForUser('fulltextsearch', $user)) {
160
				Util::addStyle(self::APP_NAME, 'fulltextsearch');
161
				$this->includeFullTextSearch();
162
			}
163
		} catch (Exception $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
164
		}
165
	}
166
167
168
	/**
169
	 *
170
	 */
171
	private function includeFullTextSearch() {
172
		$this->eventDispatcher->addListener(
173
			'\OCA\Bookmarks::loadAdditionalScripts', function() {
174
			if ($this->fullTextSearchManager->isProviderIndexed(
175
				BookmarksProvider::BOOKMARKS_PROVIDER_ID
176
			)) {
177
				$this->fullTextSearchManager->addJavascriptAPI();
178
				Util::addScript(Application::APP_NAME, 'bookmarks');
179
			}
180
		}
181
		);
182
	}
183
184
}
185
186