Skip to content

Commit

Permalink
fix issue where strtotime does not work in php7 and carbon should be …
Browse files Browse the repository at this point in the history
…used anyways

fix issue where ticket mode did not work because the switch/case was misplaced

fix issue where ticket selection was using a wrong WHERE clause
  • Loading branch information
kruisdraad committed Jan 5, 2017
1 parent 218af62 commit 04bf433
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 23 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "abuseio/collector-rbl",
"description": "Collector addon for handling notifications from RBL lists",
"version": "1.3.2",
"version": "1.3.3",
"keywords": ["laravel", "abuseio", "parser", "rbl"],
"homepage": "http://abuse.io",
"type": "library",
Expand Down
52 changes: 30 additions & 22 deletions src/Rbl.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use AbuseIO\Models\Incident;
use Validator;
use AbuseIO\Models\Ticket;
use Carbon;

/**
* Class Rbl
Expand Down Expand Up @@ -37,7 +38,7 @@ class Rbl extends Collector
* @var array
*/
protected $allowedMethods = [
'dns' => false,
'dns' => true,
'file' => true,
];

Expand Down Expand Up @@ -146,24 +147,24 @@ public function parse()
} else {
continue;
}
}

switch($mode) {
case "asns":
$this->scanAsn($config);
break;
case "netblocks":
$this->scanNetblock($config);
break;
case "ipaddresses":
$this->scanAddresses($config);
break;
case "tickets":
$this->scanTickets();
break;
}

switch($mode) {
case "asns":
$this->scanAsn($config);
break;
case "netblocks":
$this->scanNetblock($config);
break;
case "ipaddresses":
$this->scanAddresses($config);
break;
case "tickets":
$this->scanTickets();
break;
}


return $this->success();
}

Expand Down Expand Up @@ -263,9 +264,9 @@ private function scanAddresses($addresses)
*/
private function scanTickets()
{
$tickets = Ticket::where('status_id', '!=', '2')->get();
$tickets = Ticket::where('status_id', '=', 'OPEN');

foreach ($tickets as $ticket) {
foreach ($tickets->get() as $ticket) {
$this->scanAddress($ticket->ip);
}

Expand All @@ -280,6 +281,12 @@ private function scanTickets()
*/
private function scanAddress($address)
{
/*
* today's timestamp used as report time (today 00:00) to prevent a lot of duplicates on the
* same day. Using the same time will aggregate and deduplicate events into 1 per day.
*/


if (!filter_var($address, FILTER_VALIDATE_IP) === false) {
$addressReverse = implode('.', array_reverse(preg_split('/\./', $address)));

Expand Down Expand Up @@ -311,11 +318,13 @@ private function scanAddress($address)
$incident->domain = false;
$incident->class = $feedData['class'];
$incident->type = $feedData['type'];

/*
* This prevents multiple incidents on the same day. So info
* blob has a scan time and this a report time
* today's timestamp used as report time (today 00:00) to prevent a lot of duplicates on the
* same day. Using the same time will aggregate and deduplicate events into 1 per day.
*/
$incident->timestamp = strtotime('0:00');
$incident->timestamp = Carbon::today();

$incident->information = json_encode(
array_merge(
$feedData['information'],
Expand All @@ -326,7 +335,6 @@ private function scanAddress($address)
);

$this->incidents[] = $incident;

}
}
}
Expand Down

0 comments on commit 04bf433

Please sign in to comment.