security-patches
Version:
Latest Security Patches
72 lines (58 loc) • 1.8 kB
JavaScript
const fs = require("fs");
const path = require("path");
const addInputFileLimit = require("./add-Input-FileLimits");
const removeMD5 = require("./remove-md5Encript");
const argPath = process.argv.slice(2);
if (argPath.length == 0) {
console.log("Error : Provide a file path !");
process.exit(-1);
}
if (!fs.existsSync(argPath[0])) {
console.log("Error : Invalid File Path !");
process.exit(-1);
}
if (
path.basename(argPath[0]) != "app" &&
path.basename(argPath[0]) != "server"
) {
console.log("Error : Incomplete or Incorrect File Path !");
process.exit(-1);
}
const readline = require("readline").createInterface({
input: process.stdin,
output: process.stdout,
});
replaceFile(argPath[0]);
function replaceFile(basePath) {
readline.question(
`
Please select operation :
1). Encription Patch (Remove weak MD5 encription).
2). Add input file limits (Add limits to the number and size of files that can be uploaded at once).
3). Exit.
Press 1, 2, or 3: `,
async (ans) => {
var result = false;
if (ans != "1" && ans != "2" && ans != "3") {
console.log("\n \n **** Error: Enter valid input ! ****");
replaceFile(basePath);
}
if (ans == "1") {
result = await removeMD5.replaceFile(basePath);
} else if (ans == "2") {
result = await addInputFileLimit.replaceFile(basePath);
} else if (ans == "3") {
readline.close();
process.exit(-1);
}
if (result == true) {
console.log(" \n \n --- File Replaced Successfully! ", );
replaceFile(basePath);
} else if (result != false) {
console.log("\n \n **** Error : Something went wrong - ", result);
readline.close();
}
}
);
}