MultiSafepay / magento2

MultiSafepay plugin for Magento 2
Open Software License 3.0
19 stars 8 forks source link

Trying to download debug log files result in error "File not found" #13

Closed hostep closed 3 years ago

hostep commented 3 years ago

Hi folks

Using:

When we go in the backend of the shop to the General Settings of the MultiSafepay module and click the "Download" button next to the "MultiSafepay payment logs" label. We get the following error:

1 exception(s):
Exception #0 (Exception): File not found

Exception #0 (Exception): File not found
<pre>#1 Magento\Backend\App\Response\Http\FileFactory->create() called at [vendor/multisafepay/magento2-core/Util/ZipUtil.php:118]
#2 MultiSafepay\ConnectCore\Util\ZipUtil->zipLogFiles() called at [vendor/multisafepay/magento2-adminhtml/Controller/Adminhtml/Download/MultiSafepayLog.php:53]
#3 MultiSafepay\ConnectAdminhtml\Controller\Adminhtml\Download\MultiSafepayLog->execute() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#4 MultiSafepay\ConnectAdminhtml\Controller\Adminhtml\Download\MultiSafepayLog\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#5 MultiSafepay\ConnectAdminhtml\Controller\Adminhtml\Download\MultiSafepayLog\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#6 MultiSafepay\ConnectAdminhtml\Controller\Adminhtml\Download\MultiSafepayLog\Interceptor->___callPlugins() called at [generated/code/MultiSafepay/ConnectAdminhtml/Controller/Adminhtml/Download/MultiSafepayLog/Interceptor.php:26]
#7 MultiSafepay\ConnectAdminhtml\Controller\Adminhtml\Download\MultiSafepayLog\Interceptor->execute() called at [vendor/magento/framework/App/Action/Action.php:108]
#8 Magento\Framework\App\Action\Action->dispatch() called at [vendor/magento/module-backend/App/AbstractAction.php:248]
#9 Magento\Backend\App\AbstractAction->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#10 MultiSafepay\ConnectAdminhtml\Controller\Adminhtml\Download\MultiSafepayLog\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#11 MultiSafepay\ConnectAdminhtml\Controller\Adminhtml\Download\MultiSafepayLog\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-backend/App/Action/Plugin/Authentication.php:143]
#12 Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#13 MultiSafepay\ConnectAdminhtml\Controller\Adminhtml\Download\MultiSafepayLog\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#14 MultiSafepay\ConnectAdminhtml\Controller\Adminhtml\Download\MultiSafepayLog\Interceptor->___callPlugins() called at [generated/code/MultiSafepay/ConnectAdminhtml/Controller/Adminhtml/Download/MultiSafepayLog/Interceptor.php:39]
#15 MultiSafepay\ConnectAdminhtml\Controller\Adminhtml\Download\MultiSafepayLog\Interceptor->dispatch() called at [vendor/magento/framework/App/FrontController.php:186]
#16 Magento\Framework\App\FrontController->processRequest() called at [vendor/magento/framework/App/FrontController.php:118]
#17 Magento\Framework\App\FrontController->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#18 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#19 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#20 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:26]
#21 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [vendor/magento/framework/App/Http.php:116]
#22 Magento\Framework\App\Http->launch() called at [vendor/magento/framework/App/Bootstrap.php:261]
#23 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:40]
</pre>

After some debugging, it appears that the ZipArchive you are creating uses the path:

/path/to/webshop/pub/multisafepay_logs.zip

But when trying to send that file to the user, it tries to read from this path (so without the pub directory) and then fails:

/path/to/webshop/multisafepay_logs.zip

Can this be confirmed and then fixed? Also, I would suggest you use a more non-publicly accessible path like var or var/tmp in the Magento file structure, so that random visitors of the shop won't have the chance to download that file without authorization.

Thanks!

vinodsowdagar commented 3 years ago

Hi @hostep ,

Thank you for reporting this issue. I created a fix for this issue and it also includes the change for using the var/tmp directory. It is currently internally in review.

As soon as the fix is released, i will let you know.

vinodsowdagar commented 3 years ago

Hi @hostep ,

We released a new version of the plugin with a fix for this issue: https://github.com/MultiSafepay/magento2/releases/tag/2.8.0

Could you confirm if updating the plugin helped resolve this issue for you?

hostep commented 3 years ago

Thanks for the heads up @Vinod-MultiSafepay

Just upgraded the module from 2.7.1 to 2.8.1 and I can confirm that the issue is solved.

Thanks again!