Rule Idea: UriSigner check result is used and not used as a void method
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start with Symfony's UriSigner::checkRequest() entry point and inspect existing phpstan-symfony rules or annotations for ignored return values. Determine whether a standalone call can be distinguished from valid uses in assignments, conditions, and arguments. Done means direct void-style calls are reported without flagging handled results, with regression coverage for these cases.
Written by the indexing model from the issue text.
Description
I currently did stumble today over some issue in my code base which I think would be interesting for every project. I have a controller which used the UriSigner to check for a correclty signed Uri.
public function acceptAction(Request $request): Response
{
$this->uriSigner->checkRequest($request);
Actually the UriSigner itself does not throw any exception. So calling it without do anything basically is a Security issue in some projects.
Valid cases would be:
// write the result atleast in a variable
$isValid = $this->uriSigner->checkRequest($request);
// usage in a if statement
if (!$this->uriSigner->checkRequest($request)) {
throw new AccessDeniedHttpException('The given uri is not valid.');
}
// usage in complex if statements
if (!$this->uriSigner->checkRequest($request) && !$request->attributes->getBoolean('simulate')) {
throw new AccessDeniedHttpException('The given uri is not valid.');
}
// usage in method calls
$this->validate($this->uriSigner->checkRequest($request));
Invalid would be calling it like a void method:
$this->uriSigner->checkRequest($request);
I'm not sure maybe if there already exist some kind of annotations we could add to the Symfony UriSigner that the result need to be handled and the method not be used like a void method.
- Dominant language
- PHP
- Stars
- 800
- Forks
- 104
- Avg merge
- 4m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from phpstan/phpstan-symfony
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
phpstan/phpstan-symfony#510 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
phpstan/phpstan-symfony#494 · 5 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
phpstan/phpstan-symfony#268 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
phpstan/phpstan-symfony#509 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
phpstan/phpstan-symfony#466 · 4 comments ·
All issues in phpstan/phpstan-symfony
Similar issues
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·
-
0. Needs triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nextcloud/fulltextsearch#1011 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
phpstan/phpstan-doctrine#794 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Automattic/static-site-importer#1767 ·