Passed
Push — master ( c133cb...64f2e6 )
by Matthias
07:40
created
lib/FileSignatures.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
         ['mimeType' => '', 'extensions' => ['xls'], 'signature' => ['starting' => ['offset' => 512, 'bytes' => ['/0908100000060500/']]]],
46 46
         ['mimeType' => '', 'extensions' => ['doc'], 'signature' => ['starting' => ['offset' => 0, 'bytes' => ['/0d444f43/']]]],
47 47
         ['mimeType' => '', 'extensions' => ['webm'], 'signature' => ['starting' => ['offset' => 0, 'bytes' => ['/1a45dfa3/']]]],
48
-        ['mimeType' => '', 'extensions' => ['mkv','mka', 'mks', 'mk3d', 'webm'], 'signature' => ['starting' => ['offset' => 0, 'bytes' => ['/45dfa3934282886d6174726f736b61/', '/1a45dfa3/']]]],
48
+        ['mimeType' => '', 'extensions' => ['mkv', 'mka', 'mks', 'mk3d', 'webm'], 'signature' => ['starting' => ['offset' => 0, 'bytes' => ['/45dfa3934282886d6174726f736b61/', '/1a45dfa3/']]]],
49 49
         ['mimeType' => '', 'extensions' => ['gz', 'tgz', 'vlt'], 'signature' => ['starting' => ['offset' => 0, 'bytes' => ['/1f8b08/']]]],
50 50
         ['mimeType' => '', 'extensions' => ['tar'], 'signature' => ['starting' => ['offset' => 0, 'bytes' => ['/1f9d/', '/1fA0/']]]],
51 51
         ['mimeType' => '', 'extensions' => ['eps'], 'signature' => ['starting' => ['offset' => 0, 'bytes' => ['/252150532d41646f62652d332e3020455053462d332030/']]]],
Please login to merge, or discard this patch.
lib/Analyzer/FileCorruptionAnalyzer.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -94,22 +94,22 @@
 block discarded – undo
94 94
                     }
95 95
                     // starting byte sequence
96 96
                     if (array_key_exists('starting', $signature['signature'])) {
97
-						foreach ($signature['signature']['starting']['bytes'] as $bytes) {
98
-							if (preg_match($bytes, strtolower(bin2hex(substr($data, $signature['signature']['starting']['offset'], strlen($bytes) / 2))))) {
99
-									$isFileCorrupted = false;
100
-							}
101
-						}
97
+                        foreach ($signature['signature']['starting']['bytes'] as $bytes) {
98
+                            if (preg_match($bytes, strtolower(bin2hex(substr($data, $signature['signature']['starting']['offset'], strlen($bytes) / 2))))) {
99
+                                    $isFileCorrupted = false;
100
+                            }
101
+                        }
102 102
                     }
103 103
                     // trailing byte sequence
104 104
                     if (array_key_exists('trailing', $signature['signature'])) {
105 105
                         $trailingIsNotMatching = true;
106
-						foreach ($signature['signature']['trailing']['bytes'] as $bytes) {
107
-							$trailingOffset = strlen($data) - $signature['signature']['trailing']['offset'] - strlen($bytes) / 2;
108
-							if (preg_match($bytes, strtolower(bin2hex(substr($data, $trailingOffset, strlen($bytes) / 2))))) {
109
-									$trailingIsNotMatching = false;
110
-							}
111
-						}
112
-						$isFileCorrupted = $isFileCorrupted || $trailingIsNotMatching;
106
+                        foreach ($signature['signature']['trailing']['bytes'] as $bytes) {
107
+                            $trailingOffset = strlen($data) - $signature['signature']['trailing']['offset'] - strlen($bytes) / 2;
108
+                            if (preg_match($bytes, strtolower(bin2hex(substr($data, $trailingOffset, strlen($bytes) / 2))))) {
109
+                                    $trailingIsNotMatching = false;
110
+                            }
111
+                        }
112
+                        $isFileCorrupted = $isFileCorrupted || $trailingIsNotMatching;
113 113
                         return new FileCorruptionResult($isFileCorrupted);
114 114
                     }
115 115
                     return new FileCorruptionResult($isFileCorrupted);
Please login to merge, or discard this patch.
lib/Analyzer/EntropyFunnellingAnalyzer.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -144,23 +144,23 @@
 block discarded – undo
144 144
         return 0.0;
145 145
     }
146 146
 
