cantarella-framework 1.18.0 → 1.20.0

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 (60) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/modules/code-audit-codeql-import/index.mjs +46 -0
  3. package/modules/code-audit-codeql-import/module.json +14 -0
  4. package/modules/forensics-autopsy-import/index.mjs +42 -0
  5. package/modules/forensics-autopsy-import/module.json +14 -0
  6. package/modules/incident-response-velociraptor-import/index.mjs +48 -0
  7. package/modules/incident-response-velociraptor-import/module.json +14 -0
  8. package/modules/internal-bloodhound-import/index.mjs +43 -0
  9. package/modules/internal-bloodhound-import/module.json +14 -0
  10. package/modules/mobile-mobsf-import/index.mjs +45 -0
  11. package/modules/mobile-mobsf-import/module.json +14 -0
  12. package/modules/reporting-docx-export/index.mjs +145 -0
  13. package/modules/reporting-docx-export/module.json +14 -0
  14. package/modules/reporting-pdf-export/index.mjs +88 -0
  15. package/modules/reporting-pdf-export/module.json +14 -0
  16. package/modules/vuln-management-qualys-import/index.mjs +46 -0
  17. package/modules/vuln-management-qualys-import/module.json +14 -0
  18. package/modules/wrapper-auditd/index.mjs +45 -0
  19. package/modules/wrapper-auditd/module.json +21 -0
  20. package/modules/wrapper-beef/index.mjs +35 -0
  21. package/modules/wrapper-beef/module.json +21 -0
  22. package/modules/wrapper-chainsaw/index.mjs +54 -0
  23. package/modules/wrapper-chainsaw/module.json +21 -0
  24. package/modules/wrapper-cloudsploit/index.mjs +61 -0
  25. package/modules/wrapper-cloudsploit/module.json +21 -0
  26. package/modules/wrapper-covenant/index.mjs +35 -0
  27. package/modules/wrapper-covenant/module.json +21 -0
  28. package/modules/wrapper-eslint/index.mjs +53 -0
  29. package/modules/wrapper-eslint/module.json +21 -0
  30. package/modules/wrapper-foremost/index.mjs +57 -0
  31. package/modules/wrapper-foremost/module.json +21 -0
  32. package/modules/wrapper-grype/index.mjs +48 -0
  33. package/modules/wrapper-grype/module.json +21 -0
  34. package/modules/wrapper-hayabusa/index.mjs +55 -0
  35. package/modules/wrapper-hayabusa/module.json +21 -0
  36. package/modules/wrapper-kube-hunter/index.mjs +44 -0
  37. package/modules/wrapper-kube-hunter/module.json +21 -0
  38. package/modules/wrapper-mythic/index.mjs +42 -0
  39. package/modules/wrapper-mythic/module.json +21 -0
  40. package/modules/wrapper-openscap/index.mjs +47 -0
  41. package/modules/wrapper-openscap/module.json +28 -0
  42. package/modules/wrapper-recon-ng/index.mjs +40 -0
  43. package/modules/wrapper-recon-ng/module.json +21 -0
  44. package/modules/wrapper-ripgrep/index.mjs +42 -0
  45. package/modules/wrapper-ripgrep/module.json +28 -0
  46. package/modules/wrapper-scoutsuite/index.mjs +61 -0
  47. package/modules/wrapper-scoutsuite/module.json +21 -0
  48. package/modules/wrapper-sigma/index.mjs +34 -0
  49. package/modules/wrapper-sigma/module.json +28 -0
  50. package/modules/wrapper-sliver/index.mjs +35 -0
  51. package/modules/wrapper-sliver/module.json +21 -0
  52. package/modules/wrapper-syft/index.mjs +43 -0
  53. package/modules/wrapper-syft/module.json +21 -0
  54. package/modules/wrapper-tfsec/index.mjs +43 -0
  55. package/modules/wrapper-tfsec/module.json +21 -0
  56. package/modules/wrapper-trufflehog/index.mjs +49 -0
  57. package/modules/wrapper-trufflehog/module.json +21 -0
  58. package/package.json +1 -1
  59. package/packages/cli/dist/cli.js +1 -1
  60. package/packages/gui/dist/server.js +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.20.0
