|
| 1 | +# 🛡️ Audit Report Generator |
| 2 | + |
| 3 | +A browser-based tool for composing, previewing, and exporting security audit reports. Upload structured Markdown issue files, edit them in a live preview, translate content, and export polished PDF or DOCX reports — all client-side with zero backend. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Drag & drop Markdown upload** — bulk-import `.md` issue files that follow the expected template |
| 8 | +- **Live preview** — WYSIWYG preview grouped by category with a navigable Table of Contents |
| 9 | +- **Inline editing** — click any field (title, description, code, severity, etc.) to edit in place |
| 10 | +- **Severity badges** — color-coded Critical / High / Medium / Low / Info indicators |
| 11 | +- **Code highlighting** — syntax-highlighted code blocks via [highlight.js](https://highlightjs.org/) |
| 12 | +- **AI translation** — translate individual fields or entire pages via OpenAI (requires API key; controls are disabled when the key is not set) |
| 13 | +- **Finding ID reindexing** — bulk-reindex IDs with a configurable prefix and category-based numbering |
| 14 | +- **PDF export** — pixel-perfect A4 PDF with clickable TOC links (html2canvas + jsPDF) |
| 15 | +- **DOCX export** — structured Word document with TOC, bookmarks, and styled tables (docx + file-saver) |
| 16 | +- **Markdown export** — download individual issues back as `.md` files |
| 17 | +- **Bulk Markdown download** — download all issues (with edits) as a single `.zip` archive |
| 18 | +- **Auto-save** — all state is persisted to `localStorage` with debounced saving |
| 19 | +- **Dirty tracking** — per-field modification indicators with one-click restore to original |
| 20 | +- **Add blank pages** — create new issue pages from scratch without uploading a file |
| 21 | +- **Collapsible file list** — uploaded files panel collapses to save screen space |
| 22 | +- **Scroll to top** — floating button appears after scrolling down |
| 23 | + |
| 24 | +## Tech Stack |
| 25 | + |
| 26 | +| Layer | Technology | |
| 27 | +| ----------- | ----------------------------------- | |
| 28 | +| Framework | React 18 | |
| 29 | +| Language | TypeScript (strict mode) | |
| 30 | +| Build tool | Vite 6 | |
| 31 | +| Package mgr | pnpm | |
| 32 | +| PDF | html2canvas + jsPDF | |
| 33 | +| DOCX | docx + file-saver | |
| 34 | +| ZIP | JSZip + file-saver | |
| 35 | +| Syntax HL | highlight.js | |
| 36 | +| Translation | OpenAI API (`gpt-4o-mini`) | |
| 37 | +| Deployment | GitHub Pages (GitHub Actions CI/CD) | |
| 38 | + |
| 39 | +## Getting Started |
| 40 | + |
| 41 | +### Prerequisites |
| 42 | + |
| 43 | +- [Node.js](https://nodejs.org/) >= 18 |
| 44 | +- [pnpm](https://pnpm.io/) >= 8 |
| 45 | + |
| 46 | +### Install & Run |
| 47 | + |
| 48 | +```sh |
| 49 | +pnpm install |
| 50 | +pnpm dev |
| 51 | +``` |
| 52 | + |
| 53 | +The app opens at [http://localhost:3000](http://localhost:3000). |
| 54 | + |
| 55 | +### Build |
| 56 | + |
| 57 | +```sh |
| 58 | +pnpm build |
| 59 | +``` |
| 60 | + |
| 61 | +Runs TypeScript type checking (`tsc --noEmit`) followed by `vite build`. Output goes to `dist/`. |
| 62 | + |
| 63 | +### Preview Production Build |
| 64 | + |
| 65 | +```sh |
| 66 | +pnpm preview |
| 67 | +``` |
| 68 | + |
| 69 | +## Markdown Template |
| 70 | + |
| 71 | +Each issue `.md` file should follow this structure. A copy is embedded in the app (see `src/templates/template.md`) and can be downloaded from the UI. |
| 72 | + |
| 73 | +### Template Fields |
| 74 | + |
| 75 | +| Field | Description | |
| 76 | +| ------------------ | --------------------------------------------------------------- | |
| 77 | +| `Issue title` | Short name of the finding | |
| 78 | +| `Overall Risk` | Severity level: Critical, High, Medium, Low, or Info | |
| 79 | +| `Impact` | Impact rating | |
| 80 | +| `Exploitability` | How easily the issue can be exploited | |
| 81 | +| `Finding ID` | Unique identifier (e.g. `NFQ-0001`) | |
| 82 | +| `Component` | Affected file, service, or module | |
| 83 | +| `Category` | Grouping category (e.g. Security, Infrastructure, CI/CD) | |
| 84 | +| `Status` | Current status (e.g. New, In Progress, Resolved) | |
| 85 | +| `Additional Issue` | Optional extra rows in the severity table (`Title \| Severity`) | |
| 86 | +| `Impact details` | Bullet list of impacts | |
| 87 | +| `Description` | Detailed explanation with optional `Evidence:` link | |
| 88 | +| `Code example` | Fenced code block with language tag | |
| 89 | +| `Example scenario` | Realistic exploitation or failure scenario | |
| 90 | +| `Recommendation` | Bullet list of remediation steps | |
| 91 | + |
| 92 | +## Translation (Optional) |
| 93 | + |
| 94 | +The app can translate issue content to any language using the OpenAI API. |
| 95 | + |
| 96 | +1. Create a `.env` file in this directory: |
| 97 | + |
| 98 | + ```sh |
| 99 | + VITE_OPENAI_API_KEY=sk-... |
| 100 | + ``` |
| 101 | + |
| 102 | +2. Select a target language in the preview header (default: Lithuanian). |
| 103 | + |
| 104 | +3. Use the 🌐 button on any field or page, or press <kbd>Cmd+Shift+L</kbd> / <kbd>Ctrl+Shift+L</kbd> while editing. |
| 105 | + |
| 106 | +> **Note:** The API key is used client-side via `dangerouslyAllowBrowser`. This is acceptable for internal tooling but should not be used in public-facing deployments. Never commit your `.env` file. |
| 107 | +
|
| 108 | +## Deployment |
| 109 | + |
| 110 | +The project includes a GitHub Actions workflow (`.github/workflows/deploy.yml`) that automatically builds and deploys to GitHub Pages on every push to `main`. |
| 111 | + |
| 112 | +### Setup |
| 113 | + |
| 114 | +1. Push this repository to GitHub. |
| 115 | +2. Go to **Settings → Pages** and set **Source** to **GitHub Actions**. |
| 116 | +3. Push to `main` — the workflow will build and deploy automatically. |
| 117 | + |
| 118 | +## Project Structure |
| 119 | + |
| 120 | +``` |
| 121 | +web/ |
| 122 | +├── index.html # Entry HTML |
| 123 | +├── package.json |
| 124 | +├── pnpm-lock.yaml |
| 125 | +├── tsconfig.json # TypeScript configuration (strict) |
| 126 | +├── vite.config.js # Vite config (base: "./" for Pages) |
| 127 | +└── src/ |
| 128 | + ├── main.tsx # React DOM entry point |
| 129 | + ├── App.tsx # Main application component |
| 130 | + ├── Editable.tsx # Inline-editable components (text, block, code, severity) |
| 131 | + ├── parseIssue.ts # Markdown parser, grouping, severity helpers |
| 132 | + ├── generatePdf.ts # PDF generation (html2canvas + jsPDF) |
| 133 | + ├── generateDocx.ts # DOCX generation (docx library) |
| 134 | + ├── translate.ts # OpenAI translation client |
| 135 | + ├── types.ts # Shared TypeScript interfaces |
| 136 | + ├── templates/template.md # Markdown issue template (source of truth) |
| 137 | + ├── index.css # All styles |
| 138 | + └── vite-env.d.ts # Vite/TypeScript env declarations |
| 139 | +``` |
| 140 | + |
| 141 | +## License |
| 142 | + |
| 143 | +Private — internal use only. |
0 commit comments