Skip to content

Commit

Permalink
filterx/modules/cef: add parse_cef light test
Browse files Browse the repository at this point in the history
Signed-off-by: shifter <shifter@axoflow.com>
  • Loading branch information
bshifter committed Oct 5, 2024
1 parent b552918 commit 2cbffa0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/light/functional_tests/filterx/test_filterx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2338,3 +2338,31 @@ def test_startswith_endswith_includes(config, syslog_ng):

assert "processed" not in file_false.get_stats()
assert file_true.read_log() == '{"startswith_foo":true,"contains_bar":true,"endswith_baz":true,"works_with_message_value":true}\n'


def test_parse_cef(config, syslog_ng):
(file_true, file_false) = create_config(
config, r"""
custom_message = "CEF:0|KasperskyLab|SecurityCenter|13.2.0.1511|KLPRCI_TaskState|Completed successfully|1|foo=foo\\=bar bar=bar\\=baz baz=test";
$MSG = json(parse_cef(custom_message));
""",
)
syslog_ng.start(config)

assert file_true.get_stats()["processed"] == 1
assert "processed" not in file_false.get_stats()
exp = (
r"""{"version":"0","""
r""""deviceVendor":"KasperskyLab","""
r""""deviceProduct":"SecurityCenter","""
r""""deviceVersion":"13.2.0.1511","""
r""""deviceEventClassId":"KLPRCI_TaskState","""
r""""name":"Completed successfully","""
r""""agentSeverity":"1","""
r""""extensions":{"""
r""""foo":"foo=bar","""
r""""bar":"bar=baz","""
r""""baz":"test"}"""
r"""}""" + "\n"
)
assert file_true.read_log() == exp

0 comments on commit 2cbffa0

Please sign in to comment.