feat: initial commit of Ghaymah internal DNS, TCP and security testing suite and report

This commit is contained in:
2026-10-12 23:43:09 +03:00
commit bdcd2d44f5
57 changed files with 6499 additions and 0 deletions
+166
View File
@@ -0,0 +1,166 @@
// Phase 2B: Deep MCP Tool Schema Discovery
// Discover new DNS/networking capabilities via MCP tools/list
const CUMIN_TOKEN = "cumin_GjynCIFJtyoZ_73wasCoWNYf7Y-Pk0jMffHEdRzblBg";
const PROJECT_ID = "178bfad9-5edc-409f-833c-6fffca7aed5a";
const API = "https://api.cumin.dev";
const fs = require("fs");
let SESSION_ID = null;
async function mcpRequest(method, params, id) {
const body = { jsonrpc: "2.0", method, id };
if (params) body.params = params;
const headers = {
Authorization: `Bearer ${CUMIN_TOKEN}`,
"Content-Type": "application/json",
Accept: "application/json, text/event-stream"
};
if (SESSION_ID) headers["Mcp-Session-Id"] = SESSION_ID;
const res = await fetch(`${API}/mcp`, { method: "POST", headers, body: JSON.stringify(body) });
const sid = res.headers.get("Mcp-Session-Id");
if (sid) SESSION_ID = sid;
const data = await res.json();
if (data.error) throw new Error(`MCP: ${JSON.stringify(data.error)}`);
return data.result;
}
async function callTool(name, args) {
const r = await mcpRequest("tools/call", { name, arguments: args }, Date.now());
const text = r.content?.map(c => c.text || "").join("") || JSON.stringify(r);
return text;
}
async function main() {
console.log("=== DEEP MCP DISCOVERY ===\n");
// Initialize
await mcpRequest("initialize", {
protocolVersion: "2024-11-05", capabilities: {},
clientInfo: { name: "ghaymah-deep-recon", version: "1.0" }
}, 1);
console.log("✅ MCP Connected\n");
// 1. Get full tool schemas (look for DNS/networking/tag related)
const toolsList = await mcpRequest("tools/list", {}, 2);
const tools = toolsList.tools || [];
const networkTools = tools.filter(t =>
t.name.includes("constellation") || t.name.includes("network") ||
t.name.includes("dns") || t.name.includes("policy") ||
t.name.includes("tag") || t.name.includes("app") ||
t.name.includes("exec") || t.name.includes("update")
);
console.log(`📋 Total tools: ${tools.length}`);
console.log(`🔍 Network/DNS/App related tools: ${networkTools.length}\n`);
for (const t of networkTools) {
console.log(`--- ${t.name} ---`);
console.log(`Description: ${t.description || "N/A"}`);
console.log(`Schema: ${JSON.stringify(t.inputSchema?.properties || {}, null, 2).substring(0, 800)}`);
console.log();
}
// 2. Check existing constellation details
console.log("\n=== CONSTELLATION DETAILS ===");
const constellations = await callTool("list_constellations", { project_id: PROJECT_ID });
console.log("Constellations:", constellations);
// 3. Check existing apps for tags
console.log("\n=== APP DETAILS (with tags) ===");
const apps = await callTool("list_apps", { project_id: PROJECT_ID });
const appsList = JSON.parse(apps);
for (const app of appsList) {
console.log(`\nApp: ${app.name} (${app.id})`);
console.log(` Status: ${app.status}`);
console.log(` Tags: ${JSON.stringify(app.tags)}`);
console.log(` Ports: ${JSON.stringify(app.ports)}`);
console.log(` Env vars: ${app.env?.map(e => e.name).join(", ")}`);
console.log(` Image: ${app.image}`);
if (app.dns) console.log(` DNS: ${JSON.stringify(app.dns)}`);
if (app.network) console.log(` Network: ${JSON.stringify(app.network)}`);
if (app.internal_dns) console.log(` Internal DNS: ${JSON.stringify(app.internal_dns)}`);
if (app.mesh) console.log(` Mesh: ${JSON.stringify(app.mesh)}`);
// Print ALL app keys
console.log(` ALL KEYS: ${Object.keys(app).join(", ")}`);
}
// 4. List projects to understand scope
console.log("\n=== PROJECTS ===");
const projects = await callTool("list_projects", {});
console.log(projects);
// 5. Get app logs to see networking info
console.log("\n=== APP LOGS (gateway, last 20 lines) ===");
try {
const logs = await callTool("app_logs", { project_id: PROJECT_ID, id: appsList[0].id });
console.log(logs.substring(0, 2000));
} catch (e) {
console.log("Logs error:", e.message);
}
// 6. Exec in backend to check DNS config
console.log("\n=== DNS CONFIG IN BACKEND CONTAINER ===");
try {
const resolv = await callTool("exec_in_app", {
project_id: PROJECT_ID,
id: appsList.find(a => a.name === "soc-backend").id,
command: ["cat", "/etc/resolv.conf"]
});
console.log("resolv.conf:", resolv);
} catch (e) {
console.log("Exec error:", e.message);
}
// 7. Check hosts file
try {
const hosts = await callTool("exec_in_app", {
project_id: PROJECT_ID,
id: appsList.find(a => a.name === "soc-backend").id,
command: ["cat", "/etc/hosts"]
});
console.log("\nhosts:", hosts);
} catch (e) {
console.log("Hosts error:", e.message);
}
// 8. Try DNS resolution of sibling app
try {
const nslookup = await callTool("exec_in_app", {
project_id: PROJECT_ID,
id: appsList.find(a => a.name === "soc-backend").id,
command: ["nslookup", "soc-gateway"]
});
console.log("\nnslookup soc-gateway:", nslookup);
} catch (e) {
console.log("nslookup error:", e.message);
}
// 9. Try various DNS name patterns
const dnsPatterns = [
"soc-gateway",
"soc-gateway.local",
"soc-gateway.mesh",
"soc-gateway.soc-private-net",
"soc-gateway.project.mesh",
"soc-gateway.cumin.internal"
];
console.log("\n=== DNS RESOLUTION TESTS ===");
for (const name of dnsPatterns) {
try {
const result = await callTool("exec_in_app", {
project_id: PROJECT_ID,
id: appsList.find(a => a.name === "soc-backend").id,
command: ["getent", "hosts", name]
});
console.log(`${name} → ${result}`);
} catch (e) {
console.log(`${name} → ERROR: ${e.message}`);
}
}
console.log("\n=== DEEP DISCOVERY COMPLETE ===");
}
main().catch(e => { console.error("FATAL:", e.message); process.exit(1); });