UNPKG

tmrw-audit

Version:

tmrw audit: Your escape hatch from the cloud cage.

58 lines (56 loc) • 2.58 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.generateReport = generateReport; exports.displayReport = displayReport; const fs_extra_1 = __importDefault(require("fs-extra")); const chalk_1 = __importDefault(require("chalk")); /** * Generates a JSON report from scan results. * @param results - The scan results to save. * @param outputPath - Path to save the report (default: ./tmrw-audit-report.json). * @returns A promise resolving to the report path. * @throws Error if saving fails. */ async function generateReport(results, outputPath = './tmrw-audit-report.json') { try { const report = { timestamp: new Date().toISOString(), ...results, }; await fs_extra_1.default.writeJson(outputPath, report, { spaces: 2 }); return outputPath; } catch (err) { throw new Error(`Failed to save report: ${err.message}`); } } /** * Displays a saved JSON report. * @param file - Path to the report file (default: ./tmrw-audit-report.json). * @throws Error if reading or displaying fails. */ async function displayReport(file = './tmrw-audit-report.json') { try { const report = await fs_extra_1.default.readJson(file); console.log(chalk_1.default.red('\nšŸ“Š AUDIT REPORT: YOUR INFRA\'S WEAKNESS\n')); console.log(`Timestamp: ${report.timestamp}`); console.log(chalk_1.default.bold(`Cloud Lock-in Vulnerability (CLV) Score: ${report.clvScore}/100 (${report.riskLabel})`)); console.log(`Vendor Lock-In: ${report.lockInScore}%`); console.log(`Deplatforming Risk: ${report.deplatformingRisk}`); console.log(chalk_1.default.dim('CLV Score Breakdown:')); console.log(`- Vendor Lock-In Penalty: ${(report.lockInScore * 0.5).toFixed(1)}`); console.log(`- Deplatforming Risk Penalty: ${(report.deplatformingRiskScore * 0.3).toFixed(1)}`); console.log(`- Proprietary Format Penalty: ${((1 - report.portabilityScore) * 20).toFixed(1)}`); console.log(chalk_1.default.bold('\nReal-World Wake-Up Calls:')); report.deplatformingExamples.forEach((ex) => console.log(chalk_1.default.yellow(`- ${ex}`))); console.log(chalk_1.default.bold('\nEscape Plan:')); report.recommendations.forEach((rec) => console.log(`- ${rec}`)); } catch (err) { throw new Error(`Failed to display report: ${err.message}`); } }