Skip to content

Commit

Permalink
Merge branch 'feature/module-cache-construction' into feature/exploit
Browse files Browse the repository at this point in the history
MSP-9490

Conflicts:
	lib/metasploit/model/version.rb
  • Loading branch information
limhoff-r7 committed Mar 17, 2014
2 parents 85b1a03 + 61e43e4 commit bb6e024
Show file tree
Hide file tree
Showing 17 changed files with 175 additions and 2 deletions.
1 change: 1 addition & 0 deletions .coveralls.yml
@@ -0,0 +1 @@
service_name: travis-ci
2 changes: 2 additions & 0 deletions .travis.yml
@@ -1,4 +1,6 @@
language: ruby
rvm:
- '1.9.3'
- '2.0'
- '2.1'
- 'jruby-19mode'
3 changes: 3 additions & 0 deletions Gemfile
Expand Up @@ -22,8 +22,11 @@ group :test do

# Dummy app uses actionpack for ActionController, but not rails since it doesn't use activerecord.
gem 'actionpack', *rails_version_constraint
# Uploads simplecov reports to coveralls.io
gem 'coveralls', require: false
# Engine tasks are loaded using railtie
gem 'railties', *rails_version_constraint
gem 'rspec'
# need rspec-core >= 2.14.0 because 2.14.0 introduced RSpec::Core::SharedExampleGroup::TopLevel
gem 'rspec-core', '>= 2.14.0'
# need rspec-rails >= 2.12.0 as 2.12.0 adds support for redefining named subject in nested context that uses the
Expand Down
2 changes: 1 addition & 1 deletion README.md
@@ -1,4 +1,4 @@
# Metasploit::Model [![Build Status](https://travis-ci.org/rapid7/metasploit-model.png)](https://travis-ci.org/rapid7/metasploit-model)
# Metasploit::Model [![Build Status](https://travis-ci.org/rapid7/metasploit-model.png?branch=feature/exploit)](https://travis-ci.org/rapid7/metasploit-model)[![Coverage Status](https://coveralls.io/repos/rapid7/metasploit-model/badge.png?branch=feature%2Fexploit)](https://coveralls.io/r/rapid7/metasploit-model?branch=feature%2Fexploit)

TODO: Write a gem description

Expand Down
17 changes: 17 additions & 0 deletions lib/metasploit/model/architecture.rb
Expand Up @@ -19,9 +19,11 @@ module Architecture
'cbea64',
'cmd',
'dalvik',
'firefox',
'java',
'mipsbe',
'mipsle',
'nodejs',
'php',
'ppc',
'ppc64',
Expand All @@ -46,6 +48,7 @@ module Architecture
FAMILIES = [
'arm',
'cbea',
'javascript',
'mips',
'ppc',
'sparc',
Expand Down Expand Up @@ -96,6 +99,13 @@ module Architecture
:family => nil,
:summary => 'Dalvik process virtual machine used in Google Android'
},
{
abbreviation: 'firefox',
bits: nil,
endianness: nil,
family: 'javascript',
summary: "Firefox's privileged javascript API"
},
{
:abbreviation => 'java',
:bits => nil,
Expand All @@ -117,6 +127,13 @@ module Architecture
:family => 'mips',
:summary => 'Little-endian MIPS'
},
{
abbreviation: 'nodejs',
bits: nil,
endianness: nil,
family: 'javascript',
summary: 'NodeJS'
},
{
:abbreviation => 'php',
:bits => nil,
Expand Down
10 changes: 10 additions & 0 deletions lib/metasploit/model/authority/zdi.rb
@@ -0,0 +1,10 @@
# Zero Day Initiative authority-specific code.
module Metasploit::Model::Authority::Zdi
# Returns URL to {Metasploit::Model::Reference#designation the ZDI ID's} page on ZDI.
#
# @param designation [String] YY-NNNN ZDI ID.
# @return [String] URL
def self.designation_url(designation)
"http://www.zerodayinitiative.com/advisories/ZDI-#{designation}"
end
end
2 changes: 2 additions & 0 deletions lib/metasploit/model/platform.rb
Expand Up @@ -19,6 +19,7 @@ module Platform
'BSD' => nil,
'BSDi' => nil,
'Cisco' => nil,
'Firefox' => nil,
'FreeBSD' => nil,
'HPUX' => nil,
'IRIX' => nil,
Expand All @@ -27,6 +28,7 @@ module Platform
'Linux' => nil,
'NetBSD' => nil,
'Netware' => nil,
'NodeJS' => nil,
'OpenBSD' => nil,
'OSX' => nil,
'PHP' => nil,
Expand Down
2 changes: 1 addition & 1 deletion lib/metasploit/model/version.rb
Expand Up @@ -4,6 +4,6 @@ module Model
# considered unstable because certain code may not be shared between metasploit_data_models, metasploit-framework,
# and pro, so support code for that may be removed in the future. Because of the unstable API the version should
# remain below 1.0.0
VERSION = '0.23.0'
VERSION = '0.24.0'
end
end
6 changes: 6 additions & 0 deletions spec/dummy/app/models/dummy/authority.rb
Expand Up @@ -61,6 +61,12 @@ class Dummy::Authority < Metasploit::Model::Base
:obsolete => false,
:summary => 'Waraxe Advisories',
:url => 'http://www.waraxe.us/content-cat-1.html'
},
{
abbreviation: 'ZDI',
obsolete: false,
summary: 'Zero Day Initiative',
url: 'http://www.zerodayinitiative.com/advisories'
}
]

