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.
32 lines • 928 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.shannonEntropy = shannonEntropy;
exports.extractQuotedLiterals = extractQuotedLiterals;
function shannonEntropy(input) {
if (!input || input.length === 0)
return 0;
const map = {};
for (const ch of input)
map[ch] = (map[ch] || 0) + 1;
let entropy = 0;
const len = input.length;
for (const k in map) {
const p = map[k] / len;
entropy -= p * Math.log2(p);
}
return entropy;
}
// Extract quoted string-like tokens from a line
function extractQuotedLiterals(line) {
const matches = [];
const regex = /(['"]).*?\1/g; // simple non-greedy quoted
let m;
while ((m = regex.exec(line)) !== null) {
const raw = m[0];
if (raw.length >= 3) {
matches.push(raw.slice(1, -1));
}
}
return matches;
}
//# sourceMappingURL=entropy.js.map