@attackforge/reportgen-node
v2.10.4
Published
AttackForge Report generator library for Node
Downloads
75
Readme
AttackForge Report Generator Library for Node
AttackForge ReportGen is a free tool to help penetration testers create powerful and robust automated pentest reports.
It works by combining a DOCX template with an AttackForge project JSON file, and outputs a DOCX report.
Example project data and DOCX templates, as well as additional tutorial material, are available on the AttackForge ReportGen page. A video presentation on the ReportGen product can be viewed here.
Additional support material is available on our Github Support Community.
Installation
$ npm install @attackforge/reportgen-node
Creating Programmatic Reports
To programmatically create reports, it is recommended to use the AttackForge Self-Service API to retrieve the JSON report data for a given project.
Reference
The AttackForge ReportGen library exports the following functions:
generateCommunityReport
If you exported your project data from the Community version of the AttackForge product, use this library function to generate your report document.
| Argument | Description |
|--|--|
| docxTemplate: ArrayBuffer
| An ArrayBuffer
instance containing the DOCX template file to generate the report with. Example project data and DOCX templates are available here.|
| reportData: any
| The parsed AttackGen JSON report data to compile into the report template.|
generateIndividualReport
If you exported your project data from the Core, or Enterprise versions of the AttackForge product, use this library function to generate your report document.
| Argument | Description |
|--|--|
| docxTemplate: ArrayBuffer
| An ArrayBuffer
instance containing the DOCX template file to generate the report with. Example project data and DOCX templates are available here.|
| reportData: any
| The parsed AttackGen JSON report data to compile into the report template.|
Example Usage
The following Typescript code snippet provides an example of how to use ReportGen to generate a report, given an AttackForge project JSON file, and a DOCX template.
Typescript
import { readFile, writeFile } from 'node:fs/promises';
import { generateCommunityReport, generateIndividualReport } from '@attackforge/reportgen-node';
async function readDataFileContents(filePath: string): Promise<any> {
const dataFileContents = await readFile(filePath, {
encoding: 'utf-8'
});
return JSON.parse(dataFileContents);
}
async function readDocxTemplateFileContents(templateFilePath: string): Promise<ArrayBuffer> {
return readFile(templateFilePath);
}
async function exampleUsage(): Promise<void> {
const templateFileContents = await readDocxTemplateFileContents('./template.docx');
const dataFileContents = await readDataFileContents('./data.json');
const reportOutput = await generateCommunityReport(templateFileContents, dataFileContents);
await writeFile('report.docx', Buffer.from(reportOutput));
}
Javascript
const { readFile, writeFile } = require('fs/promises');
const { generateCommunityReport, generateIndividualReport } = require('@attackforge/reportgen-node');
async function readDataFileContents(filePath) {
const dataFileContents = await readFile(filePath, {
encoding: 'utf-8'
});
return JSON.parse(dataFileContents);
}
async function readDocxTemplateFileContents(templateFilePath) {
return readFile(templateFilePath);
}
async function exampleUsage() {
const templateFileContents = await readDocxTemplateFileContents('./template.docx');
const dataFileContents = await readDataFileContents('./data.json');
const reportOutput = await generateCommunityReport(templateFileContents, dataFileContents);
await writeFile('report.docx', Buffer.from(reportOutput));
}