Skip to content

Commit

Permalink
Implement deregistering an option by alias
Browse files Browse the repository at this point in the history
Rather than having to 'unregister' both 'RHOST' and 'RHOSTS' for modules using a network-connecting mixin, this allows just unregistering one option by exposing the alias key lookup to the module options library and allowing it to remove the datastore options for the module from validation.

Noted while testing #11108 that the module's unregister options were incomplete, and there were a few more like it. This allows modules operating in this style to work without modifications.
  • Loading branch information
busterb committed Feb 13, 2019
1 parent 395346a commit 16e800a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 0 additions & 2 deletions lib/msf/core/data_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,6 @@ def each(&block)
list.each(&block)
end

protected

#
# Case-insensitive key lookup
#
Expand Down
8 changes: 6 additions & 2 deletions lib/msf/core/module/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ def validate
#
def deregister_options(*names)
names.each { |name|
self.options.remove_option(name)
real_name = self.datastore.find_key_case(name)
self.datastore.delete(name)
self.options.remove_option(name)
if real_name != name
self.options.remove_option(real_name)
end
}
end

Expand Down Expand Up @@ -62,4 +66,4 @@ def register_options(options, owner = self.class)
self.datastore.import_options(self.options, 'self', true)
import_defaults(false)
end
end
end

0 comments on commit 16e800a

Please sign in to comment.