Commit Graph

77 Commits

Author SHA1 Message Date
Brent Cook 069a3e3c4e use casecmp rather than allocate a string on every comparison 2019-12-02 09:03:58 -06:00
Brent Cook 16e800a7c4 Implement deregistering an option by alias
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.
2019-02-13 05:07:20 -06:00
Brent Cook 0678d33760 Revert "ensure a value exists before returning the normalized key"
This reverts commit 063838fb17.
2018-11-26 10:10:07 -06:00
Brent Cook a98dbd1d61 Revert "Return the original key if it does not exist in the datastore"
This reverts commit 7312fa774f.
2018-11-26 10:10:07 -06:00
Brent Cook 7312fa774f Return the original key if it does not exist in the datastore 2018-11-21 06:03:50 -06:00
Brent Cook 063838fb17 ensure a value exists before returning the normalized key 2018-11-21 04:43:06 -06:00
Brent Cook da9e6edbf1 delete option aliases when an option is deleted
Otherwise the aliases will remain active and if the aliased value is redefined
2018-11-21 04:09:33 -06:00
Adam Cammack 524661617c Allow DataStore to nest Arrays arbitrarily deep 2018-05-07 09:51:40 -05:00
Brent Cook ee2ad8affe move super call in merge! so that it returns the proper value 2018-04-27 14:21:57 -05:00
Brent Cook 31563a977c use OO rather than duck typing for parameter copying 2018-04-25 18:41:14 -05:00
Brent Cook 9bdba7e234 s/clone/ds/g 2018-04-25 18:35:45 -05:00
Brent Cook 30abdfe2fd move copy up so it's clear what we call by default 2018-04-24 06:40:15 -05:00
Brent Cook 7afefe07a6 aliases was not being copied, dup it 2018-04-24 06:32:54 -05:00
Brent Cook 1d376c78e2 ensure copy exists on DataStore too 2018-04-24 06:32:38 -05:00
Brent Cook 505810ffd6 introspect the RHS since it it is not guaranteed to be a Datastore 2018-04-24 06:15:05 -05:00
Brent Cook d34119548d replace some @ with self. 2018-04-24 06:03:02 -05:00
Brent Cook 00d0beb188 use deep copy 2018-04-18 02:34:48 -10:00
Brent Cook 09e86bfbd0 define merge and merge! on datastore to also merge aliases 2018-04-18 02:27:57 -10:00
Adam Cammack 3363bcf629 Add DataStore serialization that preserves Arrays 2018-01-16 21:05:19 -06:00
Brent Cook bca8e77163 add alias support for datastore options 2017-08-08 19:26:59 -05:00
Louis Sato d5d0b9e9b8 Revert "Land #6729, Speed up the datastore"
This reverts commit c6b1955a5a, reversing
changes made to 4fb7472391.
2016-06-28 13:39:52 -05:00
wchen-r7 c6b1955a5a Land #6729, Speed up the datastore 2016-06-15 17:55:42 -05:00
Brent Cook fe1b24e666 allow nil assignment to the datastore 2016-05-23 14:56:19 -05:00
Adam Cammack a808c9fe63 Bring some sanity to the datastore
Before, the datastore would store options case-sensitive, but would
access them case-insensitive, resulting is a number of string compares.
This commit stores options in their downcase form to reduce
update/lookup time. This adds up to reducing msfconsole boot time by
about 10% and rspec time by about 45 sec. (!) on my box.

One tricky part of this conversion is that there are several places (in
pro and framework) where we export or otherwise access the datastore as
a plain hash (case-sensitive). I believe I have caught all the ways we
access the datastore that are case-sensitive and substituted the
original key capitalization in those cases.
2016-03-30 15:17:55 -05:00
Brent Cook e25525b4a7 avoid validating file-based datastore options on assignment
file:/ strings are special with some datastore options, causing them to read a
file rather than emitting the exact string. This causes a couple of problems.

1. the valid? check needs to be special on assignment, since normalization
   really means normalizing the path, not playing with the value as we would do
   for other types

2. there are races or simply out-of-order assignments when running commands
   like 'services -p 80 -R', where the datastore option is assigned before the
   file is actually written.

This is the 'easy' fix of disabling assignment validation (which we didn't have
before anyway) for types that can expect a file:/ prefix.
2016-03-28 23:03:17 -05:00
Adam Cammack 22df7c0071 Fix datastore to validate options w/o a default
Options without a default were not pulled into the `@options` hash and
therefore were not used to validate options on assignment.

