Skip to content

Commit

Permalink
Fix wrong field notation in dpluger output
Browse files Browse the repository at this point in the history
  • Loading branch information
mmta committed Nov 4, 2018
1 parent f57bc7c commit 4c9f26e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 25 deletions.
5 changes: 5 additions & 0 deletions internal/pkg/dpluger/dpluger.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ func createPluginCollect(plugin Plugin, confFile, creator string, validate bool)
pt.Creator = creator
pt.SIDField = getLogstashFieldNotation(
strings.Replace(plugin.Fields.Title, "collect:", "", 1))
pt.SIDField = "%{" + pt.SIDField + "}"
pt.CreateDate = time.Now().Format(time.RFC3339)
transformToLogstashField(&pt.P.Fields)

Expand Down Expand Up @@ -269,6 +270,10 @@ func transformToLogstashField(fields *FieldMapping) {
if t := getType(str); t == ftES {
// convert to logstash [field][subfield] notation
v = getLogstashFieldNotation(str)
// do this except for timestamp, as it is only used in date filter
if typeOfT.Field(i).Name != "Timestamp" {
v = "%{" + v + "}"
}
} else {
v = str
}
Expand Down
8 changes: 4 additions & 4 deletions internal/pkg/dpluger/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ filter {
# the rest should be the same as nonCollect plugin
date {
match => [ "{{.P.Fields.Timestamp}}", "{{.P.Fields.TimestampFormat}}" ]
target => "[timestamp]"
target => [timestamp]
}
mutate {
add_field => {
replace => {
"title" => "{{.SIDField}}"
"src_index_pattern" => "{{.P.Index}}"
"sensor" => "{{.P.Fields.Sensor}}"
Expand Down Expand Up @@ -114,7 +114,7 @@ filter {
# delete fields except those included in the whitelist below
prune {
whitelist_names => [ "@metadata", "src_index_pattern", "title", "sensor", "product",
whitelist_names => [ "timestamp", "@metadata", "src_index_pattern", "title", "sensor", "product",
"src_ip", "dst_ip", "plugin_id", "plugin_sid", "category", "subcategory",
"src_port", "dst_port", "protocol", "custom_label1", "custom_label2", "custom_label3",
"custom_data1", "custom_data2", "custom_data3" ]
Expand Down Expand Up @@ -190,7 +190,7 @@ filter {
if [@metadata][siem_plugin_type] == "{{.P.Name}}" {
date {
match => [ "{{.P.Fields.Timestamp}}", "{{.P.Fields.TimestampFormat}}" ]
target => "[timestamp]"
target => [timestamp]
}
mutate {
replace => {
Expand Down
40 changes: 19 additions & 21 deletions test/dpluger/70_siem-plugin-suricata.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# Dsiem suricata Plugin
# Type: SID
#
# Auto-generated by dpluger on 2018-10-30T19:35:27+07:00
# Auto-generated by dpluger on 2018-11-04T17:07:28+07:00
###############################################################################

filter {

# 1st step: identify the source log and clone it to another event with type => siem_events

if [application] == "suricata" and [alert]) {
if [application] == "suricata" and [alert] {
clone {
clones => [ "siem_events" ]
}
Expand Down Expand Up @@ -61,23 +61,23 @@ filter {
if [@metadata][siem_plugin_type] == "suricata" {
date {
match => [ "[timestamp]", "ISO8601" ]
target => "[timestamp]"
target => [timestamp]
}
mutate {
add_field => {
"title" => "[alert][signature]"
replace => {
"title" => "%{[alert][signature]}"
"src_index_pattern" => "suricata-*"
"sensor" => "[host][name]"
"sensor" => "%{[host][name]}"
"product" => "Intrusion Detection System"
"src_ip" => "[src_ip]"
"dst_ip" => "[dest_ip]"
"protocol" => "[proto]"
"category" => "[alert][category]"
"src_ip" => "%{[src_ip]}"
"dst_ip" => "%{[dest_ip]}"
"protocol" => "%{[proto]}"
"category" => "%{[alert][category]}"

"plugin_id" => "1001"
"plugin_sid" => "[alert][signature_id]"
"src_port" => "[src_port]"
"dst_port" => "[dest_port]"
"plugin_sid" => "%{[alert][signature_id]}"
"src_port" => "%{[src_port]}"
"dst_port" => "%{[dest_port]}"

}
}
Expand All @@ -92,13 +92,11 @@ filter {
}

# delete fields except those included in the whitelist below
filter {
prune {
whitelist_names => [ "@metadata", "src_index_pattern", "title", "sensor", "product",
"src_ip", "dst_ip", "plugin_id", "plugin_sid", "category", "subcategory",
"src_port", "dst_port", "protocol", "custom_label1", "custom_label2", "custom_label3",
"custom_data1", "custom_data2", "custom_data3" ]
}
}
prune {
whitelist_names => [ "timestamp", "@metadata", "src_index_pattern", "title", "sensor", "product",
"src_ip", "dst_ip", "plugin_id", "plugin_sid", "category", "subcategory",
"src_port", "dst_port", "protocol", "custom_label1", "custom_label2", "custom_label3",
"custom_data1", "custom_data2", "custom_data3" ]
}
}
}

0 comments on commit 4c9f26e

Please sign in to comment.