feat(audit): render a report you can send to whoever runs the router - #6
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 2b. The terminal report answers "what is wrong here" for the person who ran it. This answers it for the person they forward it to - a housemate, a landlord, whoever actually administers the router. That reader will not run the tool, so the file has to carry the whole lesson with it.
netdiff audit 192.168.1.0/24 --html report.htmlwrites one self-contained file. No server, no assets, no network, no JavaScript. Progressive disclosure is native<details>/<summary>- the same ladder as the terminal, headline collapsed and the lesson one click away. Scripted show/hide would be a dependency, a bug surface, and a thing that breaks when the file is emailed through something that strips scripts.It is
audit --html, not a standalonereportcommand.store.record_findingsdeliberately persists onlyrule/severity/device/title/evidence- the lesson text lives inaudit.RULESand is formatted at render time with context ({port},{external_port},{control_url}) that was never stored. A report built from history could therefore only show the lesson with its placeholders blanked. Rendering from the audit you just ran gets full fidelity for a fraction of the code, and leaves the "improve an explanation and it improves everywhere" property intact.Escaping
This is the second place in the codebase where untrusted strings become a language other than Python. The first was the
verifycommands, where an unquoted value became shell - fixed in #3. Device names, banners, mDNS labels and the router's own description of a port forward all reach this page, so every interpolation goes throughesc()withquote=True, andtests/test_report.pyputs a hostile value through each of the five finding fields.severityis the only value landing inside an attribute, and it is safe because it comes from the rule table rather than the network. There is a test pinning that set closed, so if a rule ever grows a free-form severity the quoting becomes load-bearing and this fails first.