From 683c10c892b2cabe1189c9da90d7ee20a762f691 Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Mon, 16 Sep 2024 08:31:55 +0200 Subject: [PATCH 1/5] add asset protection --- README.md | 36 ++++-- composer.json | 2 +- config/pimcore/config.yaml | 6 + config/services.yaml | 2 +- config/services/.gitkeep | 1 - config/services/maintenance.yaml | 14 +++ config/services/messenger.yaml | 11 ++ src/DependencyInjection/Configuration.php | 42 +++++-- src/Flysystem/Adapter/SecuredAdapter.php | 14 ++- .../ProtectPublicDirectoriesTask.php | 77 ++++++++++++ src/Messenger/Middleware/GuardMiddleware.php | 116 ++++++++++++++++++ 11 files changed, 302 insertions(+), 19 deletions(-) create mode 100644 config/pimcore/config.yaml delete mode 100644 config/services/.gitkeep create mode 100644 config/services/maintenance.yaml create mode 100644 config/services/messenger.yaml create mode 100644 src/Maintenance/ProtectPublicDirectoriesTask.php create mode 100644 src/Messenger/Middleware/GuardMiddleware.php diff --git a/README.md b/README.md index 26640a83..3a5e660b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ | Release | Supported Pimcore Versions | Supported Symfony Versions | Release Date | Maintained | Branch | |---------|----------------------------|----------------------------|--------------|----------------|--------| -| **1.x** | `^11.2` | `6.2` | -- | Feature Branch | master | +| **1.x** | `^11.3` | `6.2` | -- | Feature Branch | master | ## Installation @@ -44,6 +44,8 @@ Encrypt/Decrypt assets on the fly! ## Configuration +### File Encryption + ```yaml secure_storage: encrypter: @@ -54,12 +56,8 @@ secure_storage: secured_fly_system_storages: # form builder (if you want to encrypt form builder data) - - - storage: form_builder.chunk.storage - paths: null - - - storage: form_builder.files.storage - paths: null + - storage: form_builder.chunk.storage + - storage: form_builder.files.storage # pimcore - @@ -69,11 +67,33 @@ secure_storage: - /formdata ``` -## Custom Encrypter +#### Custom Encrypter TBD *** +### Asset Protection + +```yaml +secure_storage: + + pimcore_asset_protection: + + # protects: + # - public/var/assets [pimcore.asset.storage] + # - public/tmp/asset-cache [pimcore.asset_cache.storage] + # - public/tmp/thumbnails [pimcore.thumbnail.storage] + htaccess_protection_public_directories: + paths: + - /secure-storage + + omit_backend_search_indexing: + paths: + - /secure-storage +``` + +*** + ## Copyright and license Copyright: [DACHCOM.DIGITAL](http://dachcom-digital.ch) For licensing details please visit [LICENSE.md](LICENSE.md) diff --git a/composer.json b/composer.json index cf1d6dcb..20d18bcc 100755 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ } }, "require": { - "pimcore/pimcore": "^11.0" + "pimcore/pimcore": "^11.3" }, "require-dev": { "codeception/codeception": "^5.0", diff --git a/config/pimcore/config.yaml b/config/pimcore/config.yaml new file mode 100644 index 00000000..168e284e --- /dev/null +++ b/config/pimcore/config.yaml @@ -0,0 +1,6 @@ +framework: + messenger: + buses: + messenger.bus.pimcore-core: + middleware: + - SecureStorageBundle\Messenger\Middleware\GuardMiddleware diff --git a/config/services.yaml b/config/services.yaml index ee78c90f..98761ca7 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -1,2 +1,2 @@ imports: - - { resource: services/*.yaml } \ No newline at end of file + - { resource: services/*.yaml } diff --git a/config/services/.gitkeep b/config/services/.gitkeep deleted file mode 100644 index 8b137891..00000000 --- a/config/services/.gitkeep +++ /dev/null @@ -1 +0,0 @@ - diff --git a/config/services/maintenance.yaml b/config/services/maintenance.yaml new file mode 100644 index 00000000..61b4736c --- /dev/null +++ b/config/services/maintenance.yaml @@ -0,0 +1,14 @@ +services: + _defaults: + autowire: true + autoconfigure: true + public: false + + SecureStorageBundle\Maintenance\ProtectPublicDirectoriesTask: + autowire: true + autoconfigure: true + arguments: + $secureStorageConfig: '%pimcore.secure_storage.config%' + $locator: !tagged_locator { tag: flysystem.storage } + tags: + - { name: pimcore.maintenance.task, type: secure_storage_protect_public_directories } \ No newline at end of file diff --git a/config/services/messenger.yaml b/config/services/messenger.yaml new file mode 100644 index 00000000..e2535078 --- /dev/null +++ b/config/services/messenger.yaml @@ -0,0 +1,11 @@ +services: + _defaults: + autowire: true + autoconfigure: true + public: false + + SecureStorageBundle\Messenger\Middleware\GuardMiddleware: + arguments: + $secureStorageConfig: '%pimcore.secure_storage.config%' + tags: + - { name: messenger.middleware } diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 0d060eac..a232f3ab 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -22,22 +22,50 @@ public function getConfigTreeBuilder(): TreeBuilder ->variableNode('options')->defaultValue([])->end() ->end() ->end() + ->arrayNode('secured_fly_system_storages') ->prototype('array') + ->addDefaultsIfNotSet() + ->children() + ->scalarNode('storage') + ->isRequired() + ->validate() + ->ifNull() + ->thenInvalid('Invalid storage %s') + ->end() + ->end() + ->arrayNode('paths') + ->prototype('scalar')->end() + ->end() + ->booleanNode('allow_asset_preview_image_generation')->defaultFalse()->end() + ->booleanNode('allow_asset_update_preview_image_generation')->defaultFalse()->end() + ->booleanNode('allow_image_optimizing')->defaultFalse()->end() + ->end() + ->end() + ->end() + + ->arrayNode('pimcore_asset_protection') ->addDefaultsIfNotSet() ->children() - ->scalarNode('storage') - ->isRequired() - ->validate() - ->ifNull() - ->thenInvalid('Invalid storage %s') + ->arrayNode('htaccess_protection_public_directories') + ->addDefaultsIfNotSet() + ->children() + ->arrayNode('paths') + ->prototype('scalar')->end() + ->end() ->end() ->end() - ->arrayNode('paths') - ->prototype('scalar')->end() + ->arrayNode('omit_backend_search_indexing') + ->addDefaultsIfNotSet() + ->children() + ->arrayNode('paths') + ->prototype('scalar')->end() + ->end() + ->end() ->end() ->end() ->end() + ->end(); return $treeBuilder; diff --git a/src/Flysystem/Adapter/SecuredAdapter.php b/src/Flysystem/Adapter/SecuredAdapter.php index b3af509e..e3f2fec5 100644 --- a/src/Flysystem/Adapter/SecuredAdapter.php +++ b/src/Flysystem/Adapter/SecuredAdapter.php @@ -26,7 +26,7 @@ private function isSecuredPath(string $path): bool return true; } - foreach($this->securedPaths as $securedPath) { + foreach ($this->securedPaths as $securedPath) { if (str_starts_with($path, ltrim($securedPath, '/'))) { return true; } @@ -47,6 +47,12 @@ public function directoryExists(string $path): bool public function write(string $path, string $contents, Config $config): void { + if ($config->get('bypass_secured_adapter') === true) { + $this->inner->write($path, $contents, $config); + + return; + } + if (!$this->isSecuredPath($path)) { $this->inner->write($path, $contents, $config); @@ -64,6 +70,12 @@ public function write(string $path, string $contents, Config $config): void public function writeStream(string $path, $contents, Config $config): void { + if ($config->get('bypass_secured_adapter') === true) { + $this->inner->write($path, $contents, $config); + + return; + } + if (!$this->isSecuredPath($path)) { $this->inner->writeStream($path, $contents, $config); diff --git a/src/Maintenance/ProtectPublicDirectoriesTask.php b/src/Maintenance/ProtectPublicDirectoriesTask.php new file mode 100644 index 00000000..ecf94199 --- /dev/null +++ b/src/Maintenance/ProtectPublicDirectoriesTask.php @@ -0,0 +1,77 @@ +secureStorageConfig['pimcore_asset_protection']['htaccess_protection_public_directories']; + + if (count($assetProtectionConfig['paths']) === 0) { + return; + } + + foreach ($assetProtectionConfig['paths'] as $protectedPath) { + $this->protectPath($protectedPath); + } + } + + private function protectPath(string $protectedPath): void + { + $data = implode(PHP_EOL, $this->getProtectionLines()); + + $storages = [ + 'pimcore.asset.storage', + 'pimcore.asset_cache.storage', + 'pimcore.thumbnail.storage' + ]; + + foreach ($storages as $storageName) { + + $storage = $this->getStorage($storageName); + + if ($protectedPath === '/') { + + $secureFilePath = '.htaccess'; + if (!$storage->fileExists($secureFilePath)) { + $storage->write($secureFilePath, $data, ['bypass_secured_adapter' => true]); + } + + continue; + } + + $secureFilePath = sprintf('%s/.htaccess', $protectedPath); + if ($storage->directoryExists($protectedPath) && !$storage->fileExists($secureFilePath)) { + $storage->write($secureFilePath, $data, ['bypass_secured_adapter' => true]); + } + } + } + + private function getStorage(string $name): FilesystemOperator + { + return $this->locator->get($name); + } + + private function getProtectionLines(): array + { + $data = []; + + $data[] = 'RewriteEngine On'; + $data[] = 'RewriteCond %{HTTP_HOST}==%{HTTP_REFERER} !^(.*?)==https?://\1/admin/ [OR]'; + $data[] = 'RewriteCond %{HTTP_COOKIE} !^.*pimcore_admin_sid.*$ [NC]'; + $data[] = 'RewriteRule ^ - [L,F]'; + + return $data; + } +} diff --git a/src/Messenger/Middleware/GuardMiddleware.php b/src/Messenger/Middleware/GuardMiddleware.php new file mode 100644 index 00000000..a3128a5d --- /dev/null +++ b/src/Messenger/Middleware/GuardMiddleware.php @@ -0,0 +1,116 @@ +isGuardedMessage($envelope)) { + return $stack->next()->handle($envelope, $stack); + } + + return $envelope; + } + + private function isGuardedMessage(Envelope $envelope): bool + { + $omitMessage = match (get_class($envelope->getMessage())) { + SearchBackendMessage::class => $this->omitByBackendSearch($envelope), + //AssetPreviewImageMessage::class => false, + //AssetUpdateTasksMessage::class => false, + //OptimizeImageMessage::class => false, + default => false + }; + + return $omitMessage === true; + } + + private function omitByBackendSearch(Envelope $envelope): bool + { + $config = $this->secureStorageConfig['pimcore_asset_protection']['omit_backend_search_indexing']; + + if (count($config['paths']) === 0) { + return false; + } + + $path = $this->extractElementPath($envelope); + + if ($path === null) { + return false; + } + + return $this->checkPaths($path, $config['paths']); + } + + private function checkPaths(string $path, array $securePaths): bool + { + foreach ($securePaths as $securedPath) { + if (str_starts_with($path, $securedPath)) { + return true; + } + } + + return false; + } + + private function extractElementPath(Envelope $envelope): ?string + { + $asset = null; + + // restriction type: allow_backend_search_indexing + if (get_class($envelope->getMessage()) === SearchBackendMessage::class) { + /** @var SearchBackendMessage $message */ + $message = $envelope->getMessage(); + if ($message->getType() === 'asset') { + $asset = Asset::getById($message->getId()); + } + } + + // restriction type: allow_asset_preview_image_generation + if (get_class($envelope->getMessage()) === AssetPreviewImageMessage::class) { + /** @var AssetPreviewImageMessage $message */ + $message = $envelope->getMessage(); + $asset = Asset::getById($message->getId()); + } + + // restriction type: allow_asset_update_preview_image_generation + if (get_class($envelope->getMessage()) === AssetUpdateTasksMessage::class) { + /** @var AssetUpdateTasksMessage $message */ + $message = $envelope->getMessage(); + $asset = Asset::getById($message->getId()); + } + + // restriction type: allow_image_optimizing + if (get_class($envelope->getMessage()) === OptimizeImageMessage::class) { + /** @var OptimizeImageMessage $message */ + $message = $envelope->getMessage(); + $asset = sprintf('/%s', ltrim($message->getPath(), '/')); + } + + if (is_string($asset)) { + return $asset; + } + + if ($asset instanceof Asset) { + return $asset->getPath(); + } + + return null; + } +} \ No newline at end of file From b673a50f156c0c2d5bf8bd1a151b49dc5bdfc690 Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Mon, 16 Sep 2024 08:39:19 +0200 Subject: [PATCH 2/5] add test structure --- .github/workflows/codeception.yml | 144 ++++++++++ .github/workflows/ecs.yml | 117 ++++++++ .github/workflows/php-stan.yml | 116 ++++++++ README.md | 2 +- ecs.php | 265 ++++++++---------- phpstan.neon | 5 - tests/Functional.suite.dist.yml | 12 + tests/Functional/_bootstrap.php | 2 + tests/Support/FunctionalTester.php | 8 + tests/Support/UnitTester.php | 8 + tests/Unit.suite.dist.yml | 8 + tests/Unit/_bootstrap.php | 2 + tests/_bootstrap.php | 3 + tests/_data/.gitkeep | 0 tests/_envs/github.yml | 12 + tests/_envs/local.yml | 10 + tests/_etc/config.yaml | 11 + tests/_etc/config/app/config.yaml | 56 ++++ .../app/controller/DefaultController.php | 15 + tests/_etc/config/app/system_settings.yaml | 47 ++++ .../config/app/templates/default.html.twig | 21 ++ tests/_etc/config/bundle/config_default.yaml | 0 tests/_phpstan-bootstrap.php | 6 + 23 files changed, 720 insertions(+), 150 deletions(-) create mode 100644 .github/workflows/codeception.yml create mode 100644 .github/workflows/ecs.yml create mode 100644 .github/workflows/php-stan.yml create mode 100644 tests/Functional.suite.dist.yml create mode 100644 tests/Functional/_bootstrap.php create mode 100644 tests/Support/FunctionalTester.php create mode 100644 tests/Support/UnitTester.php create mode 100644 tests/Unit.suite.dist.yml create mode 100644 tests/Unit/_bootstrap.php create mode 100644 tests/_bootstrap.php create mode 100644 tests/_data/.gitkeep create mode 100644 tests/_envs/github.yml create mode 100644 tests/_envs/local.yml create mode 100644 tests/_etc/config.yaml create mode 100755 tests/_etc/config/app/config.yaml create mode 100644 tests/_etc/config/app/controller/DefaultController.php create mode 100755 tests/_etc/config/app/system_settings.yaml create mode 100644 tests/_etc/config/app/templates/default.html.twig create mode 100755 tests/_etc/config/bundle/config_default.yaml create mode 100644 tests/_phpstan-bootstrap.php diff --git a/.github/workflows/codeception.yml b/.github/workflows/codeception.yml new file mode 100644 index 00000000..d9ad4439 --- /dev/null +++ b/.github/workflows/codeception.yml @@ -0,0 +1,144 @@ +name: Codeception +on: + push: + branches: [ 'master' ] + pull_request: + branches: [ 'master' ] + +jobs: + codeception: + runs-on: ubuntu-latest + env: + TEST_BUNDLE_NAME: "SecureStorageBundle" + TEST_BUNDLE_INSTALLER_CLASS: false + TEST_BUNDLE_TEST_DIR: "${{ github.workspace }}/lib/test-bundle/tests" + TEST_PROJECT_ROOT_DIR: "${{ github.workspace }}" + + PIMCORE_CODECEPTION_FRAMEWORK: "${{ github.workspace }}/pimcore-codeception-framework" + PIMCORE_CODECEPTION_VERSION: "3.0" + + APP_ENV: test + PIMCORE_TEST_DB_DSN: "mysql://test:test@127.0.0.1:3306/dachcom_bundle_test" + PIMCORE_TEST_URL: "http://localhost" + PIMCORE_CLASS_DIRECTORY: "${{ github.workspace }}/lib/test-bundle/tests/_output/var/classes" + + SYMFONY_DEPRECATIONS_HELPER: "weak" + PIMCORE_PHP_ERROR_REPORTING: 32767 + + WEBDRIVER_HOST: localhost + WEBDRIVER_URL: "http://localhost:8080/" + + services: + mysql: + image: mysql:8.0 + env: + MYSQL_ROOT_PASSWORD: root + ports: + - 3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + strategy: + matrix: + php: [ 8.3 ] + symfony: [ ^6.4 ] + pimcore: [ ~11.3.0 ] + include: + - pimcore: ~11.3.0 + template_tag: v2024.2.1 + steps: + - uses: actions/checkout@v2 + with: + path: lib/test-bundle + + - name: Generate Application Structure + run: | + git clone -b ${{ matrix.template_tag }} --single-branch --depth 1 https://github.com/pimcore/skeleton.git + mv skeleton/composer.json . + mv skeleton/bin . + mv skeleton/config . + mv skeleton/public . + mv skeleton/src . + mv skeleton/templates . + mv skeleton/var . + rm -r skeleton + + - name: Setup Pimcore Codeception Framework + env: + MATRIX_PIMCORE_VERSION: ${{ matrix.pimcore }} + MATRIX_PIMCORE_TEMPLATE_TAG: ${{ matrix.template_tag }} + run: | + git clone -b ${{ env.PIMCORE_CODECEPTION_VERSION }} --single-branch --depth 1 https://github.com/dachcom-digital/pimcore-codeception-framework.git + ls -al pimcore-codeception-framework + chmod +x ./pimcore-codeception-framework/src/_etc/scripts/setup.sh + ./pimcore-codeception-framework/src/_etc/scripts/setup.sh + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: intl + coverage: none + + - name: Check PHP Version + run: php -v + + - name: Setup MySql + uses: shogo82148/actions-setup-mysql@v1 + with: + mysql-version: '8.0' + user: test + password: test + root-password: root + auto-start: true + my-cnf: | + max_allowed_packet=32505856 + max_connections=1000 + + - name: Initial Database + run: mysql -utest -ptest -h127.0.0.1 -e 'CREATE DATABASE dachcom_bundle_test CHARSET=utf8mb4;' + + - name: Setup Chromium + run: | + nohup $CHROMEWEBDRIVER/chromedriver --url-base=/wd/hub /dev/null 2>&1 & + + - name: Start Webserver and Chrome + run: | + curl -sS https://get.symfony.com/cli/installer | bash -s -- --install-dir=$HOME/.symfony/bin + ~/.symfony/bin/symfony server:start --port=8080 --dir=public --allow-http --no-tls --daemon + + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache Composer Downloads + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: | + ${{ runner.os }}-composer- + + - name: Composer install + env: + TEST_PIMCORE_VERSION: ${{ matrix.pimcore }} + TEST_SYMFONY_VERSION: ${{ matrix.symfony }} + run: | + chmod +x ./pimcore-codeception-framework/src/_etc/scripts/composer.sh + ./pimcore-codeception-framework/src/_etc/scripts/composer.sh + + - name: Assets Install + run: | + bin/console assets:install public --relative --symlink + + - name: Tests + run: | + bin/console cache:warmup --env=test + vendor/bin/codecept run --env github -c ${{ github.workspace }}/lib/test-bundle + + - name: Log Output + uses: actions/upload-artifact@v2 + if: failure() + with: + name: "Logs (PHP ${{ matrix.php }}, Pimcore ${{ matrix.pimcore }}, Symfony ${{ matrix.symfony }})" + path: ${{ github.workspace }}/lib/test-bundle/tests/_output/ + if-no-files-found: ignore diff --git a/.github/workflows/ecs.yml b/.github/workflows/ecs.yml new file mode 100644 index 00000000..cfc84ade --- /dev/null +++ b/.github/workflows/ecs.yml @@ -0,0 +1,117 @@ +name: Easy Coding Standards +on: + push: + branches: [ 'master' ] + pull_request: + branches: [ 'master' ] + +jobs: + ecs: + runs-on: ubuntu-latest + env: + TEST_BUNDLE_NAME: "SecureStorageBundle" + TEST_BUNDLE_INSTALLER_CLASS: false + TEST_BUNDLE_TEST_DIR: "${{ github.workspace }}/lib/test-bundle/tests" + TEST_PROJECT_ROOT_DIR: "${{ github.workspace }}" + + PIMCORE_CODECEPTION_FRAMEWORK: "${{ github.workspace }}/pimcore-codeception-framework" + PIMCORE_CODECEPTION_VERSION: "3.0" + + APP_ENV: test + PIMCORE_TEST_DB_DSN: "mysql://root:root@127.0.0.1:3306/dachcom_bundle_test" + PIMCORE_TEST_URL: "http://localhost" + + SYMFONY_DEPRECATIONS_HELPER: "weak" + PIMCORE_PHP_ERROR_REPORTING: 32767 + + WEBDRIVER_HOST: localhost + WEBDRIVER_URL: "http://localhost:8080/" + + services: + mysql: + image: mysql:8.0 + env: + MYSQL_ROOT_PASSWORD: root + ports: + - 3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + strategy: + matrix: + php: [ 8.3 ] + symfony: [ ^6.4 ] + pimcore: [ ~11.3.0 ] + include: + - pimcore: ~11.3.0 + template_tag: v2024.2.1 + steps: + - uses: actions/checkout@v2 + with: + path: lib/test-bundle + + - name: Generate Application Structure + run: | + git clone -b ${{ matrix.template_tag }} --single-branch --depth 1 https://github.com/pimcore/skeleton.git + mv skeleton/composer.json . + mv skeleton/bin . + mv skeleton/config . + mv skeleton/public . + mv skeleton/src . + mv skeleton/templates . + mv skeleton/var . + rm -r skeleton + + - name: Setup Pimcore Codeception Framework + env: + MATRIX_PIMCORE_VERSION: ${{ matrix.pimcore }} + MATRIX_PIMCORE_TEMPLATE_TAG: ${{ matrix.template_tag }} + run: | + git clone -b ${{ env.PIMCORE_CODECEPTION_VERSION }} --single-branch --depth 1 https://github.com/dachcom-digital/pimcore-codeception-framework.git + ls -al pimcore-codeception-framework + chmod +x ./pimcore-codeception-framework/src/_etc/scripts/setup.sh + ./pimcore-codeception-framework/src/_etc/scripts/setup.sh + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: intl + coverage: none + + - name: Check PHP Version + run: php -v + + - name: Setup MySql + run: | + sudo systemctl start mysql + mysql -uroot -proot -h127.0.0.1 -e "CREATE DATABASE dachcom_bundle_test CHARSET=utf8mb4;" + + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache Composer Downloads + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: | + ${{ runner.os }}-composer- + + - name: Composer install + env: + TEST_PIMCORE_VERSION: ${{ matrix.pimcore }} + TEST_SYMFONY_VERSION: ${{ matrix.symfony }} + run: | + chmod +x ./pimcore-codeception-framework/src/_etc/scripts/composer.sh + ./pimcore-codeception-framework/src/_etc/scripts/composer.sh + + - name: Assets Install + run: | + bin/console assets:install public --relative --symlink + + - name: Easy Coding Standard Check + continue-on-error: true + run: | + bin/console cache:warmup --env=test + vendor/bin/ecs check ${{ github.workspace }}/lib/test-bundle/src --config ${{ github.workspace }}/lib/test-bundle/ecs.php \ No newline at end of file diff --git a/.github/workflows/php-stan.yml b/.github/workflows/php-stan.yml new file mode 100644 index 00000000..b2ba4146 --- /dev/null +++ b/.github/workflows/php-stan.yml @@ -0,0 +1,116 @@ +name: PHP Stan +on: + push: + branches: [ 'master' ] + pull_request: + branches: [ 'master' ] + +jobs: + stan: + runs-on: ubuntu-latest + env: + TEST_BUNDLE_NAME: "SecureStorageBundle" + TEST_BUNDLE_INSTALLER_CLASS: false + TEST_BUNDLE_TEST_DIR: "${{ github.workspace }}/lib/test-bundle/tests" + TEST_PROJECT_ROOT_DIR: "${{ github.workspace }}" + + PIMCORE_CODECEPTION_FRAMEWORK: "${{ github.workspace }}/pimcore-codeception-framework" + PIMCORE_CODECEPTION_VERSION: "3.0" + + APP_ENV: test + PIMCORE_TEST_DB_DSN: "mysql://root:root@127.0.0.1:3306/dachcom_bundle_test" + PIMCORE_TEST_URL: "http://localhost" + + SYMFONY_DEPRECATIONS_HELPER: "weak" + PIMCORE_PHP_ERROR_REPORTING: 32767 + + WEBDRIVER_HOST: localhost + WEBDRIVER_URL: "http://localhost:8080/" + + services: + mysql: + image: mysql:8.0 + env: + MYSQL_ROOT_PASSWORD: root + ports: + - 3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + strategy: + matrix: + php: [ 8.3 ] + symfony: [ ^6.4 ] + pimcore: [ ~11.3.0 ] + include: + - pimcore: ~11.3.0 + template_tag: v2024.2.1 + steps: + - uses: actions/checkout@v2 + with: + path: lib/test-bundle + + - name: Generate Application Structure + run: | + git clone -b ${{ matrix.template_tag }} --single-branch --depth 1 https://github.com/pimcore/skeleton.git + mv skeleton/composer.json . + mv skeleton/bin . + mv skeleton/config . + mv skeleton/public . + mv skeleton/src . + mv skeleton/templates . + mv skeleton/var . + rm -r skeleton + + - name: Setup Pimcore Codeception Framework + env: + MATRIX_PIMCORE_VERSION: ${{ matrix.pimcore }} + MATRIX_PIMCORE_TEMPLATE_TAG: ${{ matrix.template_tag }} + run: | + git clone -b ${{ env.PIMCORE_CODECEPTION_VERSION }} --single-branch --depth 1 https://github.com/dachcom-digital/pimcore-codeception-framework.git + ls -al pimcore-codeception-framework + chmod +x ./pimcore-codeception-framework/src/_etc/scripts/setup.sh + ./pimcore-codeception-framework/src/_etc/scripts/setup.sh + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: intl + coverage: none + + - name: Check PHP Version + run: php -v + + - name: Setup MySql + run: | + sudo systemctl start mysql + mysql -uroot -proot -h127.0.0.1 -e "CREATE DATABASE dachcom_bundle_test CHARSET=utf8mb4;" + + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache Composer Downloads + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: | + ${{ runner.os }}-composer- + + - name: Composer install + env: + TEST_PIMCORE_VERSION: ${{ matrix.pimcore }} + TEST_SYMFONY_VERSION: ${{ matrix.symfony }} + run: | + chmod +x ./pimcore-codeception-framework/src/_etc/scripts/composer.sh + ./pimcore-codeception-framework/src/_etc/scripts/composer.sh + + - name: Assets Install + run: | + bin/console assets:install public --relative --symlink + + - name: Php Stan + run: | + bin/console cache:warmup --env=test + vendor/bin/phpstan analyse -c${{ github.workspace }}/lib/test-bundle/phpstan.neon -a ${{ github.workspace }}/lib/test-bundle/tests/_phpstan-bootstrap.php ${{ github.workspace }}/lib/test-bundle/src -l 4 \ No newline at end of file diff --git a/README.md b/README.md index 3a5e660b..643dec9e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ | Release | Supported Pimcore Versions | Supported Symfony Versions | Release Date | Maintained | Branch | |---------|----------------------------|----------------------------|--------------|----------------|--------| -| **1.x** | `^11.3` | `6.2` | -- | Feature Branch | master | +| **1.x** | `^11.3` | `^6.4` | -- | Feature Branch | master | ## Installation diff --git a/ecs.php b/ecs.php index b5e05a8e..b04a5740 100644 --- a/ecs.php +++ b/ecs.php @@ -1,162 +1,139 @@ parameters(); - $parameters->set(Option::SETS, [SetList::CLEAN_CODE, SetList::PSR_12]); + $ecsConfig->sets([SetList::CLEAN_CODE, SetList::PSR_12]); - $services = $containerConfigurator->services(); + $ecsConfig->ruleWithConfiguration(Fixer\Basic\BracesFixer::class, [ + 'allow_single_line_closure' => true, + ]); - $services->set(Fixer\Basic\BracesFixer::class) - ->call('configure', [ - [ - 'allow_single_line_closure' => true, - ] - ]); + $ecsConfig->rule(Fixer\PhpTag\BlankLineAfterOpeningTagFixer::class); - $services->set(Fixer\PhpTag\BlankLineAfterOpeningTagFixer::class); + $ecsConfig->ruleWithConfiguration(Fixer\Operator\ConcatSpaceFixer::class, [ + 'spacing' => 'one', + ] + ); - $services->set(Fixer\Operator\ConcatSpaceFixer::class) - ->call('configure', [ - [ - 'spacing' => 'one', - ] - ]); + $ecsConfig->rule(Fixer\Operator\NewWithBracesFixer::class); - $services->set(Fixer\Operator\NewWithBracesFixer::class); + $ecsConfig->ruleWithConfiguration(Fixer\Phpdoc\PhpdocAlignFixer::class, [ + 'tags' => ['method', 'param', 'property', 'return', 'throws', 'type', 'var'], + ] + ); - $services->set(Fixer\Phpdoc\PhpdocAlignFixer::class) - ->call('configure', [ - [ - 'tags' => ['method', 'param', 'property', 'return', 'throws', 'type', 'var'], - ] - ]); - - $services->set(Fixer\Operator\BinaryOperatorSpacesFixer::class) - ->call('configure', [ - [ - 'operators' => [ - '=' => 'single_space', - '=>' => 'align', - ] - ] - ]); - $services->set(Fixer\Operator\IncrementStyleFixer::class) - ->call('configure', [ - [ - 'style' => 'post', - ] - ]); - - $services->set(Fixer\Operator\UnaryOperatorSpacesFixer::class); - $services->set(Fixer\Whitespace\BlankLineBeforeStatementFixer::class); - $services->set(Fixer\CastNotation\CastSpacesFixer::class); - $services->set(Fixer\LanguageConstruct\DeclareEqualNormalizeFixer::class); - $services->set(Fixer\FunctionNotation\FunctionTypehintSpaceFixer::class); - $services->set(Fixer\Comment\SingleLineCommentStyleFixer::class) - ->call('configure', [ - [ - 'comment_types' => ['hash'], + $ecsConfig->ruleWithConfiguration(Fixer\Operator\BinaryOperatorSpacesFixer::class, [ + 'operators' => [ + '=' => 'single_space', + '=>' => 'align', ] - ]); - - $services->set(Fixer\ControlStructure\IncludeFixer::class); - $services->set(Fixer\CastNotation\LowercaseCastFixer::class); - $services->set(Fixer\ClassNotation\ClassAttributesSeparationFixer::class) - ->call('configure', [ - [ - 'elements' => [ - 'const' => 'none', - 'method' => 'one', - 'property' => 'none', - 'trait_import' => 'none' - ], - ] - ]); - - $services->set(Fixer\Casing\NativeFunctionCasingFixer::class); - $services->set(Fixer\ClassNotation\NoBlankLinesAfterClassOpeningFixer::class); - $services->set(Fixer\Phpdoc\NoBlankLinesAfterPhpdocFixer::class); - $services->set(Fixer\Comment\NoEmptyCommentFixer::class); - $services->set(Fixer\Phpdoc\NoEmptyPhpdocFixer::class); - $services->set(Fixer\Phpdoc\PhpdocSeparationFixer::class); - $services->set(Fixer\Semicolon\NoEmptyStatementFixer::class); - $services->set(Fixer\Whitespace\ArrayIndentationFixer::class); - $services->set(Fixer\Whitespace\NoExtraBlankLinesFixer::class) - ->call('configure', [ - [ - 'tokens' => ['curly_brace_block', 'extra', 'parenthesis_brace_block', 'square_brace_block', 'throw', 'use'], - ] - ]); - - $services->set(Fixer\NamespaceNotation\NoLeadingNamespaceWhitespaceFixer::class); - $services->set(Fixer\ArrayNotation\NoMultilineWhitespaceAroundDoubleArrowFixer::class); - $services->set(Fixer\CastNotation\NoShortBoolCastFixer::class); - $services->set(Fixer\Semicolon\NoSinglelineWhitespaceBeforeSemicolonsFixer::class); - $services->set(Fixer\Whitespace\NoSpacesAroundOffsetFixer::class); - $services->set(Fixer\ControlStructure\NoTrailingCommaInListCallFixer::class); - $services->set(Fixer\ControlStructure\NoUnneededControlParenthesesFixer::class); - $services->set(Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer::class); - $services->set(Fixer\Whitespace\NoWhitespaceInBlankLineFixer::class); - $services->set(Fixer\ArrayNotation\NormalizeIndexBraceFixer::class); - $services->set(Fixer\Operator\ObjectOperatorWithoutWhitespaceFixer::class); - $services->set(Fixer\Phpdoc\PhpdocAnnotationWithoutDotFixer::class); - $services->set(Fixer\Phpdoc\PhpdocIndentFixer::class); - $services->set(Fixer\Phpdoc\PhpdocInlineTagFixer::class); - $services->set(Fixer\Phpdoc\PhpdocNoAccessFixer::class); - $services->set(Fixer\Phpdoc\PhpdocNoEmptyReturnFixer::class); - $services->set(Fixer\Phpdoc\PhpdocNoPackageFixer::class); - $services->set(Fixer\Phpdoc\PhpdocNoUselessInheritdocFixer::class); - $services->set(Fixer\Phpdoc\PhpdocReturnSelfReferenceFixer::class); - $services->set(Fixer\Phpdoc\PhpdocScalarFixer::class); - $services->set(Fixer\Phpdoc\PhpdocSingleLineVarSpacingFixer::class); - $services->set(Fixer\Phpdoc\PhpdocSummaryFixer::class); - $services->set(Fixer\Phpdoc\PhpdocToCommentFixer::class); - $services->set(Fixer\Phpdoc\PhpdocTrimFixer::class); - $services->set(Fixer\Phpdoc\PhpdocTypesFixer::class); - $services->set(Fixer\Phpdoc\PhpdocVarWithoutNameFixer::class); - $services->set(Fixer\FunctionNotation\ReturnTypeDeclarationFixer::class); - $services->set(Fixer\ClassNotation\SelfAccessorFixer::class); - $services->set(Fixer\CastNotation\ShortScalarCastFixer::class); - $services->set(Fixer\StringNotation\SingleQuoteFixer::class); - $services->set(Fixer\Semicolon\SpaceAfterSemicolonFixer::class); - $services->set(Fixer\Operator\StandardizeNotEqualsFixer::class); - $services->set(Fixer\Operator\TernaryOperatorSpacesFixer::class); - $services->set(Fixer\ArrayNotation\TrimArraySpacesFixer::class); - $services->set(Fixer\ArrayNotation\WhitespaceAfterCommaInArrayFixer::class); - - $services->set(Fixer\ClassNotation\ClassDefinitionFixer::class) - ->call('configure', [ - [ - 'single_line' => true, - ] - ]); - - $services->set(Fixer\Casing\MagicConstantCasingFixer::class); - $services->set(Fixer\FunctionNotation\MethodArgumentSpaceFixer::class); - $services->set(Fixer\Alias\NoMixedEchoPrintFixer::class) - ->call('configure', [ - [ - 'use' => 'echo', - ] - ]); - - $services->set(Fixer\Import\NoLeadingImportSlashFixer::class); - $services->set(Fixer\PhpUnit\PhpUnitFqcnAnnotationFixer::class); - $services->set(Fixer\Phpdoc\PhpdocNoAliasTagFixer::class); - $services->set(Fixer\NamespaceNotation\SingleBlankLineBeforeNamespaceFixer::class); - $services->set(Fixer\ClassNotation\SingleClassElementPerStatementFixer::class); + ] + ); + + $ecsConfig->ruleWithConfiguration(Fixer\Operator\IncrementStyleFixer::class, [ + 'style' => 'post', + ] + ); + + $ecsConfig->rule(Fixer\Operator\UnaryOperatorSpacesFixer::class); + $ecsConfig->rule(Fixer\Whitespace\BlankLineBeforeStatementFixer::class); + $ecsConfig->rule(Fixer\CastNotation\CastSpacesFixer::class); + $ecsConfig->rule(Fixer\LanguageConstruct\DeclareEqualNormalizeFixer::class); + $ecsConfig->rule(Fixer\FunctionNotation\FunctionTypehintSpaceFixer::class); + $ecsConfig->ruleWithConfiguration(Fixer\Comment\SingleLineCommentStyleFixer::class, [ + 'comment_types' => ['hash'], + ] + ); + + $ecsConfig->rule(Fixer\ControlStructure\IncludeFixer::class); + $ecsConfig->rule(Fixer\CastNotation\LowercaseCastFixer::class); + $ecsConfig->ruleWithConfiguration(Fixer\ClassNotation\ClassAttributesSeparationFixer::class, [ + 'elements' => [ + 'const' => 'none', + 'method' => 'one', + 'property' => 'none', + 'trait_import' => 'none' + ], + ] + ); + + $ecsConfig->rule(Fixer\Casing\NativeFunctionCasingFixer::class); + $ecsConfig->rule(Fixer\ClassNotation\NoBlankLinesAfterClassOpeningFixer::class); + $ecsConfig->rule(Fixer\Phpdoc\NoBlankLinesAfterPhpdocFixer::class); + $ecsConfig->rule(Fixer\Comment\NoEmptyCommentFixer::class); + $ecsConfig->rule(Fixer\Phpdoc\NoEmptyPhpdocFixer::class); + $ecsConfig->rule(Fixer\Phpdoc\PhpdocSeparationFixer::class); + $ecsConfig->rule(Fixer\Semicolon\NoEmptyStatementFixer::class); + $ecsConfig->rule(Fixer\Whitespace\ArrayIndentationFixer::class); + $ecsConfig->ruleWithConfiguration(Fixer\Whitespace\NoExtraBlankLinesFixer::class, [ + 'tokens' => ['curly_brace_block', 'extra', 'parenthesis_brace_block', 'square_brace_block', 'throw', 'use'], + ] + ); + + $ecsConfig->rule(Fixer\NamespaceNotation\NoLeadingNamespaceWhitespaceFixer::class); + $ecsConfig->rule(Fixer\ArrayNotation\NoMultilineWhitespaceAroundDoubleArrowFixer::class); + $ecsConfig->rule(Fixer\CastNotation\NoShortBoolCastFixer::class); + $ecsConfig->rule(Fixer\Semicolon\NoSinglelineWhitespaceBeforeSemicolonsFixer::class); + $ecsConfig->rule(Fixer\Whitespace\NoSpacesAroundOffsetFixer::class); + $ecsConfig->rule(Fixer\ControlStructure\NoTrailingCommaInListCallFixer::class); + $ecsConfig->rule(Fixer\ControlStructure\NoUnneededControlParenthesesFixer::class); + $ecsConfig->rule(Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer::class); + $ecsConfig->rule(Fixer\Whitespace\NoWhitespaceInBlankLineFixer::class); + $ecsConfig->rule(Fixer\ArrayNotation\NormalizeIndexBraceFixer::class); + $ecsConfig->rule(Fixer\Operator\ObjectOperatorWithoutWhitespaceFixer::class); + $ecsConfig->rule(Fixer\Phpdoc\PhpdocAnnotationWithoutDotFixer::class); + $ecsConfig->rule(Fixer\Phpdoc\PhpdocIndentFixer::class); + $ecsConfig->rule(Fixer\Phpdoc\PhpdocInlineTagNormalizerFixer::class); + $ecsConfig->rule(Fixer\Phpdoc\PhpdocNoAccessFixer::class); + $ecsConfig->rule(Fixer\Phpdoc\PhpdocNoEmptyReturnFixer::class); + $ecsConfig->rule(Fixer\Phpdoc\PhpdocNoPackageFixer::class); + $ecsConfig->rule(Fixer\Phpdoc\PhpdocNoUselessInheritdocFixer::class); + $ecsConfig->rule(Fixer\Phpdoc\PhpdocReturnSelfReferenceFixer::class); + $ecsConfig->rule(Fixer\Phpdoc\PhpdocScalarFixer::class); + $ecsConfig->rule(Fixer\Phpdoc\PhpdocSingleLineVarSpacingFixer::class); + $ecsConfig->rule(Fixer\Phpdoc\PhpdocSummaryFixer::class); + $ecsConfig->rule(Fixer\Phpdoc\PhpdocToCommentFixer::class); + $ecsConfig->rule(Fixer\Phpdoc\PhpdocTrimFixer::class); + $ecsConfig->rule(Fixer\Phpdoc\PhpdocTypesFixer::class); + $ecsConfig->rule(Fixer\Phpdoc\PhpdocVarWithoutNameFixer::class); + $ecsConfig->rule(Fixer\FunctionNotation\ReturnTypeDeclarationFixer::class); + $ecsConfig->rule(Fixer\ClassNotation\SelfAccessorFixer::class); + $ecsConfig->rule(Fixer\CastNotation\ShortScalarCastFixer::class); + $ecsConfig->rule(Fixer\StringNotation\SingleQuoteFixer::class); + $ecsConfig->rule(Fixer\Semicolon\SpaceAfterSemicolonFixer::class); + $ecsConfig->rule(Fixer\Operator\StandardizeNotEqualsFixer::class); + $ecsConfig->rule(Fixer\Operator\TernaryOperatorSpacesFixer::class); + $ecsConfig->rule(Fixer\ArrayNotation\TrimArraySpacesFixer::class); + $ecsConfig->rule(Fixer\ArrayNotation\WhitespaceAfterCommaInArrayFixer::class); + $ecsConfig->rule(Fixer\Import\NoUnusedImportsFixer::class); + + $ecsConfig->ruleWithConfiguration(Fixer\ClassNotation\ClassDefinitionFixer::class, [ + 'single_line' => true, + ] + ); + + $ecsConfig->rule(Fixer\Casing\MagicConstantCasingFixer::class); + $ecsConfig->rule(Fixer\FunctionNotation\MethodArgumentSpaceFixer::class); + $ecsConfig->ruleWithConfiguration(Fixer\Alias\NoMixedEchoPrintFixer::class, [ + 'use' => 'echo', + ] + ); + + $ecsConfig->rule(Fixer\Import\NoLeadingImportSlashFixer::class); + $ecsConfig->rule(Fixer\PhpUnit\PhpUnitFqcnAnnotationFixer::class); + $ecsConfig->rule(Fixer\Phpdoc\PhpdocNoAliasTagFixer::class); + $ecsConfig->rule(Fixer\NamespaceNotation\SingleBlankLineBeforeNamespaceFixer::class); + $ecsConfig->rule(Fixer\ClassNotation\SingleClassElementPerStatementFixer::class); # new since PHP-CS-Fixer 2.6 - $services->set(Fixer\ClassNotation\NoUnneededFinalMethodFixer::class); - $services->set(Fixer\Semicolon\SemicolonAfterInstructionFixer::class); + $ecsConfig->rule(Fixer\ClassNotation\NoUnneededFinalMethodFixer::class); + $ecsConfig->rule(Fixer\Semicolon\SemicolonAfterInstructionFixer::class); # new since 2.11 - $services->set(Fixer\Operator\StandardizeIncrementFixer::class); -}; \ No newline at end of file + $ecsConfig->rule(Fixer\Operator\StandardizeIncrementFixer::class); +}; diff --git a/phpstan.neon b/phpstan.neon index 58b21458..334b250e 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -7,8 +7,3 @@ parameters: symfony: container_xml_path: %currentWorkingDirectory%/var/cache/test/TestKernelTestDebugContainer.xml constant_hassers: false - excludePaths: - # as long we don't install the dependencies :( - - src/MetaData/Extractor/ThirdParty/News/EntryMetaExtractor.php - - src/MetaData/Extractor/ThirdParty/CoreShop/OGExtractor.php - - src/MetaData/Extractor/ThirdParty/CoreShop/TitleDescriptionExtractor.php diff --git a/tests/Functional.suite.dist.yml b/tests/Functional.suite.dist.yml new file mode 100644 index 00000000..3b28e68b --- /dev/null +++ b/tests/Functional.suite.dist.yml @@ -0,0 +1,12 @@ +actor: FunctionalTester +modules: + enabled: + - \Dachcom\Codeception\Support\Helper\PimcoreCore: + connect_db: true + rebootable_client: true + - \Dachcom\Codeception\Support\Helper\PimcoreBundleCore: + run_installer: true + - \Dachcom\Codeception\Support\Helper\Browser\PhpBrowser: + depends: \Dachcom\Codeception\Support\Helper\PimcoreCore + - \Dachcom\Codeception\Support\Helper\PimcoreBackend + - \Dachcom\Codeception\Support\Helper\PimcoreUser diff --git a/tests/Functional/_bootstrap.php b/tests/Functional/_bootstrap.php new file mode 100644 index 00000000..94bf66cf --- /dev/null +++ b/tests/Functional/_bootstrap.php @@ -0,0 +1,2 @@ +renderTemplate('default/default.html.twig'); + } +} diff --git a/tests/_etc/config/app/system_settings.yaml b/tests/_etc/config/app/system_settings.yaml new file mode 100755 index 00000000..40ae8b4f --- /dev/null +++ b/tests/_etc/config/app/system_settings.yaml @@ -0,0 +1,47 @@ +pimcore: + general: + timezone: Europe/Berlin + domain: 'localhost' + redirect_to_maindomain: false + disable_usage_statistics: true + debug_admin_translations: false + default_language: en + valid_languages: + - en + - de + fallback_languages: + en: '' + de: '' + documents: + allow_trailing_slash: 'no' + generate_preview: false + versions: + days: null + steps: 10 + error_pages: + default: '/error' + localized: + en: '' + de: '' + objects: + versions: + days: null + steps: 10 + assets: + versions: + days: null + steps: 10 + email: + debug: + email_addresses: development@dachcom.ch + +pimcore_admin: + assets: + hide_edit_image: true + disable_tree_preview: true + branding: + login_screen_invert_colors: false + color_login_screen: '' + color_admin_interface: '' + color_admin_interface_background: '' + login_screen_custom_image: '' diff --git a/tests/_etc/config/app/templates/default.html.twig b/tests/_etc/config/app/templates/default.html.twig new file mode 100644 index 00000000..2c65722a --- /dev/null +++ b/tests/_etc/config/app/templates/default.html.twig @@ -0,0 +1,21 @@ + + + + + {{ pimcore_head_title() }} + {{ pimcore_head_meta() }} + {{ pimcore_head_link() }} + + +
+
+ {% if document is defined %} + {{ document.id }} + {% endif %} +
+ {% block content %} + {{ pimcore_areablock('bundleTestArea') }} + {% endblock %} +
+ + diff --git a/tests/_etc/config/bundle/config_default.yaml b/tests/_etc/config/bundle/config_default.yaml new file mode 100755 index 00000000..e69de29b diff --git a/tests/_phpstan-bootstrap.php b/tests/_phpstan-bootstrap.php new file mode 100644 index 00000000..0c3c5270 --- /dev/null +++ b/tests/_phpstan-bootstrap.php @@ -0,0 +1,6 @@ + Date: Mon, 16 Sep 2024 08:46:03 +0200 Subject: [PATCH 3/5] phpstan fixes --- README.md | 3 +++ composer.json | 3 ++- src/Encrypter/OpenSslEncrypter.php | 3 +++ src/Flysystem/Adapter/SecuredAdapter.php | 5 ----- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 643dec9e..b4dd3433 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,9 @@ return [ ## Description Encrypt/Decrypt assets on the fly! +## Required PHP Extensions +- openssl + ## Usage > [!CAUTION] diff --git a/composer.json b/composer.json index 20d18bcc..786943d1 100755 --- a/composer.json +++ b/composer.json @@ -31,6 +31,7 @@ } }, "require": { + "ext-openssl": "*", "pimcore/pimcore": "^11.3" }, "require-dev": { @@ -39,6 +40,6 @@ "codeception/module-webdriver": "^4.0", "phpstan/phpstan": "^1.0", "phpstan/phpstan-symfony": "^1.0", - "symplify/easy-coding-standard": "^9.0" + "symplify/easy-coding-standard": "~12.0.0" } } diff --git a/src/Encrypter/OpenSslEncrypter.php b/src/Encrypter/OpenSslEncrypter.php index 652926b1..f2081663 100644 --- a/src/Encrypter/OpenSslEncrypter.php +++ b/src/Encrypter/OpenSslEncrypter.php @@ -86,6 +86,7 @@ public function onCreate(): bool $this->mode = match ($this->filtername) { self::FILTERNAME_PREFIX . self::MODE_ENCRYPT => self::MODE_ENCRYPT, self::FILTERNAME_PREFIX . self::MODE_DECRYPT => self::MODE_DECRYPT, + default => '' }; return true; @@ -112,6 +113,7 @@ public function filter($in, $out, &$consumed, $closing): int $processed = match ($this->mode) { self::MODE_ENCRYPT => $this->encryptChunkData($chunk), self::MODE_DECRYPT => $this->decryptChunkData($chunk), + default => false }; if ($processed === false) { @@ -134,6 +136,7 @@ public function filter($in, $out, &$consumed, $closing): int $processed = match ($this->mode) { self::MODE_ENCRYPT => $this->encryptClosingData(), self::MODE_DECRYPT => $this->decryptClosingData(), + default => false }; if ($processed === false) { diff --git a/src/Flysystem/Adapter/SecuredAdapter.php b/src/Flysystem/Adapter/SecuredAdapter.php index e3f2fec5..de17a174 100644 --- a/src/Flysystem/Adapter/SecuredAdapter.php +++ b/src/Flysystem/Adapter/SecuredAdapter.php @@ -181,9 +181,4 @@ public function copy(string $source, string $destination, Config $config): void { $this->inner->copy($source, $destination, $config); } - - public function __call(string $method, array $parameters) - { - return $this->forwardCallTo($this->inner, $method, $parameters); - } } \ No newline at end of file From fb056904930e3ad18d00aa0ffddc8b489cc367be Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Mon, 16 Sep 2024 08:51:38 +0200 Subject: [PATCH 4/5] [TEST] adjust upload artifact --- .github/workflows/codeception.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeception.yml b/.github/workflows/codeception.yml index d9ad4439..c3197408 100644 --- a/.github/workflows/codeception.yml +++ b/.github/workflows/codeception.yml @@ -136,7 +136,7 @@ jobs: vendor/bin/codecept run --env github -c ${{ github.workspace }}/lib/test-bundle - name: Log Output - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: failure() with: name: "Logs (PHP ${{ matrix.php }}, Pimcore ${{ matrix.pimcore }}, Symfony ${{ matrix.symfony }})" From db453703d8a281f1d616e6a453e6eb9561122401 Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Mon, 16 Sep 2024 08:54:45 +0200 Subject: [PATCH 5/5] [TEST] add codeception config --- codeception.dist.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 codeception.dist.yml diff --git a/codeception.dist.yml b/codeception.dist.yml new file mode 100644 index 00000000..296aad20 --- /dev/null +++ b/codeception.dist.yml @@ -0,0 +1,19 @@ +namespace: DachcomBundle\Test +support_namespace: Support +actor: Tester +paths: + tests: tests + envs: tests/_envs + output: tests/_output + log: tests/_output/var/logs + data: tests/_data + support: tests/Support +bootstrap: _bootstrap.php +settings: + memory_limit: -1 + colors: true +params: + - env +extensions: + enabled: + - Codeception\Extension\RunFailed