Skip to content

Commit 0bd8c9d

Browse files
author
risto
committed
version 2.8.2
1 parent be072e0 commit 0bd8c9d

6 files changed

Lines changed: 89 additions & 15 deletions

File tree

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
--- version 2.8.2
2+
3+
* added support for 'varset' action.
4+
5+
* fixed a bug where reference to $:{cacheentry:varname} match variable
6+
for non-existing pattern match cache entry would create an empty entry.
7+
8+
19
--- version 2.8.1
210

311
* fixed a bug in dump file creation routine (a perl warning message was

README

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SEC (Simple Event Correlator) 2.8.1
1+
SEC (Simple Event Correlator) 2.8.2
22

33
Introduction:
44
-------------
@@ -17,15 +17,15 @@ wide variety of other ways.
1717
Availability:
1818
-------------
1919
This program is distributed under the terms of GNU General Public License,
20-
and can be downloaded from http://simple-evcorr.github.io
20+
and can be downloaded from https://simple-evcorr.github.io
2121

2222
Release Notes:
2323
--------------
2424
SEC has been tested primarily on Linux and Solaris, but since it is written
2525
in Perl and does not use any platform dependent subroutines, it should also
2626
work on other OS platforms.
2727
Because SEC is not tested against ancient Perl releases, it is recommended
28-
to run SEC with at least Perl 5.8 (see http://www.perl.org for the latest
28+
to run SEC with at least Perl 5.8 (see https://www.perl.org for the latest
2929
stable release).
3030
SEC uses Perl Getopt, POSIX, Fcntl, Socket, IO::Handle, and Sys::Syslog
3131
modules which are included in the standard Perl installation (the presence

contrib/suse.startup

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# and its symbolic link
55
# /(usr/)sbin/rcsec
66
#
7-
# LSB compatible service control script; see http://www.linuxbase.org/spec/
7+
# LSB compatible service control script; see https://www.linuxbase.org/spec/
88
# Contributed by Malcolm J Lewis <malcolmlewis@opensuse.org>
99
#
1010
### BEGIN INIT INFO

contrib/suse.sysconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## Description: Simple Event Correlator Configuration File
2-
## URL: http://simple-evcorr.sourceforge.net/
2+
## URL: https://simple-evcorr.github.io
33
## License: GPL-2.0
44
## Modified by Malcolm J Lewis <malcolmlewis@opensuse.org>
55
## Path: System/sec

sec

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/perl -w
22
#
3-
# SEC (Simple Event Correlator) 2.8.1 - sec
4-
# Copyright (C) 2000-2018 Risto Vaarandi
3+
# SEC (Simple Event Correlator) 2.8.2 - sec
4+
# Copyright (C) 2000-2019 Risto Vaarandi
55
#
66
# This program is free software; you can redistribute it and/or
77
# modify it under the terms of the GNU General Public License
@@ -179,8 +179,8 @@ $WIN32 = ($^O =~ /win/i && $^O !~ /cygwin/i && $^O !~ /darwin/i);
179179

180180
# set version and usage variables
181181

182-
$SEC_VERSION = "SEC (Simple Event Correlator) 2.8.1";
183-
$SEC_COPYRIGHT = "Copyright (C) 2000-2018 Risto Vaarandi";
182+
$SEC_VERSION = "SEC (Simple Event Correlator) 2.8.2";
183+
$SEC_COPYRIGHT = "Copyright (C) 2000-2019 Risto Vaarandi";
184184

185185
$SEC_USAGE = qq!Usage: $0 [options]
186186
@@ -325,6 +325,7 @@ use constant REWRITE => 51;
325325
use constant ADDINPUT => 52;
326326
use constant DROPINPUT => 53;
327327
use constant SIGEMUL => 54;
328+
use constant VARIABLESET => 55;
328329
use constant IF => 100;
329330
use constant WHILE => 101;
330331
use constant BREAK => 102;
@@ -867,7 +868,7 @@ sub analyze_action {
867868
my($actionlist, @action);
868869
my($actionlist2, @action2);
869870
my($createafter, $event, $timestamp);
870-
my($lifetime, $context, $alias);
871+
my($lifetime, $context, $alias, $entry);
871872
my($variable, $value, $code, $codeptr, $params, $evalok, $op);
872873

873874
if ($action =~ /^none$/i) { return NONE; }
@@ -1559,6 +1560,28 @@ sub analyze_action {
15591560
return (SIGEMUL, $signal);
15601561
}
15611562

1563+
elsif ($action =~ /^varset\s+(\S+)\s+(\S+)$/i) {
1564+
1565+
$variable = $1;
1566+
$entry = $2;
1567+
process_action_parens($entry);
1568+
1569+
if ($variable !~ /^%[[:alpha:]]\w*$/) {
1570+
log_msg(LOG_ERR, "Rule in $conffile at line $lineno:",
1571+
"Variable $variable does not have the form",
1572+
"%<letter>[<letter>|<digit>|<underscore>]...");
1573+
return INVALIDVALUE;
1574+
}
1575+
1576+
if (!length($entry)) {
1577+
log_msg(LOG_ERR, "Rule in $conffile at line $lineno:",
1578+
"Empty pattern match cache entry name given for varset action");
1579+
return INVALIDVALUE;
1580+
}
1581+
1582+
return (VARIABLESET, substr($variable, 1), $entry);
1583+
}
1584+
15621585
elsif ($action =~ /^if\s/i) {
15631586

15641587
$value = EXPRSYMBOL;
@@ -6439,6 +6462,27 @@ sub execute_sigemul_action {
64396462
return 2;
64406463
}
64416464

6465+
sub execute_varset_action {
6466+
6467+
my($actionlist, $text, $i) = @_;
6468+
my($entry, $variable, $value);
6469+
6470+
$variable = $actionlist->[$i+1];
6471+
$entry = $actionlist->[$i+2];
6472+
6473+
substitute_actionlist_var($entry, $text);
6474+
6475+
log_msg(LOG_DEBUG,
6476+
"Checking the presence of pattern match cache entry '$entry'");
6477+
6478+
$value = (exists($pmatch_cache{$entry}))?1:0;
6479+
$variables{$variable} = $value;
6480+
6481+
log_msg(LOG_DEBUG, "Variable '%$variable' set to '$value'");
6482+
6483+
return 3;
6484+
}
6485+
64426486
sub execute_if_action {
64436487

64446488
my($actionlist, $text, $i) = @_;
@@ -7442,12 +7486,16 @@ sub subst_string {
74427486

74437487
} else {
74447488

7489+
# calling defined($pmatch_cache{$4}->{$+}) will create $pmatch_cache{$4}
7490+
# if it doesn't exist, thus exists($pmatch_cache{$4}) is called first
7491+
74457492
$msg =~ s/$token2(?:$token2|([0-9]+)|\{([0-9]+)\}|
74467493
\+\{([[:alpha:]_][\w!]*|[0-9]+)\}|
74477494
:\{([[:alpha:]]\w*):([[:alpha:]_][\w!]*|[0-9]+)\})/
74487495
!defined($+)?$token:
7449-
(!defined($4)?(defined($subst_ref->{$+})?$subst_ref->{$+}:"")
7450-
:(defined($pmatch_cache{$4}->{$+})?$pmatch_cache{$4}->{$+}:""))/egx;
7496+
(!defined($4)?(defined($subst_ref->{$+})?$subst_ref->{$+}:""):
7497+
((exists($pmatch_cache{$4}) && defined($pmatch_cache{$4}->{$+}))?
7498+
$pmatch_cache{$4}->{$+}:""))/egx;
74517499
}
74527500
}
74537501

@@ -9565,6 +9613,11 @@ sub actionlist2str {
95659613
$i += 2;
95669614
}
95679615

9616+
elsif ($actionlist->[$i] == VARIABLESET) {
9617+
$result .= "varset %" . $actionlist->[$i+1] . " " . $actionlist->[$i+2];
9618+
$i += 3;
9619+
}
9620+
95689621
elsif ($actionlist->[$i] == IF) {
95699622
$result .= "if %" . $actionlist->[$i+1] . " (";
95709623
if (scalar(@{$actionlist->[$i+2]})) {
@@ -13386,6 +13439,7 @@ $actioncopyfunc[REWRITE] = \&copy_three_elem_action;
1338613439
$actioncopyfunc[ADDINPUT] = \&copy_four_elem_action;
1338713440
$actioncopyfunc[DROPINPUT] = \&copy_two_elem_action;
1338813441
$actioncopyfunc[SIGEMUL] = \&copy_two_elem_action;
13442+
$actioncopyfunc[VARIABLESET] = \&copy_three_elem_action;
1338913443
$actioncopyfunc[IF] = \&copy_if_action;
1339013444
$actioncopyfunc[WHILE] = \&copy_while_action;
1339113445
$actioncopyfunc[BREAK] = \&copy_one_elem_action;
@@ -13446,6 +13500,7 @@ $actionsubstfunc[REWRITE] = \&subst_three_elem_action;
1344613500
$actionsubstfunc[ADDINPUT] = \&subst_four_elem_action;
1344713501
$actionsubstfunc[DROPINPUT] = \&subst_two_elem_action;
1344813502
$actionsubstfunc[SIGEMUL] = \&subst_two_elem_action;
13503+
$actionsubstfunc[VARIABLESET] = \&subst_event_assign_etc_action;
1344913504
$actionsubstfunc[IF] = \&subst_if_action;
1345013505
$actionsubstfunc[WHILE] = \&subst_while_action;
1345113506
$actionsubstfunc[BREAK] = \&subst_none_break_continue;
@@ -13506,6 +13561,7 @@ $execactionfunc[REWRITE] = \&execute_rewrite_action;
1350613561
$execactionfunc[ADDINPUT] = \&execute_addinput_action;
1350713562
$execactionfunc[DROPINPUT] = \&execute_dropinput_action;
1350813563
$execactionfunc[SIGEMUL] = \&execute_sigemul_action;
13564+
$execactionfunc[VARIABLESET] = \&execute_varset_action;
1350913565
$execactionfunc[IF] = \&execute_if_action;
1351013566
$execactionfunc[WHILE] = \&execute_while_action;
1351113567
$execactionfunc[BREAK] = \&execute_break_action;

sec.man

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\"
2-
.\" SEC (Simple Event Correlator) 2.8.1 - sec.man
3-
.\" Copyright (C) 2000-2018 Risto Vaarandi
2+
.\" SEC (Simple Event Correlator) 2.8.2 - sec.man
3+
.\" Copyright (C) 2000-2019 Risto Vaarandi
44
.\"
55
.\" This program is free software; you can redistribute it and/or
66
.\" modify it under the terms of the GNU General Public License
@@ -16,7 +16,7 @@
1616
.\" along with this program; if not, write to the Free Software
1717
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1818
.\"
19-
.TH sec 1 "October 2018" "SEC 2.8.1"
19+
.TH sec 1 "June 2019" "SEC 2.8.2"
2020
.SH NAME
2121
sec \- simple event correlator
2222
.SH SYNOPSIS
@@ -2764,6 +2764,16 @@ HUP, ABRT, USR1, USR2, INT, or TERM. For example, the action
27642764
triggers the generation of SEC dump file. See the SIGNALS section for
27652765
detailed information on signals that are handled by SEC.
27662766
.TP
2767+
.I varset %<var> <entry>
2768+
If the pattern match cache entry <entry> exists, set the action list variable
2769+
%<var> to 1, otherwise set %<var> to 0. For example, if pattern match cache
2770+
contains the entry with the name SSH but not the entry with the name NTP,
2771+
the action
2772+
.I varset %ssh SSH
2773+
will set the %ssh action list variable to 1, while the action
2774+
.I varset %ntp NTP
2775+
will set the %ntp action list variable to 0.
2776+
.TP
27672777
.I if %<var> ( <action list> ) [ else ( <action list2> ) ]
27682778
If the action list variable %<var> evaluates true in the Perl boolean context
27692779
(i.e., it holds a defined value which is neither 0 nor empty string), execute

0 commit comments

Comments
 (0)