4
+
5
+ - New modules: Foremost file carving, Sigma rule conversion, Hayabusa timeline building, Chainsaw threat hunting, Velociraptor export import, Qualys report import, OpenSCAP compliance evaluation, ausearch audit log search, DOCX export, PDF export, BeEF version check, Sliver version check, Covenant version check, and Mythic status check. All tools named in the concept map are now covered.
6
+
7
+ ## 1.19.0
8
+
9
+ - New modules: Recon-ng module search, MobSF report import, BloodHound export import, ScoutSuite AWS auditing, CloudSploit cloud checks, kube-hunter Kubernetes hunting, Grype vulnerability scanning, Syft package inventory, tfsec Terraform checks, TruffleHog secret scanning, CodeQL SARIF import, ESLint code linting, ripgrep code search, and Autopsy report import.
10
+
3
11
  ## 1.18.0
4
12
 
5
13
  - New modules: tshark packet reading, SpiderFoot OSINT scanning, OWASP ZAP quick scanning, testssl.sh TLS auditing, Kiterunner API route discovery, Burp Suite issue import, aapt APK metadata, frida-ps device process listing, Bettercap network probing, Kismet device extraction, CUPP targeted wordlists, Impacket GetNPUsers AS-REP requests, ldapdomaindump domain user dumping, and bulk_extractor email and URL carving.
