Merge pull request #10541 from JMAConsulting/CRM-20411
[civicrm-core.git] / CRM / Core / IDS.php
index 93c37e5db9a83d9b9434fec9dcba5bd6c7a2649d..0a9117d857876cbaa5bd05aff5ae110f44d8e00f 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2016                                |
+ | Copyright CiviCRM LLC (c) 2004-2017                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2016
+ * @copyright CiviCRM LLC (c) 2004-2017
  */
 class CRM_Core_IDS {
 
@@ -42,9 +42,9 @@ class CRM_Core_IDS {
   );
 
   /**
-   * The init object
+   * @var string
    */
-  private $init = NULL;
+  private $path;
 
   /**
    * Check function.
@@ -52,16 +52,17 @@ class CRM_Core_IDS {
    * 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;
     }
 
@@ -159,6 +160,7 @@ class CRM_Core_IDS {
     exceptions[]        = instructions
     exceptions[]        = suggested_message
     exceptions[]        = page_text
+    exceptions[]        = details
 ";
     if (file_put_contents($configFile, $contents) === FALSE) {
       CRM_Core_Error::movedSiteError($configFile);
@@ -186,7 +188,7 @@ class CRM_Core_IDS {
     $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']) {
@@ -248,21 +250,18 @@ class CRM_Core_IDS {
   }
 
   /**
-   * 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";