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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to

### Added

- Add field-level assertions to deserialization tests ([cbea4fc], [#26])
- Add 34 edge-case and validation tests covering missing fields, null values,
empty strings, boundary integers, malformed datetimes/decimals, and nested
validation ([1ca6e4d], [#33])
Expand Down Expand Up @@ -152,6 +153,7 @@ and this project adheres to
<!-- Commit links -->

[b66a6f5]: https://github.com/LeakIX/l9format-python/commit/b66a6f5
[cbea4fc]: https://github.com/LeakIX/l9format-python/commit/cbea4fc
[3547e22]: https://github.com/LeakIX/l9format-python/commit/3547e22
[1ca6e4d]: https://github.com/LeakIX/l9format-python/commit/1ca6e4d
[0d8736e]: https://github.com/LeakIX/l9format-python/commit/0d8736e
Expand Down Expand Up @@ -218,6 +220,7 @@ and this project adheres to
[#18]: https://github.com/LeakIX/l9format-python/pull/18
[#21]: https://github.com/LeakIX/l9format-python/issues/21
[#22]: https://github.com/LeakIX/l9format-python/issues/22
[#26]: https://github.com/LeakIX/l9format-python/issues/26
[#27]: https://github.com/LeakIX/l9format-python/issues/27
[#33]: https://github.com/LeakIX/l9format-python/issues/33
[#25]: https://github.com/LeakIX/l9format-python/issues/25
Expand Down
46 changes: 44 additions & 2 deletions tests/test_l9format.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,56 @@ def test_l9event_json_from_reference_repository():
path = TESTS_DIR / "l9event.json"
with open(path) as f:
c = json.load(f)
L9Event.from_dict(c)
event = L9Event.from_dict(c)
assert event.event_type == "leak"
assert event.event_source == "DotEnvConfigPlugin"
assert event.ip == "127.0.0.1"
assert event.port == "8080"
assert event.host == "site1.example.com"
assert event.reverse == "ptr1.example.com"
assert event.protocol == "https"
assert event.summary == "GET /... qwerqwer"
assert event.http.root == "/site1"
assert event.http.url == "/site1/.env"
assert event.http.status == 200
assert event.http.length == 12423
assert event.http.title == "Apache welcome page"
assert event.ssl.detected is True
assert event.ssl.enabled is True
assert event.ssl.version == "TLSv1.3"
assert event.ssl.certificate.cn == "example.com"
assert event.ssl.certificate.key_algo == "RSA"
assert event.ssl.certificate.key_size == 2048
assert event.service.software.name == "Apache"
assert event.service.software.version == "2.2.4"
assert event.service.credentials.noauth is True
assert event.leak.stage == "open"
assert event.leak.type == "configuration"
assert event.leak.severity == "medium"
assert event.leak.dataset.rows == 4
assert event.leak.dataset.files == 1
assert event.network.asn == 0
assert event.tags == ["plc"]
assert event.transport == ["tcp", "tls", "http"]
assert event.event_pipeline == [
"ip4scout",
"l9tcpid",
"l9explore",
"DotEnvConfigPlugin",
]


def test_l9events_from_ip4scout():
for path in IP4SCOUT_FILES:
with open(path) as f:
c = json.load(f)
L9Event.from_dict(c)
event = L9Event.from_dict(c)
assert event.event_source == "ip4scout"
assert event.event_type == "synack"
assert isinstance(event.ip, str)
assert len(event.ip) > 0
assert isinstance(event.port, str)
assert len(event.port) > 0


def test_iso8601_nanosecond_parsing():
Expand Down