|
35 | 35 | end
|
36 | 36 |
|
37 | 37 |
|
| 38 | +REF_TYPES = %w(CVE BID OSVDB EDB) |
| 39 | + |
38 | 40 | describe Msf::Module do
|
39 | 41 | describe '#search_filter' do
|
40 |
| - before { subject.stub(:type => 'server') } |
41 | 42 | let(:opts) { Hash.new }
|
| 43 | + before { subject.stub(:fullname => '/module') } |
42 | 44 | subject { Msf::Module.new(opts) }
|
43 |
| - |
44 | 45 | accept = []
|
45 | 46 | reject = []
|
46 | 47 |
|
|
82 | 83 |
|
83 | 84 | context 'on a module that supports the osx platform' do
|
84 | 85 | let(:opts) { ({ 'Platform' => %w(osx) }) }
|
85 |
| - accept = %w(platform:osx) |
86 |
| - reject = %w(platform:bsd platform:windows platform:unix) |
| 86 | + accept = %w(platform:osx os:osx) |
| 87 | + reject = %w(platform:bsd platform:windows platform:unix os:bsd os:windows os:unix) |
87 | 88 |
|
88 | 89 | it_should_behave_like 'search_filter', :accept => accept, :reject => reject
|
89 | 90 | end
|
90 | 91 |
|
91 | 92 | context 'on a module that supports the linux platform' do
|
92 | 93 | let(:opts) { ({ 'Platform' => %w(linux) }) }
|
93 |
| - accept = %w(platform:linux) |
94 |
| - reject = %w(platform:bsd platform:windows platform:unix) |
| 94 | + accept = %w(platform:linux os:linux) |
| 95 | + reject = %w(platform:bsd platform:windows platform:unix os:bsd os:windows os:unix) |
95 | 96 |
|
96 | 97 | it_should_behave_like 'search_filter', :accept => accept, :reject => reject
|
97 | 98 | end
|
98 | 99 |
|
99 | 100 | context 'on a module that supports the windows platform' do
|
100 | 101 | let(:opts) { ({ 'Platform' => %w(windows) }) }
|
101 |
| - accept = %w(platform:windows) |
102 |
| - reject = %w(platform:bsd platform:osx platform:unix) |
| 102 | + accept = %w(platform:windows os:windows) |
| 103 | + reject = %w(platform:bsd platform:osx platform:unix os:bsd os:osx os:unix) |
103 | 104 |
|
104 | 105 | it_should_behave_like 'search_filter', :accept => accept, :reject => reject
|
105 | 106 | end
|
106 | 107 |
|
107 | 108 | context 'on a module that supports the osx and linux platforms' do
|
108 | 109 | let(:opts) { ({ 'Platform' => %w(osx linux) }) }
|
109 |
| - accept = %w(platform:osx platform:linux) |
110 |
| - reject = %w(platform:bsd platform:windows platform:unix) |
| 110 | + accept = %w(platform:osx platform:linux os:osx os:linux) |
| 111 | + reject = %w(platform:bsd platform:windows platform:unix os:bsd os:windows os:unix) |
111 | 112 |
|
112 | 113 | it_should_behave_like 'search_filter', :accept => accept, :reject => reject
|
113 | 114 | end
|
114 | 115 |
|
115 | 116 | context 'on a module that supports the windows and irix platforms' do
|
116 | 117 | let(:opts) { ({ 'Platform' => %w(windows irix) }) }
|
117 |
| - accept = %w(platform:windows platform:irix) |
118 |
| - reject = %w(platform:bsd platform:osx platform:linux) |
| 118 | + accept = %w(platform:windows platform:irix os:windows os:irix) |
| 119 | + reject = %w(platform:bsd platform:osx platform:linux os:bsd os:osx os:linux) |
119 | 120 |
|
120 | 121 | it_should_behave_like 'search_filter', :accept => accept, :reject => reject
|
121 | 122 | end
|
|
129 | 130 | end
|
130 | 131 |
|
131 | 132 | context 'on a module with a #name of "blah"' do
|
132 |
| - before { subject.stub(:name => 'blah') } |
| 133 | + let(:opts) { ({ 'Name' => 'blah' }) } |
133 | 134 | it_should_behave_like 'search_filter', :accept => %w(text:blah), :reject => %w(text:foo)
|
134 | 135 | it_should_behave_like 'search_filter', :accept => %w(name:blah), :reject => %w(name:foo)
|
135 | 136 | end
|
136 | 137 |
|
137 | 138 | context 'on a module with a #fullname of "blah"' do
|
138 |
| - before { subject.stub(:fullname => 'blah/blah') } |
| 139 | + before { subject.stub(:fullname => '/c/d/e/blah') } |
139 | 140 | it_should_behave_like 'search_filter', :accept => %w(text:blah), :reject => %w(text:foo)
|
140 | 141 | it_should_behave_like 'search_filter', :accept => %w(path:blah), :reject => %w(path:foo)
|
141 | 142 | end
|
142 | 143 |
|
143 | 144 | context 'on a module with a #description of "blah"' do
|
144 |
| - before { subject.stub(:description => 'blah') } |
| 145 | + let(:opts) { ({ 'Description' => 'blah' }) } |
145 | 146 | it_should_behave_like 'search_filter', :accept => %w(text:blah), :reject => %w(text:foo)
|
146 | 147 | end
|
147 | 148 |
|
|
159 | 160 | end
|
160 | 161 | end
|
161 | 162 |
|
| 163 | + REF_TYPES.each do |ref_type| |
| 164 | + ref_num = '1234-1111' |
| 165 | + context 'on a module with reference #{ref_type}-#{ref_num}' do |
| 166 | + let(:opts) { ({ 'References' => [[ref_type, ref_num]] }) } |
| 167 | + accept = ["#{ref_type.downcase}:#{ref_num}"] |
| 168 | + reject = %w(1235-1111 1234-1112 bad).map { |n| "#{ref_type.downcase}:#{n}" } |
| 169 | + |
| 170 | + it_should_behave_like 'search_filter', :accept => accept, :reject => reject |
| 171 | + end |
| 172 | + end |
| 173 | + |
162 | 174 | #
|
163 | 175 | # Still missing 'cve:', 'bid:', 'osvdb:', and 'edb:' test cases...
|
164 | 176 | #
|
|
0 commit comments