Skip to content

Commit bcdec3d

Browse files
author
David Gómez Matarrodona
committed
Timestamp processor bug fix
1 parent cb022aa commit bcdec3d

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"config" : {
3+
"datadir" : "/tmp/nsyslog",
4+
"input" : {"buffer" : 100}
5+
},
6+
7+
"inputs" : {
8+
"lines" : {
9+
"type" : "static",
10+
"config" : {
11+
"loop" : false,
12+
"lines" : [
13+
"<22>date=2021-09-23 time=15:44:16.257 device_id=FE200E3A17000421 log_id=0200015528 type=statistics pri=information session_id=\"18NDPAO7015527-18NDPAO8015527\" client_name=\"\" client_ip=\"10.6.66.201\" client_cc=\"ZZ\" dst_ip=\"10.6.67.2\" from=\"[email protected]\" hfrom=\"[email protected]\" to=\"[email protected]\" polid=\"7:1:3:museodelprado.es\" domain=\"museodelprado.es\" mailer=\"mta\" resolved=\"FAIL\" src_type=\"int\" direction=\"out\" virus=\"\" disposition=\"Accept\" classifier=\"Not Spam\" message_length=\"1748927\" subject=\"Sus entradas para el Museo del Prado\" message_id=\"[email protected]\" recv_time=\"\" notif_delay=\"0\" scan_time=\"0.081117\" xfer_time=\"1145.342651\" srcfolder=\"\" read_status=\"\""
14+
]
15+
}
16+
}
17+
},
18+
19+
"processors" : {
20+
"syslog" : {
21+
"type" : "syslogparser",
22+
"config" : {}
23+
},
24+
"parser" : {
25+
"type" : "keyvalparser",
26+
"config" : {
27+
"input" : "${syslog.message.replace(/\\s+/g,' ')}",
28+
"output" : "out"
29+
}
30+
}
31+
},
32+
33+
"transporters" : {
34+
"console" : {
35+
"type" : "console",
36+
"config" : {
37+
"format" : "${JSON}",
38+
"input" : "${out}",
39+
"json" : {
40+
"format" : true,
41+
"spaces" : 2,
42+
"color" : true
43+
}
44+
}
45+
},
46+
"null" : {
47+
"type" : "null"
48+
}
49+
},
50+
51+
"flows" : [
52+
{"id":"flow1", "from":"lines", "fork":false, "processors":["syslog","parser"], "transporters":"console"}
53+
]
54+
}

lib/processor/keyvalparser.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,13 @@ if(module.parent) {
8383
else {
8484
//let data = `action:"Accept"; flags:"149764"; ifdir:"inbound"; ifname:"LAN1.4"; loguid:"{0x5ee6ba3c,0x0,0xe820927f,0xc0000000}"; origin:"10.75.204.241"; time:"1592179260"; version:"1"; __policy_id_tag:"product=VPN-1 & FireWall-1[db_tag={7F5BAF71-1C9F-6240-8EC3-1FCB20EED4F1};mgmt=mngfw02;date=1586162511;policy_name=standard_pro\]"; dst:"10.75.8.101"; inzone:"Internal"; origin_sic_name:"CN=FW-POZOBLANCO,O=mngfw02..9xvz8g"; outzone:"External"; product:"VPN-1 & FireWall-1"; proto:"17"; rule:"77"; rule_uid:"{7D7D774C-2582-4D15-9A26-AE43D8EE3AD7}"; s_port:"63181"; service:"53"; service_id:"domain-udp"; src:"10.75.204.35";`;
8585
//let data = `<189>date=2018-11-24 time=22:52:16 devname="FW-C67-1" devid="FG1K5D3I15803580" logid="0201009233" type="utm" subtype="virus" eventtype="analytics" level="information" vd="root" eventtime=1543096336 msg="File submitted to Sandbox." action="analytics" service="HTTP" sessionid=797348764 srcip=10.67.2.34 dstip=136.243.166.107 srcport=4103 dstport=80 srcintf="PRO_WEB" srcintfrole="undefined" dstintf="C67-FOM" dstintfrole="undefined" policyid=267 proto=6 direction="incoming" filename="versions.dat.gz" url="http://upgrade.bitdefender.com/lightav32_47446/versions.dat.gz" profile="VIRUS_FS" agent="downloader" analyticscksum="6307e7a99e8598412eebf0f3ba392d6df065160c0eb26a35b7d32a7c2fad9c10" analyticssubmit="true"`;
86+
/*
8687
let data = `id=firewall sn=C0EAE483F254 time=\"2020-10-28 12:07:40\" fw=213.229.174.68 pri=6 c=262144 m=98 msg=\"Connection Opened\" n=4278644 usr=\"nicola.baldinelli\" src=172.16.0.52:52923:X1 dst=172.16.1.24:53:X0 proto=udp/dns vpnpolicy=\"WAN GroupVPN\"`;
8788
data = data.replace(/\s+/g,' ');
89+
*/
90+
91+
let data = `<22>date=2021-09-23 time=15:44:16.257 device_id=FE200E3A17000421 log_id=0200015528 type=statistics pri=information session_id="18NDPAO7015527-18NDPAO8015527" client_name="" client_ip="10.6.66.201" client_cc="ZZ" dst_ip="10.6.67.2" from="[email protected]" hfrom="[email protected]" to="[email protected]" polid="7:1:3:museodelprado.es" domain="museodelprado.es" mailer="mta" resolved="FAIL" src_type="int" direction="out" virus="" disposition="Accept" classifier="Not Spam" message_length="1748927" subject="Sus entradas para el Museo del Prado" message_id="[email protected]" recv_time="" notif_delay="0" scan_time="0.081117" xfer_time="1145.342651" srcfolder="" read_status=""`;
92+
data = data.replace(/\s+/g,' ');
8893
let keyval = new KeyValParserProcessor('test','keyval');
8994
keyval.configure({},()=>{});
9095
keyval.process({originalMessage:data},(err,res)=>{

lib/processor/timestamp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class TimestampProcessor extends Processor {
1313
this.config = extend({},config);
1414

1515
this.input = this.config.input? jsexpr.expr(this.config.input) : null;
16-
this.format = this.config.format || null;
16+
this.format = this.config.format || undefined;
1717
this.field = jsexpr.assign(this.config.field || this.config.output || "timestamp");
1818
this.unix = this.config.unix || false;
1919
callback();

0 commit comments

Comments
 (0)