#!/usr/bin/perl
#
# Copyright (C) 2011-2015 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.  

use strict;
use warnings;

use DateTime;

#-------------------------------------------------------------------------------
# Warden 2.2. Client, Sender, Example 
#
# Sample script using warden-client sending functionality. This example is not
# intended to be a standalone script. It only shows how to use warden-client
# functionality.
#-------------------------------------------------------------------------------

#-------------------------------------------------------------------------------
# Preparation of event attributes.
# This should be handled by detection application.


my $local_detected = DateTime->from_epoch(epoch => time());


my $service 		= "test";
my $detected 		= "$local_detected";
my $type 		= "portscan";
my $source_type 	= "IP";
my $source 		= "123.123.123.123";
my $target_proto 	= "TCP";
my $target_port 	= "22";
my $attack_scale 	= "1234567890";
my $note 		= "important note or comment";
my $priority 		= 1;
my $timeout 		= 20;

my @event 		= ($service, $detected, $type, $source_type, $source,
			   $target_proto, $target_port, $attack_scale, $note,
			   $priority, $timeout );

#-------------------------------------------------------------------------------
# Use of warden-client sender.
# This code should developer add to his/her detection application
# (with corresponding paths appropriately changed).

# Path to warden-client folder
my $warden_path = '/opt/warden-client';

# Inclusion of warden-client sender module
require $warden_path . '/lib/WardenClient.pm';

# Sending event to Warden server
for (my $i = 0; $i < 10; $i++) {
  print "Sending $i-st event on server\n";
  WardenClient::saveNewEvent(\@event);
  }

exit 0;