Skip to content
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

CRM-18004 - IDS: Fix undefined index & code cleanup #8219

Merged
merged 1 commit into from
Jul 25, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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