Skip to content

Commit

Permalink
Merge pull request #8219 from colemanw/CRM-18004
Browse files Browse the repository at this point in the history
CRM-18004 - IDS: Fix undefined index & code cleanup
  • Loading branch information
eileenmcnaughton authored Jul 25, 2016
2 parents 892d69c + 7c877ab commit d602332
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions CRM/Core/IDS.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,27 @@ class CRM_Core_IDS {
);

/**
* The init object
* @var string
*/
private $init = NULL;
private $path;

/**
* Check function.
*
* This function includes the IDS vendor parts and runs the
* detection routines on the request array.
*
* @param object $args cake controller object
* @param array $args
* List of path parts.
*
* @return bool
*/
public function check(&$args) {
public function check($args) {
// lets bypass a few civicrm urls from this check
$skip = array('civicrm/admin/setting/updateConfigBackend', 'civicrm/admin/messageTemplates');
CRM_Utils_Hook::idsException($skip);
$path = implode('/', $args);
if (in_array($path, $skip)) {
$this->path = implode('/', $args);
if (in_array($this->path, $skip)) {
return NULL;
}

Expand Down Expand Up @@ -186,7 +187,7 @@ private function react(IDS_Report $result) {
$impact = $result->getImpact();
if ($impact >= $this->threshold['kick']) {
$this->log($result, 3, $impact);
$this->kick($result);
$this->kick();
return TRUE;
}
elseif ($impact >= $this->threshold['warn']) {
Expand Down Expand Up @@ -248,21 +249,18 @@ private function warn($result) {
}

/**
* Kick (whatever that means!).
*
* @param array $result
* Create an error that prevents the user from continuing.
*
* @throws \Exception
*/
private function kick($result) {
private function kick() {
$session = CRM_Core_Session::singleton();
$session->reset(2);

$msg = ts('There is a validation error with your HTML input. Your activity is a bit suspicious, hence aborting');

$path = implode('/', $args);
if (in_array(
$path,
$this->path,
array("civicrm/ajax/rest", "civicrm/api/json")
)) {
require_once "api/v3/utils.php";
Expand Down

0 comments on commit d602332

Please sign in to comment.