Skip to content

Commit

Permalink
Lands #79, Hard-dependency on railties
Browse files Browse the repository at this point in the history
MSP-11359
  • Loading branch information
limhoff-r7 committed Sep 17, 2014
2 parents fb988f9 + 088b38c commit 5e34c2b
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 32 deletions.
2 changes: 2 additions & 0 deletions app/models/mdm/host.rb
@@ -1,5 +1,7 @@
# A system with an {#address IP address} on the network that has been discovered in some way.
class Mdm::Host < ActiveRecord::Base
require 'mdm/host/operating_system_normalization'

include Mdm::Host::OperatingSystemNormalization
include Metasploit::Model::Search

Expand Down
10 changes: 5 additions & 5 deletions app/models/mdm/workspace.rb
Expand Up @@ -156,11 +156,11 @@ def web_vulns

def unique_web_forms
query = <<-EOQ
SELECT DISTINCT web_forms.web_site_id, web_forms.path, web_forms.method, web_forms.query
FROM hosts, services, web_sites, web_forms
WHERE hosts.workspace_id = #{id} AND
services.host_id = hosts.id AND
web_sites.service_id = services.id AND
SELECT DISTINCT web_forms.web_site_id, web_forms.path, web_forms.method, web_forms.query
FROM hosts, services, web_sites, web_forms
WHERE hosts.workspace_id = #{id} AND
services.host_id = hosts.id AND
web_sites.service_id = services.id AND
web_forms.web_site_id = web_sites.id
EOQ
Mdm::WebForm.find_by_sql(query)
Expand Down
4 changes: 3 additions & 1 deletion app/models/metasploit_data_models/ip_address/v4/cidr.rb
@@ -1,3 +1,5 @@
require 'metasploit_data_models/ip_address/cidr'

# An IPv4 CIDR (Classless InterDomain Routing) block composed of a
# {MetasploitDataModels::IPAddress::V4::Single IPv4} {MetasploitDataModels::IPAddress::CIDR#address address} and
# {MetasploitDataModels::IPAddress::CIDR#prefix_length prefix_length} written in the form `'a.b.c.d/prefix_length'`.
Expand All @@ -11,4 +13,4 @@ class MetasploitDataModels::IPAddress::V4::CIDR < Metasploit::Model::Base
#

cidr address_class: MetasploitDataModels::IPAddress::V4::Single
end
end
4 changes: 3 additions & 1 deletion app/models/metasploit_data_models/ip_address/v4/range.rb
@@ -1,3 +1,5 @@
require 'metasploit_data_models/ip_address/range'

# A range of complete IPv4 addresses, separated by a `-`.
class MetasploitDataModels::IPAddress::V4::Range < Metasploit::Model::Base
extend MetasploitDataModels::Match::Child
Expand All @@ -9,4 +11,4 @@ class MetasploitDataModels::IPAddress::V4::Range < Metasploit::Model::Base
#

extremes class_name: 'MetasploitDataModels::IPAddress::V4::Single'
end
end
@@ -1,8 +1,9 @@
require 'metasploit_data_models/match/parent'

# A comma separated list of {MetasploitDataModels::IPAddress::V4::Segment::Single segment numbers} and
# {MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range range of segment numbers} making up one segment of
# {MetasploitDataModels::IPAddress::V4::Nmap}.
class MetasploitDataModels::IPAddress::V4::Segment::Nmap::List < Metasploit::Model::Base
extend ActiveSupport::Autoload

include MetasploitDataModels::Match::Parent

Expand Down Expand Up @@ -123,4 +124,4 @@ def value_is_array
errors.add(:value, :array)
end
end
end
end
14 changes: 2 additions & 12 deletions lib/metasploit_data_models.rb
Expand Up @@ -24,13 +24,9 @@
require 'mdm'
require 'mdm/module'
require 'metasploit_data_models/base64_serializer'
require 'metasploit_data_models/version'
require 'metasploit_data_models/engine'
require 'metasploit_data_models/serialized_prefs'

