diff --git a/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini b/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini index 19494ea..2d39fbc 100644 --- a/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini +++ b/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini @@ -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 Project's homepage
JAMSS output is very verbose and very useful, hover over any lines to see the details." diff --git a/administrator/components/com_jedchecker/libraries/rules/framework.php b/administrator/components/com_jedchecker/libraries/rules/framework.php index 4bea0dc..162f1af 100644 --- a/administrator/components/com_jedchecker/libraries/rules/framework.php +++ b/administrator/components/com_jedchecker/libraries/rules/framework.php @@ -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; } /**