Issues (15)

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 (3 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
/**
4
 * Nextcloud - OCR
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later.
7
 * See the COPYING file.
8
 * 
9
 * @author Janis Koehr <[email protected]>
10
 * @copyright Janis Koehr 2017
11
 */
12
namespace OCA\Ocr\AppInfo;
13
14
use OC\Files\View;
15
use OCA\Ocr\Controller\JobController;
16
use OCA\Ocr\Controller\PersonalSettingsController;
17
use OCA\Ocr\Db\FileMapper;
18
use OCA\Ocr\Db\OcrJobMapper;
19
use OCA\Ocr\Db\ShareMapper;
20
use OCA\Ocr\Service\JobService;
21
use OCP\AppFramework\App;
22
use OCP\AppFramework\IAppContainer;
23
use OCP\IContainer;
24
use OCA\Ocr\Controller\StatusController;
25
use OCA\Ocr\Service\StatusService;
26
use OCA\Ocr\Service\FileService;
27
use OCA\Ocr\Service\RedisService;
28
use OCA\Ocr\Service\AppConfigService;
29
use OCA\Ocr\Util\PHPUtil;
30
use OCA\Ocr\Util\FileUtil;
31
use OCA\Ocr\Util\RedisUtil;
32
use OCA\Ocr\Hooks\UserHooks;
33
use OCA\Ocr\Constants\OcrConstants;
34
35
36
/**
37
 * Class Application
38
 * 
39
 * @package OCA\Ocr\AppInfo
40
 */
41
class Application extends App {
42
43
    /**
44
     * Application constructor.
45
     * 
46
     * @param array $urlParams            
47
     */
48 16
    public function __construct(array $urlParams = array()) {
49 16
        parent::__construct(OcrConstants::APP_NAME, $urlParams);
50 16
        $container = $this->getContainer();
51
        /**
52
         * Add the js and style if OCA\Files app is loaded
53
         */
54 16
        $eventDispatcher = \OC::$server->getEventDispatcher();
55 16
        $eventDispatcher->addListener('OCA\Files::loadAdditionalScripts', 
56 16
                function () {
57
                    script(OcrConstants::APP_NAME, 'dist/ocrapp');
58
                    style(OcrConstants::APP_NAME, 'ocrstyle');
59
                    // if not loaded before - load select2 for multi select languages
60
                    vendor_script('select2/select2');
61
                    vendor_style('select2/select2');
62 16
                });
63
        /**
64
         * Register core services
65
         */
66 16
        $container->registerService('CurrentUID', 
67 16
                function (IContainer $c) {
68
                    /** @var \OC\Server $server */
69 5
                    $server = $c->query('ServerContainer');
70 5
                    $user = $server->getUserSession()
71 5
                        ->getUser();
72 5
                    return ($user) ? $user->getUID() : '';
73 16
                });
74
        // Allow automatic DI for the View, until they migrated to Nodes API
75 16
        $container->registerService(View::class, function () {
76
            return new View('');
77 16
        }, false);
78
        /**
79
         * Register the PHPUtil
80
         */
81 16
        $container->registerService('PHPUtil', 
82 16
                function (IContainer $c) {
83
                    /** @var \OC\Server $server */
84 5
                    $server = $c->query('ServerContainer');
85 5
                    return new PHPUtil($server->getL10N(OcrConstants::APP_NAME));
86 16
                });
87
        /**
88
         * Register the RedisUtil
89
         */
90 16
        $container->registerService('RedisUtil', 
91 16
                function (IContainer $c) {
92
                    /** @var \OC\Server $server */
93 7
                    $server = $c->query('ServerContainer');
94 7
                    return new RedisUtil($server->getL10N(OcrConstants::APP_NAME), $server->getLogger(), $server->getConfig());
95 16
                });
96
        /**
97
         * Register the FileUtil
98
         */
99 16
        $container->registerService('FileUtil', 
100 16
                function (IContainer $c) {
0 ignored issues
show
The parameter $c is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
101 7
                    return new FileUtil();
102 16
                });
103
        /**
104
         * Register the Ocr Job mapper
105
         */
106 16
        $container->registerService('OcrJobMapper', 
107 16
                function (IContainer $c) {
108
                    /** @var \OC\Server $server */
109 7
                    $server = $c->query('ServerContainer');
110 7
                    return new OcrJobMapper($server->getDatabaseConnection());
111 16
                });
112
        /**
113
         * Register the File mapper
114
         */
115 16
        $container->registerService('FileMapper', 
116 16
                function (IContainer $c) {
117
                    /** @var \OC\Server $server */
118 6
                    $server = $c->query('ServerContainer');
119 6
                    return new FileMapper($server->getDatabaseConnection());
120 16
                });
121
        /**
122
         * Register the Share mapper
123
         */
124 16
        $container->registerService('ShareMapper', 
125 16
                function (IContainer $c) {
126
                    /** @var \OC\Server $server */
127 6
                    $server = $c->query('ServerContainer');
128 6
                    return new ShareMapper($server->getDatabaseConnection());
129 16
                });
130
        /**
131
         * Register the App Config Service
132
         */
133 16
        $container->registerService('AppConfigService', 
134 16
                function (IAppContainer $c) {
135
                    /** @var \OC\Server $server */
136 5
                    $server = $c->query('ServerContainer');
137 5
                    return new AppConfigService($server->getConfig(), $server->getL10N(OcrConstants::APP_NAME), $c->query('RedisUtil'), 
138 5
                            $server->getLogger());
139 16
                });
140
        /**
141
         * Register the Job Service
142
         */
143 16
        $container->registerService('FileService', 
144 16 View Code Duplication
                function (IAppContainer $c) {
145
                    /** @var \OC\Server $server */
146 5
                    $server = $c->query('ServerContainer');
147 5
                    return new FileService($server->getL10N(OcrConstants::APP_NAME), $server->getLogger(), $c->query('CurrentUID'), 
148 5
                            $c->query('FileMapper'), $c->query('ShareMapper'), $c->query('FileUtil'));
149 16
                });
150
        /**
151
         * Register the Redis Service
152
         */
153 16
        $container->registerService('RedisService', 
154 16 View Code Duplication
                function (IAppContainer $c) {
155
                    /** @var \OC\Server $server */
156 5
                    $server = $c->query('ServerContainer');
157 5
                    return new RedisService($c->query('OcrJobMapper'), $c->query('FileUtil'), $c->query('RedisUtil'), 
158 5
                            $server->getL10N(OcrConstants::APP_NAME), $server->getLogger(), $server->getTempManager());
159 16
                });
160
        /**
161
         * Register the Job Service
162
         */
163 16
        $container->registerService('JobService', 
164 16
                function (IAppContainer $c) {
165
                    /** @var \OC\Server $server */
166 4
                    $server = $c->query('ServerContainer');
167 4
                    return new JobService($server->getL10N(OcrConstants::APP_NAME), $server->getLogger(), $c->query('CurrentUID'), 
168 4
                            new View('/' . $c->query('CurrentUID') . '/files'), $server->getTempManager(), 
169 4
                            $c->query('RedisService'), $c->query('OcrJobMapper'), $c->query('FileService'), 
170 4
                            $c->query('AppConfigService'), $c->query('PHPUtil'), $c->query('FileUtil'));
171 16
                });
172
        /**
173
         * Register the Status Service
174
         */
175 16
        $container->registerService('StatusService', 
176 16 View Code Duplication
                function (IAppContainer $c) {
177
                    /** @var \OC\Server $server */
178 2
                    $server = $c->query('ServerContainer');
179 2
                    return new StatusService($server->getL10N(OcrConstants::APP_NAME), $server->getLogger(), $c->query('CurrentUID'), 
180 2
                            $c->query('OcrJobMapper'), $c->query('JobService'));
181 16
                });
182
        /**
183
         * Controller
184
         */
185 16
        $container->registerService('StatusController', 
186 16 View Code Duplication
                function (IAppContainer $c) {
0 ignored issues
show
This code seems to be duplicated across 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...
187
                    /** @var \OC\Server $server */
188 1
                    $server = $c->query('ServerContainer');
189 1
                    return new StatusController($c->getAppName(), $server->getRequest(), $c->query('StatusService'));
190 16
                });
191
        /**
192
         * Controller
193
         */
194 16
        $container->registerService('JobController', 
195 16 View Code Duplication
                function (IAppContainer $c) {
0 ignored issues
show
This code seems to be duplicated across 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...
196
                    /** @var \OC\Server $server */
197 1
                    $server = $c->query('ServerContainer');
198 1
                    return new JobController($c->getAppName(), $server->getRequest(), $c->query('JobService'), 
199 1
                            $c->query('CurrentUID'));
200 16
                });
201
        /**
202
         * Controller
203
         */
204 16
        $container->registerService('UserHooks', 
205 16
                function (IAppContainer $c) {
206
                    /** @var \OC\Server $server */
207 1
                    $server = $c->query('ServerContainer');
208 1
                    return new UserHooks($c->query('ServerContainer')
209 1
                        ->getUserManager(), $c->query('OcrJobMapper'), $server->getLogger());
210 16
                });
211
        /**
212
         * Controller
213
         */
214 16
        $container->registerAlias('PersonalSettingsController', PersonalSettingsController::class);
215 16
    }
216
217
    /**
218
     * Registers the Personal Settings Page for deletion of status objects and such things.
219
     * @codeCoverageIgnore
220
     */
221
    public function registerPersonal() {
222
        \OCP\App::registerPersonal($this->getContainer()
223
            ->getAppName(), 'personal');
224
    }
225
226
    /**
227
     * Registers the User Hooks.
228
     * @codeCoverageIgnore
229
     */
230
    public function registerHooks() {
231
        $this->getContainer()
232
            ->query('UserHooks')
233
            ->register();
234
    }
235
}