Expand Down
6 changes: 6 additions & 0 deletions spec/factories/metasploit/model/references.rb
Expand Up @@ -58,6 +58,12 @@
"%d-SA#%d" % [year, number]
end

sequence :metasploit_model_reference_zdi_designation do |n|
year, number = n.divmod(1000)

"%02d-%03d" % [year, number]
end

sequence :metasploit_model_reference_url do |n|
"http://example.com/metasploit/model/reference/#{n}"
end
Expand Down
21 changes: 21 additions & 0 deletions spec/lib/metasploit/model/authority/zdi_spec.rb
@@ -0,0 +1,21 @@
require 'spec_helper'

describe Metasploit::Model::Authority::Zdi do
context 'designation_url' do
subject(:designation_url) do
described_class.designation_url(designation)
end

let(:designation) do
FactoryGirl.generate :metasploit_model_reference_zdi_designation
end

it 'should be under advisories directory' do
expect(designation_url).to match_regex(/advisories\/.*#{designation}/)
end

it "should prefix designation with 'ZDI'" do
expect(designation_url).to match_regex(/ZDI-#{designation}/)
end
end
end
2 changes: 2 additions & 0 deletions spec/lib/metasploit/model/platform_spec.rb
Expand Up @@ -28,13 +28,15 @@ def attribute_type(attribute)
it { should include 'BSD' }
it { should include 'BSDi' }
it { should include 'Cisco' }
it { should include 'Firefox' }
it { should include 'FreeBSD' }
it { should include 'HPUX' }
it { should include 'IRIX' }
it { should include 'Java' }
it { should include 'Javascript' }
it { should include 'NetBSD' }
it { should include 'Netware' }
it { should include 'NodeJS' }
it { should include 'OpenBSD' }
it { should include 'OSX' }
it { should include 'PHP' }
Expand Down
3 changes: 3 additions & 0 deletions spec/spec_helper.rb
Expand Up @@ -8,6 +8,9 @@
# Require simplecov before loading ..dummy/config/environment.rb because it will cause metasploit_data_models/lib to
# be loaded, which would result in Coverage not recording hits for any of the files.
require 'simplecov'
require 'coveralls'

SimpleCov.formatter = Coveralls::SimpleCov::Formatter

require File.expand_path('../dummy/config/environment.rb', __FILE__)
require 'rspec/rails'
Expand Down
79 changes: 79 additions & 0 deletions spec/support/shared/examples/metasploit/model/architecture.rb
Expand Up @@ -37,6 +37,10 @@
abbreviations.should include('dalvik')
end

it 'should include firefox for Firefox privileged javascript API' do
expect(abbreviations).to include('firefox')
end

it 'should include java for Java Virtual Machine' do
abbreviations.should include('java')
end
Expand All @@ -46,6 +50,10 @@
abbreviations.should include('mipsle')
end

it 'should include nodejs for javascript code that requires NodeJS extensions/libraries' do
expect(abbreviations).to include('nodejs')
end

it 'should include php for PHP code' do
abbreviations.should include('php')
end
Expand Down Expand Up @@ -76,6 +84,58 @@
abbreviations.should include('x86_64')
end
end

context 'BITS' do
subject(:bits) do
described_class::BITS
end

it { should include 32 }
it { should include 64 }
end

context 'ENDIANNESSES' do
subject(:endiannesses) do
described_class::ENDIANNESSES
end

it { should include 'big' }
it { should include 'little' }
end

context 'FAMILIES' do
subject(:families) do
described_class::FAMILIES
end

it 'includes arm for big- and little-endian ARM' do
expect(families).to include('arm')
end

it 'includes cbea for 32- and 64-bit Cell Broadband Engine Architecture' do
expect(families).to include('cbea')
end

it 'includes javascript for NodeJS' do
expect(families).to include('javascript')
end

it 'includes mips for big and little-endian MIPS' do
expect(families).to include('mips')
end

it 'includes ppc for 32- and 64-bit PPC' do
expect(families).to include('ppc')
end

it 'includes sparc for sparc' do
expect(families).to include('sparc')
end

it 'includes x86 for x86 and x86_64' do
expect(families).to include('x86')
end
end
end

context 'search' do
Expand Down Expand Up @@ -146,6 +206,13 @@
:family => nil,
:summary => 'Dalvik process virtual machine used in Google Android'

it_should_behave_like 'Metasploit::Model::Architecture seed',
abbreviation: 'firefox',
bits: nil,
endianness: nil,
family: 'javascript',
summary: "Firefox's privileged javascript API"

it_should_behave_like 'Metasploit::Model::Architecture seed',
:abbreviation => 'java',
:bits => nil,
Expand All @@ -167,6 +234,13 @@
:family => 'mips',
:summary => 'Little-endian MIPS'

it_should_behave_like 'Metasploit::Model::Architecture seed',
:abbreviation => 'nodejs',
:bits => nil,
:endianness => nil,
:family => 'javascript',
:summary => 'NodeJS'

it_should_behave_like 'Metasploit::Model::Architecture seed',
:abbreviation => 'php',
:bits => nil,
Expand Down Expand Up @@ -248,9 +322,11 @@
'cbea64',
'cmd',
'dalvik',
'firefox',
'java',
'mipsbe',
'mipsle',
'nodejs',
'php',
'ppc',
'ppc64',
Expand Down Expand Up @@ -296,9 +372,11 @@
it { should include 'cbea64' }
it { should include 'cmd' }
it { should include 'dalvik' }
it { should include 'firefox' }
it { should include 'java' }
it { should include 'mipsbe' }
it { should include 'mipsle' }
it { should include 'nodejs' }
it { should include 'php' }
it { should include 'ppc' }
it { should include 'ppc64' }
Expand Down Expand Up @@ -339,6 +417,7 @@
it { should include 'arm' }
it { should include 'cbea' }
it { should include 'mips' }
it { should include 'javascript' }
it { should include 'ppc' }
it { should include 'sparc' }
it { should include 'x86' }
Expand Down
7 changes: 7 additions & 0 deletions spec/support/shared/examples/metasploit/model/authority.rb
Expand Up @@ -109,6 +109,13 @@
:obsolete => false,
:summary => 'Waraxe Advisories',
:url => 'http://www.waraxe.us/content-cat-1.html'

it_should_behave_like 'Metasploit::Model::Authority seed',
abbreviation: 'ZDI',
extension_name: 'Metasploit::Model::Authority::Zdi',
obsolete: false,
summary: 'Zero Day Initiative',
url: 'http://www.zerodayinitiative.com/advisories'
end

context 'validations' do
Expand Down
2 changes: 2 additions & 0 deletions spec/support/shared/examples/metasploit/model/platform.rb
Expand Up @@ -16,6 +16,7 @@
it { should include('BSD') }
it { should include('BSDi') }
it { should include('Cisco') }
it { should include('Firefox') }
it { should include('FreeBSD') }
it { should include('HPUX') }
it { should include('IRIX') }
Expand All @@ -24,6 +25,7 @@
it { should include('Linux') }
it { should include('NetBSD') }
it { should include('Netware') }
it { should include('NodeJS') }
it { should include('OpenBSD') }
it { should include('OSX') }
it { should include('PHP') }
Expand Down
12 changes: 12 additions & 0 deletions spec/support/shared/examples/metasploit/model/reference.rb
Expand Up @@ -122,6 +122,18 @@

it_should_behave_like 'derives', :url, :validates => false
end

context 'ZDI' do
let(:abbreviation) do
'ZDI'
end

let(:designation) do
FactoryGirl.generate :metasploit_model_reference_zdi_designation
end

it_should_behave_like 'derives', :url, validates: false
end
end
end
end
Expand Down

0 comments on commit bb6e024

Please sign in to comment.