fix: patch log4j config file to prevent logging in xml

This commit is contained in:
HerozDotExe 2025-12-10 20:52:02 +01:00
parent 6193863abc
commit 2e944d8a85

View file

@ -5,6 +5,11 @@ import { exists } from "../utils/fs";
import { hash } from "crypto";
import fs from "fs/promises";
async function patchFileLog4j(versionManifest: Version, xmlDestination: string) {
const original = await fs.readFile(xmlDestination, {encoding: "utf-8"})
await fs.writeFile(xmlDestination, original.replace("<LegacyXMLLayout />", ""))
}
export async function getArgument(
versionManifest: Version,
destination: string,
@ -18,13 +23,15 @@ export async function getArgument(
url: versionManifest.logging.client.file.url,
path: xmlDestination,
});
}
if (
hash("sha1", await fs.readFile(xmlDestination, { encoding: "utf-8" })) !==
versionManifest.logging.client.file.sha1
) {
throw new Error("Wrong hash for log4j's xml config");
if (
hash("sha1", await fs.readFile(xmlDestination, { encoding: "utf-8" })) !==
versionManifest.logging.client.file.sha1
) {
throw new Error("Wrong hash for log4j's xml config");
}
await patchFileLog4j(versionManifest, xmlDestination)
}
return versionManifest.logging.client.argument.replace(