Skip to content

Commit

Permalink
Merge branch 'feature/MSP-10733/cred-search-operator-help'
Browse files Browse the repository at this point in the history
MSP-10733
  • Loading branch information
limhoff-r7 committed Sep 9, 2014
2 parents 78edde3 + cd0c743 commit fb988f9
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 6 deletions.
4 changes: 0 additions & 4 deletions app/models/mdm/host.rb
Expand Up @@ -519,10 +519,6 @@ class Mdm::Host < ActiveRecord::Base
:os_sp
]

#
# Search Withs
#

search_with MetasploitDataModels::Search::Operator::IPAddress,
attribute: :address

Expand Down
34 changes: 34 additions & 0 deletions config/locales/en.yml
@@ -1,4 +1,38 @@
en:
activerecord:
ancestors:
mdm/service:
search:
operator:
names:
info:
help: "Filters the results by service information or banners that contain the specified value."
name:
help: "Filters the results by service name."
proto:
help: "Filters the results by transport protocol."
port:
help: "Filters the results by port number."
mdm/host:
search:
operator:
names:
name:
help: "Filters the results by host name."
address:
help: "Filters the results by IP address or range."
os:
help: "Filters the results by operating system."
os_name:
help: "Filters the results by operating system."
mdm/tag:
search:
operator:
names:
name:
help: "Filters the results by tag."
desc:
help: "Filters the results by the description field of an associated tag."
metasploit:
model:
errors:
Expand Down
2 changes: 1 addition & 1 deletion lib/metasploit_data_models/version.rb
Expand Up @@ -6,7 +6,7 @@ module Version
# The minor version number, scoped to the {MAJOR} version number.
MINOR = 19
# The patch number, scoped to the {MINOR} version number.
PATCH = 7
PATCH = 8

# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the `PRERELEASE` in the
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
Expand Down
27 changes: 27 additions & 0 deletions spec/app/models/mdm/host_spec.rb
Expand Up @@ -846,4 +846,31 @@ def search_for(str)
end

end

context 'search' do
let(:base_class) {
described_class
}

context 'attributes' do

it_should_behave_like 'search_with',
MetasploitDataModels::Search::Operator::IPAddress,
name: :address
it_should_behave_like 'search_attribute',
:name,
type: :string
it_should_behave_like 'search_with',
MetasploitDataModels::Search::Operator::Multitext,
name: :os,
operator_names: [
:os_name,
:os_flavor,
:os_sp
]
it_should_behave_like 'search_attribute',
:os_name,
type: :string
end
end
end
19 changes: 18 additions & 1 deletion spec/app/models/mdm/service_spec.rb
Expand Up @@ -124,6 +124,23 @@
described_class
}

context 'attributes' do
it_should_behave_like 'search_attribute',
:info,
type: :string
it_should_behave_like 'search_attribute',
:name,
type: :string
it_should_behave_like 'search_attribute',
:proto,
type: {
set: :string
}
it_should_behave_like 'search_with',
MetasploitDataModels::Search::Operator::Port::List,
name: :port
end

context 'associations' do
it_should_behave_like 'search_association', :host
end
Expand All @@ -137,4 +154,4 @@
it { should validate_numericality_of(:port).only_integer }
it { should ensure_inclusion_of(:proto).in_array(described_class::PROTOS) }
end
end
end
16 changes: 16 additions & 0 deletions spec/app/models/mdm/tag_spec.rb
Expand Up @@ -97,4 +97,20 @@
}.to change(Mdm::Tag, :count).by(-1)
end
end


context 'search' do
let(:base_class) {
described_class
}

context 'attributes' do
it_should_behave_like 'search_attribute',
:name,
type: :string
it_should_behave_like 'search_attribute',
:desc,
type: :string
end
end
end

0 comments on commit fb988f9

Please sign in to comment.