Skip to content

Commit

Permalink
apply php-cs-fixer fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ata-no-one committed May 22, 2024
1 parent e846afb commit 35f2b68
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
14 changes: 14 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
->exclude([
'vendor',
'node_modules',
'build'
])
;

return (new PhpCsFixer\Config())
->setFinder($finder)
;
7 changes: 3 additions & 4 deletions lib/BackgroundJobs/ScanJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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) {
Expand All @@ -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");
}
}
2 changes: 1 addition & 1 deletion lib/BackgroundJobs/TagUnscannedJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected function run($argument): void
}
$this->tagService->setTag($fileId, TagService::UNSCANNED);
}

$this->logger->debug("Tagged " . count($fileIds) . " unscanned files");
}
}
2 changes: 1 addition & 1 deletion lib/Service/TagService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
9 changes: 4 additions & 5 deletions lib/Service/VerdictService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 35f2b68

Please sign in to comment.