syslog2cef 0.3.1__tar.gz → 0.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {syslog2cef-0.3.1/syslog2cef.egg-info → syslog2cef-0.3.2}/PKG-INFO +1 -1
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/pyproject.toml +1 -1
- {syslog2cef-0.3.1 → syslog2cef-0.3.2/syslog2cef.egg-info}/PKG-INFO +1 -1
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslogcef/cef.py +8 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslogcef/mappings/linux.json +1 -1
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslogcef/parsers.py +7 -1
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/tests/test_macos_logs.py +50 -10
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/tests/test_real_world.py +19 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/LICENSE +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/README.md +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/setup.cfg +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslog2cef.egg-info/SOURCES.txt +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslog2cef.egg-info/dependency_links.txt +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslog2cef.egg-info/entry_points.txt +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslog2cef.egg-info/requires.txt +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslog2cef.egg-info/top_level.txt +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslogcef/__init__.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslogcef/__main__.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslogcef/adaptive.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslogcef/api.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslogcef/cli.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslogcef/custom.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslogcef/dictionary.json +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslogcef/dictionary.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslogcef/mappings/__init__.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslogcef/mappings/cisco_asa.json +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslogcef/mappings/cisco_ios.json +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslogcef/mappings/f5.json +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslogcef/mappings/fortinet.json +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslogcef/mappings/sophos.json +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslogcef/mappings/vmware.json +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslogcef/net.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslogcef/normalizer.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslogcef/utils.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/syslogcef/validation.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/tests/test_adaptive.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/tests/test_cef.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/tests/test_cli.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/tests/test_cli_validation.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/tests/test_custom_parsers.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/tests/test_dictionary.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/tests/test_fuzz_grammar.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/tests/test_fuzz_properties.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/tests/test_net.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/tests/test_normalizer.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/tests/test_parsers.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/tests/test_parsers_extra.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/tests/test_pipeline.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/tests/test_rfc5424_epoch.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/tests/test_security_hardening.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/tests/test_tail_rotation.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/tests/test_utils.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/tests/test_validation.py +0 -0
- {syslog2cef-0.3.1 → syslog2cef-0.3.2}/tests/test_zipapp_safe.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "syslog2cef"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.2"
|
|
8
8
|
description = "Convert RFC3164/RFC5424 syslog lines into ArcSight CEF"
|
|
9
9
|
authors = [{name = "Tamir Suliman", email = "allamiro@gmail.com"}]
|
|
10
10
|
readme = "README.md"
|
|
@@ -28,6 +28,14 @@ DEFAULT_MAPPING = {
|
|
|
28
28
|
},
|
|
29
29
|
"extensions": {
|
|
30
30
|
"msg": "%(msg)s",
|
|
31
|
+
# The syslog HOSTNAME identifies the device that GENERATED the
|
|
32
|
+
# event, so it is the source host (shost) — never the destination
|
|
33
|
+
# (dhost), which is reserved for network-specific logs whose
|
|
34
|
+
# payload names an actual destination. shost (max 1023) rather
|
|
35
|
+
# than dvchost (max 100): RFC 5424 hostnames may reach 255 chars,
|
|
36
|
+
# which would fail --strict against dvchost's dictionary limit.
|
|
37
|
+
# Empty values are dropped, so this is a no-op for a hostless line.
|
|
38
|
+
"shost": "%(host)s",
|
|
31
39
|
# Event time (epoch milliseconds) parsed from the line, or the
|
|
32
40
|
# processing time when the line carried no usable timestamp.
|
|
33
41
|
"rt": "%(rt)s",
|
|
@@ -728,10 +728,16 @@ def autodetect_and_parse(line: str, *, mode: Optional[str] = None, now: Optional
|
|
|
728
728
|
("rsyslog_file", lambda s: bool(RSYSLOG_FILE_RE.match(s))),
|
|
729
729
|
("journald_iso", lambda s: bool(JOURNALCTL_ISO_RE.match(s))),
|
|
730
730
|
("iso_syslog", lambda s: bool(ISO_SYSLOG_RE.match(s))),
|
|
731
|
-
|
|
731
|
+
# Header-based parsers run BEFORE kv: a normal RFC3164/journald
|
|
732
|
+
# line whose *message* carries key=value pairs (containerd,
|
|
733
|
+
# dockerd, NetworkManager, ...) must be claimed by its syslog
|
|
734
|
+
# parser, not the kv format. Genuine kv streams (Fortinet, Sophos)
|
|
735
|
+
# start with date=/device= and match none of these headers, so
|
|
736
|
+
# they still fall through to kv.
|
|
732
737
|
("cisco_seq", lambda s: bool(CISCO_SEQ_RE.match(s))),
|
|
733
738
|
("journald_short", lambda s: bool(JOURNALCTL_SHORT_RE.match(s))),
|
|
734
739
|
("rfc3164", lambda s: bool(RFC3164_RE.match(s))),
|
|
740
|
+
("kv", lambda s: "=" in s[:80]),
|
|
735
741
|
]
|
|
736
742
|
|
|
737
743
|
from . import custom
|
|
@@ -101,9 +101,9 @@ class TestContinuationLines:
|
|
|
101
101
|
)
|
|
102
102
|
cont = conv.convert('\t "dsAttrTypeStandard:OperatingSystemVersion"')
|
|
103
103
|
closing = conv.convert("\t)")
|
|
104
|
-
assert "
|
|
104
|
+
assert "shost=MacBookPro" in first
|
|
105
105
|
for cef in (cont, closing):
|
|
106
|
-
assert "
|
|
106
|
+
assert "shost=MacBookPro" in cef
|
|
107
107
|
assert "sproc=opendirectoryd" in cef
|
|
108
108
|
assert "dvcpid=69" in cef
|
|
109
109
|
# Continuation lines carry the parent's event time.
|
|
@@ -123,7 +123,7 @@ class TestContinuationLines:
|
|
|
123
123
|
cont = conv.convert("\tindented continuation")
|
|
124
124
|
# Context still comes from the last *parsed* event, not the
|
|
125
125
|
# freeform fallback line.
|
|
126
|
-
assert "
|
|
126
|
+
assert "shost=MacBookPro" in cont
|
|
127
127
|
|
|
128
128
|
def test_indented_message_preserved(self):
|
|
129
129
|
conv = StreamConverter()
|
|
@@ -149,7 +149,7 @@ class TestPerSourceContext:
|
|
|
149
149
|
conv = StreamConverter()
|
|
150
150
|
conv.convert("May 28 16:04:52 MacBookPro opendirectoryd[69]: parent", source="a.log")
|
|
151
151
|
cef = conv.convert("\tindented start of another file", source="b.log")
|
|
152
|
-
assert "
|
|
152
|
+
assert "shost=MacBookPro" not in cef
|
|
153
153
|
|
|
154
154
|
def test_each_source_keeps_its_own_context(self):
|
|
155
155
|
conv = StreamConverter()
|
|
@@ -158,8 +158,8 @@ class TestPerSourceContext:
|
|
|
158
158
|
# Interleaved continuations inherit from their own file.
|
|
159
159
|
cef_a = conv.convert("\tcontinuation for A", source="a.log")
|
|
160
160
|
cef_b = conv.convert("\tcontinuation for B", source="b.log")
|
|
161
|
-
assert "
|
|
162
|
-
assert "
|
|
161
|
+
assert "shost=host-a" in cef_a and "sproc=appa" in cef_a
|
|
162
|
+
assert "shost=host-b" in cef_b and "sproc=appb" in cef_b
|
|
163
163
|
|
|
164
164
|
def test_process_lines_tags_sources(self):
|
|
165
165
|
from syslogcef.cli import process_lines
|
|
@@ -171,8 +171,8 @@ class TestPerSourceContext:
|
|
|
171
171
|
out = list(
|
|
172
172
|
process_lines(items, mode=None, mapping=None, use_multiprocessing=False, pool_size=None)
|
|
173
173
|
)
|
|
174
|
-
assert "
|
|
175
|
-
assert "
|
|
174
|
+
assert "shost=host-a" in out[0]
|
|
175
|
+
assert "shost=host-a" not in out[1]
|
|
176
176
|
|
|
177
177
|
|
|
178
178
|
class TestForcedModeContinuation:
|
|
@@ -182,8 +182,8 @@ class TestForcedModeContinuation:
|
|
|
182
182
|
conv = StreamConverter(mode="journald_short")
|
|
183
183
|
parent = conv.convert("May 28 16:04:52 MacBookPro opendirectoryd[69]: parent event")
|
|
184
184
|
cont = conv.convert("\t wrapped payload line")
|
|
185
|
-
assert "
|
|
186
|
-
assert "
|
|
185
|
+
assert "shost=MacBookPro" in parent
|
|
186
|
+
assert "shost=MacBookPro" in cont
|
|
187
187
|
assert "sproc=opendirectoryd" in cont
|
|
188
188
|
|
|
189
189
|
def test_forced_mode_still_rejects_non_continuations(self):
|
|
@@ -232,3 +232,43 @@ class TestDvcpidNumericOnly:
|
|
|
232
232
|
strict=True,
|
|
233
233
|
)
|
|
234
234
|
assert cef.startswith("CEF:0|")
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
class TestSyslogHostIsSource:
|
|
238
|
+
"""The syslog HOSTNAME is the device that generated the event, so it
|
|
239
|
+
maps to shost (source host), never dhost (destination). shost, not
|
|
240
|
+
dvchost: RFC 5424 hostnames can exceed dvchost's 100-char limit."""
|
|
241
|
+
|
|
242
|
+
def test_linux_mapping_host_is_shost_not_dhost(self):
|
|
243
|
+
from syslogcef import convert_line
|
|
244
|
+
|
|
245
|
+
cef = convert_line(
|
|
246
|
+
"<13>Aug 10 13:39:25 clay-wks-linux-15 kernel: docker0: port 1 entered blocking state"
|
|
247
|
+
)
|
|
248
|
+
assert "shost=clay-wks-linux-15" in cef
|
|
249
|
+
assert "dhost=" not in cef
|
|
250
|
+
assert "dvchost=" not in cef
|
|
251
|
+
|
|
252
|
+
def test_default_mapping_surfaces_host_as_source(self):
|
|
253
|
+
# Exercise DEFAULT_MAPPING directly: a minimal custom mapping with
|
|
254
|
+
# no extensions falls through to the default extension set, so the
|
|
255
|
+
# default's shost is what surfaces (mapping=None would route via
|
|
256
|
+
# _guess_mapping to the bundled LINUX mapping instead).
|
|
257
|
+
from syslogcef import convert_line
|
|
258
|
+
|
|
259
|
+
cef = convert_line(
|
|
260
|
+
"<13>Aug 10 13:39:25 gw-01 weirdproc: payload zzz",
|
|
261
|
+
mapping={"deviceVendor": "Acme", "deviceProduct": "Thing"},
|
|
262
|
+
)
|
|
263
|
+
assert "|Acme|Thing|" in cef # confirms the custom (default-based) mapping ran
|
|
264
|
+
assert "shost=gw-01" in cef
|
|
265
|
+
assert "dhost=" not in cef
|
|
266
|
+
|
|
267
|
+
def test_long_hostname_passes_strict(self):
|
|
268
|
+
# A 200-char hostname (valid per RFC 5424, > dvchost's 100 limit)
|
|
269
|
+
# must not fail --strict — which is why host maps to shost (1023).
|
|
270
|
+
from syslogcef import convert_line
|
|
271
|
+
|
|
272
|
+
host = "h" * 200
|
|
273
|
+
cef = convert_line(f"<13>Aug 10 13:39:25 {host} app: msg", strict=True)
|
|
274
|
+
assert f"shost={host}" in cef
|
|
@@ -75,6 +75,25 @@ def test_pri_survives_sophos_kv_line():
|
|
|
75
75
|
assert fields(cef)[6] == "2"
|
|
76
76
|
|
|
77
77
|
|
|
78
|
+
def test_rfc3164_with_kv_message_body_is_not_claimed_by_kv():
|
|
79
|
+
# An ordinary RFC3164/journald-short line whose message carries many
|
|
80
|
+
# key=value pairs (containerd, dockerd, ...) must be parsed by its
|
|
81
|
+
# syslog parser — host/app extracted, header stripped — not misread
|
|
82
|
+
# as the kv format (regression for the detector ordering, #102).
|
|
83
|
+
line = (
|
|
84
|
+
"Aug 10 13:44:31 clay-wks-linux-15 containerd[3749511]: "
|
|
85
|
+
'time="2026-08-10T13:44:31.216507070Z" level=info '
|
|
86
|
+
'msg="connecting to shim f6f0" address="unix:///run/x" '
|
|
87
|
+
"namespace=moby protocol=ttrpc version=3"
|
|
88
|
+
)
|
|
89
|
+
ev = parse_syslog(line)
|
|
90
|
+
assert ev.source_hint in {"rfc3164", "journald"}
|
|
91
|
+
assert ev.host == "clay-wks-linux-15"
|
|
92
|
+
assert ev.app == "containerd"
|
|
93
|
+
assert ev.pid == "3749511"
|
|
94
|
+
assert ev.msg.startswith("time=")
|
|
95
|
+
|
|
96
|
+
|
|
78
97
|
def test_pri_survives_raw_fallback():
|
|
79
98
|
line = "<30>completely nonstandard payload without structure"
|
|
80
99
|
ev = parse_syslog(line)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|