New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more Psalm flows for string functions #4576
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This adds string functions from https://www.php.net/manual/en/ref.strings.php This commit adds the flows for functions from "addcslashes" to "sprintf". More are to follow in later commits. Ref vimeo#3636
This is great, thanks! |
LukasReschke
added a commit
to LukasReschke/psalm
that referenced
this pull request
Nov 17, 2020
This adds string functions from https://www.php.net/manual/en/ref.strings.php This commit adds the flows for functions from "addcslashes" to "sprintf". More are to follow in later commits. Ref vimeo#3636
LukasReschke
added a commit
to LukasReschke/psalm
that referenced
this pull request
Nov 17, 2020
This should conclude all string functions from https://www.php.net/manual/en/book.strings.php Continuation of vimeo#4576 Ref vimeo#3636
3 tasks
LukasReschke
added a commit
to LukasReschke/psalm
that referenced
this pull request
Nov 17, 2020
This should conclude all string functions from https://www.php.net/manual/en/book.strings.php Continuation of vimeo#4576 Ref vimeo#3636
Using the new release 4.2, I get "Detected tainted header" using https://psalm.dev/r/21c22b8fb6 What is the best way to handle this? |
I found these snippets: https://psalm.dev/r/21c22b8fb6<?php // --taint-analysis
$test = (string) ($_POST['test'] ?? '');
header('Content-Disposition: attachment; filename="' . addslashes($test) . '"');
|
@thomasbley You could create a new function that is marked as sanitizer. https://psalm.dev/r/5fb5ba744f <?php // --taint-analysis
$test = (string) ($_POST['test'] ?? '');
/**
* @psalm-taint-escape header
*/
function addFileNameToContentDisposition(string $fileName) : string {
return addslashes($fileName);
}
header('Content-Disposition: attachment; filename="' . addFileNameToContentDisposition($test) . '"'); |
I found these snippets: https://psalm.dev/r/5fb5ba744f<?php // --taint-analysis
$test = (string) ($_POST['test'] ?? '');
/**
* @psalm-taint-escape header
*/
function addFileNameToContentDisposition(string $fileName) : string {
return addslashes($fileName);
}
header('Content-Disposition: attachment; filename="' . addFileNameToContentDisposition($test) . '"');
|
LukasReschke
added a commit
to LukasReschke/psalm
that referenced
this pull request
Nov 21, 2020
This should conclude all string functions from https://www.php.net/manual/en/book.strings.php Continuation of vimeo#4576 Ref vimeo#3636
muglug
added a commit
that referenced
this pull request
Nov 21, 2020
* Add string functions from sscanf to wordwrap This should conclude all string functions from https://www.php.net/manual/en/book.strings.php Continuation of #4576 Ref #3636 * Add StrTrReturnTypeProvider * Fix psalm error * phpcs * Line length * Ignore false return on vsprintf Co-authored-by: Matthew Brown <github@muglug.com>
danog
pushed a commit
to danog/psalm
that referenced
this pull request
Jan 29, 2021
This adds string functions from https://www.php.net/manual/en/ref.strings.php This commit adds the flows for functions from "addcslashes" to "sprintf". More are to follow in later commits. Ref vimeo#3636
danog
pushed a commit
to danog/psalm
that referenced
this pull request
Jan 29, 2021
* Add string functions from sscanf to wordwrap This should conclude all string functions from https://www.php.net/manual/en/book.strings.php Continuation of vimeo#4576 Ref vimeo#3636 * Add StrTrReturnTypeProvider * Fix psalm error * phpcs * Line length * Ignore false return on vsprintf Co-authored-by: Matthew Brown <github@muglug.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds string functions from https://www.php.net/manual/en/ref.strings.php
This commit adds the flows for functions from "addcslashes" to "sprintf".
More are to follow in later commits, if that is deemed useful :)
Ref #3636