Documentation
¶
Overview ¶
Package report 的 docx 子模块:手写的最小 OOXML(.docx)生成器。 不引入第三方文档库——.docx 本质是 zip + XML,报告需要的元素(标题层级/ 段落/列表/表格/分页)用一小段生成器即可覆盖,换来:零新依赖、单二进制哲学 不破、输出结构完全可控(内置中文报告模板的字体/字号/表格边框都在 styles.xml)。
Package report renders a deliverable Markdown report from the exploration graph: confirmed findings (with severity/evidence) (docs §15 P5).
Index ¶
- func FindingFilename(f *db.DBFinding) string
- func FindingsCSV(fs []*db.DBFinding) []byte
- func FindingsMarkdown(fs []*db.DBFinding, generatedAt time.Time) string
- func FormatTimeUTC(t time.Time) string
- func Markdown(in Input) string
- func SeverityCN(s string) string
- func SeverityHex(sev string) string
- func SeverityHexSoft(sev string) string
- func SingleFindingMarkdown(f *db.DBFinding, generatedAt time.Time) string
- type Docx
- func (d *Docx) Bullet(text string)
- func (d *Docx) Code(text string)
- func (d *Docx) CoverLine(text string, sz int, bold bool)
- func (d *Docx) Encode(w io.Writer) error
- func (d *Docx) H1(text string)
- func (d *Docx) H2(text string)
- func (d *Docx) H3(text string)
- func (d *Docx) H4(text string)
- func (d *Docx) P(text string)
- func (d *Docx) PRich(text string)
- func (d *Docx) PageBreak()
- func (d *Docx) SetHeaderText(text string)
- func (d *Docx) TOC()
- func (d *Docx) Table(header []string, rows [][]string)
- func (d *Docx) TableFills(header []string, rows [][]string, fills []string)
- type Input
- type Run
- type TaskDocxInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindingFilename ¶
FindingFilename 为「一漏洞一文件」生成安全的 .md 文件名,形如 `critical_SQL注入_#123.md`。去掉路径分隔符与控制字符,避免 zip 内非法路径。
func FindingsCSV ¶
FindingsCSV 把一批 findings 渲染成 CSV(带 UTF-8 BOM,便于 Excel 正确识别中文)。 不含大段 report/evidence 全文,只放摘要类字段;需要全文用 Markdown/JSON 导出。
func FindingsMarkdown ¶
FindingsMarkdown 把一批 findings 整合成一份汇总报告(摘要 + 按严重等级分组, 每条含类别/状态/所属任务/证据/详细报告)。
func FormatTimeUTC ¶ added in v0.3.18
FormatTimeUTC 统一时间展示(UTC,报告里避免时区歧义)。
func SeverityHex ¶ added in v0.3.93
SeverityHex 严重度主色(标题/表格底色用,A2)。
func SeverityHexSoft ¶ added in v0.3.93
SeverityHexSoft 严重度柔和底色(表格行底色用,比主色浅)。
Types ¶
type Docx ¶ added in v0.3.18
type Docx struct {
// contains filtered or unexported fields
}
Docx 是一份正在组装的文档;方法按顺序追加元素。
func BuildFindingDocx ¶ added in v0.3.18
func BuildFindingDocx(f *db.DBFinding, generatedAt time.Time, assetNameMap map[int64]string, retests []*db.FindingRetest) *Docx
BuildFindingDocx 渲染单漏洞报告(复现步骤/证据/修复建议的自包含文档)。
func BuildTaskDocx ¶ added in v0.3.18
func BuildTaskDocx(in TaskDocxInput) *Docx
BuildTaskDocx 渲染任务总报告: 封面页(居中标题/委托方/密级/日期)→ 目录页(TOC 字段)→ 一、评估概览 → 二、测试范围与方法论 → 三、漏洞明细(按类别折叠分组+着色+复测+流量证据)→ 四、修复优先级路线图 → 附录 A 资产清单。 同类漏洞×多主机的重复上报在类别层折叠呈现。
func (*Docx) SetHeaderText ¶ added in v0.3.94
SetHeaderText 自定义页眉文字(客户名/报告名)。须在 Encode 前调用。
func (*Docx) TOC ¶ added in v0.3.94
func (d *Docx) TOC()
TOC 目录字段:Word 打开时按 updateFields 设置自动刷新(settings.xml 已置 updateFields,见 Encode)。\o "1-3" 收 Heading1-3——H4(漏洞明细小节)不进目录。
type Input ¶
type Input struct {
Title string
Goal string
GeneratedAt time.Time
AssetCounts map[string]int
Findings []*db.Node
}
Input bundles what the report needs.
type TaskDocxInput ¶ added in v0.3.18
type TaskDocxInput struct {
TaskID int64
Title string
Goal string
GeneratedAt time.Time
AssetCounts map[string]int
Findings []*db.DBFinding
// AssetNames 资产 id → 可读名(域名/IP/URL)。nil/缺项回退 "id:N"(A8)。
AssetNames map[int64]string
// Retests finding id → 复测记录(最新在前)。报告带「复测记录」小节(A9)。
Retests map[int64][]*db.FindingRetest
// Customer 委托方(企业名,逗号连接;空 = 封面省略该行)。A12
Customer string
// TestWindow 测试窗口描述(如「2026-10-29 ~ 2026-10-31」;空 = 只给生成时间)。A12
TestWindow string
// AppendixAssets 附录资产清单:类型 → 可读名列表(A16;nil = 无附录)。
AppendixAssets map[string][]string
// Classification 密级/用途占位(空 = 默认「内部资料 · 仅限授权方」)。A12
Classification string
// PageHeader 页眉文字(空 = 「渗透测试报告」)。
PageHeader string
}
TaskDocxInput 是总报告的输入。