vimeo / psalm

A static analysis tool for finding errors in PHP applications
https://psalm.dev
MIT License
5.58k stars 664 forks source link

Taint analysis: allow marking properties as taint sources? #10896

Open Ocramius opened 7 months ago

Ocramius commented 7 months ago

I've snooped around taint analysis, which I found to be useful in very legacy projects that heavily on superglobals like $_GET, $_SESSION, etc.

In more recent / modern projects:

The current taint analysis only operates with taint sources being function-alike nodes:

I'm wondering if it makes sense to allow object properties to be marked as taint sources.

psalm-github-bot[bot] commented 7 months ago

Hey @Ocramius, can you reproduce the issue on https://psalm.dev? These will be used as phpunit tests when implementing the feature or fixing this bug.

Ocramius commented 7 months ago

Seems like this is achievable via custom taint sources:

https://github.com/vimeo/psalm/blob/7d6c88e88a55cf04af4d6932cfb906d15ac2fe23/docs/security_analysis/custom_taint_sources.md#L19-L74