Architecture¶
toledot is a command-line tool and a Python library with the same core. Reading files needs one runtime dependency beyond the Python standard library: faithful-core, the shared foundation library of the Faithful Oversight tools, pinned to an exact version. Remote collection and the secret providers use optional dependencies, installed as extras.
domain controller ──► PowerShell collector ──┐
├──► collection file header, events, trailer with SHA-256
WinRM ──► toledot collect ───────────────────┘
│
.evtx, XML, JSON, CSV exports ─────────────────────────┤
▼
formats detect each file's format from its first bytes;
a reader yields Event, Problem, and LogFacts items
│
▼
events catalog ──► correlate build the Account: changes, notices, coverage, problems
(data/events.toml) │
▼
outputs one report document, rendered as JSON, Markdown, HTML, CSV,
plus a manifest
│
▼
cli arguments, file writing, exit codes
Both collectors write the same collection file. Nothing after the readers knows which format an event came from.
The pipeline¶
pipeline.runhashes every input file with SHA-256 and detects its format withformats.detect. It refuses a file it cannot read, a file in no known format, and two files with the same contents. It does this for every file before it parses any of them.formats.readruns the reader for each format. A reader is a function from a file and the read options to a stream of items:Event: one Windows event, with its values as text, and aSourcethat says the file and position.Problem: a record or part of a file that could not be read. A problem never stops the rest of the file.LogFacts: what a collector recorded about a log when it read it. Only the collection file reader yields these.
correlate.buildconsumes the streams. It looks each event up in the catalog, files logon events by computer and logon ID, keeps the other events, and counts what it read. It then joins events into changes, links each change to its logon session, and works out coverage. It returns anAccount.outputs.build_reportturns theAccountinto one report document, a plain dictionary. The renderers for JSON, Markdown, HTML, and CSV read only that dictionary.outputs.write_reportswrites the files and a manifest.cliprints a summary and returns an exit code.
Modules¶
Module |
Responsibility |
|---|---|
|
The command-line interface, exit codes, and the |
|
|
|
The one shape every format is read into: |
|
One reader for each input format: |
|
Load and strictly validate |
|
Hash and detect each file, then read them all and build the account. |
|
Turn events into the |
|
The records |
|
The plain sentences for changes, origins, and coverage. |
|
Build the report document, render each format, and write the files all together. |
|
|
|
The synthetic collection files for the |
|
The event catalog |
|
JSON Schemas for the report, the collection file, and the manifest. |
The event catalog¶
data/events.toml is the one place that knows what an event means. It holds each event’s field names for each schema version, which fields play which role (who did it, to what, from where), the label and kind of each changed attribute, and the labels the English message text uses. It also holds the %%NNNN codes, the logon types, both account control flag layouts, and the well-known SIDs and RIDs.
Every entry names a source page and carries a confirmed flag. catalog refuses a catalog that is malformed in any way. It never uses one partly, because a wrong field name in an audit tool is worse than a missing one.
Three things read the catalog:
The JSON and CSV readers use it to name values that their formats lose, through
ReadOptions.correlateuses it to find each role in an event and to word each detail.The PowerShell collector asks for exactly the events in the catalog. A test keeps the script’s list in step with the catalog.
The collect package¶
Module |
Responsibility |
|---|---|
|
Registers |
|
Checks each line the controller sends, and its end line, in a private file. It also builds the script’s parameters and the result, and hands the connection to faithful-core. |
|
Names the packaged PowerShell script and reads it through faithful-core. |
Both collection paths run the same script, so there is one format to read and one script to review. See Collecting events.
Rules the design follows¶
Separation. Readers handle input,
correlateis logic, andoutputshandles output.correlatenever reads files or prints.One shape. Every format is read into the same
Event, so nothing after the readers depends on the format.A problem is a result. A record that cannot be read becomes a
Problemin the report, and the account is incomplete. It is never skipped silently.Say no more than the events say. When an event does not record something, the report says so and does not guess. An origin that cannot be linked is
not in the input, never a guess.One report document. Every format is rendered from the same document, so the formats cannot disagree.
A versioned contract. The report, the collection file, and the manifest follow published JSON Schemas. See Reports and output for the compatibility promise.
No prompts. The tool never asks questions interactively, so it runs unchanged in scripts and pipelines.
Structured exit codes.
0success and a complete account,1an account not shown to be complete,2usage error,3input, output, or collection error, and4internal error. Any exception that is not aToledotErrorends in exit code4, with a message that says it is a bug. This keeps a crash apart from a result.Careful output. Report files are complete before they appear, are never overwritten without
--force, and are swapped in with rollback on failure. A manifest of file hashes, written last, makes any partial or mixed set detectable.Read-only. The collector reads event logs and writes only its own file. The tool does not change the systems it examines.
Offline analysis.
toledot reportreads files and writes reports. It never touches the network. Onlytoledot collectdoes, and only when you run it. ADR 5 records that exception.
Packaging¶
Python package on PyPI:
faithful-toledot, with the commandtoledot. Its one runtime dependency isfaithful-core, pinned to an exact version.Extras:
live(pypsrp),keyring,vault,aws, andazure. See the README.Further formats, such as a standalone executable or a container image, are added only when a decision record justifies them.
Decisions¶
Significant decisions are recorded in architecture decision records.