147
-     /**
148
-      * Calculates the median of an array.
149
-      *
150
-      * @param  array $array
151
-      *
152
-      * @return float
153
-      */
154
-     public function median($array)
155
-     {
156
-         if (is_array($array) && count($array) > 0) {
157
-             $count = count($array);
158
-             sort($array);
159
-             $mid = floor(($count - 1) / 2);
160
-
161
-             return ($array[$mid] + $array[$mid + 1 - $count % 2]) / 2;
162
-         }
163
-
164
-         return 0.0;
165
-     }
147
+        /**
148
+         * Calculates the median of an array.
149
+         *
150
+         * @param  array $array
151
+         *
152
+         * @return float
153
+         */
154
+        public function median($array)
155
+        {
156
+            if (is_array($array) && count($array) > 0) {
157
+                $count = count($array);
158
+                sort($array);
159
+                $mid = floor(($count - 1) / 2);
160
+
161
+                return ($array[$mid] + $array[$mid + 1 - $count % 2]) / 2;
162
+            }
163
+
164
+            return 0.0;
165
+        }
166 166
 }
Please login to merge, or discard this patch.
templates/personal.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
         <h3>
29 29
             <?php p($l->t('Current color mode')); ?>
30 30
         </h3>
31
-        <select id="color-scheme" name="color-scheme" data-placeholder="<?php p($l->t('Color mode'));?>">
31
+        <select id="color-scheme" name="color-scheme" data-placeholder="<?php p($l->t('Color mode')); ?>">
32 32
             <option value="<?php p($_['color_active']['code']); ?>">
33 33
 				<?php p($_['color_active']['name']); ?>
34 34
 			</option>
