mirror of
https://github.com/yogeshojha/rengine.git
synced 2026-10-20 15:21:30 +02:00
a548afffa2e43ccc0bc7bbe7c2bb09dd424711b2
5
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
2cb8d73280 |
style: strip explanatory comments across the codebase
The comment rule in CLAUDE.md is one line maximum, never narration: no multi-line blocks, no module-header explainers, no sentences that explain or justify the code to the reader. The tree had drifted a long way from it, and most of the drift is mine. Removed: 232 lines of multi-line comment blocks 203 single-line comments that argued instead of stating 154 comments joined by so/because/otherwise/rather-than 143 narrating comments in the frontend 112 test docstrings (the test name already says what it asserts) 25 test module docstrings and 25 decorative section dividers Collapsed: 324 multi-line docstrings to one factual line 271 one-line docstrings that had a justifying clause bolted on Kept: functional directives, section dividers, short field labels, alembic revision headers, and the eight FastAPI route docstrings that render in /docs. Where a fact was load-bearing it is in CLAUDE.md, which is where it belongs. 284 python tests and 34 frontend tests pass, ruff and ruff-format clean across ten packages, svelte-check 0 errors, prettier and eslint clean, app.main imports. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013dKUV96WkQQETZBMoAG98C |
||
|
|
2c9d922bc8 |
feat(reports): a lighter document, and a running head that is not against the paper's edge
The first cut was rejected outright, and fairly. Four things were wrong. The running head and foot sat 1.4mm from the physical sheet: vertical-align:top on the @top-* margin boxes pins text to the paper, not to the text block. They now hang off the block with RUNNING_CLEAR of air on the inside edge. Severity was five saturated hues, restated by every theme and slightly different in each. It is now one reserved ramp defined once, light rather than heavy, with lightness carrying the rank so it survives deuteranopia; it clears the CVD and normal-vision floors all-pairs on white paper. A dark page picks up the dark restep automatically, so a dark theme carries no severity block at all. shared/utils/color.py converts through OKLCH, so a theme names one colour and the document derives the wash a badge sits on and the ink that sits on the wash — every badge clears 7:1, including one from a theme a user uploads. Badges are pills, never saturated slabs, and never inline-flex, which WeasyPrint lays out as a block so the badge stretched its whole column. Mono is for machine values now — hostnames, evidence, hashes. Labels, table headers and the running head are the body face, and uppercase_labels finally does something: the CSS had hard-coded uppercase and ignored the token. Prose fills the text column, justified and hyphenated, instead of sitting in a narrow measure with dead space beside it. Chapters still start a new page, but a document may now ask them to run on, and the page estimate knows the difference: 52 pages against 52, and 48 against 48. Two defects the redesign surfaced: the risk summary never passed the variables its own template reads, so that severity table had always printed empty; and the standalone HTML export had no margins at all, because @page geometry does not apply on screen. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AW5pitnosX8LEFEYxH8gFS |
||
|
|
068f14bbfb |
feat(reports): the document says its answer before you open it
A design pass over the rendered documents, on the six themes, the print stylesheet, the charts and the cover artwork. The brief was a baseline that looked templated; the bar was a client deliverable someone would be proud to hand over. The structural failure was the severity chart. On a real scan, 589 informational findings swamped 20 criticals into an invisible sliver, on the one page everyone reads. Severity counts are now stat tiles, so the number is always legible, and the ring and bar draw only the actionable set with the informational total stated in the caption. That is the dataviz rule that a dominant neutral bucket is a KPI, not a slice. The executive page now opens with a verdict band: the gauge, the headline, the severity tiles, then five surface figures in one row, and only then the prose at a readable measure. Every cover carries a grade mark, so the report tells you its answer on the front; on blueprint the reticle artwork is drawn around it. Findings are a card with a hierarchy and a facts row where a table used to be, control mapping is a line of text per framework rather than a wall of chips, tables have a settled rhythm, and the section number sits in the accent. The warning collector from the previous commit found every WeasyPrint defect here. font-weight accepts only the hundreds, so two themes had been rendering headings in a silent bold. content(text) drops the whitespace between an inline span and its neighbour, so the running header read "1Executive summary" and the bookmark with it; both now read a precomputed attribute. break-after: avoid on a div is not honoured, so labels were orphaning from their content. A dark-paper theme needs its background on @page as well as html, or the margins print white, which is why noir had a white frame. word-break: break-word is invalid, and the hostname column in the asset table was being crushed to a sliver by auto layout. Two string edits in this pass silently missed because ruff had reformatted the target; reading the function back after each edit is now written down. Verified on the gov.cy scan: all 26 sections in all six themes, 57 to 60 pages each, zero renderer warnings. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017f2Mf2HGwFaTRnui4UxpRd |
||
|
|
0522444245 |
feat(reports): white-labelling, and a renderer that cannot be made to fetch
Uploaded typefaces and instance-wide branding defaults, which together make a report genuinely white-labellable: a client's own font, a logo set once, and a theme that names both. The security half came first, because the logo field was a live SSRF. It was a free-text string rendered into an <img src>, and WeasyPrint would have fetched whatever it pointed at from inside the worker. Nothing fetches now, at four layers. The load-bearing one is a WeasyPrint url_fetcher that allows data: URIs and files under three known roots and refuses everything else; it was checked against cloud metadata, internal https, loopback, /etc/passwd, a UNC host, ftp and protocol-relative references. Above it sit three input guards: a logo must be embedded data of a known image type, an uploaded theme may not use @import or a url() that is not data:, and authored markdown loses any image that is not embedded. A new feature that lets a report name a resource goes through the fetcher, not around it. A typeface is bytes, never a link. The family row records files named by us, so a hostile filename never reaches disk, and the family directory refuses anything resolving outside itself. A face is accepted only when the bytes agree: the signature is sniffed and then fontTools opens it and requires outlines, which is why fonttools is now an api dependency rather than only a WeasyPrint one. A 5-byte file with a valid TTF header and a 4 KB file of padding are both refused. The family name is banned from carrying quotes or braces because it is written into a quoted CSS font-family string. The standalone HTML export now embeds only the families the theme actually names, which halves it, and no longer carries file:// references that would have been dead outside the container. Instance defaults fill only what a template leaves blank, so setting a logo once never overrides a per-client deliverable that set its own. Verified: a real TTF family uploaded and embedded in a 53-page PDF under an uploaded theme with an uploaded logo, and every probe above refused. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017f2Mf2HGwFaTRnui4UxpRd |
||
|
|
424e6d6e23 |
feat(reports): a document engine, not an export
reNgine 2 could produce a PDF. This produces a deliverable, and it is built the way scan engines are built: sections are plug-and-play directories under reports/, each with a pydantic config model that IS the source of truth. That model feeds GET /reports/catalog, the builder renders its own form from it, and the API validates against it. Adding a section is a directory. Scan Engine is to stages what Report Template is to sections. WeasyPrint 69 renders it, chosen over Chromium and Typst after measuring what each can actually do. Only real CSS Paged Media gives a table of contents with true page numbers, running headers, a PDF outline and footnotes; SysReptor reaches the same verdict and pipes Chromium's HTML into WeasyPrint for exactly that reason. reNgine drops the Chromium hop because it templates in Jinja and draws its charts as SVG in Python, so a browser buys nothing and costs 400 MB per report. Typst was rejected because a user-uploadable theme would then have to be Typst code rather than CSS. A theme is data. shared/definitions/report_theme.py is the schema, six themes ship as YAML, and a user uploads their own; there is no markup in a theme, so there is no injection surface. Fonts are vendored so an offline instance still renders in Latin, Greek and Cyrillic. Everything the document claims is computed once, in reports/analysis/engine.py: a posture score whose every deduction is named, weaknesses ranked by the signals behind the rank rather than severity alone, attack paths that chain observations into a route, a remediation plan ordered by risk removed, per-dimension change against the previous run, and caveats that state what was never assessed. Two narrators read that one brief. Without AI the report still argues its case; with AI the prose is better and the model never sees a row, only the brief, capped and cached per check. An AI failure falls back and the report still completes. Generation is a job. POST /reports queues, the worker walks progress over SSE, and four formats come out of one render: PDF, self-contained HTML, Markdown and JSON. The estimate reads each section's own limits, so the page count it promises is close to the one it delivers. AI moves out of Settings into its own top-level page: connection, a model per tier, what it may be used for, what it has cost, and the narrative cache. Verified on a 1,379-host gov.cy scan: 124 pages in 19.5s across 19 sections, all six themes, and a broken key still producing a complete report. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017f2Mf2HGwFaTRnui4UxpRd |