signal created_at fix (includes code)

Created on 13 January 2023, over 1 year ago
Updated 16 January 2023, over 1 year ago

Problem/Motivation

The Signal's created_at should be the datetime of the alert and not the datetime of the push

CrowdSec SDK has been updated:
* creation of Watcher function buildSignal //more flexible than createSignal
* creation of Watcher function buildSimpleSignalForIp // for basic signals (see code bellow)
* deprecation of createSignal helper function

Code evolutions in crowdsec/src/Buffer.php

Because it's faster for this first interaction than to push the code (my account is allowed no fork yet):

// in addSignal(...)
// ...
 $now = (new \DateTime('now', new \DateTimeZone('UTC')))->format('Y-m-d\TH:i:s.u\Z');

    $signals[] = [
      'scenario' => $scenario,
      'ip' => $ip,
      'duration' => $duration,
      'created_at' => $now,
    ];
// ...
// in push()
// ...
 try {
        $pushSignals[] = buildSimpleSignalForIp(
          $signal['ip'],
          $signal['scenario'],
          new DateTime($signal['created_at']),
          '',
          $signal['duration']
        );
      }
      catch (ClientException $e) {
// ...
πŸ“Œ Task
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡«πŸ‡·France rr404

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024