flancer32 / mage2_ext_csp

Magento 2 module to collect CSP violations reports and to eliminate JS console warnings
GNU General Public License v3.0
54 stars 18 forks source link

Doesn't work on 2.4.3 #22

Open eBusinessAtlantique opened 2 years ago

eBusinessAtlantique commented 2 years ago

Hello I don't see the module working on M2.4.3-p1. No rules added whatever the settings are.

git-seb commented 2 years ago

Same here on Magento 2.4.4 this is the error I'm getting:

Command 'fl32:csp:analyze': Analyze CSP violation reports and compose policy rules.

In Mysql.php line 109:

  SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens, query was: SELECT `fl32_csp_repor
  t`.* FROM `fl32_csp_report`

In Mysql.php line 90:

  SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens

fl32:csp:analyze

Fatal error: Uncaught Exception: User Error: Some transactions have not been committed or rolled back in /vendor/magento/framework/DB/Adapter/Pdo/Mysql.php on line 4055 in /vendor/magento/framework/App/ErrorHandler.php:61
Stack trace:
#0 [internal function]: Magento\Framework\App\ErrorHandler->handler(256, 'Some transactio...', '...', 4055)
#1 /vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(4055): trigger_error('Some transactio...', 256)
#2 [internal function]: Magento\Framework\DB\Adapter\Pdo\Mysql->__destruct()
#3 {main}
  thrown in /vendor/magento/framework/App/ErrorHandler.php on line 61
clivewalkden commented 1 year ago

This is still an issue on 2.4.4-p1

Command 'fl32:csp:analyze': Analyze CSP violation reports and compose policy rules.

In Mysql.php line 109:

  SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens, query was: SELECT `fl32_csp_report`.* FROM `fl32_csp_report`  

In Mysql.php line 90:

  SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens  

fl32:csp:analyze [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [--root-dir [ROOT-DIR]] [--skip-config] [--skip-root-check] [--skip-core-commands] [--skip-magento-compatibility-check] [--] <command>

PHP Fatal error:  Uncaught Exception: User Error: Some transactions have not been committed or rolled back in /opt/magento/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php on line 4055 in /opt/magento/vendor/magento/framework/App/ErrorHandler.php:61
Stack trace:
#0 [internal function]: Magento\Framework\App\ErrorHandler->handler()
#1 /opt/magento/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(4055): trigger_error()
#2 [internal function]: Magento\Framework\DB\Adapter\Pdo\Mysql->__destruct()
#3 {main}
  thrown in /opt/magento/vendor/magento/framework/App/ErrorHandler.php on line 61

Fatal error: Uncaught Exception: User Error: Some transactions have not been committed or rolled back in /opt/magento/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php on line 4055 in /opt/magento/vendor/magento/framework/App/ErrorHandler.php:61
Stack trace:
#0 [internal function]: Magento\Framework\App\ErrorHandler->handler()
#1 /opt/magento/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(4055): trigger_error()
#2 [internal function]: Magento\Framework\DB\Adapter\Pdo\Mysql->__destruct()
#3 {main}
  thrown in /opt/magento/vendor/magento/framework/App/ErrorHandler.php on line 61
clivewalkden commented 1 year ago

This is fixed on the Base module on a PR today https://github.com/flancer32/mage2_ext_base/pull/5 and can be closed

git-seb commented 1 year ago

This is fixed on the Base module on a PR today flancer32/mage2_ext_base#5 and can be closed

I've applied this fix but now I get the following error:

Return value of "Flancer32\Csp\Cli\Analyze\Interceptor::execute()" must be of the type int, "null" returned.

This error comes right after:

Command 'fl32:csp:analyze': Analyze CSP violation reports and compose policy rules.
0 rules were added. 0 reports were deleted (id: 0-0).
Command 'fl32:csp:analyze' is completed.

So maybe this error happens because zero rules were added and zero reports were deleted? F.y.i. using Magento 2.4.6-p2

(F.y.i. I've requested @flancer64 to create a new version/tag which just happened 👍👍)