forked from joomla-extensions/jedchecker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request joomla-extensions#14 from dulici/master
Added error_reporting(0) rule
- Loading branch information
Showing
3 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
source/administrator/components/com_jedchecker/libraries/rules/errorreporting.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
; This is the configuration file of the error reporting rule. | ||
; | ||
; @author Denis Dulici | ||
; @date 18/08/2013 | ||
; @copyright Copyright (C) 2008 - 2013 mijosoft.com . All rights reserved. | ||
; @license GNU General Public License version 2 or later; see LICENSE | ||
|
||
|
||
; The valid constants to search for | ||
errorreportings="error_reporting(0)" |
96 changes: 96 additions & 0 deletions
96
source/administrator/components/com_jedchecker/libraries/rules/errorreporting.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
/** | ||
* @author Denis Dulici | ||
* @date 18/08/2013 | ||
* @copyright Copyright (C) 2008 - 2013 mijosoft.com . All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE | ||
*/ | ||
|
||
defined('_JEXEC') or die('Restricted access'); | ||
|
||
|
||
// Include the rule base class | ||
require_once(JPATH_COMPONENT_ADMINISTRATOR.'/models/rule.php'); | ||
|
||
|
||
/** | ||
* This class searches all files for the _JEXEC check | ||
* which prevents direct file access. | ||
* | ||
*/ | ||
class jedcheckerRulesErrorreporting extends JEDcheckerRule | ||
{ | ||
/** | ||
* The formal ID of this rule. For example: SE1. | ||
* | ||
* @var string | ||
*/ | ||
protected $id = 'errorreporting'; | ||
|
||
/** | ||
* The title or caption of this rule. | ||
* | ||
* @var string | ||
*/ | ||
protected $title = 'COM_JEDCHECKER_RULE_ERRORREPORTING'; | ||
|
||
/** | ||
* The description of this rule. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'COM_JEDCHECKER_RULE_ERRORREPORTING_DESC'; | ||
|
||
|
||
/** | ||
* Initiates the file search and check | ||
* | ||
* @return void | ||
*/ | ||
public function check() | ||
{ | ||
// Find all php files of the extension | ||
$files = JFolder::files($this->basedir, '.php$', true, true); | ||
|
||
// Iterate through all files | ||
foreach($files as $file) | ||
{ | ||
// Try to find the base64 use in the file | ||
if($this->find($file)) { | ||
// Add as error to the report if it was not found | ||
$this->report->addError($file, JText::_('COM_JEDCHECKER_ERROR_ERRORREPORTING')); | ||
} | ||
} | ||
} | ||
|
||
|
||
/** | ||
* Reads a file and searches for any encoding function defined in the params | ||
* Not a very clever way of doing this, but it should be fine for now | ||
* | ||
* @param string $file The path to the file | ||
* @return boolean True if the statement was found, otherwise False. | ||
*/ | ||
protected function find($file) | ||
{ | ||
$content = (array) file($file); | ||
|
||
// Get the functions to look for | ||
$encodings = explode(',', $this->params->get('errorreportings')); | ||
|
||
foreach($encodings as $encoding) { | ||
$encoding = trim($encoding); | ||
foreach ($content AS $line) | ||
{ | ||
// Search for "base64" | ||
$pos_1 = stripos($line, $encoding); | ||
|
||
if ($pos_1 !== false) { | ||
return true; | ||
} | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters