Skip to content

Give a foreach over an IteratorAggregate the taints of what getIterator() returns - #14687

Merged
danog merged 1 commit into
vimeo:masterfrom
danog:foreach-iterator-aggregate-taints
Nov 23, 2026
Merged

danog merged 1 commit into
vimeo:masterfrom
danog:foreach-iterator-aggregate-taints

Conversation

@danog

@danog danog commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

A foreach over an IteratorAggregate only got the taint of the object itself, not of the iterator its getIterator() returns, so the sources and flows of getIterator() (and the taint of its analysed body) were lost, while an explicit ->getIterator() kept them. The loop now gets what that iterator gives, following an IteratorAggregate returned in turn.

final class Query implements IteratorAggregate {
    /** @psalm-taint-source input */
    public function getIterator(): ArrayIterator { /* ... */ }
}

foreach (new Query() as $value) {
    echo $value; // before: no issue, after: TaintedHtml
}

This is what Symfony's request bags (foreach ($request->query as $value)) need in psalm-plugin-symfony.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Performance: unchanged · Types: unchanged · Taint: +61 −1

Project Memory (MB) Wall (s) Issues Weighted (types) Taint Dead code
✅ laravel 1 771 $\color{gray}{\textsf{+0.1\%}}$ 102.1 $\color{gray}{\textsf{+1.9\%}}$ 25 754 $\color{red}{\textsf{+34}}$ $\color{green}{\textsf{-1}}$ 53 054 715 $\color{orange}{\textsf{+34}}$ $\color{orange}{\textsf{-1}}$ 0
✅ symfony 3 619 $\color{gray}{\textsf{-0.3\%}}$ 165.3 $\color{gray}{\textsf{-1.5\%}}$ 51 748 $\color{red}{\textsf{+4}}$ $\color{gray}{\textsf{-0}}$ 100 580 1 576 $\color{orange}{\textsf{+4}}$ $\color{gray}{\textsf{-0}}$ 0
✅ doctrine-orm 380 19.8 $\color{gray}{\textsf{+0.6\%}}$ 3 481 6 153 0 0
✅ psl 618 25.4 $\color{gray}{\textsf{+0.2\%}}$ 1 395 5 637 1 0
✅ phpunit 456 19.9 $\color{gray}{\textsf{-0.8\%}}$ 1 735 3 418 18 0
✅ php-parser 226 13.5 $\color{gray}{\textsf{+0.1\%}}$ 17 118 21 193 0 0
✅ tempest 898 $\color{gray}{\textsf{+0.3\%}}$ 36.3 $\color{gray}{\textsf{+0.5\%}}$ 5 093 $\color{red}{\textsf{+23}}$ $\color{gray}{\textsf{-0}}$ 10 567 275 $\color{orange}{\textsf{+23}}$ $\color{gray}{\textsf{-0}}$ 0
✅ amphp-amp 47 1.1 $\color{gray}{\textsf{+0.9\%}}$ 29 49 0 0
✅ webmozarts-assert 273 3.1 $\color{gray}{\textsf{+1.3\%}}$ 575 2 714 0 0
✅ guzzle-promises 46 1.2 $\color{gray}{\textsf{-0.8\%}}$ 156 436 2 0
✅ monolog 136 4.1 $\color{gray}{\textsf{+1.5\%}}$ 917 2 491 10 0
✅ drupal 4 844 242.3 $\color{gray}{\textsf{+0.7\%}}$ 97 838 169 727 575 0
✅ wordpress 2 042 185.3 $\color{gray}{\textsf{+3.1\%}}$ 143 516 678 190 461 1
Total 15 356 819.5 $\color{gray}{\textsf{+0.9\%}}$ 349 355 $\color{red}{\textsf{+61}}$ $\color{green}{\textsf{-1}}$ 1 054 209 3 633 $\color{orange}{\textsf{+61}}$ $\color{orange}{\textsf{-1}}$ 1
How to read this table
  • Memory: Psalm's own peak figure, threads=1. More than +5 % fails, unless the PR changes composer.json.
  • Wall: base and head run on the same runner; ±10 % is noise. Above +10 % warns, never fails. re-run: a reversed second run was taken and the faster kept.
  • Issues: head count over all categories, then $\color{red}{\textsf{+added}}$ $\color{green}{\textsf{-removed}}$ against base.
  • Weighted (types): type issues weighted by error level (levels 1–8 as is, always-errors 10, strictness checks 1). Taint and dead-code issues are not weighed. The projects' own code is pinned and their dependencies resolve identically for base and head, so a change means Psalm reports more, fewer or differently serious issues. A rise is not necessarily a regression.
  • Taint: head count of Tainted* issues, then $\color{orange}{\textsf{+added}}$ $\color{orange}{\textsf{-removed}}$ against base. Both are orange as either direction needs review: more can be new detection or false positives, fewer can be fixed false positives or lost detection.
  • Dead code: head count of unused-code issues, shown only when a run reported some (findUnusedCode). More is red, fewer is green.
  • Total: sum over the projects compared on both sides. Its wall time warns above +5 % (±5 % is noise); the other thresholds apply per project.
  • Colors: $\color{red}{\textsf{red}}$ past a fail or warn threshold (or more issues), $\color{green}{\textsf{green}}$ an improvement past noise (or fewer issues), $\color{orange}{\textsf{orange}}$ needs review, $\color{gray}{\textsf{gray}}$ noise.
  • Performance: regressed if a head run crashed or timed out or a memory or wall delta is red, else improved if one is green, else unchanged. Its icon is the check result: ❌ fail · ⚠️ warn · ✅ pass; the icon next to each project is that project's result, 💥 = not comparable: base crashed or timed out (counts as ⚠️).
  • Types (heading): direction of the total weighted change, increased · decreased · unchanged. Taint and Dead code (heading): added and removed counts, present only when non-zero. Informational, never fails the check.
