-
Notifications
You must be signed in to change notification settings - Fork 55
Security-focused PHPstan #916
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
base: main
Are you sure you want to change the base?
Conversation
…natives and allow execution calls in robo-components. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
| $this->taskReplaceInFile('.bootstrap/.ddev/config.yaml') | ||
| ->from('8880') | ||
| ->to((string) rand(6000, 8000)) | ||
| ->to((string) random_int(6000, 8000)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the benefit of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, it would be fine with rand. This is just a demonstration of a security-focused ruleset for phpstan. If we stick to random_int, we can be sure the numbers are not predictable. At some places, it matters a lot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See Slack devstuff for more context.
mariano-dagostino
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phpstan.neon
Outdated
| - RoboFile.php | ||
| - | ||
| function: 'popen()' | ||
| message: 'use Symfony Process instead' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we link to the component page? https://symfony.com/doc/current/components/process.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
|
@mariano-dagostino I added some more rules and adapted the custom code, good point! |
| function: 'print_r()' | ||
| message: 'use some logger instead' | ||
| allowParamsAnywhere: | ||
| 2: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is 2 in this context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Allowed: print_r($var, true) - returns output as string (for logging)
❌ Disallowed: print_r($var) or print_r($var, false) - outputs directly to screen
No description provided.