0

I uploaded new version of extension on Magento Marketplace. And I've got Code Sniffer error during technical testing:

The use of function exec() is forbidden
severity : 10
Line : 441
Column : 17
Source : Magento2.Security.InsecureFunction.Found

How should I replace exec() ?

I use server command and cannot just delete exec().

  • can you provide info what you are trying to exec? executing commands will always be unsafe. you should try to implement what the stuff in exec does in PHP – Philipp Sander Oct 23 '19 at 9:25
  • This is command for exec: identify -ping "/path/to/image/file/phpCB6C.tmp" – PHPer Oct 23 '19 at 9:43
  • 1
    you can definitly do the same in PHP. however "-ping" seems to not to be a valid option. imagemagick.org/script/identify.php – Philipp Sander Oct 23 '19 at 10:46
1

use Magento\Framework\ShellInterface

example in Magento\Cron\Observer\ProcessCronQueueObserver (execute method)

| improve this answer | |
  • Thank you. It will be useful to know. In my case, I solved the problem by deleting exec() and use getimagesize() instead. – PHPer Oct 23 '19 at 13:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.