-
Notifications
You must be signed in to change notification settings - Fork 6
SendmailRunner #117
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
SendmailRunner #117
Conversation
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.
Pull Request Overview
This PR introduces a new SendmailRunner class that provides a secure wrapper for executing sendmail commands with strict validation and safety measures.
- Implements path validation against a configurable allowlist of known sendmail binary locations
- Provides secure command execution using
proc_openwith shell bypass to prevent injection attacks - Includes RFC 5322 compliant message formatting with CRLF normalization
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| * | ||
| * @category Xmf\Mail | ||
| * @package Xmf | ||
| * @author XOOPS Development Team < |
Copilot
AI
Sep 10, 2025
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.
The author email address is incomplete. It should include the full email address after the '<' character.
| * @author XOOPS Development Team < | |
| * @author XOOPS Development Team <dev@xoops.org> |
| if (!is_resource($pipes[0]) || feof($pipes[0])) { | ||
| throw new \RuntimeException('sendmail closed the input pipe prematurely.'); | ||
| } | ||
| usleep(10000); |
Copilot
AI
Sep 10, 2025
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.
The magic number 10000 (microseconds) should be defined as a named constant to improve code readability and maintainability.
| $addr = $m[1]; | ||
| } | ||
| // Forbid any whitespace/control to prevent header/arg injection. | ||
| if (preg_match('/\s/', $addr) || preg_match('/[\r\n]/', $addr)) { |
Copilot
AI
Sep 10, 2025
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.
These two separate regex operations can be combined into a single pattern for better performance: if (preg_match('/[\s\r\n]/', $addr)) {
| if (preg_match('/\s/', $addr) || preg_match('/[\r\n]/', $addr)) { | |
| if (preg_match('/\s/', $addr)) { |
No description provided.