I am not entirely sure how this fix works, since it would seem that
non-override options would not get pulled in if an option was first set
in the global datastore. However, a previous value does not get
overridden and new values are validated. Anything further is merely
speculation on my part.
2016-03-22 19:12:53 -05:00
Adam Cammack 5c163960ed Fix datastore to not freeze options on the default 2016-03-22 19:07:58 -05:00
Brent Cook 654590911b Enforce integrity of datastore options on assignment 2016-03-15 14:00:32 -05:00
Brent Cook 694f7f0a65 stop turning all default options into strings
we need to adjust vprint* functions, since they now fallthrough to the
'framework.datastore' checks because the false case actually triggers.
2016-03-05 23:09:14 -06:00
root 51dd88114b Fix grammer in comments 2015-04-13 13:21:41 +05:00
William Vu 0ad3473ebb Implement case-insensitive datastore.delete 2015-02-24 20:47:00 -06:00
Tab Assassin 7e5e0f7fc8 Retab lib 2013-08-30 16:28:33 -05:00
James Lee db676f1a88 Whitespace at EOL 2013-03-07 18:20:08 -06:00
HD Moore d656e3185f Mark all libraries as defaulting to 8-bit strings 2012-06-29 00:18:28 -05:00
HD Moore b89af3546d Revert the previous global fix in favor of a different method.
Fixes #6501
2012-03-07 07:37:36 -06:00
HD Moore de9b35d7b0 Fixes #6485 by allowing validation to write back normalized values to
global. This isn't perfect, but we have no better solution unless we
clone the module datastore and unset the default imported_by for the
module run (actively testing that too in a branch)
2012-02-29 01:49:26 -06:00
HD Moore 7b40d8d819 Allow updates to fallthrough to the global store just like reads 2012-02-29 01:40:54 -06:00
James Lee e7a545c483 spaces at EOL in core stuff 2011-11-20 12:10:08 +11:00
HD Moore 6bdf2a4e2b Proactively wrap each() in other Hash based classes to avoid situations that trigger modification during enumeration
git-svn-id: file:///home/svn/framework3/trunk@12479 4d416f70-5f16-0410-b530-b9f4589650da
2011-04-30 04:59:27 +00:00
HD Moore 5c2f104ade Fix module.replicant(), closes #2252
git-svn-id: file:///home/svn/framework3/trunk@9824 4d416f70-5f16-0410-b530-b9f4589650da
2010-07-14 17:06:12 +00:00
James Lee 618b377d58 let's try this again. don't convert datastore values to strings when copying, only dup things that are already Strings, see #2189, #2098, #2096
git-svn-id: file:///home/svn/framework3/trunk@9684 4d416f70-5f16-0410-b530-b9f4589650da
2010-07-06 17:59:36 +00:00
James Lee c0eaed263c abstract some copy-paste; add DataStore#copy for doing a deep copy instead of the shallow copy performed by #dup and #clone
git-svn-id: file:///home/svn/framework3/trunk@9650 4d416f70-5f16-0410-b530-b9f4589650da
2010-07-01 21:56:38 +00:00
James Lee 832d0bcbfa add exploit datastore to sessions so we can tell exactly how the session was created
git-svn-id: file:///home/svn/framework3/trunk@8651 4d416f70-5f16-0410-b530-b9f4589650da
2010-02-26 01:09:23 +00:00
HD Moore 9b4df1cf42 Add the datastore.clear method
git-svn-id: file:///home/svn/framework3/trunk@8450 4d416f70-5f16-0410-b530-b9f4589650da
2010-02-11 05:14:36 +00:00
HD Moore d67cb3cdde Really fixes #464
git-svn-id: file:///home/svn/framework3/trunk@7525 4d416f70-5f16-0410-b530-b9f4589650da
2009-11-16 02:52:23 +00:00
HD Moore ba9f7b41b3 Fix save() again
git-svn-id: file:///home/svn/framework3/trunk@7524 4d416f70-5f16-0410-b530-b9f4589650da
2009-11-16 02:48:00 +00:00
HD Moore 1ad262a53e Fixes #464 by using the correct logic to only save user defined variables and to reset default options after a register_*_options call by a mixin
git-svn-id: file:///home/svn/framework3/trunk@7523 4d416f70-5f16-0410-b530-b9f4589650da
2009-11-16 02:39:08 +00:00
HD Moore 737dc327a3 Fixes #435. Resolves a long-standing issue where datastore entries with a default of 'false' were being ignored.
git-svn-id: file:///home/svn/framework3/trunk@7334 4d416f70-5f16-0410-b530-b9f4589650da
2009-11-03 18:09:05 +00:00
HD Moore 91dd38550f Fixes #398. Allow globals to override local defaults, but fallthrough to local defaults if no global or local is set
git-svn-id: file:///home/svn/framework3/trunk@7280 4d416f70-5f16-0410-b530-b9f4589650da
2009-10-26 18:48:06 +00:00
kris efe44ba6b5 bleh.. a bit of tabs vs spaces
git-svn-id: file:///home/svn/framework3/trunk@7171 4d416f70-5f16-0410-b530-b9f4589650da
2009-10-16 18:27:18 +00:00