diff options
author | Kate <26026535+provokateurin@users.noreply.github.com> | 2023-04-05 09:02:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-05 09:02:31 +0200 |
commit | 54140dd6bfda81276bd889a9a141d51e328100d1 (patch) | |
tree | 4411695614d3224931abc3a07d03e7f05c93f803 | |
parent | 746a1e9922ccbbd3756934eb3d20c03ca0ebdbe8 (diff) | |
parent | e7926b964441b8b6d6ffc6a656896bc0276e9cc3 (diff) | |
download | nextcloud-server-54140dd6bfda81276bd889a9a141d51e328100d1.tar.gz nextcloud-server-54140dd6bfda81276bd889a9a141d51e328100d1.zip |
Merge pull request #37504 from nextcloud/fix/app-framework-tainter
Update AppFrameworkTainter to use non-deprecated interface
-rw-r--r-- | build/psalm/AppFrameworkTainter.php | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/build/psalm/AppFrameworkTainter.php b/build/psalm/AppFrameworkTainter.php index c12dcfc6ce2..9a68885b175 100644 --- a/build/psalm/AppFrameworkTainter.php +++ b/build/psalm/AppFrameworkTainter.php @@ -22,39 +22,37 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ + use Psalm\CodeLocation; -use Psalm\Plugin\Hook\AfterFunctionLikeAnalysisInterface; +use Psalm\Plugin\EventHandler\AfterFunctionLikeAnalysisInterface; +use Psalm\Plugin\EventHandler\Event\AfterFunctionLikeAnalysisEvent; use Psalm\Type\TaintKindGroup; class AppFrameworkTainter implements AfterFunctionLikeAnalysisInterface { - public static function afterStatementAnalysis( - PhpParser\Node\FunctionLike $stmt, - Psalm\Storage\FunctionLikeStorage $classlike_storage, - Psalm\StatementsSource $statements_source, - Psalm\Codebase $codebase, - array &$file_replacements = [] - ): ?bool { - if ($statements_source->getFQCLN() !== null) { - if ($codebase->classExtendsOrImplements($statements_source->getFQCLN(), \OCP\AppFramework\Controller::class)) { - if ($stmt instanceof PhpParser\Node\Stmt\ClassMethod) { - if ($stmt->isPublic() && !$stmt->isMagic()) { - foreach ($stmt->params as $i => $param) { - $expr_type = new Psalm\Type\Union([new Psalm\Type\Atomic\TString()]); - $expr_identifier = (strtolower($statements_source->getFQCLN()) . '::' . strtolower($classlike_storage->cased_name) . '#' . ($i + 1)); - - if ($expr_type) { - $codebase->addTaintSource( - $expr_type, - $expr_identifier, - TaintKindGroup::ALL_INPUT, - new CodeLocation($statements_source, $param) - ); - } - } - } - } - } + public static function afterStatementAnalysis(AfterFunctionLikeAnalysisEvent $event): ?bool { + if ($event->getStatementsSource()->getFQCLN() === null) { + return null; + } + if (!$event->getCodebase()->classExtendsOrImplements($event->getStatementsSource()->getFQCLN(), \OCP\AppFramework\Controller::class)) { + return null; + } + if (!($event->getStmt() instanceof PhpParser\Node\Stmt\ClassMethod)) { + return null; } + if (!$event->getStmt()->isPublic() || $event->getStmt()->isMagic()) { + return null; + } + foreach ($event->getStmt()->params as $i => $param) { + $expr_type = new Psalm\Type\Union([new Psalm\Type\Atomic\TString()]); + $expr_identifier = (strtolower($event->getStatementsSource()->getFQCLN()) . '::' . strtolower($event->getFunctionlikeStorage()->cased_name) . '#' . ($i + 1)); + $event->getCodebase()->addTaintSource( + $expr_type, + $expr_identifier, + TaintKindGroup::ALL_INPUT, + new CodeLocation($event->getStatementsSource(), $param) + ); + } + return null; } } |