ruby-nessus 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ module Helpers
2
+ DOT_NESSUS = File.join(File.dirname(__FILE__),'example.nessus')
3
+ end
data/spec/host_spec.rb ADDED
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+ require 'helpers/xml'
3
+
4
+ describe "Host" do
5
+
6
+ before(:all) do
7
+ @xml = Nessus::XML.new(Helpers::DOT_NESSUS)
8
+ @host = @xml.all_hosts.first
9
+ end
10
+
11
+ it "should parse the host hostname" do
12
+ @host.hostname.should == 'scanme.insecure.org'
13
+ end
14
+
15
+ it "should parse the host start time" do
16
+ @host.scan_start_time.to_s.should == '2009-11-08T02:21:24+00:00'
17
+ end
18
+
19
+ it "should parse the host stop time" do
20
+ @host.scan_stop_time.to_s.should == '2009-11-08T02:31:28+00:00'
21
+ end
22
+
23
+ it "should parse the host runtime" do
24
+ @host.scan_runtime.should == '0 hours 10 minutes and 4 seconds'
25
+ end
26
+
27
+ it "should parse the hosts open ports" do
28
+ @host.open_ports.should == 6
29
+ end
30
+
31
+ it "should calculate the hosts informational event count" do
32
+ @host.informational_events.should == 5
33
+ end
34
+
35
+ it "should calculate the hosts low severity event count" do
36
+ @host.low_severity_events.should == 19
37
+ end
38
+
39
+ it "should calculate the hosts medium severity event count" do
40
+ @host.medium_severity_events.should == 3
41
+ end
42
+
43
+ it "should calculate the hosts high severity event count" do
44
+ @host.high_severity_events.should == 0
45
+ end
46
+
47
+ it "should calculate the hosts total event count" do
48
+ @host.event_count.should == 22
49
+ end
50
+
51
+ end
@@ -1,7 +1 @@
1
1
  require 'spec_helper'
2
-
3
- describe "RubyNessus" do
4
- it "fails" do
5
- fail "hey buddy, you should probably rename this file and start specing for real"
6
- end
7
- end
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,6 @@
1
- require 'ruby-nessus'
2
-
1
+ require 'rubygems'
2
+ gem 'rspec', '>=1.1.12'
3
3
  require 'spec'
4
4
  require 'spec/autorun'
5
-
6
- Spec::Runner.configure do |config|
7
-
8
- end
5
+
6
+ require "ruby-nessus"
data/spec/xml_spec.rb ADDED
@@ -0,0 +1,71 @@
1
+ require 'spec_helper'
2
+ require 'helpers/xml'
3
+
4
+ describe "Scan" do
5
+ include Helpers
6
+
7
+ before(:all) do
8
+ @xml = Nessus::XML.new(Helpers::DOT_NESSUS)
9
+ end
10
+
11
+ it "should parse the scan title" do
12
+ @xml.title.should == 'Ruby-Nessus Example Policy'
13
+ end
14
+
15
+ it "should parse the scan time" do
16
+ @xml.time.to_s.should == '2009-11-08T02:21:22+00:00'
17
+ end
18
+
19
+ it "should parse the scan policy title" do
20
+ @xml.policy_title.should == 'Ruby-Nessus Example Policy'
21
+ end
22
+
23
+ it "should parse the scan policy notes" do
24
+ @xml.policy_notes.should == "This is an example .nessus file for testing the Ruby-Nessus gem."
25
+ end
26
+
27
+ it "should parse the scan start time" do
28
+ @xml.start_time.to_s.should == '2009-11-08T02:21:23+00:00'
29
+ end
30
+
31
+ it "should parse the scan stop time" do
32
+ @xml.stop_time.to_s.should == '2009-11-08T02:31:29+00:00'
33
+ end
34
+
35
+ it "should parse the scan runtime" do
36
+ @xml.runtime.should == '0 hours 10 minutes and 6 seconds'
37
+ end
38
+
39
+ it "should parse the scan total host count" do
40
+ @xml.host_count.should == 1
41
+ end
42
+
43
+ it "should calculate the percentage of low severity events" do
44
+ @xml.event_percentage_for("low", true).should == "86"
45
+ end
46
+
47
+ it "should calculate the low severity event total" do
48
+ @xml.low_severity_count.should == 19
49
+ end
50
+
51
+ it "should calculate the percentage of medium severity events" do
52
+ @xml.event_percentage_for("medium", true).should == "14"
53
+ end
54
+
55
+ it "should calculate the medium severity event total" do
56
+ @xml.medium_severity_count.should == 3
57
+ end
58
+
59
+ it "should calculate the percentage of high severity events" do
60
+ @xml.event_percentage_for("high", true).should == "0"
61
+ end
62
+
63
+ it "should calculate the high severity event total" do
64
+ @xml.high_severity_count.should == 0
65
+ end
66
+
67
+ it "should calculate the total for all severity events" do
68
+ @xml.total_event_count.should == 22
69
+ end
70
+
71
+ end
data/tasks/spec.rb CHANGED
@@ -1,14 +1,10 @@
1
1
  require 'spec/rake/spectask'
