Architecture¶
mishpat 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.
admin workstation or domain controller
Export-MishpatGpo.ps1 ──► export bundle header, file lines, structure, trailer with SHA-256
WinRM ──► mishpat collect ─┘ │
│
Get-GPOReport XML, Backup-GPO folders ───────────────┤
▼
pipeline fingerprint both inputs (size and SHA-256), refuse identical ones
│
▼
inputs detect each input's kind from its content; formats read it
formats into a Snapshot: GPOs, settings, links, scopes, and problems
│
▼
compare pair GPOs, compare each part, and say what was not compared
result: a Comparison (differences, gaps, problems, notices)
│
▼
outputs one report document, rendered as JSON, Markdown, HTML, CSV,
plus a manifest
│
▼
cli arguments, file writing, exit codes
The exporter and mishpat collect write the same bundle. Nothing after the readers knows which kind of input a GPO came from, except through what the input recorded.
The pipeline¶
pipeline.runreads the size and SHA-256 of both inputs, for a folder over the path and hash of every file in it, before it parses either. It refuses two inputs with the same contents.inputs.read_sidedetects the kind of each input from its content and calls the reader. A folder goes to the backup reader. A file that starts with the bundle marker goes to the bundle reader. Any other file goes to the report reader. Each reader returns GPOs and problems, and the result becomes aSnapshot.compare.comparepairs the GPOs of the two snapshots, compares each part of each pair, compares the structure of the domain when both sides have it, and returns aComparison. It adds a gap for everything that one side does not record.outputs.build_reportturns theComparisoninto 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 |
|
Argument types shared by the commands: bounded numbers. |
|
|
|
The plain data every reader produces: |
|
One reader for each kind of input: |
|
Detect the kind of an input and read it into a |
|
Fingerprint both inputs, read them, and compare them. |
|
Pair GPOs and compare them. No file access and no output. |
|
The records |
|
Build the report document, render each format, and write the files all together. |
|
|
|
The synthetic bundles for the |
|
The PowerShell exporter |
|
JSON Schemas for the report, the export bundle, and the manifest. |
The model¶
model is the one shape every input is read into. A Snapshot is one side of a comparison: the GPOs an input holds, the scopes of management when the input records them, and the problems it had.
The model keeps a difference between not captured and empty. A field that an input does not record is None: the links of a GPO from a backup without gpreport.xml, the permissions from a report that lacks them, the WMI filter as the text unknown, the scopes of a snapshot with no structure line. A field that an input records as empty is an empty list. compare never compares a None. It adds a gap that says what was not compared and why.
The readers¶
faithful_core.xmlsafeparses the XML forformats.reportandformats.backup, with the standard library’spyexpat. It refuses aDOCTYPEand entity declarations, limits nesting and size, and decodes the bytes itself, ignoring the declared encoding.formats.reportreadsGet-GPOReportXML. It identifies each element by its namespace URI and maps every extension to settings. Extensions it does not know are read generically.formats.registrypolreadsRegistry.polfiles.formats.backupreads backups through an abstractTree, so the same code reads a real folder (FolderTree) and the files of a bundle (MemoryTree).formats.bundlereads the export bundle strictly, places its files in aMemoryTree, and reads them with the backup reader. It turns the structure line into scopes and fills each GPO’s links and WMI filter query from it. It also holds the reference writer used by the example and the tests.
The comparison¶
compare.compare follows these rules. ADR 6 records why.
Pairing. GPOs pair by GUID, or by display name with
--match name.Identity. A setting’s identity is its scope, area, kind, and key, compared without regard to case. The key depends on the kind of setting.
Sets. Members of user rights, security filtering, and delegation entries are sorted. Policy options are keyed by name. A new order is not a change.
Gaps, not invented differences. Context that an input does not record is never compared. It becomes a gap.
Link order per scope. Order is compared among the GPOs linked on a scope in both inputs.
Whole domains. A GPO that is missing from one input is
removedoraddedonly when both inputs are whole domains. Otherwise it isonly-beforeoronly-after.Completeness. Only problems make a comparison incomplete.
The collect package¶
Module |
Responsibility |
|---|---|
|
Registers |
|
Checks each line the controller sends, its structure line, 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 exports.
Rules the design follows¶
Separation. Readers handle input,
compareis logic, andoutputshandles output.comparenever reads files or prints.One shape. Every kind of input is read into the same model, so nothing after the readers depends on the kind.
A problem is a result. An element or file part that cannot be read becomes a
Problemin the report, and the comparison is incomplete. It is never skipped silently.Unknowns are results. What an input does not record becomes a gap in the report. It is never a difference, and it is never a clean pass.
Say no more than the inputs say. The report states what changed, not what it means for a computer.
One report document. Every format is rendered from the same document, so the formats cannot disagree.
A versioned contract. The report, the export bundle, and the manifest follow published JSON Schemas with a version number. Breaking changes to a schema require a major release. See Reports and output.
No prompts. The tool never asks questions interactively, so it runs unchanged in scripts and pipelines.
Structured exit codes.
0success with no differences and nothing unread,1differences or an unread input as--fail-onsets,2usage error,3input, output, or collection error, and4internal error. Any exception that is not aMishpatErrorends 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 a partial set detectable, and so does a mixed set.Read-only. The exporter reads Group Policy and the directory and writes only its own file. The tool does not change the systems it examines.
Offline analysis.
mishpat comparereads files and writes reports. It never touches the network. Onlymishpat collectdoes, and only when you run it. ADR 5 records that exception.
Packaging¶
Python package on PyPI:
faithful-mishpat, with the commandmishpat. 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.