mirror of
https://github.com/nmap/nmap.git
synced 2025-12-09 06:01:28 +00:00
Tolerate missing script.db; categories will not work.
This commit is contained in:
17
nse_main.lua
17
nse_main.lua
@@ -711,9 +711,13 @@ local function get_chosen_scripts (rules)
|
||||
check_rules(rules);
|
||||
|
||||
local db_env = {Entry = nil};
|
||||
local db_closure = assert(loadfile(script_database_path, "t", db_env),
|
||||
"database appears to be corrupt or out of date;\n"..
|
||||
local db_closure = loadfile(script_database_path, "t", db_env)
|
||||
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");
|
||||
db_closure = function () return end
|
||||
end
|
||||
|
||||
local chosen_scripts, files_loaded = {}, {};
|
||||
local used_rules, forced_rules = {}, {};
|
||||
@@ -1316,7 +1320,13 @@ if script_database_update then
|
||||
local t, path = cnse.fetchfile_absolute('scripts/'); -- fetch script directory
|
||||
assert(t == 'directory', 'could not locate scripts directory');
|
||||
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 = {};
|
||||
for f in lfs.dir(path) do
|
||||
if match(f, '%.nse$') then
|
||||
@@ -1339,6 +1349,7 @@ if script_database_update then
|
||||
db:close();
|
||||
log_write("stdout", "Script Database updated successfully.");
|
||||
end
|
||||
end
|
||||
|
||||
-- Load all user chosen scripts
|
||||
local chosen_scripts = get_chosen_scripts(rules);
|
||||
|
||||
Reference in New Issue
Block a user