Skip to content

Commit e7ecda7

Browse files
committed
Ensure that if present the HTTP_X_FORWARDED_FOR IP address is used instead of the SERVER_ADDR when logging items from the IDS
Update Core IP address to match IDS Pattern
1 parent 6bc0781 commit e7ecda7

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

CRM/Core/IDS.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,8 @@ public function react(IDS_Report $result) {
247247
* @return bool
248248
*/
249249
private function log($result, $reaction = 0) {
250-
$ip = (isset($_SERVER['SERVER_ADDR']) &&
251-
$_SERVER['SERVER_ADDR'] != '127.0.0.1') ? $_SERVER['SERVER_ADDR'] : (
252-
isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : '127.0.0.1'
253-
);
250+
// Include X_FORWARD_FOR ip address if set as per IDS patten.
251+
$ip = $_SERVER['REMOTE_ADDR'] . (isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? ' (' . $_SERVER['HTTP_X_FORWARDED_FOR'] . ')' : '');
254252

255253
$data = [];
256254
$session = CRM_Core_Session::singleton();

0 commit comments

Comments
 (0)