diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2025-02-17 18:06:45 +0100 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2025-02-17 18:08:23 +0100 |
commit | e757b649b7b6415ae5f77e59b5160052896b2c21 (patch) | |
tree | 21f63c87b66d8f316c5c2166e58dfb547db79b65 /apps/files_external/lib | |
parent | 9edabfa21fa7e587c0ad95d2d230d215b060ade0 (diff) | |
download | nextcloud-server-e757b649b7b6415ae5f77e59b5160052896b2c21.tar.gz nextcloud-server-e757b649b7b6415ae5f77e59b5160052896b2c21.zip |
fix: Fix psalm taint false-positives by small refactoringsfix/fix-psalm-taint-errors-2
Mostly make it clear that we trust admin input or that we correctly
escape strings.
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/files_external/lib')
-rw-r--r-- | apps/files_external/lib/Config/ConfigAdapter.php | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/apps/files_external/lib/Config/ConfigAdapter.php b/apps/files_external/lib/Config/ConfigAdapter.php index c84fbb19102..db53c8cf6c9 100644 --- a/apps/files_external/lib/Config/ConfigAdapter.php +++ b/apps/files_external/lib/Config/ConfigAdapter.php @@ -40,6 +40,19 @@ class ConfigAdapter implements IMountProvider { } /** + * @param class-string $class + * @return class-string<IObjectStore> + * @throws \InvalidArgumentException + * @psalm-taint-escape callable + */ + private function validateObjectStoreClassString(string $class): string { + if (!\is_subclass_of($class, IObjectStore::class)) { + throw new \InvalidArgumentException('Invalid object store'); + } + return $class; + } + + /** * Process storage ready for mounting * * @throws QueryException @@ -51,10 +64,7 @@ class ConfigAdapter implements IMountProvider { $objectStore = $storage->getBackendOption('objectstore'); if ($objectStore) { - $objectClass = $objectStore['class']; - if (!is_subclass_of($objectClass, IObjectStore::class)) { - throw new \InvalidArgumentException('Invalid object store'); - } + $objectClass = $this->validateObjectStoreClassString($objectStore['class']); $storage->setBackendOption('objectstore', new $objectClass($objectStore)); } |