cantarella-framework 0.8.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 +4 -0
- package/modules/api-openapi-checker/index.mjs +44 -0
- package/modules/api-openapi-checker/module.json +14 -0
- package/modules/code-audit-secret-scanner/index.mjs +71 -0
- package/modules/code-audit-secret-scanner/module.json +14 -0
- package/modules/forensics-file-hash/index.mjs +25 -0
- package/modules/forensics-file-hash/module.json +14 -0
- package/modules/network-tls-checker/index.mjs +57 -0
- package/modules/network-tls-checker/module.json +14 -0
- package/package.json +1 -1
- package/packages/cli/dist/cli.js +1 -1
- package/packages/gui/dist/server.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -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
|
+
}
|
package/package.json
CHANGED
package/packages/cli/dist/cli.js
CHANGED
|
@@ -11,7 +11,7 @@ process.stdout.on("error", (error) => {
|
|
|
11
11
|
process.exit(0);
|
|
12
12
|
throw error;
|
|
13
13
|
});
|
|
14
|
-
const VERSION = "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.
|
|
82
|
-
update_message: (await checkForUpdate("0.
|
|
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()],
|