Please login to merge, or discard this patch.
lib/Events/FilesEvents.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
 class FilesEvents {
29 29
 
30
-	/** @var string */
30
+    /** @var string */
31 31
     private $userId;
32 32
     
33 33
     /** @var ILogger */
@@ -37,74 +37,74 @@  discard block
 block discarded – undo
37 37
     private $monitor;
38 38
 
39 39
 
40
-	/**
40
+    /**
41 41
      * @param ILogger   $logger
42 42
      * @param Monitor   $monitor
43
-	 * @param string    $userId
44
-	 */
45
-	public function __construct(
43
+     * @param string    $userId
44
+     */
45
+    public function __construct(
46 46
         ILogger $logger,
47 47
         Monitor $monitor,
48 48
         $userId
49 49
 
50
-	) {
50
+    ) {
51 51
         $this->logger = $logger;
52 52
         $this->monitor = $monitor;
53
-		$this->userId = $userId;
54
-	}
53
+        $this->userId = $userId;
54
+    }
55 55
 
56
-	/**
57
-	 * @param array $params
58
-	 */
59
-	public function onFileUpdate(array $params) {
56
+    /**
57
+     * @param array $params
58
+     */
59
+    public function onFileUpdate(array $params) {
60 60
         $this->logger->debug("Updating ".$params['path'].": Params: ".print_r($params, true), ['app' =>  Application::APP_ID]);
61 61
         $this->analyze([$params['path']], Monitor::WRITE);
62
-	}
62
+    }
63 63
 
64 64
 
65
-	/**
66
-	 * @param array $params
67
-	 */
68
-	public function onFileRename(array $params) {
65
+    /**
66
+     * @param array $params
67
+     */
68
+    public function onFileRename(array $params) {
69 69
         $this->logger->debug("Renaming ".$params['oldpath']." to ".$params['newpath'].": Params: ".print_r($params, true), ['app' =>  Application::APP_ID]);
70 70
         $this->analyze([$params['oldpath'], $params['newpath']], Monitor::RENAME);
71 71
     }
72 72
 
73 73
     /**
74
-	 * @param array $params
75
-	 */
74
+     * @param array $params
75
+     */
76 76
     public function onFileCreate(array $params) {
77 77
         $this->logger->debug("Creating ".$params['path'].": Params: ".print_r($params, true), ['app' =>  Application::APP_ID]);
78 78
         $this->analyze([$params['path']], Monitor::CREATE);
79 79
     }
80 80
     
81 81
     /**
82
-	 * @param array $params
83
-	 */
82
+     * @param array $params
83
+     */
84 84
     public function onFileWrite(array $params) {
85 85
         $this->logger->debug("Writing ".$params['path'].": Params: ".print_r($params, true), ['app' =>  Application::APP_ID]);
86 86
         $this->analyze([$params['path']], Monitor::WRITE);
87 87
     }
88 88
     
89 89
     /**
90
-	 * @param array $params
91
-	 */
90
+     * @param array $params
91
+     */
92 92
     public function onFileDelete(array $params) {
93 93
         $this->logger->debug("Deleting ".$params['path'].": Params: ".print_r($params, true), ['app' =>  Application::APP_ID]);
94 94
         $this->analyze([$params['path']], Monitor::DELETE);
95 95
     }
96 96
     
97 97
     /**
98
-	 * @param array $params
99
-	 */
98
+     * @param array $params
99
+     */
100 100
     public function onFileCopy(array $params) {
101 101
         $this->logger->debug("Copying ".$params['oldpath']." to ".$params['newpath'].": Params: ".print_r($params, true), ['app' =>  Application::APP_ID]);
102 102
         $this->analyze([$params['oldpath'], $params['newpath']], Monitor::RENAME);
103 103
     }
104 104
     
105 105
     /**
106
-	 * @param array $params
107
-	 */
106
+     * @param array $params
107
+     */
108 108
     public function onFileTouch(array $params) {
109 109
         $this->logger->debug("Touching ".$params['path'].": Params: ".print_r($params, true), ['app' =>  Application::APP_ID]);
110 110
         $this->analyze([$params['path']], Monitor::WRITE);
Please login to merge, or discard this patch.
lib/FilesHooks.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -26,86 +26,86 @@
 block discarded – undo
26 26
 
27 27
 class FilesHooks {
28 28
 
29
-	/**
30
-	 * Retrieve the FilesEvents' Controller.
31
-	 *
32
-	 * @return FilesEvents
33
-	 */
34
-	protected static function getController(): FilesEvents {
35
-		$app = new Application();
29
+    /**
30
+     * Retrieve the FilesEvents' Controller.
31
+     *
32
+     * @return FilesEvents
33
+     */
34
+    protected static function getController(): FilesEvents {
35
+        $app = new Application();
36 36
 
37
-		return $app->getContainer()
38
-				   ->query(FilesEvents::class);
39
-	}
37
+        return $app->getContainer()
38
+                    ->query(FilesEvents::class);
39
+    }
40 40
 
41
-	/**
42
-	 * Hook events: file is updated.
43
-	 *
44
-	 * @param array $params
45
-	 */
46
-	public static function onFileUpdate(array $params) {
47
-		self::getController()
48
-			->onFileUpdate($params);
49
-	}
41
+    /**
42
+     * Hook events: file is updated.
43
+     *
44
+     * @param array $params
45
+     */
46
+    public static function onFileUpdate(array $params) {
47
+        self::getController()
48
+            ->onFileUpdate($params);
49
+    }
50 50
 
51 51
 
52
-	/**
53
-	 * Hook events: file is renamed.
54
-	 *
55
-	 * @param array $params
56
-	 */
57
-	public static function onFileRename(array $params) {
58
-		self::getController()
59
-			->onFileRename($params);
52
+    /**
53
+     * Hook events: file is renamed.
54
+     *
55
+     * @param array $params
56
+     */
57
+    public static function onFileRename(array $params) {
58
+        self::getController()
59
+            ->onFileRename($params);
60 60
     }
61 61
 	
62
-	/**
63
-	 * Hook events: file is created.
64
-	 *
65
-	 * @param array $params
66
-	 */
62
+    /**
63
+     * Hook events: file is created.
64
+     *
65
+     * @param array $params
66
+     */
67 67
     public static function onFileCreate(array $params) {
68
-		self::getController()
69
-			->onFileCreate($params);
68
+        self::getController()
69
+            ->onFileCreate($params);
70 70
     }
71 71
 	
72
-	/**
73
-	 * Hook events: file is written.
74
-	 *
75
-	 * @param array $params
76
-	 */
72
+    /**
73
+     * Hook events: file is written.
74
+     *
75
+     * @param array $params
76
+     */
77 77
     public static function onFileWrite(array $params) {
78
-		self::getController()
79
-			->onFileWrite($params);
78
+        self::getController()
79
+            ->onFileWrite($params);
80 80
     }
81 81
 	
82
-	/**
83
-	 * Hook events: file is deleted.
84
-	 *
85
-	 * @param array $params
86
-	 */
82
+    /**
83
+     * Hook events: file is deleted.
84
+     *
85
+     * @param array $params
86
+     */
87 87
     public static function onFileDelete(array $params) {
88
-		self::getController()
89
-			->onFileDelete($params);
88
+        self::getController()
89
+            ->onFileDelete($params);
90 90
     }
91 91
 	
92
-	/**
93
-	 * Hook events: file is touched.
94
-	 *
95
-	 * @param array $params
96
-	 */
92
+    /**
93
+     * Hook events: file is touched.
94
+     *
95
+     * @param array $params
96
+     */
97 97
     public static function onFileTouch(array $params) {
98
-		self::getController()
99
-			->onFileTouch($params);
98
+        self::getController()
99
+            ->onFileTouch($params);
100 100
     }
101 101
 	
102
-	/**
103
-	 * Hook events: file is copied.
104
-	 *
105
-	 * @param array $params
106
-	 */
102
+    /**
103
+     * Hook events: file is copied.
104
+     *
105
+     * @param array $params
106
+     */
107 107
     public static function onFileCopy(array $params) {
108
-		self::getController()
109
-			->onFileCopy($params);
110
-	}
108
+        self::getController()
109
+            ->onFileCopy($params);
110
+    }
111 111
 }
112 112
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Service/DetectionService.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -89,18 +89,18 @@
 block discarded – undo
89 89
 
90 90
         foreach ($sequences as $id => $sequence) {
91 91
             if (sizeof($sequence) >= $this->config->getAppValue(Application::APP_ID, 'minimum_sequence_length', 0)) {
92
-                usort($sequence, function ($a, $b) {
92
+                usort($sequence, function($a, $b) {
93 93
                     return $b->getId() - $a->getId();
94 94
                 });
95 95
                 $result = $this->sequenceAnalyzer->analyze($id, $sequence);
96
-                $this->logger->debug('detection: suspicion score of sequence ' . $id . ' is ' . $result->getSuspicionScore() . '.', array('app' => Application::APP_ID));
96
+                $this->logger->debug('detection: suspicion score of sequence '.$id.' is '.$result->getSuspicionScore().'.', array('app' => Application::APP_ID));
97 97
                 if ($result->getSuspicionScore() >= 0.5) {
98 98
                     $detection = new Detection($id, $sequence);
99 99
                     array_push($detectionObjects, $detection);
100 100
                 }
101 101
             }
102 102
         }
103
-        usort($detectionObjects, function ($a, $b) {
103
+        usort($detectionObjects, function($a, $b) {
104 104
             return $b->getId() - $a->getId();
105 105
         });
106 106
         return $detectionObjects;
Please login to merge, or discard this patch.
lib/AppInfo/Application.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -68,33 +68,33 @@  discard block
 block discarded – undo
68 68
         $container = $this->getContainer();
69 69
 
70 70
         // mapper
71
-        $container->registerService('FileOperationMapper', function ($c) {
71
+        $container->registerService('FileOperationMapper', function($c) {
72 72
             return new FileOperationMapper(
73 73
                 $c->query('ServerContainer')->getDb()
74 74
             );
75 75
         });
76 76
 
77
-        $container->registerService('RecoveredFileOperationMapper', function ($c) {
77
+        $container->registerService('RecoveredFileOperationMapper', function($c) {
78 78
             return new RecoveredFileOperationMapper(
79 79
                 $c->query('ServerContainer')->getDb()
80 80
             );
81 81
         });
82 82
 
83
-        $container->registerService('DetectionDeserializer', function ($c) {
83
+        $container->registerService('DetectionDeserializer', function($c) {
84 84
             return new DetectionDeserializer(
85 85
                 $c->query('FileOperationMapper')
86 86
             );
87 87
         });
88 88
 
89 89
         // services
90
-        $container->registerService('FileOperationService', function ($c) {
90
+        $container->registerService('FileOperationService', function($c) {
91 91
             return new FileOperationService(
92 92
                 $c->query(FileOperationMapper::class),
93 93
                 $c->query('ServerContainer')->getUserSession()->getUser()->getUID()
94 94
             );
95 95
         });
96 96
 
97
-        $container->registerService('RecoveredFileOperationService', function ($c) {
97
+        $container->registerService('RecoveredFileOperationService', function($c) {
98 98
             return new RecoveredFileOperationService(
99 99
                 $c->query(FileOperationMapper::class),
100 100
                 $c->query(RecoveredFileOperationMapper::class),
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
             );
103 103
         });
104 104
 
105
-        $container->registerService('DetectionService', function ($c) {
105
+        $container->registerService('DetectionService', function($c) {
106 106
             return new DetectionService(
107 107
                 $c->query(ILogger::class),
108 108
                 $c->query('FileOperationService'),
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
         });
115 115
 
116 116
         // classifier
117
-        $container->registerService('Classifier', function ($c) {
117
+        $container->registerService('Classifier', function($c) {
118 118
             return new Classifier(
119 119
                 $c->query(ILogger::class),
120 120
                 $c->query(FileOperationMapper::class),
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         });
124 124
 
125 125
         // controller
126
-        $container->registerService('DetectionController', function ($c) {
126
+        $container->registerService('DetectionController', function($c) {
127 127
             return new DetectionController(
128 128
                 $c->query('AppName'),
129 129
                 $c->query('Request'),
@@ -132,28 +132,28 @@  discard block
 block discarded – undo
132 132
         });
133 133
 
134 134
         // entropy
135
-        $container->registerService('Entropy', function ($c) {
135
+        $container->registerService('Entropy', function($c) {
136 136
             return new Entropy(
137 137
                 $c->query(ILogger::class)
138 138
             );
139 139
         });
140 140
 
141 141
         // analyzer
142
-        $container->registerService('SequenceSizeAnalyzer', function ($c) {
142
+        $container->registerService('SequenceSizeAnalyzer', function($c) {
143 143
             return new SequenceSizeAnalyzer();
144 144
         });
145 145
 
146
-        $container->registerService('FileTypeFunnellingAnalyzer', function ($c) {
146
+        $container->registerService('FileTypeFunnellingAnalyzer', function($c) {
147 147
             return new FileTypeFunnellingAnalyzer();
148 148
         });
149 149
 
150
-        $container->registerService('EntropyFunnellingAnalyzer', function ($c) {
150
+        $container->registerService('EntropyFunnellingAnalyzer', function($c) {
151 151
             return new EntropyFunnellingAnalyzer(
152 152
                 $c->query(ILogger::class)
153 153
             );
154 154
         });
155 155
 
156
-        $container->registerService('FileExtensionAnalyzer', function ($c) {
156
+        $container->registerService('FileExtensionAnalyzer', function($c) {
157 157
             return new FileExtensionAnalyzer(
158 158
                 $c->query(ILogger::class),
159 159
                 $c->query(Entropy::class)
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
             );
162 162
         });
163 163
 
164
-        $container->registerService('SequenceAnalyzer', function ($c) {
164
+        $container->registerService('SequenceAnalyzer', function($c) {
165 165
             return new SequenceAnalyzer(
166 166
                 $c->query(SequenceSizeAnalyzer::class),
167 167
                 $c->query(FileTypeFunnellingAnalyzer::class),
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
             );
170 170
         });
171 171
 
172
-        $container->registerService('EntropyAnalyzer', function ($c) {
172
+        $container->registerService('EntropyAnalyzer', function($c) {
173 173
             return new EntropyAnalyzer(
174 174
                 $c->query(ILogger::class),
175 175
                 $c->query(IRootFolder::class),
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
             );
179 179
         });
180 180
 
181
-        $container->registerService('FileCorruptionAnalyzer', function ($c) {
181
+        $container->registerService('FileCorruptionAnalyzer', function($c) {
182 182
             return new FileCorruptionAnalyzer(
183 183
                 $c->query(ILogger::class),
184 184
                 $c->query(IRootFolder::class),
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
             );
187 187
         });
188 188
 
189
-        $container->registerService('Monitor', function ($c) {
189
+        $container->registerService('Monitor', function($c) {
190 190
             return new Monitor(
191 191
                 $c->query(IRequest::class),
192 192
                 $c->query(IConfig::class),
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
             );
203 203
         });
204 204
 
205
-        $container->registerService('FilesEvents', function ($c) {
205
+        $container->registerService('FilesEvents', function($c) {
206 206
             return new FilesEvents(
207 207
                 $c->query(ILogger::class),
208 208
                 $c->query(Monitor::class),
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
     {
219 219
         // register sabre plugin to catch the profind requests
220 220
         $eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher();
221
-        $eventDispatcher->addListener('OCA\DAV\Connector\Sabre::addPlugin', function (SabrePluginEvent $event) {
221
+        $eventDispatcher->addListener('OCA\DAV\Connector\Sabre::addPlugin', function(SabrePluginEvent $event) {
222 222
             $logger = $this->getContainer()->query(ILogger::class);
223 223
             $config = $this->getContainer()->query(IConfig::class);
224 224
             $userSession = $this->getContainer()->query(IUserSession::class);
Please login to merge, or discard this patch.
lib/Monitor.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -137,10 +137,10 @@
 block discarded – undo
137 137
     {
138 138
         $path = $paths[0];
139 139
 		
140
-		if ($path === '') {
141
-			$this->logger->debug("Path is empty.");
142
-			return;
143
-		}
140
+        if ($path === '') {
141
+            $this->logger->debug("Path is empty.");
142
+            return;
143
+        }
144 144
 
145 145
         $storage = $this->rootFolder->getUserFolder($this->userId)->get(dirname($path))->getStorage();
146 146
         if ($this->userId === null || $this->nestingLevel !== 0 || /*!$this->isUploadedFile($storage, $path) ||*/ $this->isCreatingSkeletonFiles()) {
Please login to merge, or discard this patch.