Skip to content

Conversation

@mambax7
Copy link
Contributor

@mambax7 mambax7 commented Sep 10, 2025

No description provided.

@mambax7 mambax7 requested a review from Copilot September 10, 2025 22:42
Copy link

Copilot AI left a 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_open with 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 <
Copy link

Copilot AI Sep 10, 2025

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.

Suggested change
* @author XOOPS Development Team <
* @author XOOPS Development Team <dev@xoops.org>

Copilot uses AI. Check for mistakes.
if (!is_resource($pipes[0]) || feof($pipes[0])) {
throw new \RuntimeException('sendmail closed the input pipe prematurely.');
}
usleep(10000);
Copy link

Copilot AI Sep 10, 2025

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.

Copilot uses AI. Check for mistakes.
$addr = $m[1];
}
// Forbid any whitespace/control to prevent header/arg injection.
if (preg_match('/\s/', $addr) || preg_match('/[\r\n]/', $addr)) {
Copy link

Copilot AI Sep 10, 2025

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)) {

Suggested change
if (preg_match('/\s/', $addr) || preg_match('/[\r\n]/', $addr)) {
if (preg_match('/\s/', $addr)) {

Copilot uses AI. Check for mistakes.
@mambax7 mambax7 merged commit 4e5cb71 into XOOPS:master Sep 10, 2025
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant