-
Notifications
You must be signed in to change notification settings - Fork 31
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
Task #228793 chore: Logs implenetation for import ucm functionality #426
base: j4x
Are you sure you want to change the base?
Conversation
header('Expires: 0'); | ||
header('Cache-Control: must-revalidate'); | ||
header('Pragma: public'); | ||
header('Content-Length: ' . filesize($logFilePath)); |
Check failure
Code scanning / SonarCloud
I/O function calls should not be vulnerable to path injection attacks High
flush(); | ||
|
||
// Read and output the file content | ||
readfile($logFilePath); |
Check failure
Code scanning / SonarCloud
I/O function calls should not be vulnerable to path injection attacks High
*/ | ||
public function downloadLog() | ||
{ | ||
$logFileName = Factory::getApplication()->input->getString('file'); |
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.
@punambaravkar
Take only file name from input and use it.
// Use basename() to extract only the filename, preventing directory traversal. and use it in the next lines
$safeFileName = basename(logFileName);
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.
Done
{ | ||
$logFileName = Factory::getApplication()->input->getString('file'); | ||
|
||
// Full path to the log file |
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.
// Construct the full path.
$baseDir = JPATH_ADMINISTRATOR . '/logs/'
$fullPath = realpath($baseDir . $safeFileName);
// Validate: Ensure the path is within the intended directory.
if (strpos($fullPath, $baseDir) !== 0 || !$fullPath)
{
JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
return false;
}
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.
Done
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
No description provided.