diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 00000000..1a21f492 --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,14 @@ +in(__DIR__) + ->exclude([ + 'vendor', + 'node_modules', + 'build' + ]) +; + +return (new PhpCsFixer\Config()) + ->setFinder($finder) +; \ No newline at end of file diff --git a/lib/BackgroundJobs/ScanJob.php b/lib/BackgroundJobs/ScanJob.php index 08df5d7a..db6956f8 100644 --- a/lib/BackgroundJobs/ScanJob.php +++ b/lib/BackgroundJobs/ScanJob.php @@ -49,8 +49,7 @@ protected function run($argument): void $quantity = $this->appConfig->getAppValue(self::APP_ID, 'scanQueueLength'); try { $quantity = intval($quantity); - } - catch (Exception) { + } catch (Exception) { $quantity = 5; } @@ -73,7 +72,7 @@ protected function run($argument): void $fileIds = $this->tagService->getRandomTaggedFileIds([$maliciousTag->getId(), $cleanTag->getId(), $unscannedTag->getId(), $pupTag->getId()], $quantity, $unscannedTag); } } - + $this->logger->debug("Scanning files"); foreach ($fileIds as $fileId) { @@ -83,7 +82,7 @@ protected function run($argument): void $this->logger->error("Failed to scan file with id " . $fileId . ": " . $e->getMessage()); } } - + $this->logger->debug("Scanned " . count($fileIds) . " files"); } } diff --git a/lib/BackgroundJobs/TagUnscannedJob.php b/lib/BackgroundJobs/TagUnscannedJob.php index 7add2239..2547f0b7 100644 --- a/lib/BackgroundJobs/TagUnscannedJob.php +++ b/lib/BackgroundJobs/TagUnscannedJob.php @@ -60,7 +60,7 @@ protected function run($argument): void } $this->tagService->setTag($fileId, TagService::UNSCANNED); } - + $this->logger->debug("Tagged " . count($fileIds) . " unscanned files"); } } diff --git a/lib/Service/TagService.php b/lib/Service/TagService.php index 07c47807..5b9b1b82 100644 --- a/lib/Service/TagService.php +++ b/lib/Service/TagService.php @@ -90,7 +90,7 @@ public function removeTagFromFile(string $tagName, int $fileId): bool public function hasCleanMaliciousOrPupTag(int $fileId): bool { if ($this->tagMapper->haveTag([$fileId], 'files', $this->getTag(self::CLEAN)->getId()) || - $this->tagMapper->haveTag([$fileId], 'files', $this->getTag(self::MALICIOUS)->getId()) || + $this->tagMapper->haveTag([$fileId], 'files', $this->getTag(self::MALICIOUS)->getId()) || $this->tagMapper->haveTag([$fileId], 'files', $this->getTag(self::PUP)->getId())) { return true; } diff --git a/lib/Service/VerdictService.php b/lib/Service/VerdictService.php index 4241d6dc..6263e503 100644 --- a/lib/Service/VerdictService.php +++ b/lib/Service/VerdictService.php @@ -93,22 +93,21 @@ public function scanFileById(int $fileId): VaasVerdict throw new NotPermittedException("File is not in the allowlist"); } } - + if ($this->vaas == null) { $this->vaas = $this->createAndConnectVaas(); } try { $verdict = $this->vaas->ForFile($filePath); - } - catch (Exception $e) { + } catch (Exception $e) { $this->logger->error("Vaas for file: " . $e->getMessage()); $this->vaas = null; throw $e; } - $this->logger->info("VaaS scan result for " . $node->getName() . " (" . $fileId . "): Verdict: " - . $verdict->Verdict->value . ", Detection: " . $verdict->Detection . ", SHA256: " . $verdict->Sha256 . + $this->logger->info("VaaS scan result for " . $node->getName() . " (" . $fileId . "): Verdict: " + . $verdict->Verdict->value . ", Detection: " . $verdict->Detection . ", SHA256: " . $verdict->Sha256 . ", FileType: " . $verdict->FileType . ", MimeType: " . $verdict->MimeType . ", UUID: " . $verdict->Guid); $this->tagService->removeTagFromFile(TagService::CLEAN, $fileId);