@abdulr7man/pensieve 0.0.0-stage → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/LICENSE +684 -0
  2. package/README.md +180 -2
  3. package/VERSION +1 -0
  4. package/agents/README.md +16 -0
  5. package/agents/pensieve-code-auditor.md +58 -0
  6. package/agents/pensieve-mapper.md +46 -0
  7. package/agents/pensieve-planner.md +67 -0
  8. package/agents/pensieve-reconner.md +76 -0
  9. package/agents/pensieve-reporter.md +61 -0
  10. package/agents/pensieve-roe-checker.md +46 -0
  11. package/agents/pensieve-scoper.md +77 -0
  12. package/agents/pensieve-tester.md +83 -0
  13. package/agents/pensieve-validator.md +62 -0
  14. package/bin/pensieve +452 -0
  15. package/bin/pensieve-installer.cjs +5 -0
  16. package/commands/pensieve-close.md +6 -0
  17. package/commands/pensieve-map.md +6 -0
  18. package/commands/pensieve-new-engagement.md +6 -0
  19. package/commands/pensieve-pause.md +15 -0
  20. package/commands/pensieve-plan.md +6 -0
  21. package/commands/pensieve-progress.md +34 -0
  22. package/commands/pensieve-quick.md +8 -0
  23. package/commands/pensieve-recon.md +6 -0
  24. package/commands/pensieve-report.md +6 -0
  25. package/commands/pensieve-resume.md +6 -0
  26. package/commands/pensieve-retest.md +10 -0
  27. package/commands/pensieve-scope.md +49 -0
  28. package/commands/pensieve-surface.md +8 -0
  29. package/commands/pensieve-test.md +6 -0
  30. package/commands/pensieve-validate.md +6 -0
  31. package/docker/Dockerfile.pensieve-toolbox +75 -0
  32. package/docker/compose.pensieve-net.yml +37 -0
  33. package/docker/squid.conf.template +21 -0
  34. package/package.json +39 -4
  35. package/packs/ad/ad-killchain/checklist.md +64 -0
  36. package/packs/ad/ad-killchain/pack.yaml +19 -0
  37. package/packs/cloud/cloud-cis/checklist.md +66 -0
  38. package/packs/cloud/cloud-cis/pack.yaml +20 -0
  39. package/packs/fintech/practice-core/checklist.md +33 -0
  40. package/packs/fintech/practice-core/learnings.md +5 -0
  41. package/packs/fintech/practice-core/pack.yaml +18 -0
  42. package/packs/infra/ptes-infra/checklist.md +22 -0
  43. package/packs/infra/ptes-infra/pack.yaml +19 -0
  44. package/packs/mobile/owasp-masvs/checklist.md +80 -0
  45. package/packs/mobile/owasp-masvs/pack.yaml +20 -0
  46. package/packs/owasp-api-v4/checklist.md +85 -0
  47. package/packs/owasp-api-v4/learnings.md +6 -0
  48. package/packs/owasp-api-v4/pack.yaml +23 -0
  49. package/packs/owasp-api-v4/runbooks/API1/SKILL.md +66 -0
  50. package/packs/owasp-api-v4/runbooks/API10/SKILL.md +67 -0
  51. package/packs/owasp-api-v4/runbooks/API2/SKILL.md +129 -0
  52. package/packs/owasp-api-v4/runbooks/API3/SKILL.md +55 -0
  53. package/packs/owasp-api-v4/runbooks/API4/SKILL.md +59 -0
  54. package/packs/owasp-api-v4/runbooks/API5/SKILL.md +60 -0
  55. package/packs/owasp-api-v4/runbooks/API6/SKILL.md +63 -0
  56. package/packs/owasp-api-v4/runbooks/API7/SKILL.md +70 -0
  57. package/packs/owasp-api-v4/runbooks/API8/SKILL.md +72 -0
  58. package/packs/owasp-api-v4/runbooks/API9/SKILL.md +66 -0
  59. package/packs/thickclient/thickclient-core/checklist.md +60 -0
  60. package/packs/thickclient/thickclient-core/pack.yaml +24 -0
  61. package/packs/web/asvs-l2/checklist.md +50 -0
  62. package/packs/web/asvs-l2/learnings.md +6 -0
  63. package/packs/web/asvs-l2/pack.yaml +19 -0
  64. package/packs/web/asvs-l2/runbooks/V2-AUTH-ENUM/SKILL.md +75 -0
  65. package/packs/web/asvs-l2/runbooks/V2-AUTH-LIVE/SKILL.md +78 -0
  66. package/packs/web/asvs-l2/runbooks/V2-AUTH-MFA/SKILL.md +76 -0
  67. package/packs/web/asvs-l2/runbooks/V2-AUTH-RATE/SKILL.md +72 -0
  68. package/packs/web/owasp-testing-checklist/checklist.md +52 -0
  69. package/packs/web/owasp-testing-checklist/learnings.md +47 -0
  70. package/packs/web/owasp-testing-checklist/pack.yaml +21 -0
  71. package/packs/web/unauth-perimeter/checklist.md +72 -0
  72. package/packs/web/unauth-perimeter/pack.yaml +18 -0
  73. package/packs/web/unauth-perimeter/runbooks/PERIM-01/SKILL.md +60 -0
  74. package/packs/web/unauth-perimeter/runbooks/PERIM-02/SKILL.md +63 -0
  75. package/packs/web/unauth-perimeter/runbooks/PERIM-03/SKILL.md +62 -0
  76. package/packs/web/unauth-perimeter/runbooks/PERIM-04/SKILL.md +75 -0
  77. package/packs/web/unauth-perimeter/runbooks/PERIM-05/SKILL.md +66 -0
  78. package/packs/web/unauth-perimeter/runbooks/PERIM-06/SKILL.md +59 -0
  79. package/packs/web/unauth-perimeter/runbooks/PERIM-07/SKILL.md +56 -0
  80. package/packs/web/unauth-perimeter/runbooks/PERIM-08/SKILL.md +57 -0
  81. package/packs/web/unauth-perimeter/runbooks/PERIM-09/SKILL.md +62 -0
  82. package/packs/web/unauth-perimeter/runbooks/PERIM-10/SKILL.md +60 -0
  83. package/packs/whitebox/code-audit-core/checklist.md +36 -0
  84. package/packs/whitebox/code-audit-core/learnings.md +6 -0
  85. package/packs/whitebox/code-audit-core/pack.yaml +14 -0
  86. package/prompts/orchestrator-core.md +52 -0
  87. package/reference/attack-playbooks.md +57 -0
  88. package/reference/otp-relay.md +98 -0
  89. package/reference/param-profiles.md +48 -0
  90. package/reference/templates/FINDING.md +97 -0
  91. package/reference/tool-selection.md +64 -0
  92. package/reference/vulnerability-finding-standard.md +80 -0
  93. package/runtimes/hermes/hooks/injection-scan.py +290 -0
  94. package/runtimes/hermes/hooks/scope-guard.py +136 -0
  95. package/skills/pensieve/SKILL.md +134 -0
  96. package/skills/pensieve-close/SKILL.md +31 -0
  97. package/skills/pensieve-map/SKILL.md +25 -0
  98. package/skills/pensieve-new-engagement/SKILL.md +28 -0
  99. package/skills/pensieve-pause/SKILL.md +22 -0
  100. package/skills/pensieve-plan/SKILL.md +39 -0
  101. package/skills/pensieve-progress/SKILL.md +35 -0
  102. package/skills/pensieve-quick/SKILL.md +47 -0
  103. package/skills/pensieve-recon/SKILL.md +30 -0
  104. package/skills/pensieve-report/SKILL.md +46 -0
  105. package/skills/pensieve-resume/SKILL.md +33 -0
  106. package/skills/pensieve-retest/SKILL.md +35 -0
  107. package/skills/pensieve-scope/SKILL.md +35 -0
  108. package/skills/pensieve-surface/SKILL.md +36 -0
  109. package/skills/pensieve-test/SKILL.md +35 -0
  110. package/skills/pensieve-validate/SKILL.md +28 -0
  111. package/skills/pensieve-wiki/SKILL.md +39 -0
  112. package/src/installer/cli.cjs +209 -0
  113. package/src/installer/home.cjs +155 -0
  114. package/src/installer/runtimes.cjs +276 -0
  115. package/src/installer/uninstall.cjs +342 -0
  116. package/src/pensieve-sdk/bin/pensieve-sdk.cjs +1045 -0
  117. package/src/pensieve-sdk/lib/agent-translate.cjs +50 -0
  118. package/src/pensieve-sdk/lib/approvals.cjs +408 -0
  119. package/src/pensieve-sdk/lib/audit.cjs +290 -0
  120. package/src/pensieve-sdk/lib/checklist.cjs +337 -0
  121. package/src/pensieve-sdk/lib/clientlist.cjs +814 -0
  122. package/src/pensieve-sdk/lib/close.cjs +133 -0
  123. package/src/pensieve-sdk/lib/config.cjs +156 -0
  124. package/src/pensieve-sdk/lib/cvss.cjs +91 -0
  125. package/src/pensieve-sdk/lib/env.cjs +272 -0
  126. package/src/pensieve-sdk/lib/evidence.cjs +217 -0
  127. package/src/pensieve-sdk/lib/findings.cjs +1096 -0
  128. package/src/pensieve-sdk/lib/frontmatter.cjs +178 -0
  129. package/src/pensieve-sdk/lib/graph.cjs +607 -0
  130. package/src/pensieve-sdk/lib/ids.cjs +63 -0
  131. package/src/pensieve-sdk/lib/init.cjs +79 -0
  132. package/src/pensieve-sdk/lib/liveness.cjs +176 -0
  133. package/src/pensieve-sdk/lib/loop.cjs +619 -0
  134. package/src/pensieve-sdk/lib/migrate.cjs +57 -0
  135. package/src/pensieve-sdk/lib/monitor.cjs +69 -0
  136. package/src/pensieve-sdk/lib/pack.cjs +607 -0
  137. package/src/pensieve-sdk/lib/paths.cjs +73 -0
  138. package/src/pensieve-sdk/lib/pdf.cjs +291 -0
  139. package/src/pensieve-sdk/lib/recon.cjs +296 -0
  140. package/src/pensieve-sdk/lib/renderers/__pycache__/formal_report.cpython-314.pyc +0 -0
  141. package/src/pensieve-sdk/lib/renderers/formal_report.py +608 -0
  142. package/src/pensieve-sdk/lib/report.cjs +1135 -0
  143. package/src/pensieve-sdk/lib/runbook.cjs +124 -0
  144. package/src/pensieve-sdk/lib/sarif.cjs +154 -0
  145. package/src/pensieve-sdk/lib/scope.cjs +621 -0
  146. package/src/pensieve-sdk/lib/security.cjs +61 -0
  147. package/src/pensieve-sdk/lib/skills.cjs +193 -0
  148. package/src/pensieve-sdk/lib/state.cjs +610 -0
  149. package/src/pensieve-sdk/lib/subagent.cjs +658 -0
  150. package/src/pensieve-sdk/lib/target.cjs +149 -0
  151. package/src/pensieve-sdk/lib/tools.cjs +66 -0
  152. package/src/pensieve-sdk/lib/vault.cjs +122 -0
  153. package/src/pensieve-sdk/lib/vendor/cvss40.LICENSE +22 -0
  154. package/src/pensieve-sdk/lib/vendor/cvss40.js +1208 -0
  155. package/src/pensieve-sdk/package.json +11 -0
  156. package/templates/ACCOUNTS.md +35 -0
  157. package/templates/ATTACK-SURFACE.md +30 -0
  158. package/templates/FINDING.md +43 -0
  159. package/templates/PLAN.md +33 -0
  160. package/templates/PROJECT.md +29 -0
  161. package/templates/ROE.md +50 -0
  162. package/templates/RUN-LOG.md +19 -0
  163. package/templates/SCOPE.md +32 -0
  164. package/templates/VALIDATION.md +62 -0
  165. package/templates/report/REPORT.md +49 -0
  166. package/workflows/close.md +34 -0
  167. package/workflows/map.md +39 -0
  168. package/workflows/new-engagement.md +37 -0
  169. package/workflows/plan.md +45 -0
  170. package/workflows/progress.md +28 -0
  171. package/workflows/quick.md +67 -0
  172. package/workflows/recon.md +87 -0
  173. package/workflows/report.md +51 -0
  174. package/workflows/resume.md +26 -0
  175. package/workflows/retest.md +53 -0
  176. package/workflows/scope.md +47 -0
  177. package/workflows/surface.md +29 -0
  178. package/workflows/test.md +95 -0
  179. package/workflows/validate.md +34 -0
