mirror of
https://github.com/nmap/nmap.git
synced 2026-08-03 22:29:06 +00:00
Fixed a bug I introduced in r23911 that caused some "rules" to not
mark a script as selected by name. Removed some dead code.
This commit is contained in:
parent
a60656d845
commit
110b0d35b0
1 changed files with 4 additions and 9 deletions
13
nse_main.lua
13
nse_main.lua
|
|
@ -395,6 +395,9 @@ do
|
|||
filename);
|
||||
end
|
||||
local basename = match(filename, "([^/\\]+)$") or filename;
|
||||
if selected_by_name then
|
||||
print_debug(2, "Script %s was selected by name.", basename);
|
||||
end
|
||||
local short_basename = match(filename, "([^/\\]+)%.nse$") or
|
||||
match(filename, "([^/\\]+)%.[^.]*$") or filename;
|
||||
local file_closure = assert(loadfile(filename));
|
||||
|
|
@ -570,14 +573,13 @@ local function get_chosen_scripts (rules)
|
|||
end
|
||||
local env = {m = m};
|
||||
|
||||
local script;
|
||||
for globalized_rule, rule_table in pairs(entry_rules) do
|
||||
if setfenv(rule_table.compiled_rule, env)() then -- run the compiled rule
|
||||
used_rules[rule_table.original_rule] = true;
|
||||
local t, path = cnse.fetchscript(filename);
|
||||
if t == "file" then
|
||||
if not files_loaded[path] then
|
||||
chosen_scripts[#chosen_scripts+1] = Script.new(path);
|
||||
chosen_scripts[#chosen_scripts+1] = Script.new(path, selected_by_name);
|
||||
files_loaded[path] = true;
|
||||
-- do not break so other rules can be marked as used
|
||||
end
|
||||
|
|
@ -587,12 +589,6 @@ local function get_chosen_scripts (rules)
|
|||
end
|
||||
end
|
||||
end
|
||||
if script then
|
||||
script.selected_by_name = selected_by_name;
|
||||
if script.selected_by_name then
|
||||
print_debug(2, "Script %s was selected by name.", script.basename);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
setfenv(db_closure, {Entry = entry});
|
||||
|
|
@ -610,7 +606,6 @@ local function get_chosen_scripts (rules)
|
|||
elseif t == "file" and not files_loaded[path] then
|
||||
local script = Script.new(path, true);
|
||||
chosen_scripts[#chosen_scripts+1] = script;
|
||||
print_debug(2, "Script %s was selected by name.", path);
|
||||
files_loaded[path] = true;
|
||||
elseif t == "directory" then
|
||||
for f in cnse.dir(path) do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue