syslog2cef 0.2.0__tar.gz → 0.2.1__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.2.0/syslog2cef.egg-info → syslog2cef-0.2.1}/PKG-INFO +1 -1
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/pyproject.toml +1 -1
- {syslog2cef-0.2.0 → syslog2cef-0.2.1/syslog2cef.egg-info}/PKG-INFO +1 -1
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslog2cef.egg-info/SOURCES.txt +2 -1
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslogcef/dictionary.py +9 -5
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslogcef/mappings/__init__.py +1 -1
- syslog2cef-0.2.1/tests/test_zipapp_safe.py +47 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/LICENSE +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/README.md +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/setup.cfg +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslog2cef.egg-info/dependency_links.txt +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslog2cef.egg-info/entry_points.txt +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslog2cef.egg-info/requires.txt +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslog2cef.egg-info/top_level.txt +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslogcef/__init__.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslogcef/__main__.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslogcef/adaptive.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslogcef/api.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslogcef/cef.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslogcef/cli.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslogcef/custom.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslogcef/dictionary.json +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslogcef/mappings/cisco_asa.json +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslogcef/mappings/cisco_ios.json +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslogcef/mappings/f5.json +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslogcef/mappings/fortinet.json +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslogcef/mappings/linux.json +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslogcef/mappings/sophos.json +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslogcef/mappings/vmware.json +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslogcef/net.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslogcef/normalizer.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslogcef/parsers.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslogcef/utils.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/syslogcef/validation.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/tests/test_adaptive.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/tests/test_cef.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/tests/test_cli.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/tests/test_custom_parsers.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/tests/test_dictionary.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/tests/test_fuzz_grammar.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/tests/test_fuzz_properties.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/tests/test_net.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/tests/test_normalizer.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/tests/test_parsers.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/tests/test_parsers_extra.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/tests/test_pipeline.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/tests/test_real_world.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/tests/test_utils.py +0 -0
- {syslog2cef-0.2.0 → syslog2cef-0.2.1}/tests/test_validation.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "syslog2cef"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.1"
|
|
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"
|
|
@@ -21,18 +21,22 @@ from __future__ import annotations
|
|
|
21
21
|
|
|
22
22
|
import json
|
|
23
23
|
from functools import lru_cache
|
|
24
|
-
from
|
|
24
|
+
from importlib import resources
|
|
25
25
|
from typing import Dict, FrozenSet, Tuple
|
|
26
26
|
|
|
27
|
-
_DICTIONARY_PATH = Path(__file__).parent / "dictionary.json"
|
|
28
|
-
|
|
29
27
|
|
|
30
28
|
@lru_cache(maxsize=1)
|
|
31
29
|
def _load() -> dict:
|
|
32
|
-
|
|
30
|
+
# importlib.resources, not a filesystem path: the package also runs
|
|
31
|
+
# from the standalone zipapp, where package files are inside the
|
|
32
|
+
# archive and Path(__file__)-style access fails (mappings/__init__.py
|
|
33
|
+
# uses the same mechanism for the same reason).
|
|
34
|
+
with resources.files("syslogcef").joinpath("dictionary.json").open(
|
|
35
|
+
"r", encoding="utf-8"
|
|
36
|
+
) as fp:
|
|
33
37
|
data = json.load(fp)
|
|
34
38
|
if not isinstance(data.get("keys"), dict) or not isinstance(data.get("aliases"), dict):
|
|
35
|
-
raise ValueError(
|
|
39
|
+
raise ValueError("dictionary.json: expected 'keys' and 'aliases' objects")
|
|
36
40
|
return data
|
|
37
41
|
|
|
38
42
|
|
|
@@ -17,7 +17,7 @@ __all__ = [
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def _load(name: str) -> Mapping[str, Any]:
|
|
20
|
-
with resources.files(
|
|
20
|
+
with resources.files("syslogcef.mappings").joinpath(f"{name}.json").open("r", encoding="utf-8") as fp:
|
|
21
21
|
return json.load(fp)
|
|
22
22
|
|
|
23
23
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""The package must work when imported from inside a zip archive.
|
|
2
|
+
|
|
3
|
+
The release workflow ships a standalone zipapp (.pyz). Any package data
|
|
4
|
+
read via a filesystem path (Path(__file__)...) works from a normal
|
|
5
|
+
install but raises NotADirectoryError inside the archive — exactly the
|
|
6
|
+
failure that broke the v0.2.0 zipapp build when dictionary.json was
|
|
7
|
+
first added. This test zips the package and converts a line through it,
|
|
8
|
+
so every package-data access path is exercised under zipimport.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import subprocess
|
|
14
|
+
import sys
|
|
15
|
+
import zipfile
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
|
|
18
|
+
PACKAGE_DIR = Path(__file__).resolve().parent.parent / "syslogcef"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def test_convert_line_works_under_zipimport(tmp_path: Path):
|
|
22
|
+
archive = tmp_path / "app.zip"
|
|
23
|
+
with zipfile.ZipFile(archive, "w") as zf:
|
|
24
|
+
for path in sorted(PACKAGE_DIR.rglob("*")):
|
|
25
|
+
if path.is_file() and "__pycache__" not in path.parts:
|
|
26
|
+
zf.write(path, Path("syslogcef") / path.relative_to(PACKAGE_DIR))
|
|
27
|
+
|
|
28
|
+
# A fresh interpreter with ONLY the zip on sys.path: dictionary,
|
|
29
|
+
# mappings, and every other package-data file must load from inside
|
|
30
|
+
# the archive. Exercise kv aliasing + validation so both data files
|
|
31
|
+
# are actually read.
|
|
32
|
+
code = (
|
|
33
|
+
"import sys; sys.path.insert(0, sys.argv[1]); "
|
|
34
|
+
"from syslogcef import convert_line; "
|
|
35
|
+
"cef = convert_line('srcip=10.0.0.1 dstip=10.0.0.2 action=x', validate=True); "
|
|
36
|
+
"assert cef.startswith('CEF:0|'), cef; "
|
|
37
|
+
"print('ZIPAPP_OK')"
|
|
38
|
+
)
|
|
39
|
+
result = subprocess.run(
|
|
40
|
+
[sys.executable, "-c", code, str(archive)],
|
|
41
|
+
capture_output=True,
|
|
42
|
+
text=True,
|
|
43
|
+
timeout=60,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
assert result.returncode == 0, f"stderr: {result.stderr[-800:]}"
|
|
47
|
+
assert "ZIPAPP_OK" in result.stdout
|
|
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
|