# Only include the Rails engine when using Rails.
if defined? Rails
require 'metasploit_data_models/engine'
end
require 'metasploit_data_models/version'

module MetasploitDataModels
def self.root
Expand All @@ -44,9 +40,3 @@ def self.root
end
end

lib_pathname = MetasploitDataModels.root.join('lib')
# has to work under 1.8.7, so can't use to_path
lib_path = lib_pathname.to_s
# Add path to gem's lib so that concerns for models are loaded correctly if models are reloaded
ActiveSupport::Dependencies.autoload_paths << lib_path
ActiveSupport::Dependencies.autoload_once_paths << lib_path
4 changes: 3 additions & 1 deletion lib/metasploit_data_models/ip_address/cidr.rb
@@ -1,3 +1,5 @@
require 'metasploit_data_models/match/child'

# Common behavior for Class-InterDomain Routing (`<address>/<prefix-length>`) notation under
# {MetasploitDataModels::IPAddress},
module MetasploitDataModels::IPAddress::CIDR
Expand Down Expand Up @@ -171,4 +173,4 @@ def address_valid
errors.add(:address, :invalid)
end
end
end
end
2 changes: 2 additions & 0 deletions lib/metasploit_data_models/match.rb
@@ -0,0 +1,2 @@
module MetasploitDataModels::Match
end
3 changes: 2 additions & 1 deletion lib/metasploit_data_models/match/child.rb
@@ -1,3 +1,4 @@
require 'metasploit_data_models/match'
# Adds a {#match match class method} to the extending class. The extending class must define `MATCH_REGEXP`.
#
# @example Define `match` class method
Expand Down Expand Up @@ -45,4 +46,4 @@ def match_regexp
def regexp
self::REGEXP
end
end
end
4 changes: 3 additions & 1 deletion lib/metasploit_data_models/match/parent.rb
@@ -1,3 +1,5 @@
require 'metasploit_data_models/match'

# Uses classes that extend {MetasploitDataModels::Match::Child}
#
# @example Add match_child to class.
Expand Down Expand Up @@ -100,4 +102,4 @@ def match_child(formatted_value)

child
end
end
end
4 changes: 2 additions & 2 deletions lib/metasploit_data_models/version.rb
Expand Up @@ -4,9 +4,9 @@ module Version
# The major version number.
MAJOR = 0
# The minor version number, scoped to the {MAJOR} version number.
MINOR = 19
MINOR = 20
# The patch number, scoped to the {MINOR} version number.
PATCH = 8
PATCH = 0

# 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
13 changes: 7 additions & 6 deletions metasploit_data_models.gemspec
Expand Up @@ -39,26 +39,27 @@ Gem::Specification.new do |s|
# @see MSP-2971
s.add_runtime_dependency 'activerecord', '>= 3.2.13', '< 4.0.0'
s.add_runtime_dependency 'activesupport'
s.add_runtime_dependency 'metasploit-concern', '~> 0.1.0'
s.add_runtime_dependency 'metasploit-model', '~> 0.26.1'

s.add_runtime_dependency 'metasploit-concern', '~> 0.2.1'
s.add_runtime_dependency 'metasploit-model', '~> 0.27.0'
s.add_runtime_dependency 'railties', '< 4.0.0'

# arel-helpers: Useful tools to help construct database queries with ActiveRecord and Arel.
s.add_runtime_dependency 'arel-helpers'

if RUBY_PLATFORM =~ /java/
# markdown formatting for yard
s.add_development_dependency 'kramdown'

s.add_runtime_dependency 'jdbc-postgres'
s.add_runtime_dependency 'activerecord-jdbcpostgresql-adapter'

s.platform = Gem::Platform::JAVA
else
# markdown formatting for yard
s.add_development_dependency 'redcarpet'

s.add_runtime_dependency 'pg'

s.platform = Gem::Platform::RUBY
end
end

0 comments on commit 5e34c2b

Please sign in to comment.