-
-
Notifications
You must be signed in to change notification settings - Fork 366
provide more descriptive reason for failure #1177
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
Conversation
WalkthroughUpdated the error message in front/php/templates/security.php to include the expected configuration file path using $_SERVER['DOCUMENT_ROOT']."/../config/app.conf". No control flow or logic changes. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 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.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
front/php/templates/security.php (1)
34-34: apache_request_headers() may be undefined; add a portable fallback.This can fatal on Nginx/FPM where apache_request_headers is unavailable.
-$authHeader = apache_request_headers()['Authorization'] ?? ''; +$headers = function_exists('getallheaders') + ? getallheaders() + : (function_exists('apache_request_headers') ? apache_request_headers() : []); +$authHeader = $headers['Authorization'] ?? '';
🧹 Nitpick comments (3)
front/php/templates/security.php (3)
35-41: Start session before accessing $_SESSION; remove unused variable.$sessionLogin is read before session_start and never used.
-$sessionLogin = isset($_SESSION['login']) ? $_SESSION['login'] : 0; - -// Start session if not already started -if (session_status() == PHP_SESSION_NONE) { - session_start(); -} +// Start session before accessing $_SESSION +if (session_status() === PHP_SESSION_NONE) { + session_start(); +}
45-46: Harden cookie deletion (path/flags must match set-time attributes).Ensure deletion is effective and secure.
- setcookie(COOKIE_SAVE_LOGIN_NAME, "", time() - 3600); + setcookie(COOKIE_SAVE_LOGIN_NAME, '', [ + 'expires' => time() - 3600, + 'path' => '/', + 'secure' => (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'), + 'httponly' => true, + 'samesite' => 'Lax', + ]);
79-80: Remove redundant exit after redirect.redirect() already calls exit(); this line is unreachable.
- redirect('/index.php'); - exit; // exit is needed to prevent authentication bypass + redirect('/index.php'); // redirect() already exits
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
front/php/templates/security.php(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: docker_dev
| if (!file_exists(CONFIG_PATH)) { | ||
| die("Configuration file not found."); | ||
| die("Configuration file not found in " . $_SERVER['DOCUMENT_ROOT'] . "/../config/app.conf"); | ||
| } |
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.
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.
| 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.
The original message states the configuration file was not found. This provides a bit more context as to where it was not found.
Summary by CodeRabbit