68 lines
2.4 KiB
Ruby
68 lines
2.4 KiB
Ruby
# encoding: UTF-8
|
|
|
|
require 'spec_helper'
|
|
|
|
describe Vulnerability do
|
|
|
|
describe '#new' do
|
|
subject(:vulnerability) { Vulnerability.new(title, type, references, modules, fixed_version) }
|
|
let(:title) { 'A vulnerability title' }
|
|
let(:type) { 'XSS' }
|
|
let(:references) { %w{http://ref1.com http://ref2.com} }
|
|
|
|
context 'w/o metasploit and fixed version modules argument' do
|
|
subject(:vulnerability) { Vulnerability.new(title, type, references) }
|
|
|
|
its(:title) { should be title }
|
|
its(:references) { should be references }
|
|
its(:type) { should be type }
|
|
its(:metasploit_modules) { should be_empty }
|
|
its(:fixed_in) { should be_empty }
|
|
its(:cve) { should be_empty }
|
|
end
|
|
|
|
context 'with metasploit modules argument' do
|
|
subject(:vulnerability) { Vulnerability.new(title, type, references, modules) }
|
|
let(:modules) { %w{exploit/some_exploit exploit/unix/anotherone } }
|
|
|
|
its(:metasploit_modules) { should be modules }
|
|
its(:fixed_in) { should be_empty }
|
|
its(:cve) { should be_empty }
|
|
end
|
|
|
|
context 'with metasploit modules and fixed version argument' do
|
|
let(:modules) { %w{exploit/some_exploit exploit/unix/anotherone } }
|
|
let(:fixed_version) { '1.0' }
|
|
|
|
its(:metasploit_modules) { should be modules }
|
|
its(:fixed_in) { should == '1.0' }
|
|
its(:cve) { should be_empty }
|
|
end
|
|
|
|
context 'with cve argument' do
|
|
subject(:vulnerability) { Vulnerability.new(title, type, references, [], '', cve) }
|
|
let(:cve) { %w{2011-001 2011-002} }
|
|
|
|
its(:metasploit_modules) { should be_empty }
|
|
its(:fixed_in) { should be_empty }
|
|
its(:cve) { should be cve }
|
|
end
|
|
|
|
end
|
|
|
|
describe '::load_from_xml_node' do
|
|
subject(:vulnerability) { Vulnerability.load_from_xml_node(node) }
|
|
let(:node) {
|
|
xml(MODELS_FIXTURES + '/vulnerability/xml_node.xml').xpath('//vulnerability')
|
|
}
|
|
|
|
its(:title) { should == 'Vuln Title' }
|
|
its(:type) { should == 'CSRF' }
|
|
its(:references) { should == ['Ref 1', 'Ref 2'] }
|
|
its(:metasploit_modules) { should == %w{exploit/ex1} }
|
|
its(:cve) { should == %w{2011-001} }
|
|
its(:fixed_in) { should == '1.0'}
|
|
end
|
|
|
|
end
|