opnsense / core

OPNsense GUI, API and systems backend
https://opnsense.org/
BSD 2-Clause "Simplified" License
3.08k stars 701 forks source link

mvc: InvalidArgumentException: Sanitizer scrub not registered #7551

Open fichtner opened 1 week ago

fichtner commented 1 week ago

Important notices

Our forum is located at https://forum.opnsense.org , please consider joining discussions there in stead of using GitHub for these matters.

Before you ask a new question, we ask you kindly to acknowledge the following:

From a 24.7.b crash report:

[19-Jun-2024 07:25:51 America/New_York] InvalidArgumentException: Sanitizer scrub not registered in /usr/local/opnsense/mvc/app/library/OPNsense/Core/SanitizeFilter.php:51
Stack trace:
#0 /usr/local/opnsense/mvc/app/library/OPNsense/Core/SanitizeFilter.php(62): OPNsense\Core\SanitizeFilter->sanitize_item('os-sunnyvalley-...', 'scrub')
#1 /usr/local/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php(800): OPNsense\Core\SanitizeFilter->sanitize('os-sunnyvalley-...', 'scrub')
#2 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Dispatcher.php(165): OPNsense\Core\Api\FirmwareController->detailsAction('os-sunnyvalley-...')
#3 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Router.php(156): OPNsense\Mvc\Dispatcher->dispatch(Object(OPNsense\Mvc\Request), Object(OPNsense\Mvc\Response), Object(OPNsense\Mvc\Session))
#4 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Router.php(139): OPNsense\Mvc\Router->performRequest(Object(OPNsense\Mvc\Dispatcher))
#5 /usr/local/opnsense/www/api.php(36): OPNsense\Mvc\Router->routeRequest('/api/core/firmw...')
#6 {main}
fichtner commented 1 week ago

Also found this, maybe fixed?

[13-Jun-2024 23:45:09 America/Toronto] TypeError: Cannot assign OPNsense\Mvc\Response to property OPNsense\Mvc\Dispatcher::$returnedValue of type array|string|null in /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Dispatcher.php:165
Stack trace:
#0 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Router.php(156): OPNsense\Mvc\Dispatcher->dispatch(Object(OPNsense\Mvc\Request), Object(OPNsense\Mvc\Response), Object(OPNsense\Mvc\Session))
#1 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Router.php(139): OPNsense\Mvc\Router->performRequest(Object(OPNsense\Mvc\Dispatcher))
#2 /usr/local/opnsense/www/api.php(36): OPNsense\Mvc\Router->routeRequest('/api/caddy/diag...')
#3 {main}
AdSchellevis commented 1 week ago

@fichtner scrub doesn't seem to be a phalcon filter, let's ask @mib43 to test their code on our latest beta as well. I expect they do need some (small) modifications to handle the Phalcon deprecation on our end.

AdSchellevis commented 1 week ago

Also found this, maybe fixed?

yep, @Monviech fixed this in https://github.com/opnsense/plugins/commit/0e178ebb64a4179fea33bd0bc12b6a2b85798309

As the new code is more type-safe than the previous version, errors like these are slightly more likely to appear on programming issues at consumers of our code.

fichtner commented 1 week ago

@fichtner scrub doesn't seem to be a phalcon filter, let's ask @mib43 to test their code on our latest beta as well. I expect they do need some (small) modifications to handle the Phalcon deprecation on our end.

This is our code calling 'scrub'.

fichtner commented 1 week ago

https://github.com/opnsense/core/blame/master/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php#L800

Looks like a minor overlook while refactoring in f7999a7d56776

AdSchellevis commented 1 week ago

@fichtner looks like I forgot to rename that one to pkgname as both are the same filters. Zenarmor is likely doing something similar, in which case a similar fix as https://github.com/opnsense/core/commit/df7adc41c2f1c61a466be2b66c390dea206f5252 might be needed

ureyni commented 1 week ago

I tested Zenarmor with version 24.7.b and encountered errors related to the new routing.php file. I'll be reporting

AdSchellevis commented 1 week ago

@ureyni if your scrub is the same as what we used to scrub packages, you can just replace it with pkgname like we did on your end.