-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from GDATASoftwareAG/upload-scanning
Upload scanning
- Loading branch information
Showing
15 changed files
with
599 additions
and
113 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/php | ||
{ | ||
"name": "PHP", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"image": "mcr.microsoft.com/devcontainers/php:1-8.2-bullseye", | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
"forwardPorts": [8080] | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "sudo chmod a+x \"$(pwd)\" && sudo rm -rf /var/www/html && sudo ln -s \"$(pwd)\" /var/www/html" | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,32 @@ | ||
#!/bin/bash | ||
|
||
docker stop nextcloud-container | ||
docker run -d --name nextcloud-container --rm --publish 80:80 --publish 8080:8080 --publish 8443:8443 nextcloud:stable | ||
sleep 1 | ||
docker run -d --name nextcloud-container --rm --publish 80:80 nextcloud:28 | ||
echo "Waiting for sunrise..." | ||
sleep 15 | ||
docker exec --user www-data -it nextcloud-container php occ maintenance:install --admin-user=admin --admin-pass=admin | ||
|
||
until docker exec --user www-data -it nextcloud-container php occ maintenance:install --admin-user=admin --admin-pass=admin >/dev/null | ||
do | ||
echo "Try again waiting 2 seconds" | ||
sleep 2 | ||
done | ||
|
||
make build | ||
make appstore | ||
tar -xf ./build/artifacts/gdatavaas.tar.gz -C ./build/artifacts | ||
docker exec --user www-data -it nextcloud-container mkdir apps/gdatavaas | ||
docker cp ./build/artifacts/gdatavaas nextcloud-container:/var/www/html/apps/gdatavaas | ||
docker cp ./build/artifacts/gdatavaas nextcloud-container:/var/www/html/apps/ | ||
docker exec -it nextcloud-container chown -R www-data:www-data /var/www/html/apps/gdatavaas | ||
docker exec --user www-data -it nextcloud-container php occ app:update --all | ||
docker exec --user www-data -it nextcloud-container php occ app:enable gdatavaas | ||
|
||
docker exec --user www-data -it nextcloud-container php occ config:app:set gdatavaas username --value=vaas-integration-test | ||
docker exec --user www-data -it nextcloud-container php occ config:app:set gdatavaas clientId --value=$CLIENT_ID | ||
docker exec --user www-data -it nextcloud-container php occ config:app:set gdatavaas clientSecret --value=$CLIENT_SECRET | ||
docker exec --user www-data -it nextcloud-container php occ config:app:set gdatavaas authMethod --value=ClientCredentials | ||
docker exec --user www-data -it nextcloud-container php occ config:app:set gdatavaas autoScanFiles --value=true | ||
docker exec --user www-data -it nextcloud-container php occ config:app:set gdatavaas scanQueueLength --value=100 | ||
|
||
docker exec --user www-data -it nextcloud-container php occ log:manage --level DEBUG | ||
docker exec --user www-data -it nextcloud-container php occ app:disable firstrunwizard | ||
|
||
|
||
docker exec --user www-data -it nextcloud-container php cron.php | ||
# docker exec --user www-data -it nextcloud-container php cron.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
<?php | ||
/** | ||
* @copyright Copyright (c) 2018 Roeland Jago Douma <[email protected]> | ||
* | ||
* @author Roeland Jago Douma <[email protected]> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
namespace OCA\GDataVaas\Activity; | ||
|
||
use OCA\GDataVaas\AppInfo\Application; | ||
use OCP\Activity\IEvent; | ||
use OCP\Activity\IProvider; | ||
use OCP\IURLGenerator; | ||
use OCP\L10N\IFactory; | ||
use Psr\Log\LoggerInterface; | ||
|
||
class Provider implements IProvider { | ||
public const TYPE_VIRUS_DETECTED = 'virus_detected'; | ||
|
||
public const SUBJECT_VIRUS_DETECTED = 'virus_detected'; | ||
public const SUBJECT_VIRUS_DETECTED_UPLOAD = 'virus_detected_upload'; | ||
public const SUBJECT_VIRUS_DETECTED_SCAN = 'virus_detected_scan'; | ||
|
||
public const MESSAGE_FILE_DELETED = 'file_deleted'; | ||
|
||
/** @var IFactory */ | ||
private $languageFactory; | ||
|
||
/** @var IURLGenerator */ | ||
private $urlGenerator; | ||
private LoggerInterface $logger; | ||
|
||
public function __construct(IFactory $languageFactory, IURLGenerator $urlGenerator, LoggerInterface $logger) { | ||
$this->languageFactory = $languageFactory; | ||
$this->urlGenerator = $urlGenerator; | ||
$this->logger = $logger; | ||
} | ||
|
||
public function parse($language, IEvent $event, IEvent $previousEvent = null) { | ||
if ($event->getApp() !== Application::APP_ID || $event->getType() !== self::TYPE_VIRUS_DETECTED) { | ||
throw new \InvalidArgumentException(); | ||
} | ||
|
||
$parameters = []; | ||
$subject = ''; | ||
|
||
if ($event->getSubject() === self::SUBJECT_VIRUS_DETECTED) { | ||
$subject = 'File {file} is infected with {virus}'; | ||
|
||
$params = $event->getSubjectParameters(); | ||
$parameters['virus'] = [ | ||
'type' => 'highlight', | ||
'id' => $params[1], | ||
'name' => $params[1], | ||
]; | ||
|
||
$parameters['file'] = [ | ||
'type' => 'highlight', | ||
'id' => $event->getObjectName(), | ||
'name' => basename($event->getObjectName()), | ||
]; | ||
$event->setIcon($this->urlGenerator->imagePath('gdatavaas', 'favicon.svg')); | ||
|
||
if ($event->getMessage() === self::MESSAGE_FILE_DELETED) { | ||
$event->setParsedMessage('The file has been removed'); | ||
} | ||
} elseif ($event->getSubject() === self::SUBJECT_VIRUS_DETECTED_UPLOAD) { | ||
$subject = 'File containing {virus} detected'; | ||
|
||
$params = $event->getSubjectParameters(); | ||
$parameters['virus'] = [ | ||
'type' => 'highlight', | ||
'id' => $params[0], | ||
'name' => $params[0], | ||
]; | ||
|
||
$event->setParsedSubject($subject); | ||
$event->setRichSubject($subject); | ||
$event->setIcon($this->urlGenerator->imagePath('gdatavaas', 'favicon.svg')); | ||
|
||
if ($event->getMessage() === self::MESSAGE_FILE_DELETED) { | ||
$event->setParsedMessage('The file has been removed'); | ||
} | ||
} elseif ($event->getSubject() === self::SUBJECT_VIRUS_DETECTED_SCAN) { | ||
$subject = 'File {file} is infected with {virus}'; | ||
|
||
$params = $event->getSubjectParameters(); | ||
$parameters['virus'] = [ | ||
'type' => 'highlight', | ||
'id' => $params[0], | ||
'name' => $params[0], | ||
]; | ||
$parameters['file'] = [ | ||
'type' => 'highlight', | ||
'id' => $event->getObjectName(), | ||
'name' => $event->getObjectName(), | ||
]; | ||
$event->setIcon($this->urlGenerator->imagePath('gdatavaas', 'favicon.svg')); | ||
|
||
if ($event->getMessage() === self::MESSAGE_FILE_DELETED) { | ||
$event->setParsedMessage('The file has been removed'); | ||
} | ||
} | ||
|
||
$this->setSubjects($event, $subject, $parameters); | ||
|
||
return $event; | ||
} | ||
|
||
private function setSubjects(IEvent $event, string $subject, array $parameters): void { | ||
$placeholders = $replacements = []; | ||
foreach ($parameters as $placeholder => $parameter) { | ||
$placeholders[] = '{' . $placeholder . '}'; | ||
if ($parameter['type'] === 'file') { | ||
$replacements[] = $parameter['path']; | ||
} else { | ||
$replacements[] = $parameter['name']; | ||
} | ||
} | ||
|
||
$event->setParsedSubject(str_replace($placeholders, $replacements, $subject)) | ||
->setRichSubject($subject, $parameters); | ||
} | ||
} |
Oops, something went wrong.