Skip to content

Commit 4ad9532

Browse files
authored
Merge pull request #92 from stacknil/stacknil/parser-handler-registry
refactor(parser): add handler registry
2 parents d33cbd9 + dce6a22 commit 4ad9532

25 files changed

Lines changed: 1498 additions & 1142 deletions

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ All notable user-visible changes should be recorded here.
1717

1818
### Changed
1919

20+
- Refactored parser internals into timestamp, source-envelope, program-dispatch,
21+
program-handler, and failure-classifier modules behind the unchanged
22+
`AuthLogParser` interface.
2023
- Detector rules now emit separate findings for time-separated detection
2124
episodes within the same rule subject instead of collapsing each subject to a
2225
single best window.

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ set(CMAKE_CXX_EXTENSIONS OFF)
99
add_library(loglens_lib
1010
src/config.cpp
1111
src/parser.cpp
12+
src/parser/failure_classifier.cpp
13+
src/parser/pam_handlers.cpp
14+
src/parser/program_dispatch.cpp
15+
src/parser/source_envelope_parser.cpp
16+
src/parser/sshd_handlers.cpp
17+
src/parser/su_handlers.cpp
18+
src/parser/sudo_handlers.cpp
19+
src/parser/text_utils.cpp
20+
src/parser/timestamp_parser.cpp
1221
src/signal.cpp
1322
src/detector.cpp
1423
src/report.cpp

docs/parser-conformance-matrix.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Parser Conformance Matrix
22

33
This matrix documents the parser behavior that LogLens currently treats as
4-
reviewable contract surface. It is derived from `src/parser.cpp`,
4+
reviewable contract surface. It is derived from `src/parser.cpp`, the internal
5+
`src/parser/` handler registry,
56
`src/event.hpp`, `tests/test_parser.cpp`, and the checked-in parser fixture
67
corpus.
78

docs/parser-contract.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,24 @@ Recognized success or audit families include accepted password, accepted publick
4747

4848
This is the main trust boundary: unsupported input should remain inspectable, even when it does not produce a finding.
4949

50+
## Internal parsing pipeline
51+
52+
`AuthLogParser` remains the single public parser interface. Its implementation
53+
is split into internal modules with one-way flow:
54+
55+
1. `timestamp_parser` parses the selected input mode's timestamp and hostname.
56+
2. `source_envelope_parser` extracts the program tag, optional pid, and raw message.
57+
3. `program_dispatch` selects a registered `sshd`, PAM, `sudo`, or `su` handler.
58+
4. The selected handler either emits a normalized event or returns a structured
59+
failure result.
60+
5. `failure_classifier` assigns malformed-source and unsupported-pattern
61+
telemetry without turning unsupported evidence into an event.
62+
63+
All registered program handlers return the same internal result shape:
64+
`matched`, optional `event`, `failure_category`, and `reason`. The registry and
65+
handler modules are implementation details; callers continue to depend only on
66+
`AuthLogParser`, `Event`, and the parser telemetry contract.
67+
5068
Parser failure categories are intentionally coarser than unknown-pattern
5169
buckets:
5270

0 commit comments

Comments
 (0)