@@ -0,0 +1,46 @@
1
+ import { readFileSync } from "node:fs";
2
+
3
+ let input = "";
4
+ process.stdin.setEncoding("utf8");
5
+ process.stdin.on("data", (chunk) => (input += chunk));
6
+ process.stdin.on("end", () => {
7
+ const request = JSON.parse(input || "{}");
8
+ const emit = (event) => process.stdout.write(`${JSON.stringify(event)}\n`);
9
+ try {
10
+ const result = build(String(request.target ?? ""));
11
+ emit({ type: "result", summary: result.summary, data: result.data });
12
+ emit({ type: "done", summary: `CodeQL import finished: ${result.data.issues.length} issues.` });
13
+ } catch (error) {
14
+ emit({ type: "error", message: error.message });
15
+ process.exitCode = 1;
16
+ }
17
+ });
18
+
19
+ function build(target) {
20
+ let raw;
21
+ try {
22
+ raw = readFileSync(target, "utf8");
23
+ } catch {
24
+ throw new Error(`Cannot read CodeQL SARIF file: ${target}.`);
25
+ }
26
+ let parsed;
27
+ try {
28
+ parsed = JSON.parse(raw);
29
+ } catch {
30
+ throw new Error(`Invalid CodeQL SARIF file: ${target} is not valid JSON.`);
31
+ }
32
+ const runs = Array.isArray(parsed.runs) ? parsed.runs : [];
33
+ const results = runs.length > 0 && Array.isArray(runs[0].results) ? runs[0].results : [];
34
+ const issues = [];
35
+ for (const entry of results) {
36
+ issues.push({
37
+ rule: entry.ruleId ?? "",
38
+ level: entry.level ?? "",
39
+ message: entry.message?.text ?? "",
40
+ });
41
+ }
42
+ return {
43
+ summary: `CodeQL import read ${issues.length} issues from ${target}.`,
44
+ data: { source: target, issues: issues.slice(0, 100) },
45
+ };
46
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "category": "code-audit",
3
+ "core_api": "^0.1.0",
4
+ "description": "Imports findings from a CodeQL SARIF file and reports them.",
5
+ "entry": "index.mjs",
6
+ "id": "code-audit/codeql-import",
7
+ "kind": "native",
8
+ "maintenance": "active",
9
+ "name": "CodeQL Import",
10
+ "options": [],
11
+ "risk": "info",
12
+ "schema_version": 1,
13
+ "version": "0.1.0"
14
+ }
@@ -0,0 +1,42 @@
1
+ import { readFileSync } from "node:fs";
2
+
3
+ let input = "";
4
+ process.stdin.setEncoding("utf8");
5
+ process.stdin.on("data", (chunk) => (input += chunk));
6
+ process.stdin.on("end", () => {
7
+ const request = JSON.parse(input || "{}");
8
+ const emit = (event) => process.stdout.write(`${JSON.stringify(event)}\n`);
9
+ try {
10
+ const result = build(String(request.target ?? ""));
11
+ emit({ type: "result", summary: result.summary, data: result.data });
12
+ emit({ type: "done", summary: `Autopsy import finished: ${result.data.sections.length} sections.` });
13
+ } catch (error) {
14
+ emit({ type: "error", message: error.message });
15
+ process.exitCode = 1;
16
+ }
17
+ });
18
+
19
+ function build(target) {
20
+ let raw;
21
+ try {
22
+ raw = readFileSync(target, "utf8");
23
+ } catch {
24
+ throw new Error(`Cannot read Autopsy report file: ${target}.`);
25
+ }
26
+ const sections = [];
27
+ const parts = raw.split(/<h2[^>]*>/i);
28
+ for (let index = 1; index < parts.length; index += 1) {
29
+ const part = parts[index];
30
+ const name = part.split("</h2>")[0].replace(/<[^>]+>/g, "").trim();
31
+ const rows = (part.match(/<tr>/gi) ?? []).length;
32
+ if (name) sections.push({ name, artifacts: rows });
33
+ }
34
+ if (!sections.length) {
35
+ throw new Error(`No report sections found in ${target}.`);
36
+ }
37
+ const total = sections.reduce((sum, section) => sum + section.artifacts, 0);
38
+ return {
39
+ summary: `Autopsy import read ${total} artifacts across ${sections.length} sections from ${target}.`,
40
+ data: { source: target, total, sections },
41
+ };
42
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "category": "forensics",
3
+ "core_api": "^0.1.0",
4
+ "description": "Imports artifact counts from an Autopsy HTML report and reports them by section.",
5
+ "entry": "index.mjs",
6
+ "id": "forensics/autopsy-import",
7
+ "kind": "native",
8
+ "maintenance": "active",
9
+ "name": "Autopsy Import",
10
+ "options": [],
11
+ "risk": "info",
12
+ "schema_version": 1,
13
+ "version": "0.1.0"
14
+ }
@@ -0,0 +1,48 @@
1
+ import { readFileSync } from "node:fs";
2
+
3
+ let input = "";
4
+ process.stdin.setEncoding("utf8");
5
+ process.stdin.on("data", (chunk) => (input += chunk));
6
+ process.stdin.on("end", () => {
7
+ const request = JSON.parse(input || "{}");
8
+ const emit = (event) => process.stdout.write(`${JSON.stringify(event)}\n`);
9
+ try {
10
+ const result = build(String(request.target ?? ""));
11
+ emit({ type: "result", summary: result.summary, data: result.data });
12
+ emit({ type: "done", summary: `Velociraptor import finished: ${result.data.rows} rows.` });
13
+ } catch (error) {
14
+ emit({ type: "error", message: error.message });
15
+ process.exitCode = 1;
16
+ }
17
+ });
18
+
19
+ function build(target) {
20
+ let raw;
21
+ try {
22
+ raw = readFileSync(target, "utf8");
23
+ } catch {
24
+ throw new Error(`Cannot read Velociraptor export file: ${target}.`);
25
+ }
26
+ const trimmed = raw.trim();
27
+ if (trimmed.startsWith("[")) {
28
+ let parsed;
29
+ try {
30
+ parsed = JSON.parse(trimmed);
31
+ } catch {
32
+ throw new Error(`Invalid Velociraptor export file: ${target} is not valid JSON.`);
33
+ }
34
+ if (!Array.isArray(parsed)) throw new Error(`Invalid Velociraptor export file: ${target} is not a JSON array.`);
35
+ const columns = parsed.length > 0 ? Object.keys(parsed[0]) : [];
36
+ return {
37
+ summary: `Velociraptor import read ${parsed.length} rows from ${target}.`,
38
+ data: { source: target, format: "json", rows: parsed.length, columns, sample: parsed.slice(0, 5) },
39
+ };
40
+ }
41
+ const lines = trimmed.split("\n").filter((line) => line.trim());
42
+ if (!lines.length) throw new Error(`No rows found in ${target}.`);
43
+ const columns = lines[0].split(",").map((cell) => cell.trim());
44
+ return {
45
+ summary: `Velociraptor import read ${lines.length - 1} rows from ${target}.`,
46
+ data: { source: target, format: "csv", rows: Math.max(0, lines.length - 1), columns },
47
+ };
48
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "category": "incident-response",
3
+ "core_api": "^0.1.0",
4
+ "description": "Imports rows from a Velociraptor query export and reports what it contains.",
5
+ "entry": "index.mjs",
6
+ "id": "incident-response/velociraptor-import",
7
+ "kind": "native",
8
+ "maintenance": "active",
9
+ "name": "Velociraptor Import",
10
+ "options": [],
11
+ "risk": "info",
12
+ "schema_version": 1,
13
+ "version": "0.1.0"
14
+ }
@@ -0,0 +1,43 @@
1
+ import { readFileSync } from "node:fs";
2
+
3
+ let input = "";
4
+ process.stdin.setEncoding("utf8");
5
+ process.stdin.on("data", (chunk) => (input += chunk));
6
+ process.stdin.on("end", () => {
7
+ const request = JSON.parse(input || "{}");
8
+ const emit = (event) => process.stdout.write(`${JSON.stringify(event)}\n`);
9
+ try {
10
+ const result = build(String(request.target ?? ""));
11
+ emit({ type: "result", summary: result.summary, data: result.data });
12
+ emit({ type: "done", summary: `BloodHound import finished: ${result.data.total} ${result.data.type}.` });
13
+ } catch (error) {
14
+ emit({ type: "error", message: error.message });
15
+ process.exitCode = 1;
16
+ }
17
+ });
18
+
19
+ function build(target) {
20
+ let raw;
21
+ try {
22
+ raw = readFileSync(target, "utf8");
23
+ } catch {
24
+ throw new Error(`Cannot read BloodHound export file: ${target}.`);
25
+ }
26
+ let parsed;
27
+ try {
28
+ parsed = JSON.parse(raw);
29
+ } catch {
30
+ throw new Error(`Invalid BloodHound export file: ${target} is not valid JSON.`);
31
+ }
32
+ const data = Array.isArray(parsed.data) ? parsed.data : [];
33
+ const type = parsed.meta?.type ?? "objects";
34
+ const names = [];
35
+ for (const entry of data) {
36
+ const name = entry.properties?.name ?? entry.name ?? "";
37
+ if (name) names.push(name);
38
+ }
39
+ return {
40
+ summary: `BloodHound import read ${data.length} ${type} from ${target}.`,
41
+ data: { source: target, type, total: data.length, names: names.slice(0, 100) },
42
+ };
43
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "category": "internal",
3
+ "core_api": "^0.1.0",
4
+ "description": "Imports objects from a BloodHound JSON export and reports what it contains.",
5
+ "entry": "index.mjs",
6
+ "id": "internal/bloodhound-import",
7
+ "kind": "native",
8
+ "maintenance": "active",
9
+ "name": "BloodHound Import",
10
+ "options": [],
11
+ "risk": "info",
12
+ "schema_version": 1,
13
+ "version": "0.1.0"
14
+ }
@@ -0,0 +1,45 @@
1
+ import { readFileSync } from "node:fs";
2
+
3
+ let input = "";
4
+ process.stdin.setEncoding("utf8");
5
+ process.stdin.on("data", (chunk) => (input += chunk));
6
+ process.stdin.on("end", () => {
7
+ const request = JSON.parse(input || "{}");
8
+ const emit = (event) => process.stdout.write(`${JSON.stringify(event)}\n`);
9
+ try {
10
+ const result = build(String(request.target ?? ""));
11
+ emit({ type: "result", summary: result.summary, data: result.data });
12
+ emit({ type: "done", summary: `MobSF import finished: ${result.data.findings} findings.` });
13
+ } catch (error) {
14
+ emit({ type: "error", message: error.message });
15
+ process.exitCode = 1;
16
+ }
17
+ });
18
+
19
+ function build(target) {
20
+ let raw;
21
+ try {
22
+ raw = readFileSync(target, "utf8");
23
+ } catch {
24
+ throw new Error(`Cannot read MobSF report file: ${target}.`);
25
+ }
26
+ let parsed;
27
+ try {
28
+ parsed = JSON.parse(raw);
29
+ } catch {
30
+ throw new Error(`Invalid MobSF report file: ${target} is not valid JSON.`);
31
+ }
32
+ const findings = parsed.findings ?? parsed.results ?? {};
33
+ const count = Array.isArray(findings) ? findings.length : Object.keys(findings).length;
34
+ return {
35
+ summary: `MobSF import read ${parsed.app_name ?? target}: ${count} findings, average CVSS ${parsed.average_cvss ?? "unknown"}.`,
36
+ data: {
37
+ source: target,
38
+ app_name: parsed.app_name ?? "",
39
+ package_name: parsed.package_name ?? "",
40
+ average_cvss: parsed.average_cvss ?? null,
41
+ security_score: parsed.security_score ?? null,
42
+ findings: count,
43
+ },
44
+ };
45
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "category": "mobile",
3
+ "core_api": "^0.1.0",
4
+ "description": "Imports findings from a MobSF JSON report and reports the app score and findings.",
5
+ "entry": "index.mjs",
6
+ "id": "mobile/mobsf-import",
7
+ "kind": "native",
8
+ "maintenance": "active",
9
+ "name": "MobSF Import",
10
+ "options": [],
11
+ "risk": "info",
12
+ "schema_version": 1,
13
+ "version": "0.1.0"
14
+ }
@@ -0,0 +1,145 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { deflateRawSync } from "node:zlib";
3
+
4
+ let input = "";
5
+ process.stdin.setEncoding("utf8");
6
+ process.stdin.on("data", (chunk) => (input += chunk));
7
+ process.stdin.on("end", () => {
8
+ const request = JSON.parse(input || "{}");
9
+ const emit = (event) => process.stdout.write(`${JSON.stringify(event)}\n`);
10
+ try {
11
+ const result = build(String(request.target ?? ""));
12
+ emit({ type: "result", summary: result.summary, data: result.data });
13
+ emit({ type: "done", summary: `DOCX export finished: ${result.data.events} events.` });
14
+ } catch (error) {
15
+ emit({ type: "error", message: error.message });
16
+ process.exitCode = 1;
17
+ }
18
+ });
19
+
20
+ const CRC_TABLE = (() => {
21
+ const table = new Int32Array(256);
22
+ for (let n = 0; n < 256; n += 1) {
23
+ let c = n;
24
+ for (let k = 0; k < 8; k += 1) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
25
+ table[n] = c;
26
+ }
27
+ return table;
28
+ })();
29
+
30
+ function crc32(buffer) {
31
+ let c = 0xffffffff;
32
+ for (const byte of buffer) c = CRC_TABLE[(c ^ byte) & 0xff] ^ (c >>> 8);
33
+ return (c ^ 0xffffffff) >>> 0;
34
+ }
35
+
36
+ function zipEntry(name, data, offset) {
37
+ const compressed = deflateRawSync(data);
38
+ const crc = crc32(data);
39
+ const nameBuffer = Buffer.from(name, "utf8");
40
+ const local = Buffer.alloc(30);
41
+ local.writeUInt32LE(0x04034b50, 0);
42
+ local.writeUInt16LE(20, 4);
43
+ local.writeUInt16LE(0, 6);
44
+ local.writeUInt16LE(8, 8);
45
+ local.writeUInt16LE(0, 10);
46
+ local.writeUInt16LE(0, 12);
47
+ local.writeUInt32LE(crc, 14);
48
+ local.writeUInt32LE(compressed.length, 18);
49
+ local.writeUInt32LE(data.length, 22);
50
+ local.writeUInt16LE(nameBuffer.length, 26);
51
+ local.writeUInt16LE(0, 28);
52
+ const central = Buffer.alloc(46);
53
+ central.writeUInt32LE(0x02014b50, 0);
54
+ central.writeUInt16LE(20, 4);
55
+ central.writeUInt16LE(20, 6);
56
+ central.writeUInt16LE(0, 8);
57
+ central.writeUInt16LE(8, 10);
58
+ central.writeUInt16LE(0, 12);
59
+ central.writeUInt16LE(0, 14);
60
+ central.writeUInt32LE(crc, 16);
61
+ central.writeUInt32LE(compressed.length, 20);
62
+ central.writeUInt32LE(data.length, 24);
63
+ central.writeUInt16LE(nameBuffer.length, 28);
64
+ central.writeUInt16LE(0, 30);
65
+ central.writeUInt16LE(0, 32);
66
+ central.writeUInt16LE(0, 34);
67
+ central.writeUInt16LE(0, 36);
68
+ central.writeUInt32LE(0, 38);
69
+ central.writeUInt32LE(offset, 42);
70
+ return {
71
+ local: Buffer.concat([local, nameBuffer, compressed]),
72
+ central: Buffer.concat([central, nameBuffer]),
73
+ size: 30 + nameBuffer.length + compressed.length,
74
+ };
75
+ }
76
+
77
+ function escapeXml(value) {
78
+ return String(value ?? "")
79
+ .replace(/&/g, "&amp;")
80
+ .replace(/</g, "&lt;")
81
+ .replace(/>/g, "&gt;");
82
+ }
83
+
84
+ function buildDocx(paragraphs) {
85
+ const body = paragraphs
86
+ .map((paragraph) => `<w:p><w:r><w:t>${escapeXml(paragraph)}</w:t></w:r></w:p>`)
87
+ .join("");
88
+ const documentXml = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:body>${body}</w:body></w:document>`;
89
+ const contentTypes = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/></Types>`;
90
+ const rels = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/></Relationships>`;
91
+ const files = [
92
+ ["[Content_Types].xml", Buffer.from(contentTypes, "utf8")],
93
+ ["_rels/.rels", Buffer.from(rels, "utf8")],
94
+ ["word/document.xml", Buffer.from(documentXml, "utf8")],
95
+ ];
96
+ const locals = [];
97
+ const centrals = [];
98
+ let offset = 0;
99
+ for (const [name, data] of files) {
100
+ const entry = zipEntry(name, data, offset);
101
+ locals.push(entry.local);
102
+ centrals.push(entry.central);
103
+ offset += entry.size;
104
+ }
105
+ const centralDir = Buffer.concat(centrals);
106
+ const end = Buffer.alloc(22);
107
+ end.writeUInt32LE(0x06054b50, 0);
108
+ end.writeUInt16LE(0, 4);
109
+ end.writeUInt16LE(0, 6);
110
+ end.writeUInt16LE(files.length, 8);
111
+ end.writeUInt16LE(files.length, 10);
112
+ end.writeUInt32LE(centralDir.length, 12);
113
+ end.writeUInt32LE(offset, 16);
114
+ end.writeUInt16LE(0, 20);
115
+ return Buffer.concat([...locals, centralDir, end]);
116
+ }
117
+
118
+ function build(target) {
119
+ let raw;
120
+ try {
121
+ raw = readFileSync(target, "utf8");
122
+ } catch {
123
+ throw new Error(`Cannot read results file: ${target}.`);
124
+ }
125
+ let parsed;
126
+ try {
127
+ parsed = JSON.parse(raw);
128
+ } catch {
129
+ throw new Error(`Invalid results file: ${target} is not valid JSON.`);
130
+ }
131
+ const events = Array.isArray(parsed.events) ? parsed.events : [];
132
+ const paragraphs = [`Cantarella Report: ${parsed.module?.id ?? "unknown"}`];
133
+ let count = 0;
134
+ for (const event of events) {
135
+ if (event.type !== "result" && event.type !== "error") continue;
136
+ const text = event.type === "result" ? (event.summary ?? "") : (event.message ?? "");
137
+ paragraphs.push(`[${event.type}] ${text}`);
138
+ count += 1;
139
+ }
140
+ const docx = buildDocx(paragraphs);
141
+ return {
142
+ summary: `DOCX export built: ${count} events from ${target}.`,
143
+ data: { source: target, events: count, docx: docx.toString("base64") },
144
+ };
145
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "category": "reporting",
3
+ "core_api": "^0.1.0",
4
+ "description": "Converts a Cantarella run results file into a Word document.",
5
+ "entry": "index.mjs",
6
+ "id": "reporting/docx-export",
7
+ "kind": "native",
8
+ "maintenance": "active",
9
+ "name": "DOCX Export",
10
+ "options": [],
11
+ "risk": "info",
12
+ "schema_version": 1,
13
+ "version": "0.1.0"
14
+ }
@@ -0,0 +1,88 @@
1
+ import { readFileSync } from "node:fs";
2
+
3
+ let input = "";
4
+ process.stdin.setEncoding("utf8");
5
+ process.stdin.on("data", (chunk) => (input += chunk));
6
+ process.stdin.on("end", () => {
7
+ const request = JSON.parse(input || "{}");
8
+ const emit = (event) => process.stdout.write(`${JSON.stringify(event)}\n`);
9
+ try {
10
+ const result = build(String(request.target ?? ""));
11
+ emit({ type: "result", summary: result.summary, data: result.data });
12
+ emit({ type: "done", summary: `PDF export finished: ${result.data.events} events.` });
13
+ } catch (error) {
14
+ emit({ type: "error", message: error.message });
15
+ process.exitCode = 1;
16
+ }
17
+ });
18
+
19
+ function escapePdf(value) {
20
+ return String(value ?? "")
21
+ .replace(/\\/g, "\\\\")
22
+ .replace(/\(/g, "\\(")
23
+ .replace(/\)/g, "\\)");
24
+ }
25
+
26
+ function buildPdf(lines) {
27
+ const contentLines = [];
28
+ let y = 750;
29
+ for (const line of lines.slice(0, 40)) {
30
+ contentLines.push(`BT /F1 11 Tf 40 ${y} Td (${escapePdf(line)}) Tj ET`);
31
+ y -= 16;
32
+ }
33
+ const content = contentLines.join("\n");
34
+ const contentBuffer = Buffer.from(content, "utf8");
35
+ const objects = [
36
+ "<< /Type /Catalog /Pages 2 0 R >>",
37
+ "<< /Type /Pages /Kids [3 0 R] /Count 1 >>",
38
+ "<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Resources << /Font << /F1 5 0 R >> >> /Contents 4 0 R >>",
39
+ `<< /Length ${contentBuffer.length} >>\nstream\n${content}\nendstream`,
40
+ "<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>",
41
+ ];
42
+ const parts = [Buffer.from("%PDF-1.4\n", "utf8")];
43
+ const offsets = [0];
44
+ let offset = parts[0].length;
45
+ objects.forEach((object, index) => {
46
+ const body = Buffer.from(`${index + 1} 0 obj\n${object}\nendobj\n`, "utf8");
47
+ offsets.push(offset);
48
+ parts.push(body);
49
+ offset += body.length;
50
+ });
51
+ const xrefOffset = offset;
52
+ let xref = `xref\n0 ${objects.length + 1}\n0000000000 65535 f \n`;
53
+ for (let index = 1; index <= objects.length; index += 1) {
54
+ xref += `${String(offsets[index]).padStart(10, "0")} 00000 n \n`;
55
+ }
56
+ xref += `trailer\n<< /Size ${objects.length + 1} /Root 1 0 R >>\nstartxref\n${xrefOffset}\n%%EOF`;
57
+ parts.push(Buffer.from(xref, "utf8"));
58
+ return Buffer.concat(parts);
59
+ }
60
+
61
+ function build(target) {
62
+ let raw;
63
+ try {
64
+ raw = readFileSync(target, "utf8");
65
+ } catch {
66
+ throw new Error(`Cannot read results file: ${target}.`);
67
+ }
68
+ let parsed;
69
+ try {
70
+ parsed = JSON.parse(raw);
71
+ } catch {
72
+ throw new Error(`Invalid results file: ${target} is not valid JSON.`);
73
+ }
74
+ const events = Array.isArray(parsed.events) ? parsed.events : [];
75
+ const lines = [`Cantarella Report: ${parsed.module?.id ?? "unknown"}`];
76
+ let count = 0;
77
+ for (const event of events) {
78
+ if (event.type !== "result" && event.type !== "error") continue;
79
+ const text = event.type === "result" ? (event.summary ?? "") : (event.message ?? "");
80
+ lines.push(`[${event.type}] ${text}`);
81
+ count += 1;
82
+ }
83
+ const pdf = buildPdf(lines);
84
+ return {
85
+ summary: `PDF export built: ${count} events from ${target}.`,
86
+ data: { source: target, events: count, pdf: pdf.toString("base64") },
87
+ };
88
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "category": "reporting",
3
+ "core_api": "^0.1.0",
4
+ "description": "Converts a Cantarella run results file into a PDF document.",
5
+ "entry": "index.mjs",
6
+ "id": "reporting/pdf-export",
7
+ "kind": "native",
8
+ "maintenance": "active",
9
+ "name": "PDF Export",
10
+ "options": [],
11
+ "risk": "info",
12
+ "schema_version": 1,
13
+ "version": "0.1.0"
14
+ }
@@ -0,0 +1,46 @@
1
+ import { readFileSync } from "node:fs";
2
+
3
+ let input = "";
4
+ process.stdin.setEncoding("utf8");
5
+ process.stdin.on("data", (chunk) => (input += chunk));
6
+ process.stdin.on("end", () => {
7
+ const request = JSON.parse(input || "{}");
8
+ const emit = (event) => process.stdout.write(`${JSON.stringify(event)}\n`);
9
+ try {
10
+ const result = build(String(request.target ?? ""));
11
+ emit({ type: "result", summary: result.summary, data: result.data });
12
+ emit({ type: "done", summary: `Qualys import finished: ${result.data.vulnerabilities.length} vulnerabilities.` });
13
+ } catch (error) {
14
+ emit({ type: "error", message: error.message });
15
+ process.exitCode = 1;
16
+ }
17
+ });
18
+
19
+ function field(block, tag) {
20
+ const match = block.match(new RegExp(`<${tag}>([\\s\\S]*?)</${tag}>`));
21
+ return match ? match[1].trim() : "";
22
+ }
23
+
24
+ function build(target) {
25
+ let raw;
26
+ try {
27
+ raw = readFileSync(target, "utf8");
28
+ } catch {
29
+ throw new Error(`Cannot read Qualys report file: ${target}.`);
30
+ }
31
+ const hosts = [];
32
+ const ipMatches = raw.match(/<IP>([\s\S]*?)<\/IP>/g) ?? [];
33
+ for (const ipMatch of ipMatches) {
34
+ const value = ipMatch.replace(/<\/?IP>/g, "").trim();
35
+ if (value) hosts.push(value);
36
+ }
37
+ const vulnerabilities = [];
38
+ const blocks = raw.match(/<VULN_INFO>[\s\S]*?<\/VULN_INFO>/g) ?? [];
39
+ for (const block of blocks) {
40
+ vulnerabilities.push({ qid: field(block, "QID"), severity: field(block, "SEVERITY") });
41
+ }
42
+ return {
43
+ summary: `Qualys import read ${hosts.length} hosts and ${vulnerabilities.length} vulnerabilities from ${target}.`,
44
+ data: { source: target, hosts, vulnerabilities: vulnerabilities.slice(0, 100) },
45
+ };
46
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "category": "vuln-management",
3
+ "core_api": "^0.1.0",
4
+ "description": "Imports hosts and vulnerabilities from a Qualys XML report and reports them.",
5
+ "entry": "index.mjs",
6
+ "id": "vuln-management/qualys-import",
7
+ "kind": "native",
8
+ "maintenance": "active",
9
+ "name": "Qualys Import",
10
+ "options": [],
11
+ "risk": "info",
12
+ "schema_version": 1,
13
+ "version": "0.1.0"
14
+ }