-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Psalm security checks #18235
base: main
Are you sure you want to change the base?
Add Psalm security checks #18235
Conversation
For now, I am not able to find a way to suppress false-positive errors. For instance, I tried to handle the following error:
Even if I consider that the function is already secure enough (a classname cannot contain a index 0365b72f38..8a96432ee1 100644
--- a/src/autoload/legacy-autoloader.php
+++ b/src/autoload/legacy-autoloader.php
@@ -34,14 +34,17 @@
*/
/**
- * Classes loader
+ * GLPI autoloader for classes that do not follow the PSR-4.
*
- * @param string $classname : class to load
- *
- * @return void|boolean
+ * @psalm-suppress TaintedInclude
*/
-function glpi_autoload($classname)
+function glpi_autoload(string $classname): void
{
+ if (preg_match('/\./', $classname) === 1) {
+ // security check, a valid classname is not supposed to contain a `.`
+ return;
+ }
+
$plug = isPluginItemType($classname);
if (!$plug) {
// PSR-4 styled autoloading for classes without namespace
@@ -57,7 +60,7 @@ function glpi_autoload($classname)
$plugin_class = $plug['class'];
if (!Plugin::isPluginLoaded($plugin_key)) {
- return false;
+ return;
}
$plugin_path = null; |
.github/actions/init_show-versions.sh | ||
- name: "Build dependencies / translations" | ||
run: | | ||
docker compose exec -T app .github/actions/init_build.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I've seen, psalm just requires composer deps; we should save time and resources if we do not build JS, locales etc.
Checklist before requesting a review
Description
This PR add a security scan using Psalm.
I used
cpx/cpx
to execute the command as the package dependencies are not compatible with some of our dependencies.