1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-09 14:11:29 +00:00

Tolerate missing script.db; categories will not work.

This commit is contained in:
dmiller
2022-09-08 18:14:50 +00:00
parent d6bea8dcde
commit dee423f798

View File

@@ -711,9 +711,13 @@ local function get_chosen_scripts (rules)
check_rules(rules); check_rules(rules);
local db_env = {Entry = nil}; local db_env = {Entry = nil};
local db_closure = assert(loadfile(script_database_path, "t", db_env), local db_closure = loadfile(script_database_path, "t", db_env)
"database appears to be corrupt or out of date;\n".. if not db_closure then
log_write("stdout",
"NSE script database appears to be corrupt or out of date;\n"..
"\tplease update using: nmap --script-updatedb"); "\tplease update using: nmap --script-updatedb");
db_closure = function () return end
end
local chosen_scripts, files_loaded = {}, {}; local chosen_scripts, files_loaded = {}, {};
local used_rules, forced_rules = {}, {}; local used_rules, forced_rules = {}, {};
@@ -1316,7 +1320,13 @@ if script_database_update then
local t, path = cnse.fetchfile_absolute('scripts/'); -- fetch script directory local t, path = cnse.fetchfile_absolute('scripts/'); -- fetch script directory
assert(t == 'directory', 'could not locate scripts directory'); assert(t == 'directory', 'could not locate scripts directory');
script_database_path = path.."script.db"; script_database_path = path.."script.db";
local db = assert(open(script_database_path, 'w')); local db = open(script_database_path, 'w')
-- If user requested update with --script-updatedb, a failure here is fatal.
if cnse.scriptupdatedb then
assert(db, "Could not open script.db for writing")
end
-- If we're doing this for convenience only, it's ok to fail.
if db then
local scripts = {}; local scripts = {};
for f in lfs.dir(path) do for f in lfs.dir(path) do
if match(f, '%.nse$') then if match(f, '%.nse$') then
@@ -1339,6 +1349,7 @@ if script_database_update then
db:close(); db:close();
log_write("stdout", "Script Database updated successfully."); log_write("stdout", "Script Database updated successfully.");
end end
end
-- Load all user chosen scripts -- Load all user chosen scripts
local chosen_scripts = get_chosen_scripts(rules); local chosen_scripts = get_chosen_scripts(rules);