Skip to content

Commit

Permalink
fix: update any IP fields using inet6_ntop() #5207
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarchand authored and laf committed Dec 29, 2016
1 parent c257332 commit 8352a3a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 7 additions & 0 deletions alerts.php
Expand Up @@ -185,6 +185,13 @@ function RunFollowUp()
$alert['query'] = GenSQL($alert['rule']);
}
$chk = dbFetchRows($alert['query'], array($alert['device_id']));
//make sure we can json_encode all the datas later
$cnt = count($chk);
for ($i = 0; $i < $cnt; $i++) {
if (isset($chk[$i]['ip'])) {
$chk[$i]['ip'] = inet6_ntop($chk[$i]['ip']);
}
}
$o = sizeof($alert['details']['rule']);
$n = sizeof($chk);
$ret = 'Alert #'.$alert['id'];
Expand Down
7 changes: 5 additions & 2 deletions includes/alerts.inc.php
Expand Up @@ -171,8 +171,11 @@ function RunRules($device)
}
$sql = $rule['query'];
$qry = dbFetchRows($sql, array($device));
if (isset($qry[0]['ip'])) {
$qry[0]['ip'] = inet6_ntop($qry[0]['ip']);
$cnt = count($qry);
for ($i = 0; $i < $cnt; $i++) {
if (isset($qry[$i]['ip'])) {
$qry[$i]['ip'] = inet6_ntop($qry[$i]['ip']);
}
}
$s = sizeof($qry);
if ($s == 0 && $inv === false) {
Expand Down

0 comments on commit 8352a3a

Please sign in to comment.