File tree Expand file tree Collapse file tree 2 files changed +44
-7
lines changed
lib/rex/post/meterpreter/extensions/stdapi/sys
spec/lib/rex/post/meterpreter/extensions/stdapi/sys Expand file tree Collapse file tree 2 files changed +44
-7
lines changed Original file line number Diff line number Diff line change @@ -381,13 +381,16 @@ def self.key2str(key)
381381 # type (like REG_SZ).
382382 #
383383 def self . type2str ( type )
384- return REG_SZ if ( type == 'REG_SZ' )
385- return REG_MULTI_SZ if ( type == 'REG_MULTI_SZ' )
386- return REG_DWORD if ( type == 'REG_DWORD' )
387- return REG_BINARY if ( type == 'REG_BINARY' )
388- return REG_EXPAND_SZ if ( type == 'REG_EXPAND_SZ' )
389- return REG_NONE if ( type == 'REG_NONE' )
390- return nil
384+ case type
385+ when 'REG_BINARY' then REG_BINARY
386+ when 'REG_DWORD' then REG_DWORD
387+ when 'REG_EXPAND_SZ' then REG_EXPAND_SZ
388+ when 'REG_MULTI_SZ' then REG_MULTI_SZ
389+ when 'REG_NONE' then REG_NONE
390+ when 'REG_SZ' then REG_SZ
391+ else
392+ nil
393+ end
391394 end
392395
393396 #
Original file line number Diff line number Diff line change 1+ require 'rex/post/meterpreter/extensions/stdapi/sys/registry'
2+
3+ RSpec . describe Rex ::Post ::Meterpreter ::Extensions ::Stdapi ::Sys ::Registry do
4+
5+ describe '.type2str' do
6+ subject { described_class . type2str ( type ) }
7+
8+ context "with 'REG_BINARY'" do
9+ let ( :type ) { 'REG_BINARY' }
10+ it { should eq ( 3 ) }
11+ end
12+ context "with 'REG_DWORD'" do
13+ let ( :type ) { 'REG_DWORD' }
14+ it { should eq ( 4 ) }
15+ end
16+ context "with 'REG_EXPAND_SZ'" do
17+ let ( :type ) { 'REG_EXPAND_SZ' }
18+ it { should eq ( 2 ) }
19+ end
20+ context "with 'REG_MULTI_SZ'" do
21+ let ( :type ) { 'REG_MULTI_SZ' }
22+ it { should eq ( 7 ) }
23+ end
24+ context "with 'REG_NONE'" do
25+ let ( :type ) { 'REG_NONE' }
26+ it { should eq ( 0 ) }
27+ end
28+ context "with 'REG_SZ'" do
29+ let ( :type ) { 'REG_SZ' }
30+ it { should eq ( 1 ) }
31+ end
32+ end
33+
34+ end
You can’t perform that action at this time.
0 commit comments