✅ laravel: issues +34 −1

Memory 1 769 → 1 771 MB (+0.1 %) · Wall 100.1 → 102.1 s (+1.9 %)

Taint 682 → 715 (+34 −1)

Issue type added removed
TaintedCallable 31 0
TaintedFile 1 0
TaintedInclude 0 1
TaintedSSRF 1 0
TaintedUnserialize 1 0

Added (34)

  • src/Illuminate/Bus/PendingBatch.php:470 TaintedCallable (error): Detected tainted text
  • src/Illuminate/Bus/PendingBatch.php:470 TaintedCallable (error): Detected tainted text
  • src/Illuminate/Bus/Queueable.php:362 TaintedCallable (error): Detected tainted text
  • src/Illuminate/Bus/Queueable.php:362 TaintedCallable (error): Detected tainted text
  • src/Illuminate/Collections/Traits/EnumeratesValues.php:832 TaintedCallable (error): Detected tainted text
  • src/Illuminate/Collections/Traits/EnumeratesValues.php:832 TaintedCallable (error): Detected tainted text
  • src/Illuminate/Concurrency/SyncDriver.php:30 TaintedCallable (error): Detected tainted text
  • src/Illuminate/Concurrency/SyncDriver.php:30 TaintedCallable (error): Detected tainted text
  • src/Illuminate/Database/Console/PruneCommand.php:172 TaintedCallable (error): Detected tainted text
  • src/Illuminate/Database/Console/PruneCommand.php:172 TaintedCallable (error): Detected tainted text
  • … and 24 more

Removed (1)

  • src/Illuminate/Filesystem/Filesystem.php:127 TaintedInclude (error): Detected tainted code passed to include or similar
✅ symfony: issues +4 −0

Memory 3 629 → 3 619 MB (−0.3 %) · Wall 167.9 → 165.3 s (−1.5 %)

Taint 1 572 → 1 576 (+4 −0)

Issue type added removed
TaintedHtml 2 0
TaintedTextWithQuotes 2 0

Added (4)

  • src/Symfony/Component/HttpFoundation/EventStreamResponse.php:95 TaintedHtml (error): Detected tainted HTML
  • src/Symfony/Component/HttpFoundation/EventStreamResponse.php:95 TaintedHtml (error): Detected tainted HTML
  • src/Symfony/Component/HttpFoundation/EventStreamResponse.php:95 TaintedTextWithQuotes (error): Detected tainted text with possible quotes
  • src/Symfony/Component/HttpFoundation/EventStreamResponse.php:95 TaintedTextWithQuotes (error): Detected tainted text with possible quotes
✅ tempest: issues +23 −0

Memory 896 → 898 MB (+0.3 %) · Wall 36.1 → 36.3 s (+0.5 %)

Taint 252 → 275 (+23 −0)

Issue type added removed
TaintedCallable 5 0
TaintedFile 6 0
TaintedHtml 3 0
TaintedSSRF 6 0
TaintedTextWithQuotes 3 0

Added (23)

  • packages/console/src/Testing/ConsoleTester.php:151 TaintedHtml (error): Detected tainted HTML
  • packages/console/src/Testing/ConsoleTester.php:151 TaintedTextWithQuotes (error): Detected tainted text with possible quotes
  • packages/console/src/Testing/ConsoleTester.php:158 TaintedHtml (error): Detected tainted HTML
  • packages/console/src/Testing/ConsoleTester.php:158 TaintedTextWithQuotes (error): Detected tainted text with possible quotes
  • packages/container/src/GenericContainer.php:240 TaintedCallable (error): Detected tainted text
  • packages/container/src/GenericContainer.php:296 TaintedCallable (error): Detected tainted text
  • packages/container/src/GenericContainer.php:296 TaintedCallable (error): Detected tainted text
  • packages/debug/src/Debug.php:103 TaintedHtml (error): Detected tainted HTML
  • packages/debug/src/Debug.php:103 TaintedTextWithQuotes (error): Detected tainted text with possible quotes
  • packages/reflection/src/FunctionReflector.php:19 TaintedCallable (error): Detected tainted text
  • … and 13 more

head 2bfad0e · base be56c19 (merge-base) · workflow run

@danog danog added the release:fix The PR will be included in 'Fixes' section of the release notes label Nov 23, 2026
@danog
danog merged commit 345beac into vimeo:master Nov 23, 2026
57 of 75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:fix The PR will be included in 'Fixes' section of the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant