UNPKG

ubon

Version:

Security scanner for AI-generated apps (Cursor, Lovable, Windsurf, v0). Catches hardcoded secrets, prompt injection, hallucinated imports, Server Actions / Edge runtime mistakes, and the vibe-coded vulnerabilities traditional linters miss.

60 lines 1.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ResultCache = void 0; const fs_1 = require("fs"); const path_1 = require("path"); const crypto_1 = require("crypto"); class ResultCache { directory; cachePath; data; constructor(directory, signature) { this.directory = directory; const cacheDir = (0, path_1.join)(directory, '.ubon'); try { if (!(0, fs_1.existsSync)(cacheDir)) (0, fs_1.mkdirSync)(cacheDir, { recursive: true }); } catch { } this.cachePath = (0, path_1.join)(cacheDir, 'results-cache.json'); this.data = { signature, files: {} }; this.load(signature); } load(signature) { try { if ((0, fs_1.existsSync)(this.cachePath)) { const raw = JSON.parse((0, fs_1.readFileSync)(this.cachePath, 'utf-8')); if (raw && raw.signature === signature && raw.files) { this.data = raw; } } } catch { } } save() { try { (0, fs_1.writeFileSync)(this.cachePath, JSON.stringify(this.data, null, 2)); } catch { } } static hashContent(content) { const h = (0, crypto_1.createHash)('sha256'); h.update(content); return h.digest('hex'); } get(file, contentHash) { const entry = this.data.files[file]; if (!entry) return null; return entry.hash === contentHash ? entry.results : null; } set(file, contentHash, results) { this.data.files[file] = { hash: contentHash, results }; } clear() { this.data.files = {}; this.save(); } } exports.ResultCache = ResultCache; //# sourceMappingURL=result-cache.js.map