mirror of
https://github.com/joomla-extensions/jedchecker.git
synced 2025-01-03 22:57:21 +00:00
add direct search for leftover files and folders
This commit is contained in:
parent
ded1cab905
commit
a2565abe68
@ -64,7 +64,8 @@ COM_JEDCHECKER_ERROR_FRAMEWORK_JERR="JError is deprecated, you should use JFacto
|
||||
COM_JEDCHECKER_ERROR_FRAMEWORK_ERRORLOG="error_log and var_dump"
|
||||
COM_JEDCHECKER_ERROR_FRAMEWORK_DEPRECATED="JRequest is deprecated, you should use JFactory::getApplication()->input;"
|
||||
COM_JEDCHECKER_ERROR_FRAMEWORK_TODO="TODO statement detected"
|
||||
COM_JEDCHECKER_ERROR_FRAMEWORK_GIT="Code-versioning folders detected"
|
||||
COM_JEDCHECKER_ERROR_FRAMEWORK_LEFTOVER_FOLDER="Leftover folder detected"
|
||||
COM_JEDCHECKER_ERROR_FRAMEWORK_LEFTOVER_FILE="Leftover file detected"
|
||||
COM_JEDCHECKER_ERROR_FRAMEWORK_STRICT="PHP Strict Standards: Only variables should be assigned by reference"
|
||||
COM_JEDCHECKER_RULE_JAMSS="JAMSS - Joomla! Anti-Malware Scan Script"
|
||||
COM_JEDCHECKER_RULE_JAMSS_DESC="JAMSS will raise many flags for use of potentially dangerous methods, additionally checking for some known attack signatures. Find out more on the <a href='https://github.com/btoplak/Joomla-Anti-Malware-Scan-Script' target='_blank'>Project's homepage</a><br>JAMSS output is very verbose and very useful, hover over any lines to see the details."
|
||||
|
@ -54,8 +54,26 @@ class JedcheckerRulesFramework extends JEDcheckerRule
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
// Warn about code versioning files included
|
||||
$leftover_folders = $this->params->get('leftover_folders');
|
||||
$regex_leftover_folders = '(?:' . str_replace(',', '|', preg_quote($leftover_folders, '/')) . ')$';
|
||||
|
||||
$folders = JFolder::folders($this->basedir, $regex_leftover_folders, true, true, array(), array());
|
||||
$files = JFolder::files($this->basedir, $regex_leftover_folders, true, true, array(), array());
|
||||
|
||||
foreach ($folders as $folder)
|
||||
{
|
||||
$this->report->addWarning($folder, JText::_("COM_JEDCHECKER_ERROR_FRAMEWORK_LEFTOVER_FOLDER"));
|
||||
}
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
$this->report->addWarning($file, JText::_("COM_JEDCHECKER_ERROR_FRAMEWORK_LEFTOVER_FILE"));
|
||||
}
|
||||
|
||||
$this->leftover_folders = explode(',', $leftover_folders);
|
||||
|
||||
$files = JFolder::files($this->basedir, '\.php$', true, true);
|
||||
$this->leftover_folders = explode(',', $this->params->get('leftover_folders'));
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
@ -71,7 +89,7 @@ class JedcheckerRulesFramework extends JEDcheckerRule
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given resource is a leftover folder
|
||||
* Check if the given resource is inside of a leftover folder
|
||||
*
|
||||
* @param string $file The file name to test
|
||||
*
|
||||
@ -79,20 +97,15 @@ class JedcheckerRulesFramework extends JEDcheckerRule
|
||||
*/
|
||||
private function excludeResource($file)
|
||||
{
|
||||
// Warn about code versioning files included
|
||||
$result = false;
|
||||
|
||||
foreach ($this->leftover_folders as $leftover_folder)
|
||||
{
|
||||
if (strpos($file, $leftover_folder) !== false)
|
||||
if (strpos($file, '/' . $leftover_folder . '/') !== false)
|
||||
{
|
||||
$error_message = JText::_("COM_JEDCHECKER_ERROR_FRAMEWORK_GIT") . ":";
|
||||
$this->report->addWarning($file, $error_message, 0);
|
||||
$result = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user