cantarella-framework 1.7.0 → 1.8.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.8.0
4
+
5
+ - New modules: Ansible playbook runs, Trivy filesystem scans, Markdown report building, and OWASP Dependency-Check scans.
6
+
3
7
  ## 1.7.0
4
8
 
5
9
  - New modules: JADX APK decompilation, Metasploit module search, Volatility 3 memory analysis, and wordlist generation.
@@ -0,0 +1,55 @@
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: `Markdown report built from ${result.data.source}.` });
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 results file: ${target}.`);
25
+ }
26
+ let parsed;
27
+ try {
28
+ parsed = JSON.parse(raw);
29
+ } catch {
30
+ throw new Error(`Invalid results file: ${target} is not valid JSON.`);
31
+ }
32
+ const events = Array.isArray(parsed.events) ? parsed.events : [];
33
+ const results = events.filter((event) => event.type === "result");
34
+ const errors = events.filter((event) => event.type === "error");
35
+ const lines = ["# Cantarella Report", "", `Source: ${target}`, "", `Results: ${results.length}`, `Errors: ${errors.length}`, ""];
36
+ if (results.length) {
37
+ lines.push("## Findings", "");
38
+ for (const result of results) {
39
+ lines.push(`- ${result.summary ?? "(no summary)"}`);
40
+ }
41
+ lines.push("");
42
+ }
43
+ if (errors.length) {
44
+ lines.push("## Errors", "");
45
+ for (const error of errors) {
46
+ lines.push(`- ${error.message ?? "(no message)"}`);
47
+ }
48
+ lines.push("");
49
+ }
50
+ const markdown = lines.join("\n");
51
+ return {
52
+ summary: `Markdown report built: ${results.length} results, ${errors.length} errors.`,
53
+ data: { source: target, results: results.length, errors: errors.length, markdown },
54
+ };
55
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "category": "reporting",
3
+ "core_api": "^0.1.0",
4
+ "description": "Builds a Markdown report from a Cantarella run results file.",
5
+ "entry": "index.mjs",
6
+ "id": "reporting/markdown-report",
7
+ "kind": "native",
8
+ "maintenance": "active",
9
+ "name": "Markdown Report",
10
+ "options": [],
11
+ "risk": "info",
12
+ "schema_version": 1,
13
+ "version": "0.1.0"
14
+ }
@@ -0,0 +1,54 @@
1
+ import { spawn } from "node:child_process";
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
+ const target = String(request.target ?? "");
10
+ const args = [target];
11
+ const inventory = String(request.options?.inventory ?? "").trim();
12
+ if (inventory) args.push("-i", inventory);
13
+ const tags = String(request.options?.tags ?? "").trim();
14
+ if (tags) args.push("--tags", tags);
15
+ const child = spawn("ansible-playbook", args, { stdio: ["ignore", "pipe", "pipe"] });
16
+ let stdout = "";
17
+ let stderr = "";
18
+ child.stdout.on("data", (chunk) => (stdout += chunk));
19
+ child.stderr.on("data", (chunk) => (stderr += chunk));
20
+ child.on("error", (error) => {
21
+ emit({ type: "error", message: `Ansible failed: ${error.message}` });
22
+ process.exitCode = 1;
23
+ });
24
+ child.on("close", (code) => {
25
+ const plain = stdout.replace(/\x1b\[[0-9;]*m/g, "");
26
+ const hosts = [];
27
+ for (const line of plain.split("\n")) {
28
+ const trimmed = line.trim();
29
+ const match = trimmed.match(/^(\S+)\s+:\s+ok=(\d+)\s+changed=(\d+)\s+unreachable=(\d+)\s+failed=(\d+)\s+skipped=(\d+)/);
30
+ if (!match) continue;
31
+ hosts.push({
32
+ host: match[1],
33
+ ok: Number(match[2]),
34
+ changed: Number(match[3]),
35
+ unreachable: Number(match[4]),
36
+ failed: Number(match[5]),
37
+ skipped: Number(match[6]),
38
+ });
39
+ }
40
+ if (code !== 0 && !hosts.length) {
41
+ emit({ type: "error", message: `Ansible failed: ${stderr.trim() || `exited with ${code}`}` });
42
+ process.exitCode = 1;
43
+ return;
44
+ }
45
+ const failed = hosts.reduce((sum, host) => sum + host.failed, 0);
46
+ const changed = hosts.reduce((sum, host) => sum + host.changed, 0);
47
+ emit({
48
+ type: "result",
49
+ summary: `Ansible playbook finished: ${failed} failed, ${changed} changed across ${hosts.length} hosts.`,
50
+ data: { target, hosts, total_failed: failed, total_changed: changed },
51
+ });
52
+ emit({ type: "done", summary: `Ansible playbook finished: ${failed} failed, ${changed} changed.` });
53
+ });
54
+ });
@@ -0,0 +1,34 @@
1
+ {
2
+ "category": "automation",
3
+ "core_api": "^0.1.0",
4
+ "description": "Runs an Ansible playbook and reports the per-host PLAY RECAP results.",
5
+ "entry": "index.mjs",
6
+ "external_tools": [
7
+ {
8
+ "command": "ansible-playbook",
9
+ "install_hint": "Install Ansible from your distribution packages or with pipx install ansible-core.",
10
+ "name": "Ansible"
11
+ }
12
+ ],
13
+ "id": "automation/ansible",
14
+ "kind": "wrapper",
15
+ "maintenance": "active",
16
+ "name": "Ansible",
17
+ "options": [
18
+ {
19
+ "default": "",
20
+ "description": "Inventory file or host list passed with -i, empty means the playbook default.",
21
+ "name": "inventory",
22
+ "type": "string"
23
+ },
24
+ {
25
+ "default": "",
26
+ "description": "Only run tasks with these tags, empty means all tasks.",
27
+ "name": "tags",
28
+ "type": "string"
29
+ }
30
+ ],
31
+ "risk": "medium",
32
+ "schema_version": 1,
33
+ "version": "0.1.0"
34
+ }
@@ -0,0 +1,74 @@
1
+ import { spawn } from "node:child_process";
2
+ import { mkdtemp, readFile, rm } from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+
6
+ let input = "";
7
+ process.stdin.setEncoding("utf8");
8
+ process.stdin.on("data", (chunk) => (input += chunk));
9
+ process.stdin.on("end", () => {
10
+ const request = JSON.parse(input || "{}");
11
+ const emit = (event) => process.stdout.write(`${JSON.stringify(event)}\n`);
12
+ const target = String(request.target ?? "");
13
+ run(request, target, emit).catch((error) => {
14
+ emit({ type: "error", message: `Dependency-Check failed: ${error.message}` });
15
+ process.exitCode = 1;
16
+ });
17
+ });
18
+
19
+ async function run(request, target, emit) {
20
+ const outDir = await mkdtemp(join(tmpdir(), "cantarella-depcheck-"));
21
+ try {
22
+ const child = spawn("dependency-check", ["--scan", target, "--format", "JSON", "--out", outDir], { stdio: ["ignore", "pipe", "pipe"] });
23
+ let stdout = "";
24
+ let stderr = "";
25
+ child.stdout.on("data", (chunk) => (stdout += chunk));
26
+ child.stderr.on("data", (chunk) => (stderr += chunk));
27
+ const code = await new Promise((resolve, reject) => {
28
+ child.on("error", reject);
29
+ child.on("close", resolve);
30
+ });
31
+ let report = null;
32
+ try {
33
+ report = JSON.parse(await readFile(join(outDir, "dependency-check-report.json"), "utf8"));
34
+ } catch {
35
+ report = null;
36
+ }
37
+ const vulnerabilities = [];
38
+ if (report && Array.isArray(report.dependencies)) {
39
+ for (const dep of report.dependencies) {
40
+ if (!Array.isArray(dep.vulnerabilities)) continue;
41
+ for (const vuln of dep.vulnerabilities) {
42
+ vulnerabilities.push({
43
+ cve: vuln.name ?? "",
44
+ severity: vuln.severity ?? "UNKNOWN",
45
+ file: dep.fileName ?? "",
46
+ description: vuln.description ?? "",
47
+ });
48
+ }
49
+ }
50
+ }
51
+ if (code !== 0 && !vulnerabilities.length && !report) {
52
+ emit({ type: "error", message: `Dependency-Check failed: ${stderr.trim() || stdout.trim() || `exited with ${code}`}` });
53
+ process.exitCode = 1;
54
+ return;
55
+ }
56
+ if (!report) {
57
+ emit({ type: "error", message: "Dependency-Check finished but no report file was produced." });
58
+ process.exitCode = 1;
59
+ return;
60
+ }
61
+ const bySeverity = {};
62
+ for (const vuln of vulnerabilities) {
63
+ bySeverity[vuln.severity] = (bySeverity[vuln.severity] ?? 0) + 1;
64
+ }
65
+ emit({
66
+ type: "result",
67
+ summary: `Dependency-Check found ${vulnerabilities.length} vulnerabilities in ${target}.`,
68
+ data: { target, total: vulnerabilities.length, by_severity: bySeverity, vulnerabilities: vulnerabilities.slice(0, 100) },
69
+ });
70
+ emit({ type: "done", summary: `Dependency-Check finished: ${vulnerabilities.length} vulnerabilities.` });
71
+ } finally {
72
+ await rm(outDir, { recursive: true, force: true });
73
+ }
74
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "category": "vuln-management",
3
+ "core_api": "^0.1.0",
4
+ "description": "Scans project dependencies with OWASP Dependency-Check and reports the CVEs found.",
5
+ "entry": "index.mjs",
6
+ "external_tools": [
7
+ {
8
+ "command": "dependency-check",
9
+ "install_hint": "Install OWASP Dependency-Check from your distribution packages or the OWASP releases.",
10
+ "name": "OWASP Dependency-Check"
11
+ }
12
+ ],
13
+ "id": "vuln-management/dependency-check",
14
+ "kind": "wrapper",
15
+ "maintenance": "active",
16
+ "name": "Dependency-Check",
17
+ "options": [],
18
+ "risk": "low",
19
+ "schema_version": 1,
20
+ "version": "0.1.0"
21
+ }
@@ -0,0 +1,57 @@
1
+ import { spawn } from "node:child_process";
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
+ const target = String(request.target ?? "");
10
+ const child = spawn("trivy", ["fs", target, "--format", "json", "--quiet"], { stdio: ["ignore", "pipe", "pipe"] });
11
+ let stdout = "";
12
+ let stderr = "";
13
+ child.stdout.on("data", (chunk) => (stdout += chunk));
14
+ child.stderr.on("data", (chunk) => (stderr += chunk));
15
+ child.on("error", (error) => {
16
+ emit({ type: "error", message: `Trivy failed: ${error.message}` });
17
+ process.exitCode = 1;
18
+ });
19
+ child.on("close", (code) => {
20
+ let report = null;
21
+ try {
22
+ report = JSON.parse(stdout);
23
+ } catch {
24
+ report = null;
25
+ }
26
+ const vulnerabilities = [];
27
+ if (report && Array.isArray(report.Results)) {
28
+ for (const result of report.Results) {
29
+ if (!Array.isArray(result.Vulnerabilities)) continue;
30
+ for (const vuln of result.Vulnerabilities) {
31
+ vulnerabilities.push({
32
+ cve: vuln.VulnerabilityID ?? "",
33
+ severity: vuln.Severity ?? "UNKNOWN",
34
+ package: vuln.PkgName ?? "",
35
+ installed_version: vuln.InstalledVersion ?? "",
36
+ title: vuln.Title ?? "",
37
+ });
38
+ }
39
+ }
40
+ }
41
+ if (code !== 0 && !vulnerabilities.length && !report) {
42
+ emit({ type: "error", message: `Trivy failed: ${stderr.trim() || `exited with ${code}`}` });
43
+ process.exitCode = 1;
44
+ return;
45
+ }
46
+ const bySeverity = {};
47
+ for (const vuln of vulnerabilities) {
48
+ bySeverity[vuln.severity] = (bySeverity[vuln.severity] ?? 0) + 1;
49
+ }
50
+ emit({
51
+ type: "result",
52
+ summary: `Trivy found ${vulnerabilities.length} vulnerabilities in ${target}.`,
53
+ data: { target, total: vulnerabilities.length, by_severity: bySeverity, vulnerabilities: vulnerabilities.slice(0, 100) },
54
+ });
55
+ emit({ type: "done", summary: `Trivy scan finished: ${vulnerabilities.length} vulnerabilities.` });
56
+ });
57
+ });
@@ -0,0 +1,21 @@
1
+ {
2
+ "category": "devsecops",
3
+ "core_api": "^0.1.0",
4
+ "description": "Scans a filesystem path with Trivy and reports the vulnerabilities found.",
5
+ "entry": "index.mjs",
6
+ "external_tools": [
7
+ {
8
+ "command": "trivy",
9
+ "install_hint": "Install Trivy from your distribution packages or from the aquasecurity releases.",
10
+ "name": "Trivy"
11
+ }
12
+ ],
13
+ "id": "devsecops/trivy",
14
+ "kind": "wrapper",
15
+ "maintenance": "active",
16
+ "name": "Trivy",
17
+ "options": [],
18
+ "risk": "low",
19
+ "schema_version": 1,
20
+ "version": "0.1.0"
21
+ }
package/package.json CHANGED
@@ -19,7 +19,7 @@
19
19
  "release:notes": "node scripts/release-notes.mjs"
20
20
  },
21
21
  "type": "module",
22
- "version": "1.7.0",
22
+ "version": "1.8.0",
23
23
  "workspaces": [
24
24
  "packages/*"
25
25
  ],
@@ -11,7 +11,7 @@ process.stdout.on("error", (error) => {
11
11
  process.exit(0);
12
12
  throw error;
13
13
  });
14
- const VERSION = "1.7.0";
14
+ const VERSION = "1.8.0";
15
15
  const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../..");
16
16
  function banner() {
17
17
  return (process.stdout.columns ?? 80) >= 72 ? BANNER : COMPACT_BANNER;
@@ -78,8 +78,8 @@ export function createGuiServer(root) {
78
78
  }
79
79
  }
80
80
  sendJson(response, 200, {
81
- version: "1.7.0",
82
- update_message: (await checkForUpdate("1.7.0")).message,
81
+ version: "1.8.0",
82
+ update_message: (await checkForUpdate("1.8.0")).message,
83
83
  categories: CATEGORIES,
84
84
  modules: modules.map(({ manifest }) => manifest),
85
85
  external_tools: [...tools.values()],