Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion front/php/templates/security.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function redirect($url) {

// Load configuration
if (!file_exists(CONFIG_PATH)) {
die("Configuration file not found.");
die("Configuration file not found in " . $_SERVER['DOCUMENT_ROOT'] . "/../config/app.conf");
}
Comment on lines 50 to 52
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Don't expose filesystem paths; return 500 and log details instead.

The new message leaks server path info and duplicates the CONFIG_PATH logic. Log the exact path, send a generic error to clients, and also guard for unreadable files.

-if (!file_exists(CONFIG_PATH)) {
-    die("Configuration file not found in " . $_SERVER['DOCUMENT_ROOT'] . "/../config/app.conf");
-}
+if (!file_exists(CONFIG_PATH) || !is_readable(CONFIG_PATH)) {
+    http_response_code(500);
+    error_log("Config missing or unreadable: " . CONFIG_PATH);
+    die("Configuration file not found or unreadable. See server logs for details.");
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!file_exists(CONFIG_PATH)) {
die("Configuration file not found.");
die("Configuration file not found in " . $_SERVER['DOCUMENT_ROOT'] . "/../config/app.conf");
}
if (!file_exists(CONFIG_PATH) || !is_readable(CONFIG_PATH)) {
http_response_code(500);
error_log("Config missing or unreadable: " . CONFIG_PATH);
die("Configuration file not found or unreadable. See server logs for details.");
}
🤖 Prompt for AI Agents
In front/php/templates/security.php around lines 50 to 52, the current die
message leaks server filesystem paths and repeats CONFIG_PATH logic; instead
check both file_exists and is_readable for CONFIG_PATH, log the exact
CONFIG_PATH (and any error) to server logs via error_log or the app logger, and
send a generic HTTP 500 response to the client (e.g., http_response_code(500)
with a non-descriptive message) before exiting; do not echo or include
$_SERVER['DOCUMENT_ROOT'] or full paths in the response.

$configLines = file(CONFIG_PATH);

Expand Down
Loading