@@ -0,0 +1,608 @@
1
+ #!/usr/bin/env python3
2
+ """PENSIEVE formal penetration-test report renderer (v0.6 01-04, brief 1.11).
3
+
4
+ A faithful ADAPTATION of the owner's keystone formal_report.py
5
+ (~/Downloads/sonatype-reports/reports/formal_report.py, reuse authorized):
6
+ same formal document structure — TLP front matter, document control, risk
7
+ methodology, findings summary index, one self-contained table per finding,
8
+ evidence-manifest appendix, branded header/footer — but:
9
+
10
+ * the CONTENT model is a PENSIEVE engagement (findings register + evidence
11
+ ledger + scope/project metadata), not Sonatype SCA data;
12
+ * the BRAND is the neutral Pensieve identity passed in the
13
+ payload (assets/branding/config.json + config.yaml overrides) — none of
14
+ keystone's brand identity is carried over;
15
+ * reportlab is the ONLY dependency (keystone's matplotlib severity chart
16
+ is replaced by a severity-count table so the lane-B probe stays a single
17
+ import check);
18
+ * the script is standalone: the engagement payload arrives as JSON on
19
+ stdin (or --payload <file>), the PDF is written to --output.
20
+
21
+ Exit 0 + one JSON line on stdout on success; message on stderr + exit 1 on
22
+ failure (the sdk surfaces that stderr in its renderer-exec refusal).
23
+ """
24
+ import argparse
25
+ import io
26
+ import json
27
+ import os
28
+ import re
29
+ import sys
30
+ from datetime import datetime
31
+
32
+ from reportlab.lib import colors
33
+ from reportlab.lib.pagesizes import letter
34
+ from reportlab.lib.units import inch
35
+ from reportlab.platypus import (SimpleDocTemplate, Table, TableStyle, Paragraph,
36
+ Spacer, PageBreak, Image, KeepTogether,
37
+ ListFlowable, ListItem)
38
+ from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
39
+
40
+ CONTENT_W = (8.5 - 1.4) * inch - 12
41
+
42
+ # FIRST TLP definitions (standard, shared with keystone's TLP table).
43
+ TLP_ROWS = [
44
+ ("Red", "#C00000", "Personal, confidential, and for the intended recipient only. "
45
+ "The recipient has no rights to share information classified red with any person "
46
+ "outside the defined range of recipients."),
47
+ ("Amber", "#E36C0A", "Restricted sharing. The recipient may share information "
48
+ "classified amber only with intended recipients inside the organisation and with "
49
+ "those required to act on it."),
50
+ ("Green", "#548235", "Sharing within the same community. May be shared inside the "
51
+ "organisation or within the same sector, but not published on public channels."),
52
+ ("White", "#BFBFBF", "No restrictions."),
53
+ ]
54
+
55
+ ABBREVIATIONS = [
56
+ ("CVE", "Common Vulnerabilities and Exposures"),
57
+ ("CVSS", "Common Vulnerability Scoring System"),
58
+ ("CWE", "Common Weakness Enumeration"),
59
+ ("NCA", "National Cybersecurity Authority"),
60
+ ("PCI DSS", "Payment Card Industry Data Security Standard"),
61
+ ("ROE", "Rules of Engagement"),
62
+ ("SAMA", "Saudi Central Bank"),
63
+ ("TLP", "Traffic Light Protocol"),
64
+ ]
65
+
66
+ # PENSIEVE pipeline methodology (recon -> map -> plan -> test -> report),
67
+ # expressed in the four-phase formal style keystone uses.
68
+ METHODOLOGY = [
69
+ ("Scoping and Rules of Engagement",
70
+ "The scope is agreed with the client and recorded in SCOPE.md with the "
71
+ "rules of engagement. Every asset tested and every action taken is "
72
+ "checked against this scope by the deterministic tooling before execution."),
73
+ ("Reconnaissance and Mapping",
74
+ "In-scope assets are enumerated and the attack surface is mapped. Raw "
75
+ "tool output is preserved in a hash-chained evidence ledger so every "
76
+ "later claim can be traced back to a verifiable capture."),
77
+ ("Exploitation and Independent Validation",
78
+ "Candidate findings are exploited within the rules of engagement. A "
79
+ "finding is only reported after independent replay validation; findings "
80
+ "that do not meet the validation bar are recorded as rejected. Severity "
81
+ "is computed from the CVSS vector by the tooling, never assigned by hand."),
82
+ ("Reporting",
83
+ "Validated findings are compiled into this report, verified against the "
84
+ "findings register, and released only after recorded human approval. The "
85
+ "evidence manifest in the appendix lists every supporting capture with "
86
+ "its SHA-256 digest."),
87
+ ]
88
+
89
+ # CVSS 3.1 qualitative bands — severity here IS the sdk-computed register
90
+ # severity; this table documents the banding for the reader.
91
+ RISK_BANDS = [
92
+ ("Critical", "#C00000", "9.0 – 10.0",
93
+ "Direct, severe business impact. Remediate immediately; treat as an incident."),
94
+ ("High", "#E36C0A", "7.0 – 8.9",
95
+ "Significant impact with realistic exploitation. Remediate urgently, ahead of routine work."),
96
+ ("Medium", "#BF9000", "4.0 – 6.9",
97
+ "Meaningful impact requiring some conditions. Schedule remediation within the normal cycle."),
98
+ ("Low", "#548235", "0.1 – 3.9",
99
+ "Limited impact. Remediate opportunistically or accept with a recorded rationale."),
100
+ ("Informational", "#7F7F7F", "0.0",
101
+ "No direct security impact; hardening or hygiene observation."),
102
+ ]
103
+ SEVERITY_COLOR = {name: col for name, col, _, _ in RISK_BANDS}
104
+
105
+ BRAND_FALLBACK = {
106
+ "companyName": "PENSIEVE",
107
+ "reportTitle": "Penetration Test Report",
108
+ "accentColor": "1F5F6B",
109
+ "footerText": "Confidential — for the intended recipients only",
110
+ "logoPath": None,
111
+ }
112
+
113
+
114
+ def _rl(s):
115
+ """Escape engagement-sourced text before it enters ReportLab markup, and
116
+ fold to cp1252 (the base-14 fonts are WinAnsi — cp1252 keeps em/en dashes,
117
+ bullets and curly quotes; a truly exotic codepoint degrades to '?' rather
118
+ than crash the whole render)."""
119
+ if s is None:
120
+ return ""
121
+ s = str(s)
122
+ s = s.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
123
+ return s.encode("cp1252", "replace").decode("cp1252")
124
+
125
+
126
+ def _md_plain(text):
127
+ """Strip the lightweight markdown reporters use in prose sections:
128
+ **bold**, `code`, _italic_ markers and heading hashes. Table lines are
129
+ dropped by the sdk before prose reaches the payload."""
130
+ out = []
131
+ for line in (text or "").split("\n"):
132
+ line = line.replace("**", "").replace("`", "").replace("__", "")
133
+ out.append(line)
134
+ return "\n".join(out)
135
+
136
+
137
+ def _list_item(line):
138
+ """A '- ' bullet or a '1. ' numbered item (the report layer's ordered PoC
139
+ steps and remediation) -> the item text, else None."""
140
+ if line.startswith("- "):
141
+ return line[2:].strip()
142
+ m = re.match(r"^(\d+)\.\s+(.*)$", line)
143
+ if m:
144
+ return m.group(2).strip()
145
+ return None
146
+
147
+
148
+ def _prose(text, style, bullet_style=None):
149
+ """Plain-text/markdown-lite prose -> flowables. Blank lines split
150
+ paragraphs; '- ' lines and '1. ' numbered lines become list items (35-01
151
+ REP-03: the ordered PoC steps and remediation keep their step numbers as
152
+ list items instead of running together into one paragraph)."""
153
+ flow = []
154
+ for para in (text or "").split("\n\n"):
155
+ para = para.strip()
156
+ if not para:
157
+ continue
158
+ lines = [l.strip() for l in _md_plain(para).split("\n") if l.strip()]
159
+ bullets = [item for item in (_list_item(l) for l in lines) if item is not None]
160
+ keep = [l for l in lines if _list_item(l) is None]
161
+ if keep:
162
+ flow.append(Paragraph(_rl(" ".join(keep)), style))
163
+ flow.append(Spacer(1, 4))
164
+ if bullets:
165
+ flow.append(ListFlowable(
166
+ [ListItem(Paragraph(_rl(b), bullet_style or style), leftIndent=10)
167
+ for b in bullets],
168
+ bulletType="bullet", start="•", leftIndent=12,
169
+ bulletFontSize=6.5, spaceBefore=1, spaceAfter=1))
170
+ flow.append(Spacer(1, 4))
171
+ return flow
172
+
173
+
174
+ def _styles(accent):
175
+ ss = getSampleStyleSheet()
176
+ return {
177
+ "cover_t": ParagraphStyle("ct", parent=ss["Title"], fontSize=23, leading=28,
178
+ textColor=colors.HexColor(accent), alignment=0),
179
+ "cover_s": ParagraphStyle("cs", parent=ss["Normal"], fontSize=13, leading=18,
180
+ textColor=colors.HexColor("#404040")),
181
+ "h1": ParagraphStyle("h1", parent=ss["Heading1"], fontSize=16, leading=20,
182
+ textColor=colors.HexColor(accent), spaceBefore=2,
183
+ spaceAfter=9, keepWithNext=True),
184
+ "h2": ParagraphStyle("h2", parent=ss["Heading2"], fontSize=12.5, leading=16,
185
+ textColor=colors.HexColor("#1F2430"), spaceBefore=10,
186
+ spaceAfter=5, keepWithNext=True),
187
+ "h3": ParagraphStyle("h3", parent=ss["Heading3"], fontSize=10.5, leading=14,
188
+ textColor=colors.HexColor("#404040"), spaceBefore=8,
189
+ spaceAfter=3, keepWithNext=True),
190
+ "body": ParagraphStyle("b", parent=ss["Normal"], fontSize=9.3, leading=13.2,
191
+ textColor=colors.HexColor("#1A1A1A")),
192
+ "cap": ParagraphStyle("cap", parent=ss["Normal"], fontSize=8.5, leading=11,
193
+ textColor=colors.HexColor(accent), fontName="Helvetica-Bold",
194
+ spaceBefore=8, spaceAfter=3),
195
+ "lbl": ParagraphStyle("lbl", parent=ss["Normal"], fontSize=7.9, leading=10,
196
+ textColor=colors.HexColor("#1F4E5E"), fontName="Helvetica-Bold"),
197
+ "val": ParagraphStyle("val", parent=ss["Normal"], fontSize=7.9, leading=10.6,
198
+ textColor=colors.HexColor("#1A1A1A")),
199
+ "mono": ParagraphStyle("mo", parent=ss["Normal"], fontSize=7.5, leading=10.4,
200
+ fontName="Courier", textColor=colors.HexColor("#333333")),
201
+ "hid": ParagraphStyle("hid", parent=ss["Normal"], fontSize=8.6,
202
+ fontName="Helvetica-Bold", textColor=colors.HexColor("#1F4E5E")),
203
+ "hti": ParagraphStyle("hti", parent=ss["Normal"], fontSize=8.6,
204
+ fontName="Helvetica-Bold", textColor=colors.white),
205
+ "th": ParagraphStyle("th", parent=ss["Normal"], fontSize=8, leading=10.4,
206
+ fontName="Helvetica-Bold", textColor=colors.white),
207
+ }
208
+
209
+
210
+ def _grid(rows, accent, widths, header=True):
211
+ st = [
212
+ ("GRID", (0, 0), (-1, -1), 0.4, colors.HexColor("#9CA3AF")),
213
+ ("VALIGN", (0, 0), (-1, -1), "TOP"),
214
+ ("TOPPADDING", (0, 0), (-1, -1), 4),
215
+ ("BOTTOMPADDING", (0, 0), (-1, -1), 4),
216
+ ("LEFTPADDING", (0, 0), (-1, -1), 5),
217
+ ("RIGHTPADDING", (0, 0), (-1, -1), 5),
218
+ ]
219
+ if header:
220
+ st += [("BACKGROUND", (0, 0), (-1, 0), colors.HexColor(accent)),
221
+ ("ROWBACKGROUNDS", (0, 1), (-1, -1),
222
+ [colors.white, colors.HexColor("#F7F9FB")])]
223
+ t = Table(rows, colWidths=widths, hAlign="LEFT", repeatRows=1 if header else 0)
224
+ t.setStyle(TableStyle(st))
225
+ return t
226
+
227
+
228
+ class _Numbering:
229
+ def __init__(self):
230
+ self.t = 0
231
+
232
+ def table(self, title):
233
+ self.t += 1
234
+ return f"Table {self.t}: {title}"
235
+
236
+
237
+ def _finding_table(f, N, S, accent):
238
+ sev = f.get("severity") or "Informational"
239
+ bar = colors.HexColor(SEVERITY_COLOR.get(sev, "#7F7F7F"))
240
+
241
+ assets = ", ".join(f.get("assets") or []) or "—"
242
+ ev_ids = ", ".join(f.get("evidence") or [])
243
+
244
+ def cell(text):
245
+ paras = _prose(text, S["val"])
246
+ return paras[0] if len(paras) == 1 else paras or Paragraph("—", S["val"])
247
+
248
+ # 35-01 (REP-03): the payload's ordered 9-section standard shape. The
249
+ # header rows below ARE the standard's sections 1-3 (title, severity/CWE,
250
+ # score/status, vector, affected assets); the body rows render sections
251
+ # 4-9 in the payload's pinned order — Description, Technical Details /
252
+ # Proof of Concept (evidence combined inline), Impact, Remediation,
253
+ # References, Retest / Validation. A payload without sections (the
254
+ # pre-35-01 shape) falls back to the legacy prose rows.
255
+ SECTION_ROW_KEYS = ("description", "poc", "impact", "remediation",
256
+ "references", "retest")
257
+ sections = [s for s in (f.get("sections") or [])
258
+ if isinstance(s, dict) and s.get("key") in SECTION_ROW_KEYS]
259
+
260
+ rows = [
261
+ [Paragraph(_rl(f.get("id", "")), S["hid"]),
262
+ Paragraph(f"<b>{_rl(f.get('title', ''))}</b>", S["hti"]), "", "", ""],
263
+ [Paragraph("Severity", S["lbl"]),
264
+ Paragraph(f"<font color='{SEVERITY_COLOR.get(sev, '#7F7F7F')}'><b>{_rl(sev)}</b></font>", S["val"]),
265
+ Paragraph("CWE", S["lbl"]), Paragraph(_rl(f.get("cwe") or "—"), S["val"]), ""],
266
+ [Paragraph("CVSS", S["lbl"]),
267
+ Paragraph(_rl(f.get("cvss_score")), S["val"]),
268
+ Paragraph("Status", S["lbl"]), Paragraph(_rl(f.get("status", "")), S["val"]), ""],
269
+ [Paragraph("Vector", S["lbl"]), Paragraph(_rl(f.get("cvss_vector") or "—"), S["mono"]), "", "", ""],
270
+ [Paragraph("Affected Assets", S["lbl"]), Paragraph(_rl(assets), S["val"]), "", "", ""],
271
+ ]
272
+
273
+ if sections:
274
+ for s in sections:
275
+ text = s.get("text") or ""
276
+ if s.get("key") == "poc" and ev_ids:
277
+ text = (text + "\n\n" if text else "") + \
278
+ f"Evidence ledger reference(s): {ev_ids} (see Appendix — Evidence manifest)."
279
+ rows.append([Paragraph(_rl(s.get("label", "")), S["lbl"]), cell(text), "", "", ""])
280
+ else:
281
+ ev_text = f.get("evidence_text") or ""
282
+ if ev_ids:
283
+ ev_text = (ev_text + "\n\n" if ev_text else "") + \
284
+ f"Evidence ledger reference(s): {ev_ids} (see Appendix — Evidence manifest)."
285
+ remediation = f.get("remediation") or ""
286
+ rem_flow = _prose(remediation, S["val"]) or [Paragraph("_pending_", S["val"])]
287
+ rows.append([Paragraph("Description", S["lbl"]), cell(f.get("summary") or "—"), "", "", ""])
288
+ rows.append([Paragraph("Impact", S["lbl"]), cell(f.get("impact") or "—"), "", "", ""])
289
+ rows.append([Paragraph("Remediation", S["lbl"]),
290
+ rem_flow[0] if len(rem_flow) == 1 else rem_flow, "", "", ""])
291
+ rows.append([Paragraph("Evidence", S["lbl"]), cell(ev_text or "—"), "", "", ""])
292
+
293
+ W = [1.15 * inch, 1.75 * inch, 1.05 * inch, 1.25 * inch, 1.73 * inch]
294
+ # repeatRows=1 reprints the coloured ID/title bar if the table splits
295
+ # across a page boundary; splitByRow lets it split at all.
296
+ t = Table(rows, colWidths=W, hAlign="LEFT", repeatRows=1, splitByRow=1)
297
+ spans = [("SPAN", (1, 0), (-1, 0))]
298
+ for i in (1, 2):
299
+ spans.append(("SPAN", (3, i), (4, i)))
300
+ for i in range(3, len(rows)):
301
+ spans.append(("SPAN", (1, i), (-1, i)))
302
+ t.setStyle(TableStyle([
303
+ ("BACKGROUND", (1, 0), (-1, 0), bar),
304
+ ("BACKGROUND", (0, 0), (0, -1), colors.HexColor("#F2F2F2")),
305
+ *spans,
306
+ ("GRID", (0, 0), (-1, -1), 0.4, colors.HexColor("#9CA3AF")),
307
+ ("VALIGN", (0, 0), (-1, -1), "TOP"),
308
+ ("TOPPADDING", (0, 0), (-1, -1), 3), ("BOTTOMPADDING", (0, 0), (-1, -1), 3),
309
+ ("LEFTPADDING", (0, 0), (-1, -1), 4.5), ("RIGHTPADDING", (0, 0), (-1, -1), 4.5),
310
+ ]))
311
+ return [Paragraph(N.table(f"{_rl(f.get('id', ''))} — {_rl(f.get('title', ''))}"), S["cap"]),
312
+ t, Spacer(1, 11)]
313
+
314
+
315
+ def build_pdf(payload, out_path):
316
+ meta = payload.get("meta") or {}
317
+ br = dict(BRAND_FALLBACK)
318
+ br.update(payload.get("branding") or {})
319
+ accent = "#" + str(br.get("accentColor") or BRAND_FALLBACK["accentColor"]).lstrip("#")
320
+ S = _styles(accent)
321
+ N = _Numbering()
322
+
323
+ classification = meta.get("classification") or "CONFIDENTIAL"
324
+ tlp = (meta.get("tlp") or "Amber").strip().capitalize()
325
+ tlp_color = dict((r[0], r[1]) for r in TLP_ROWS).get(tlp, "#E36C0A")
326
+
327
+ findings = payload.get("findings") or []
328
+ counts = {}
329
+ for f in findings:
330
+ sev = f.get("severity") or "Informational"
331
+ counts[sev] = counts.get(sev, 0) + 1
332
+
333
+ buf = io.BytesIO()
334
+
335
+ def deco(canvas, doc):
336
+ canvas.saveState()
337
+ canvas.setFont("Helvetica-Bold", 7.5)
338
+ canvas.setFillColor(colors.HexColor(tlp_color))
339
+ canvas.drawCentredString(letter[0] / 2, letter[1] - 0.35 * inch,
340
+ f"{classification} | TLP: {tlp.upper()}")
341
+ canvas.setFont("Helvetica", 7)
342
+ canvas.setFillColor(colors.grey)
343
+ canvas.drawString(0.7 * inch, 0.4 * inch,
344
+ (br.get("footerText") or "").encode("cp1252", "replace").decode("cp1252"))
345
+ canvas.drawRightString(letter[0] - 0.7 * inch, 0.4 * inch, f"Page {doc.page}")
346
+ canvas.restoreState()
347
+
348
+ doc = SimpleDocTemplate(buf, pagesize=letter, leftMargin=0.7 * inch,
349
+ rightMargin=0.7 * inch, topMargin=0.75 * inch,
350
+ bottomMargin=0.65 * inch,
351
+ title=meta.get("title", "Penetration Test Report"))
352
+ el = []
353
+
354
+ # ---------------- Cover ----------------
355
+ lp = br.get("logoPath")
356
+ if lp and os.path.isfile(lp):
357
+ try:
358
+ img = Image(lp)
359
+ ratio = img.imageWidth / max(img.imageHeight, 1)
360
+ img.drawHeight = 0.62 * inch
361
+ img.drawWidth = 0.62 * inch * ratio
362
+ img.hAlign = "LEFT"
363
+ el += [img, Spacer(1, 18)]
364
+ except Exception:
365
+ el.append(Spacer(1, 18))
366
+ else:
367
+ el.append(Spacer(1, 18))
368
+
369
+ el += [Spacer(1, 150),
370
+ Paragraph(_rl(meta.get("title") or br.get("reportTitle")), S["cover_t"]),
371
+ Spacer(1, 6),
372
+ Paragraph(_rl(meta.get("service") or "Technical Report"), S["cover_s"]),
373
+ Paragraph(_rl(br.get("companyName", "")), S["cover_s"]),
374
+ Spacer(1, 26)]
375
+
376
+ cover_rows = [
377
+ [Paragraph("TLP", S["lbl"]), Paragraph(f"<b>{_rl(tlp)}</b>", S["val"])],
378
+ [Paragraph("Document Classification", S["lbl"]), Paragraph(_rl(classification), S["val"])],
379
+ [Paragraph("Date", S["lbl"]),
380
+ Paragraph(_rl(meta.get("date") or datetime.utcnow().strftime("%d/%m/%Y")), S["val"])],
381
+ [Paragraph("Version", S["lbl"]), Paragraph(_rl(meta.get("version", "1.0")), S["val"])],
382
+ [Paragraph("Reference", S["lbl"]), Paragraph(_rl(meta.get("reference", "—")), S["val"])],
383
+ ]
384
+ el += [_grid(cover_rows, accent, [1.9 * inch, 3.4 * inch], header=False), PageBreak()]
385
+
386
+ # ---------------- TLP explanation ----------------
387
+ el += [Paragraph("Traffic Light Protocol (TLP)", S["h1"]),
388
+ Paragraph("The Traffic Light Protocol is used to indicate the sharing "
389
+ "boundaries that apply to this document. Four classifications are "
390
+ "defined.", S["body"]),
391
+ Spacer(1, 8)]
392
+ rows = [[Paragraph("TLP", S["th"]), Paragraph("Sharing boundary", S["th"])]]
393
+ for name, col, desc in TLP_ROWS:
394
+ rows.append([Paragraph(f"<font color='{col}'><b>{name}</b></font>", S["val"]),
395
+ Paragraph(desc, S["val"])])
396
+ el += [_grid(rows, accent, [0.9 * inch, CONTENT_W - 0.9 * inch]), Spacer(1, 16)]
397
+
398
+ # ---------------- Document control ----------------
399
+ el += [Paragraph("Document Control", S["h1"]), Paragraph("General Information", S["h2"])]
400
+ gi = [
401
+ [Paragraph("Client", S["lbl"]), Paragraph(_rl(meta.get("client") or "—"), S["val"])],
402
+ [Paragraph("Engagement", S["lbl"]), Paragraph(_rl(meta.get("engagement", "—")), S["val"])],
403
+ [Paragraph("Service", S["lbl"]), Paragraph(_rl(meta.get("service") or "Penetration Test"), S["val"])],
404
+ [Paragraph("Classification and Scope of Use", S["lbl"]),
405
+ Paragraph(f"{_rl(classification)} — {_rl(meta.get('scope_of_use', 'Internal'))}", S["val"])],
406
+ ]
407
+ el += [_grid(gi, accent, [2.0 * inch, CONTENT_W - 2.0 * inch], header=False), Spacer(1, 10)]
408
+
409
+ el += [Paragraph("Approval", S["h2"])]
410
+ ap = [[Paragraph("", S["th"]), Paragraph("Name", S["th"]), Paragraph("Date", S["th"])]]
411
+ ap.append([Paragraph("Prepared By", S["lbl"]),
412
+ Paragraph(_rl(meta.get("prepared_by") or "—"), S["val"]), Paragraph("—", S["val"])])
413
+ ap.append([Paragraph("Approved By", S["lbl"]),
414
+ Paragraph(_rl(meta.get("approved_by") or "—"), S["val"]),
415
+ Paragraph(_rl((meta.get("approved_at") or "—")[:10]), S["val"])])
416
+ el += [_grid(ap, accent, [1.5 * inch, 3.2 * inch, 1.5 * inch]), Spacer(1, 10)]
417
+
418
+ el += [Paragraph("History", S["h2"])]
419
+ hi = [[Paragraph("Version", S["th"]), Paragraph("Date", S["th"]),
420
+ Paragraph("Changes", S["th"]), Paragraph("Delivered To", S["th"])]]
421
+ hi.append([Paragraph(_rl(meta.get("version", "1.0")), S["val"]),
422
+ Paragraph(_rl(meta.get("date") or datetime.utcnow().strftime("%d/%m/%Y")), S["val"]),
423
+ Paragraph(_rl(meta.get("changes", "Initial issue")), S["val"]),
424
+ Paragraph(_rl(meta.get("client") or "—"), S["val"])])
425
+ el += [_grid(hi, accent, [0.8 * inch, 1.1 * inch, 2.6 * inch, 2.4 * inch]), Spacer(1, 14)]
426
+
427
+ el += [Paragraph("Abbreviations", S["h2"])]
428
+ ab = [[Paragraph("Abbreviation", S["th"]), Paragraph("Description", S["th"])]]
429
+ for a, d in ABBREVIATIONS:
430
+ ab.append([Paragraph(a, S["val"]), Paragraph(d, S["val"])])
431
+ el += [_grid(ab, accent, [1.3 * inch, CONTENT_W - 1.3 * inch]), PageBreak()]
432
+
433
+ # ---------------- Executive summary ----------------
434
+ el += [Paragraph("Executive Summary", S["h1"])]
435
+ summary_paras = payload.get("executive_summary") or []
436
+ if summary_paras:
437
+ for p in summary_paras:
438
+ el += _prose(p, S["body"])
439
+ else:
440
+ el += [Paragraph("This report presents the results of the security assessment "
441
+ f"of engagement {_rl(meta.get('engagement', ''))}.", S["body"]),
442
+ Spacer(1, 5)]
443
+ total = len(findings)
444
+ band_txt = ", ".join(f"<b>{v}</b> {k.lower()}"
445
+ for k, v, _, _ in [(n, counts.get(n, 0), None, None)
446
+ for n, *_ in RISK_BANDS] if v) or "no"
447
+ el += [Paragraph(
448
+ f"The assessment identified <b>{total}</b> finding{'' if total == 1 else 's'}: "
449
+ f"{band_txt}. Severities are computed from CVSS vectors by the assessment "
450
+ "tooling and independently replay-validated before inclusion.", S["body"]),
451
+ Spacer(1, 8)]
452
+
453
+ el += [Paragraph(N.table("Findings by Severity"), S["cap"])]
454
+ sc = [[Paragraph("Severity", S["th"]), Paragraph("CVSS Range", S["th"]),
455
+ Paragraph("Count", S["th"])]]
456
+ for name, col, rng, _ in RISK_BANDS:
457
+ if counts.get(name):
458
+ sc.append([Paragraph(f"<font color='{col}'><b>{name}</b></font>", S["val"]),
459
+ Paragraph(rng, S["val"]), Paragraph(str(counts[name]), S["val"])])
460
+ el += [_grid(sc, accent, [1.5 * inch, 1.5 * inch, 1.0 * inch]), Spacer(1, 12)]
461
+
462
+ if findings:
463
+ el += [Paragraph(N.table("Key Findings"), S["cap"])]
464
+ kf = [[Paragraph("ID", S["th"]), Paragraph("Severity", S["th"]),
465
+ Paragraph("Finding", S["th"]), Paragraph("CWE", S["th"])]]
466
+ for f in findings[:5]:
467
+ kf.append([Paragraph(f"<b>{_rl(f.get('id'))}</b>", S["val"]),
468
+ Paragraph(f"<font color='{SEVERITY_COLOR.get(f.get('severity'), '#7F7F7F')}'>"
469
+ f"<b>{_rl(f.get('severity'))}</b></font>", S["val"]),
470
+ Paragraph(_rl(f.get("title")), S["val"]),
471
+ Paragraph(_rl(f.get("cwe") or "—"), S["val"])])
472
+ el += [_grid(kf, accent, [0.6 * inch, 1.0 * inch, 4.2 * inch, 1.13 * inch])]
473
+ el += [PageBreak()]
474
+
475
+ # ---------------- Scope & methodology ----------------
476
+ scope = payload.get("scope") or {}
477
+ el += [Paragraph("Scope and Methodology", S["h1"]), Paragraph("Scope of Assessment", S["h2"])]
478
+ if scope.get("objectives"):
479
+ el += [Paragraph("Objectives", S["h3"])] + _prose(scope["objectives"], S["body"])
480
+ if scope.get("in_scope"):
481
+ el += [Paragraph("In Scope", S["h3"])] + _prose(scope["in_scope"], S["body"])
482
+ if scope.get("out_of_scope"):
483
+ el += [Paragraph("Out of Scope", S["h3"])] + _prose(scope["out_of_scope"], S["body"])
484
+ if scope.get("coverage_notes"):
485
+ el += [Paragraph("Coverage Limitations", S["h3"])] + _prose(scope["coverage_notes"], S["body"])
486
+ el += [Spacer(1, 6), Paragraph("Methodology", S["h2"]),
487
+ Paragraph("The assessment follows four phases.", S["body"]), Spacer(1, 4)]
488
+ for name, desc in METHODOLOGY:
489
+ el += [Paragraph(name, S["h3"]), Paragraph(desc, S["body"])]
490
+ el += [Spacer(1, 10)]
491
+
492
+ # ---------------- Risk methodology ----------------
493
+ el += [PageBreak(), Paragraph("Risk Rating Methodology", S["h1"]),
494
+ Paragraph("Each finding is scored with the Common Vulnerability Scoring "
495
+ "System (CVSS) by the assessment tooling — severity is computed "
496
+ "from the vector, never assigned by hand — and validated by "
497
+ "independent replay before inclusion in this report. The "
498
+ "qualitative bands below map the CVSS score to the reported "
499
+ "severity.", S["body"]),
500
+ Spacer(1, 8), Paragraph(N.table("Risk Severity Bands"), S["cap"])]
501
+ rb = [[Paragraph("Rating", S["th"]), Paragraph("CVSS Range", S["th"]),
502
+ Paragraph("Description and Required Action", S["th"])]]
503
+ for name, col, rng, desc in RISK_BANDS:
504
+ rb.append([Paragraph(f"<font color='{col}'><b>{name}</b></font>", S["val"]),
505
+ Paragraph(rng, S["val"]), Paragraph(desc, S["val"])])
506
+ el += [_grid(rb, accent, [1.1 * inch, 1.0 * inch, CONTENT_W - 2.1 * inch]), PageBreak()]
507
+
508
+ # ---------------- Findings summary index ----------------
509
+ el += [Paragraph("Findings Summary", S["h1"]),
510
+ Paragraph(f"The assessment identified {total} finding{'' if total == 1 else 's'}. "
511
+ "Each is identified by its register id, used throughout "
512
+ "this report and in follow-up tracking.", S["body"]),
513
+ Spacer(1, 8), Paragraph(N.table("Findings Summary Index"), S["cap"])]
514
+ fs_rows = [[Paragraph("ID", S["th"]), Paragraph("Severity", S["th"]),
515
+ Paragraph("CWE", S["th"]), Paragraph("CVSS", S["th"]),
516
+ Paragraph("Finding", S["th"]), Paragraph("Affected Assets", S["th"])]]
517
+ for f in findings:
518
+ fs_rows.append([
519
+ Paragraph(f"<b>{_rl(f.get('id'))}</b>", S["val"]),
520
+ Paragraph(f"<font color='{SEVERITY_COLOR.get(f.get('severity'), '#7F7F7F')}'>"
521
+ f"<b>{_rl(f.get('severity'))}</b></font>", S["val"]),
522
+ Paragraph(_rl(f.get("cwe") or "—"), S["val"]),
523
+ Paragraph(_rl(f.get("cvss_score")), S["val"]),
524
+ Paragraph(_rl(f.get("title")), S["val"]),
525
+ Paragraph(_rl(", ".join(f.get("assets") or []) or "—"), S["val"]),
526
+ ])
527
+ el += [_grid(fs_rows, accent, [0.5 * inch, 0.85 * inch, 0.75 * inch, 0.5 * inch,
528
+ 2.6 * inch, 1.73 * inch]), Spacer(1, 16)]
529
+
530
+ # ---------------- Detailed findings ----------------
531
+ el += [Paragraph("Detailed Findings", S["h1"]),
532
+ Paragraph("The following tables provide the self-contained detail for each "
533
+ "finding listed in the findings summary.", S["body"]), Spacer(1, 6)]
534
+ for f in findings:
535
+ el += _finding_table(f, N, S, accent)
536
+
537
+ # ---------------- Conclusion ----------------
538
+ el += [Spacer(1, 14), Paragraph("Conclusion", S["h1"])]
539
+ crit = counts.get("Critical", 0) + counts.get("High", 0)
540
+ el += [Paragraph(
541
+ f"The assessment identified {total} finding{'' if total == 1 else 's'} "
542
+ f"within the agreed scope, of which {crit} "
543
+ f"{'is' if crit == 1 else 'are'} rated High or Critical. "
544
+ "Addressing the highest-severity findings first delivers the greatest "
545
+ "reduction in risk for the least effort, and is the sequence recommended "
546
+ "by this report.", S["body"])]
547
+
548
+ # ---------------- Appendix ----------------
549
+ el += [PageBreak(), Paragraph("Appendix", S["h1"]),
550
+ Paragraph("Evidence Manifest", S["h2"]),
551
+ Paragraph("Every evidence item is held in a hash-chained ledger; the "
552
+ "SHA-256 digest below verifies the stored capture.", S["body"]),
553
+ Spacer(1, 6), Paragraph(N.table("Evidence Manifest"), S["cap"])]
554
+ ev = payload.get("evidence") or []
555
+ ev_rows = [[Paragraph("ID", S["th"]), Paragraph("Capture", S["th"]),
556
+ Paragraph("Linked Finding", S["th"]), Paragraph("SHA-256 (first 16)", S["th"])]]
557
+ for e in ev:
558
+ ev_rows.append([Paragraph(f"<b>{_rl(e.get('id'))}</b>", S["val"]),
559
+ Paragraph(_rl(e.get("path")), S["mono"]),
560
+ Paragraph(_rl(e.get("finding_id") or "—"), S["val"]),
561
+ Paragraph(_rl((e.get("sha256") or "")[:16] + "…"), S["mono"])])
562
+ if not ev:
563
+ ev_rows.append([Paragraph("—", S["val"]), Paragraph("no evidence recorded", S["val"]),
564
+ Paragraph("", S["val"]), Paragraph("", S["val"])])
565
+ el += [_grid(ev_rows, accent, [0.85 * inch, 3.0 * inch, 1.0 * inch, 2.08 * inch]),
566
+ Spacer(1, 12)]
567
+
568
+ rejected = payload.get("rejected") or []
569
+ if rejected:
570
+ el += [Paragraph("Rejected Findings", S["h2"]),
571
+ Paragraph("The following candidates did not meet the independent "
572
+ "replay-validation bar and are recorded for completeness.",
573
+ S["body"]), Spacer(1, 4)]
574
+ for r in rejected:
575
+ el += [Paragraph(f"• {_rl(r.get('id'))} — {_rl(r.get('title'))}", S["body"])]
576
+
577
+ doc.build(el, onFirstPage=deco, onLaterPages=deco)
578
+ buf.seek(0)
579
+ with open(out_path, "wb") as fh:
580
+ fh.write(buf.getvalue())
581
+ return out_path
582
+
583
+
584
+ def main():
585
+ ap = argparse.ArgumentParser(description="PENSIEVE formal report renderer (lane-B host tool)")
586
+ ap.add_argument("--output", required=True, help="PDF output path")
587
+ ap.add_argument("--payload", help="payload JSON file (default: stdin)")
588
+ args = ap.parse_args()
589
+
590
+ try:
591
+ raw = open(args.payload).read() if args.payload else sys.stdin.read()
592
+ payload = json.loads(raw)
593
+ except (OSError, json.JSONDecodeError) as e:
594
+ print(f"renderer: cannot read payload JSON: {e}", file=sys.stderr)
595
+ sys.exit(1)
596
+
597
+ try:
598
+ build_pdf(payload, args.output)
599
+ except Exception as e:
600
+ print(f"renderer: PDF build failed: {e}", file=sys.stderr)
601
+ sys.exit(1)
602
+
603
+ size = os.path.getsize(args.output)
604
+ print(json.dumps({"ok": True, "written": args.output, "bytes": size}))
605
+
606
+
607
+ if __name__ == "__main__":
608
+ main()