2
- Spec::Rake::SpecTask.new(:spec) do |spec|
3
- spec.libs << 'lib' << 'spec'
4
- spec.spec_files = FileList['spec/**/*_spec.rb']
2
+
3
+ desc "Run all specifications"
4
+ Spec::Rake::SpecTask.new(:spec) do |t|
5
+ t.libs += ['lib', 'spec']
6
+ t.spec_opts = ['--colour', '--format', 'specdoc']
5
7
  end
6
-
7
- Spec::Rake::SpecTask.new(:rcov) do |spec|
8
- spec.libs << 'lib' << 'spec'
9
- spec.pattern = 'spec/**/*_spec.rb'
10
- spec.rcov = true
11
- end
12
-
13
- task :spec => :check_dependencies
8
+
9
+ task :test => :spec
14
10
  task :default => :spec
data/tasks/yard.rb ADDED
@@ -0,0 +1,18 @@
1
+ lib_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
2
+ unless $LOAD_PATH.include?(lib_dir)
3
+ $LOAD_PATH.unshift(lib_dir)
4
+ end
5
+
6
+ require 'yard'
7
+
8
+ YARD::Rake::YardocTask.new do |t|
9
+ t.files = ['lib/**/*.rb']
10
+ t.options = [
11
+ '--protected',
12
+ '--files', 'History.txt',
13
+ '--title', 'ruby-nessus',
14
+ '--quiet'
15
+ ]
16
+ end
17
+
18
+ task :docs => :yardoc
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-nessus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dustin Willis Webber
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-10 00:00:00 -06:00
12
+ date: 2009-11-21 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -61,6 +61,7 @@ files:
61
61
  - examples/example.rb
62
62
  - examples/pdf_example.rb
63
63
  - examples/ruby-nessus-example.pdf
64
+ - init.rb
64
65
  - lib/ruby-nessus.rb
65
66
  - lib/ruby-nessus/core_ext/helpers.rb
66
67
  - lib/ruby-nessus/event.rb
@@ -68,11 +69,15 @@ files:
68
69
  - lib/ruby-nessus/nessus.rb
69
70
  - lib/ruby-nessus/port.rb
70
71
  - lib/ruby-nessus/xml.rb
72
+ - spec/event_spec.rb
73
+ - spec/helpers/example.nessus
74
+ - spec/helpers/xml.rb
75
+ - spec/host_spec.rb
71
76
  - spec/ruby-nessus_spec.rb
72
- - spec/spec.opts
73
77
  - spec/spec_helper.rb
74
- - tasks/rdoc.rb
78
+ - spec/xml_spec.rb
75
79
  - tasks/spec.rb
80
+ - tasks/yard.rb
76
81
  has_rdoc: true
77
82
  homepage: http://github.com/mephux/ruby-nessus
78
83
  licenses: []
@@ -102,7 +107,11 @@ signing_key:
102
107
  specification_version: 3
103
108
  summary: Ruby-Nessus is a ruby interface for the popular Nessus vulnerability scanner.
104
109
  test_files:
110
+ - spec/event_spec.rb
111
+ - spec/helpers/xml.rb
112
+ - spec/host_spec.rb
105
113
  - spec/ruby-nessus_spec.rb
106
114
  - spec/spec_helper.rb
115
+ - spec/xml_spec.rb
107
116
  - examples/example.rb
108
117
  - examples/pdf_example.rb
data/spec/spec.opts DELETED
@@ -1 +0,0 @@
1
- --color
data/tasks/rdoc.rb DELETED
@@ -1,9 +0,0 @@
1
- require 'rake/rdoctask'
2
- Rake::RDocTask.new do |rdoc|
3
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
4
-
5
- rdoc.rdoc_dir = 'rdoc'
6
- rdoc.title = "ruby-nessus #{version}"
7
- rdoc.rdoc_files.include('README*')
8
- rdoc.rdoc_files.include('lib/**/*.rb')
9
- end