Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ and this project adheres to

## [Unreleased]

### Changed

- Re-export all public models from `__init__.py` and define `__all__`
([1dcfbef], [#21])
- Tests now import from `l9format` package directly instead of
`l9format.l9format` ([e8aef2e], [#21])

## [1.4.0] - 2026-02-07

### Added
Expand Down Expand Up @@ -125,6 +132,8 @@ and this project adheres to

<!-- Commit links -->

[1dcfbef]: https://github.com/LeakIX/l9format-python/commit/1dcfbef
[e8aef2e]: https://github.com/LeakIX/l9format-python/commit/e8aef2e
[8f45e82]: https://github.com/LeakIX/l9format-python/commit/8f45e82
[82245e9]: https://github.com/LeakIX/l9format-python/commit/82245e9
[fac243d]: https://github.com/LeakIX/l9format-python/commit/fac243d
Expand Down Expand Up @@ -183,3 +192,4 @@ and this project adheres to
[#15]: https://github.com/LeakIX/l9format-python/pull/15
[#16]: https://github.com/LeakIX/l9format-python/pull/16
[#18]: https://github.com/LeakIX/l9format-python/pull/18
[#21]: https://github.com/LeakIX/l9format-python/issues/21
66 changes: 66 additions & 0 deletions l9format/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,67 @@
__version__ = "1.4.0"

from l9format.l9format import (
Certificate,
DatasetSummary,
GeoLocation,
GeoPoint,
L9Aggregation,
L9AMQPEvent,
L9DNSEvent,
L9Event,
L9FTPEvent,
L9HttpEvent,
L9LDAPEvent,
L9LeakEvent,
L9MemcachedEvent,
L9MongoDBEvent,
L9MySQLEvent,
L9PostgreSQLEvent,
L9RDPEvent,
L9RedisEvent,
L9RTSPEvent,
L9ServiceEvent,
L9SIPEvent,
L9SMTPEvent,
L9SSHEvent,
L9SSLEvent,
L9TelnetEvent,
L9VNCEvent,
Network,
ServiceCredentials,
Software,
SoftwareModule,
)

__all__ = [
"Certificate",
"DatasetSummary",
"GeoLocation",
"GeoPoint",
"L9Aggregation",
"L9AMQPEvent",
"L9DNSEvent",
"L9Event",
"L9FTPEvent",
"L9HttpEvent",
"L9LDAPEvent",
"L9LeakEvent",
"L9MemcachedEvent",
"L9MongoDBEvent",
"L9MySQLEvent",
"L9PostgreSQLEvent",
"L9RDPEvent",
"L9RedisEvent",
"L9RTSPEvent",
"L9ServiceEvent",
"L9SIPEvent",
"L9SMTPEvent",
"L9SSHEvent",
"L9SSLEvent",
"L9TelnetEvent",
"L9VNCEvent",
"Network",
"ServiceCredentials",
"Software",
"SoftwareModule",
]
48 changes: 44 additions & 4 deletions tests/test_l9format.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
from pathlib import Path

from l9format import l9format
from l9format import L9Event

TESTS_DIR = Path(os.path.dirname(__file__))

Expand All @@ -16,13 +16,13 @@
def test_l9event_json_from_reference_repository():
path = TESTS_DIR / "l9event.json"
c = json.load(open(str(path), "r"))
l9format.L9Event.from_dict(c)
L9Event.from_dict(c)


def test_l9events_form_ip4scout():
for path in IP4SCOUT_FILES:
c = json.load(open(str(path), "r"))
l9format.L9Event.from_dict(c)
L9Event.from_dict(c)


def test_iso8601_nanosecond_parsing():
Expand All @@ -36,10 +36,50 @@ def test_iso8601_nanosecond_parsing():
c = json.load(open(str(path), "r"))
# Use a timestamp with nanosecond precision (9 decimal places)
c["time"] = "2023-10-05T23:30:36.823867784Z"
event = l9format.L9Event.from_dict(c)
event = L9Event.from_dict(c)
assert event.time.year == 2023
assert event.time.month == 10
assert event.time.day == 5
assert event.time.hour == 23
assert event.time.minute == 30
assert event.time.second == 36


def test_all_models_importable_from_package():
"""Verify all public models are importable from the l9format package."""
import l9format

expected_models = [
"Certificate",
"DatasetSummary",
"GeoLocation",
"GeoPoint",
"L9Aggregation",
"L9AMQPEvent",
"L9DNSEvent",
"L9Event",
"L9FTPEvent",
"L9HttpEvent",
"L9LDAPEvent",
"L9LeakEvent",
"L9MemcachedEvent",
"L9MongoDBEvent",
"L9MySQLEvent",
"L9PostgreSQLEvent",
"L9RDPEvent",
"L9RedisEvent",
"L9RTSPEvent",
"L9ServiceEvent",
"L9SIPEvent",
"L9SMTPEvent",
"L9SSHEvent",
"L9SSLEvent",
"L9TelnetEvent",
"L9VNCEvent",
"Network",
"ServiceCredentials",
"Software",
"SoftwareModule",
]
for name in expected_models:
assert hasattr(l9format, name), f"{name} not importable from l9format"