cantarella-framework 0.7.0 → 0.9.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,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.0
4
+
5
+ - New native modules: TLS certificate checker, secret scanner, OpenAPI checker, and file hash.
6
+
7
+ ## 0.8.0
8
+
9
+ - New native modules: HTTP security headers, DNS records, hash identifier, and username checker.
10
+
3
11
  ## 0.7.0
4
12
 
5
13
  - Self-update: `canta update core` checks npm and installs the latest release; the GUI banner reports real update status. GitHub Actions workflow publishes tagged releases to npm.
@@ -0,0 +1,44 @@
1
+ import { readFile } from "node:fs/promises";
2
+
3
+ let input = "";
4
+ process.stdin.setEncoding("utf8");
5
+ process.stdin.on("data", (chunk) => (input += chunk));
6
+ process.stdin.on("end", async () => {
7
+ const request = JSON.parse(input || "{}");
8
+ const emit = (event) => process.stdout.write(`${JSON.stringify(event)}\n`);
9
+ const target = String(request.target ?? "");
10
+ try {
11
+ const text = /^https?:\/\//.test(target)
12
+ ? await (await fetch(target, { signal: AbortSignal.timeout(8000) })).text()
13
+ : await readFile(target, "utf8");
14
+ const doc = JSON.parse(text);
15
+ const paths = doc.paths ?? {};
16
+ const methods = {};
17
+ const operations = [];
18
+ for (const [route, item] of Object.entries(paths)) {
19
+ for (const method of Object.keys(item ?? {})) {
20
+ if (!["get", "post", "put", "patch", "delete", "head", "options"].includes(method)) continue;
21
+ methods[method.toUpperCase()] = (methods[method.toUpperCase()] ?? 0) + 1;
22
+ operations.push({ method: method.toUpperCase(), path: route, secured: Boolean(item[method]?.security?.length || doc.security?.length) });
23
+ }
24
+ }
25
+ const schemes = Object.keys(doc.components?.securitySchemes ?? doc.securityDefinitions ?? {});
26
+ const unsecured = operations.filter((operation) => !operation.secured);
27
+ emit({
28
+ type: "result",
29
+ summary: `OpenAPI ${doc.openapi ?? doc.swagger ?? "unknown"}: ${Object.keys(paths).length} paths, ${operations.length} operations, ${schemes.length} security schemes.`,
30
+ data: {
31
+ title: doc.info?.title,
32
+ version: doc.info?.version,
33
+ paths: Object.keys(paths).length,
34
+ methods,
35
+ security_schemes: schemes,
36
+ operations_without_security: unsecured,
37
+ },
38
+ });
39
+ emit({ type: "done", summary: "OpenAPI check finished." });
40
+ } catch (error) {
41
+ emit({ type: "error", message: `OpenAPI check failed: ${error.message}` });
42
+ process.exitCode = 1;
43
+ }
44
+ });
@@ -0,0 +1,14 @@
1
+ {
2
+ "schema_version": 1,
3
+ "id": "api/openapi-checker",
4
+ "name": "OpenAPI Checker",
5
+ "version": "0.1.0",
6
+ "category": "api",
7
+ "kind": "native",
8
+ "risk": "low",
9
+ "description": "Summarizes paths, methods, and security schemes from an OpenAPI JSON document.",
10
+ "entry": "index.mjs",
11
+ "core_api": "^0.1.0",
12
+ "maintenance": "active",
13
+ "options": []
14
+ }
@@ -0,0 +1,71 @@
1
+ import { readdir, readFile, stat } from "node:fs/promises";
2
+ import path from "node:path";
3
+
4
+ let input = "";
5
+ process.stdin.setEncoding("utf8");
6
+ process.stdin.on("data", (chunk) => (input += chunk));
7
+ process.stdin.on("end", async () => {
8
+ const request = JSON.parse(input || "{}");
9
+ const emit = (event) => process.stdout.write(`${JSON.stringify(event)}\n`);
10
+ const target = String(request.target ?? ".");
11
+ const patterns = [
12
+ ["AWS access key", /\bAKIA[0-9A-Z]{16}\b/g],
13
+ ["GitHub token", /\bgh[pousr]_[A-Za-z0-9_]{30,}\b/g],
14
+ ["npm token", /\bnpm_[A-Za-z0-9]{30,}\b/g],
15
+ ["Private key", /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/g],
16
+ ["Generic secret assignment", /\b(?:api[_-]?key|secret|token|password)\s*[:=]\s*["'][^"'\s]{12,}["']/gi],
17
+ ];
18
+ const skip = new Set(["node_modules", ".git", "dist", ".cantarella"]);
19
+ const findings = [];
20
+
21
+ async function scan(file) {
22
+ let text;
23
+ try {
24
+ text = await readFile(file, "utf8");
25
+ } catch {
26
+ return;
27
+ }
28
+ if (text.includes("\0")) return;
29
+ const lines = text.split("\n");
30
+ for (const [name, pattern] of patterns) {
31
+ pattern.lastIndex = 0;
32
+ for (const match of text.matchAll(pattern)) {
33
+ const line = text.slice(0, match.index).split("\n").length;
34
+ findings.push({ type: name, file, line, preview: lines[line - 1]?.trim().slice(0, 80).replace(/(["'])[^"']{8,}(["'])/g, "$1[redacted]$2") });
35
+ }
36
+ }
37
+ }
38
+
39
+ async function walk(entry) {
40
+ const info = await stat(entry);
41
+ if (info.isDirectory()) {
42
+ if (skip.has(path.basename(entry))) return;
43
+ for (const child of await readdir(entry)) await walk(path.join(entry, child));
44
+ } else if (info.size <= 1024 * 1024) {
45
+ await scan(entry);
46
+ }
47
+ }
48
+
49
+ try {
50
+ await walk(target);
51
+ if (findings.length) {
52
+ emit({
53
+ type: "finding",
54
+ title: "Likely secrets found in local files",
55
+ severity: "high",
56
+ description: `${findings.length} likely secret patterns found. Values are redacted in the result.`,
57
+ });
58
+ }
59
+ emit({
60
+ type: "result",
61
+ summary: findings.length
62
+ ? `Found ${findings.length} likely secrets under ${target}.`
63
+ : `No likely secrets found under ${target}.`,
64
+ data: { target, findings },
65
+ });
66
+ emit({ type: "done", summary: "Secret scan finished." });
67
+ } catch (error) {
68
+ emit({ type: "error", message: `Secret scan failed: ${error.message}` });
69
+ process.exitCode = 1;
70
+ }
71
+ });
@@ -0,0 +1,14 @@
1
+ {
2
+ "schema_version": 1,
3
+ "id": "code-audit/secret-scanner",
4
+ "name": "Secret Scanner",
5
+ "version": "0.1.0",
6
+ "category": "code-audit",
7
+ "kind": "native",
8
+ "risk": "low",
9
+ "description": "Scans a local file or directory for likely secrets without printing their values.",
10
+ "entry": "index.mjs",
11
+ "core_api": "^0.1.0",
12
+ "maintenance": "active",
13
+ "options": []
14
+ }
@@ -0,0 +1,25 @@
1
+ import { createHash } from "node:crypto";
2
+ import { readFile, stat } from "node:fs/promises";
3
+
4
+ let input = "";
5
+ process.stdin.setEncoding("utf8");
6
+ process.stdin.on("data", (chunk) => (input += chunk));
7
+ process.stdin.on("end", async () => {
8
+ const request = JSON.parse(input || "{}");
9
+ const emit = (event) => process.stdout.write(`${JSON.stringify(event)}\n`);
10
+ const target = String(request.target ?? "");
11
+ try {
12
+ const [data, info] = await Promise.all([readFile(target), stat(target)]);
13
+ const hash = (algorithm) => createHash(algorithm).update(data).digest("hex");
14
+ const hashes = { md5: hash("md5"), sha1: hash("sha1"), sha256: hash("sha256") };
15
+ emit({
16
+ type: "result",
17
+ summary: `${target}: ${info.size} bytes, SHA-256 ${hashes.sha256}.`,
18
+ data: { file: target, size_bytes: info.size, modified_at: info.mtime.toISOString(), hashes },
19
+ });
20
+ emit({ type: "done", summary: "File hash finished." });
21
+ } catch (error) {
22
+ emit({ type: "error", message: `File hash failed: ${error.message}` });
23
+ process.exitCode = 1;
24
+ }
25
+ });
@@ -0,0 +1,14 @@
1
+ {
2
+ "schema_version": 1,
3
+ "id": "forensics/file-hash",
4
+ "name": "File Hash",
5
+ "version": "0.1.0",
6
+ "category": "forensics",
7
+ "kind": "native",
8
+ "risk": "info",
9
+ "description": "Computes MD5, SHA-1, and SHA-256 hashes and basic metadata for a local file.",
10
+ "entry": "index.mjs",
11
+ "core_api": "^0.1.0",
12
+ "maintenance": "active",
13
+ "options": []
14
+ }
@@ -0,0 +1,57 @@
1
+ import tls from "node:tls";
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 raw = String(request.target ?? "").replace(/^https?:\/\//, "").split("/")[0];
10
+ const [host, portText] = raw.split(":");
11
+ const port = Number(portText ?? 443);
12
+ if (!host) {
13
+ emit({ type: "error", message: "A target host is required." });
14
+ process.exitCode = 1;
15
+ return;
16
+ }
17
+ const socket = tls.connect({ host, port, servername: host, timeout: 8000 }, () => {
18
+ const cert = socket.getPeerCertificate();
19
+ const validTo = cert.valid_to ? new Date(cert.valid_to) : null;
20
+ const daysLeft = validTo ? Math.floor((validTo.getTime() - Date.now()) / 86400000) : null;
21
+ if (daysLeft !== null && daysLeft < 30) {
22
+ emit({
23
+ type: "finding",
24
+ title: daysLeft < 0 ? "TLS certificate expired" : "TLS certificate expires soon",
25
+ severity: daysLeft < 0 ? "high" : "medium",
26
+ description: `Certificate for ${host} expires in ${daysLeft} days.`,
27
+ });
28
+ }
29
+ emit({
30
+ type: "result",
31
+ summary: `${host}:${port} uses ${socket.getProtocol()}; certificate expires ${cert.valid_to ?? "unknown"} (${daysLeft ?? "?"} days).`,
32
+ data: {
33
+ host,
34
+ port,
35
+ protocol: socket.getProtocol(),
36
+ authorized: socket.authorized,
37
+ subject: cert.subject,
38
+ issuer: cert.issuer,
39
+ valid_from: cert.valid_from,
40
+ valid_to: cert.valid_to,
41
+ days_left: daysLeft,
42
+ fingerprint256: cert.fingerprint256,
43
+ },
44
+ });
45
+ emit({ type: "done", summary: `TLS check finished for ${host}.` });
46
+ socket.end();
47
+ });
48
+ socket.on("timeout", () => {
49
+ emit({ type: "error", message: `TLS connection to ${host}:${port} timed out.` });
50
+ process.exitCode = 1;
51
+ socket.destroy();
52
+ });
53
+ socket.on("error", (error) => {
54
+ emit({ type: "error", message: `TLS check failed for ${host}:${port}: ${error.message}` });
55
+ process.exitCode = 1;
56
+ });
57
+ });
@@ -0,0 +1,14 @@
1
+ {
2
+ "schema_version": 1,
3
+ "id": "network/tls-checker",
4
+ "name": "TLS Certificate Checker",
5
+ "version": "0.1.0",
6
+ "category": "network",
7
+ "kind": "native",
8
+ "risk": "low",
9
+ "description": "Checks TLS protocol, certificate issuer, validity, and expiry for a host.",
10
+ "entry": "index.mjs",
11
+ "core_api": "^0.1.0",
12
+ "maintenance": "active",
13
+ "options": []
14
+ }
@@ -0,0 +1,45 @@
1
+ let input = "";
2
+ process.stdin.setEncoding("utf8");
3
+ process.stdin.on("data", (chunk) => (input += chunk));
4
+ process.stdin.on("end", async () => {
5
+ const request = JSON.parse(input || "{}");
6
+ const emit = (event) => process.stdout.write(`${JSON.stringify(event)}\n`);
7
+ const username = encodeURIComponent(String(request.target ?? "").trim());
8
+ if (!username) {
9
+ emit({ type: "error", message: "A username is required." });
10
+ process.exitCode = 1;
11
+ return;
12
+ }
13
+ const sites = [
14
+ ["GitHub", `https://github.com/${username}`],
15
+ ["GitLab", `https://gitlab.com/${username}`],
16
+ ["Reddit", `https://www.reddit.com/user/${username}`],
17
+ ["HackerOne", `https://hackerone.com/${username}`],
18
+ ["TryHackMe", `https://tryhackme.com/p/${username}`],
19
+ ];
20
+ const results = [];
21
+ await Promise.all(
22
+ sites.map(async ([site, url]) => {
23
+ try {
24
+ const response = await fetch(url, {
25
+ method: "HEAD",
26
+ redirect: "manual",
27
+ signal: AbortSignal.timeout(8000),
28
+ });
29
+ results.push({ site, url, status: response.status, likely_exists: response.status === 200 });
30
+ } catch (error) {
31
+ results.push({ site, url, status: null, likely_exists: false, error: error.message });
32
+ }
33
+ }),
34
+ );
35
+ results.sort((a, b) => a.site.localeCompare(b.site));
36
+ const found = results.filter((item) => item.likely_exists);
37
+ emit({
38
+ type: "result",
39
+ summary: found.length
40
+ ? `Username likely exists on: ${found.map((item) => item.site).join(", ")}.`
41
+ : "Username was not found on the checked sites.",
42
+ data: { username: decodeURIComponent(username), results },
43
+ });
44
+ emit({ type: "done", summary: "Username check finished." });
45
+ });
@@ -0,0 +1,14 @@
1
+ {
2
+ "schema_version": 1,
3
+ "id": "osint/username-checker",
4
+ "name": "Username Checker",
5
+ "version": "0.1.0",
6
+ "category": "osint",
7
+ "kind": "native",
8
+ "risk": "low",
9
+ "description": "Checks whether a username appears on a small set of public sites.",
10
+ "entry": "index.mjs",
11
+ "core_api": "^0.1.0",
12
+ "maintenance": "active",
13
+ "options": []
14
+ }
@@ -0,0 +1,33 @@
1
+ let input = "";
2
+ process.stdin.setEncoding("utf8");
3
+ process.stdin.on("data", (chunk) => (input += chunk));
4
+ process.stdin.on("end", () => {
5
+ const request = JSON.parse(input || "{}");
6
+ const emit = (event) => process.stdout.write(`${JSON.stringify(event)}\n`);
7
+ const hash = String(request.target ?? "").trim();
8
+ const candidates = [];
9
+ if (/^\$2[aby]\$\d{2}\$/.test(hash)) candidates.push("bcrypt");
10
+ if (/^\$argon2/.test(hash)) candidates.push("Argon2");
11
+ if (/^\$6\$/.test(hash)) candidates.push("SHA-512 crypt");
12
+ if (/^\$5\$/.test(hash)) candidates.push("SHA-256 crypt");
13
+ if (/^\$1\$/.test(hash)) candidates.push("MD5 crypt");
14
+ if (/^[a-f0-9]+$/i.test(hash)) {
15
+ const byLength = {
16
+ 32: ["MD5", "NTLM"],
17
+ 40: ["SHA-1"],
18
+ 56: ["SHA-224"],
19
+ 64: ["SHA-256"],
20
+ 96: ["SHA-384"],
21
+ 128: ["SHA-512"],
22
+ };
23
+ candidates.push(...(byLength[hash.length] ?? []));
24
+ }
25
+ emit({
26
+ type: "result",
27
+ summary: candidates.length
28
+ ? `Likely hash type: ${candidates.join(" or ")}.`
29
+ : "Hash type not recognized from format alone.",
30
+ data: { length: hash.length, candidates },
31
+ });
32
+ emit({ type: "done", summary: "Hash identification finished." });
33
+ });
@@ -0,0 +1,14 @@
1
+ {
2
+ "schema_version": 1,
3
+ "id": "password/hash-identifier",
4
+ "name": "Hash Identifier",
5
+ "version": "0.1.0",
6
+ "category": "password",
7
+ "kind": "native",
8
+ "risk": "info",
9
+ "description": "Identifies likely hash types from length and format.",
10
+ "entry": "index.mjs",
11
+ "core_api": "^0.1.0",
12
+ "maintenance": "active",
13
+ "options": []
14
+ }
@@ -0,0 +1,35 @@
1
+ import { promises as dns } from "node:dns";
2
+
3
+ let input = "";
4
+ process.stdin.setEncoding("utf8");
5
+ process.stdin.on("data", (chunk) => (input += chunk));
6
+ process.stdin.on("end", async () => {
7
+ const request = JSON.parse(input || "{}");
8
+ const emit = (event) => process.stdout.write(`${JSON.stringify(event)}\n`);
9
+ const domain = String(request.target ?? "").replace(/^https?:\/\//, "").split("/")[0];
10
+ const lookups = {
11
+ A: () => dns.resolve4(domain),
12
+ AAAA: () => dns.resolve6(domain),
13
+ MX: () => dns.resolveMx(domain),
14
+ NS: () => dns.resolveNs(domain),
15
+ TXT: () => dns.resolveTxt(domain),
16
+ CNAME: () => dns.resolveCname(domain),
17
+ SOA: () => dns.resolveSoa(domain),
18
+ };
19
+ const records = {};
20
+ for (const [type, lookup] of Object.entries(lookups)) {
21
+ try {
22
+ const values = await lookup();
23
+ if (values && (Array.isArray(values) ? values.length : true)) records[type] = values;
24
+ } catch {
25
+ // No records of this type.
26
+ }
27
+ }
28
+ const count = Object.keys(records).length;
29
+ emit({
30
+ type: "result",
31
+ summary: `Found ${count} DNS record types for ${domain}: ${Object.keys(records).join(", ") || "none"}.`,
32
+ data: { domain, records },
33
+ });
34
+ emit({ type: "done", summary: `DNS lookup finished for ${domain}.` });
35
+ });
@@ -0,0 +1,14 @@
1
+ {
2
+ "schema_version": 1,
3
+ "id": "recon/dns-records",
4
+ "name": "DNS Records",
5
+ "version": "0.1.0",
6
+ "category": "recon",
7
+ "kind": "native",
8
+ "risk": "low",
9
+ "description": "Collects A, AAAA, MX, NS, TXT, CNAME, and SOA records for a domain.",
10
+ "entry": "index.mjs",
11
+ "core_api": "^0.1.0",
12
+ "maintenance": "active",
13
+ "options": []
14
+ }
@@ -0,0 +1,43 @@
1
+ let input = "";
2
+ process.stdin.setEncoding("utf8");
3
+ process.stdin.on("data", (chunk) => (input += chunk));
4
+ process.stdin.on("end", async () => {
5
+ const request = JSON.parse(input || "{}");
6
+ const emit = (event) => process.stdout.write(`${JSON.stringify(event)}\n`);
7
+ const url = /^https?:\/\//.test(request.target ?? "") ? request.target : `https://${request.target}`;
8
+ try {
9
+ const response = await fetch(url, { redirect: "manual", signal: AbortSignal.timeout(8000) });
10
+ const checks = [
11
+ "strict-transport-security",
12
+ "content-security-policy",
13
+ "x-content-type-options",
14
+ "x-frame-options",
15
+ "referrer-policy",
16
+ "permissions-policy",
17
+ ];
18
+ const present = {};
19
+ const missing = [];
20
+ for (const header of checks) {
21
+ const value = response.headers.get(header);
22
+ if (value) present[header] = value;
23
+ else missing.push(header);
24
+ }
25
+ if (missing.length) {
26
+ emit({
27
+ type: "finding",
28
+ title: "Missing HTTP security headers",
29
+ severity: "low",
30
+ description: `Missing: ${missing.join(", ")}.`,
31
+ });
32
+ }
33
+ emit({
34
+ type: "result",
35
+ summary: `${url} returned HTTP ${response.status}; ${checks.length - missing.length}/${checks.length} security headers present.`,
36
+ data: { url, status: response.status, present, missing },
37
+ });
38
+ emit({ type: "done", summary: `Header check finished for ${url}.` });
39
+ } catch (error) {
40
+ emit({ type: "error", message: `Could not fetch ${url}: ${error.message}` });
41
+ process.exitCode = 1;
42
+ }
43
+ });
@@ -0,0 +1,14 @@
1
+ {
2
+ "schema_version": 1,
3
+ "id": "web/http-headers",
4
+ "name": "HTTP Security Headers",
5
+ "version": "0.1.0",
6
+ "category": "web",
7
+ "kind": "native",
8
+ "risk": "low",
9
+ "description": "Checks a URL for common HTTP security headers.",
10
+ "entry": "index.mjs",
11
+ "core_api": "^0.1.0",
12
+ "maintenance": "active",
13
+ "options": []
14
+ }
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "prepublishOnly": "npm test"
19
19
  },
20
20
  "type": "module",
21
- "version": "0.7.0",
21
+ "version": "0.9.0",
22
22
  "workspaces": [
23
23
  "packages/*"
24
24
  ],
@@ -11,7 +11,7 @@ process.stdout.on("error", (error) => {
11
11
  process.exit(0);
12
12
  throw error;
13
13
  });
14
- const VERSION = "0.7.0";
14
+ const VERSION = "0.9.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: "0.7.0",
82
- update_message: (await checkForUpdate("0.7.0")).message,
81
+ version: "0.9.0",
82
+ update_message: (await checkForUpdate("0.9.0")).message,
83
83
  categories: CATEGORIES,
84
84
  modules: modules.map(({ manifest }) => manifest),
85
85
  external_tools: [...tools.values()],