psalm
psalm copied to clipboard
Allow to implement custom taint type classes
Instead of just having a generic TaintedCustom for custom taint - this change allows plugins/extensions to register their own custom taint type classes.
Examples
$registry = Config::getInstance()->taint_kind_registry;
$registry->defineKinds([
'mine' => \Example\Package\TaintedMine::class,
'yours' => \Example\Package\TaintedYours::class,
], TaintKindGroup::GROUP_INPUT);
$registry->defineGroup('my-input', 'html', 'sql', 'shell');
$registry->defineGroupProxy('input-sql', 'input', [
'sql' => \Example\Package\TaintedSqlSecondOrder::class,
]);
$registry->getKind('html'); // returns TaintedHtml::class;
$registry->getGroupKinds('input'); // returns ['html', 'sql', ...]
Fixes: #9186
TODO
- [x] Extend
inputinTaintKindGroup - [x] Add documentation & examples for custom taint type classes
The failing BC tests are handled code-wise in those methods
Psalm\Codebase#addTaintSource()Psalm\Codebase#addTaintSink()