Fix security vulnerabilities

This commit is contained in:
2026-10-13 15:52:34 +01:00
parent 74103a19c9
commit eefb2ea5d2
46 changed files with 375 additions and 403 deletions
+12 -2
View File
@@ -1,7 +1,8 @@
import { existsSync, writeFileSync } from "fs";
import { existsSync, readdirSync, writeFileSync } from "fs";
import grabDirNames from "../../utils/grab-dir-names";
import grabCacheNames from "./grab-cache-names";
import path from "path";
import { AppData } from "../../data/app-data";
export default async function writeCache({ key, value, paradigm = "html", expiry_seconds, }) {
try {
const { BUNEXT_CACHE_DIR } = grabDirNames();
@@ -16,7 +17,16 @@ export default async function writeCache({ key, value, paradigm = "html", expiry
msg: `Cache entry already exists`,
};
}
writeFileSync(path.join(target_path), value);
const max_entries = global.BUNEXT_CONFIG?.max_cache_entries ||
AppData["DefaultMaxCacheEntries"];
const entries_count = readdirSync(BUNEXT_CACHE_DIR).filter((f) => f.endsWith(".meta.json")).length;
if (entries_count >= max_entries) {
return {
success: false,
msg: `Cache entries limit (${max_entries}) reached`,
};
}
writeFileSync(target_path, value);
const cache_file_meta = {
date_created: Date.now(),
paradigm,