Skip to content

Commit

Permalink
feat: create semperis dsp parser (#2259)
Browse files Browse the repository at this point in the history
* feat: create semperis dsp parser

* add parsing of strange message body

* create pluggable module for semperis
  • Loading branch information
ikheifets-splunk authored Nov 14, 2023
1 parent 945ee6a commit 72f35c2
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docs/sources/vendor/Semperis/DSP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Semperis DSP

## Key facts

* MSG Format based filter


## Links

| Ref | Link |
|----------------|---------------------------------------------------------------------------------------------------------|
| Splunk Add-on | None |

## Sourcetypes

| sourcetype | notes |
|-----------------|---------------------------------------------------------------------------------------------------------|
| semperis:dsp | none |

## Sourcetype and Index Configuration

| key | sourcetype | index | notes |
|-----------------|----------------|--------|----------------|
| semperis_dsp | semperis:dsp | netops | None |
35 changes: 35 additions & 0 deletions package/etc/conf.d/conflib/syslog/app-syslog-semperis_dsp.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
block parser app-syslog-semperis_dsp() {
channel {
rewrite {
r_set_splunk_dest_default(
index("netops")
sourcetype("semperis:dsp")
vendor("semperis")
product("dsp")
template("t_kv_values")
);
};

parser {
regexp-parser(
template("${MESSAGE}")
prefix(".tmp.")
patterns('\[(?<message>.*)')
);
kv-parser(
prefix(".values.")
pair-separator("[")
value-separator("]")
template("${.tmp.message}")
);
};
};
};


application app-syslog-semperis_dsp[sc4s-syslog-pgm] {
filter {
program('Semperis.DSP' type(string) flags(ignore-case,prefix));
};
parser { app-syslog-semperis_dsp(); };
};
2 changes: 2 additions & 0 deletions package/lite/etc/addons/semperis/addon_metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
name: "semperis"
35 changes: 35 additions & 0 deletions package/lite/etc/addons/semperis/app-syslog-semperis_dsp.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
block parser app-syslog-semperis_dsp() {
channel {
rewrite {
r_set_splunk_dest_default(
index("netops")
sourcetype("semperis:dsp")
vendor("semperis")
product("dsp")
template("t_kv_values")
);
};

parser {
regexp-parser(
template("${MESSAGE}")
prefix(".tmp.")
patterns('\[(?<message>.*)')
);
kv-parser(
prefix(".values.")
pair-separator("[")
value-separator("]")
template("${.tmp.message}")
);
};
};
};


application app-syslog-semperis_dsp[sc4s-syslog-pgm] {
filter {
program('Semperis.DSP' type(string) flags(ignore-case,prefix));
};
parser { app-syslog-semperis_dsp(); };
};
1 change: 1 addition & 0 deletions package/lite/etc/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,4 @@ addons:
- wallix
- thycotic
- tim
- semperis
48 changes: 48 additions & 0 deletions tests/test_semperis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2023 Splunk, Inc.
#
# Use of this source code is governed by a BSD-2-clause-style
# license that can be found in the LICENSE-BSD2 file or at
# https://opensource.org/licenses/BSD-2-Clause
import shortuuid
import pytest
from jinja2 import Environment, select_autoescape

from .sendmessage import sendsingle
from .splunkutils import splunk_single
from .timeutils import time_operations
import datetime

env = Environment(autoescape=select_autoescape(default_for_string=False))


@pytest.mark.addons("semperis")
def test_semperis(record_property, setup_splunk, setup_sc4s):
host = f"{shortuuid.ShortUUID().random(length=5).lower()}-{shortuuid.ShortUUID().random(length=5).lower()}"

dt = datetime.datetime.now()
iso, bsd, time, date, tzoffset, _, epoch = time_operations(dt)

# Tune time functions
epoch = epoch[:-7]

mt = env.from_string(
'{{ mark }} {{ bsd }} {{ host }} Semperis.DSP [AdChanges@51802] [ForestId] 1111 [ChangeId] 1111 [PartitionNamingContext] DC=corpcert,DC=heb,DC=com [DistinguishedName] CN=krbtgt,CN=Users,DC=corpcert,DC=heb,DC=com [ClassName] user [AttributeName] msDS-SupportedEncryptionTypes [ObjectModificationType] ModifyObject [AttributeModificationType] Modify [LinkedValueDN] [ValidUntil] {{ iso }} [OriginatingServer] {{ host }} [OriginatingTime] {{ iso }} [OriginatingUsers] [OriginatingUserWorkstations] [StringValueFrom] 327680 [StringValueTo] 327680 '
)

message = mt.render(mark="<110>", bsd=bsd, host=host, date=date, time=time, iso=iso)
sendsingle(message, setup_sc4s[0], setup_sc4s[1][514])

st = env.from_string(
'search _time={{ epoch }} index=netops host={{ host }} sourcetype="semperis:dsp"'
)
search = st.render(
epoch=epoch, bsd=bsd, host=host, date=date, time=time, tzoffset=tzoffset
)

result_count, _ = splunk_single(setup_splunk, search)

record_property("host", host)
record_property("resultCount", result_count)
record_property("message", message)

assert result_count == 1

0 comments on commit 72f35c2

Please sign in to comment.