scandb 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -0
- data/Manifest.txt +1 -0
- data/README.txt +2 -1
- data/Rakefile +1 -0
- data/lib/scandb/database.rb +5 -7
- data/lib/scandb/model.rb +9 -0
- data/lib/scandb/nmap.rb +3 -3
- data/lib/scandb/persistence.rb +28 -0
- data/lib/scandb/runner.rb +10 -4
- data/lib/scandb/version.rb +1 -1
- metadata +6 -5
data/History.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
=== 0.1.2 / 2008-10-19
|
2
|
+
|
3
|
+
* Have ScanDB use it's own DataMapper Repository name-space to avoid
|
4
|
+
conflicts with other DataMapper libraries.
|
5
|
+
* Bug fix for Runner.command_line, where it was not setting up the DataMapper
|
6
|
+
repository.
|
7
|
+
* Minor performance improvement for Nmap.import_xml.
|
8
|
+
|
1
9
|
=== 0.1.1 / 2008-08-17
|
2
10
|
|
3
11
|
* Added a work-around to DataMappers current problem with lazy-loading
|
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
data/Rakefile
CHANGED
@@ -7,6 +7,7 @@ require './lib/scandb/version.rb'
|
|
7
7
|
Hoe.new('scandb', ScanDB::VERSION) do |p|
|
8
8
|
p.rubyforge_name = 'scandb'
|
9
9
|
p.developer('Postmodern Modulus III', 'postmodern.mod3@gmail.com')
|
10
|
+
p.remote_rdoc_dir = ''
|
10
11
|
p.extra_deps = [
|
11
12
|
['do_sqlite3', '>=0.9.3'],
|
12
13
|
['dm-core', '>=0.9.3'],
|
data/lib/scandb/database.rb
CHANGED
@@ -39,15 +39,15 @@ module ScanDB
|
|
39
39
|
# Database configuration file
|
40
40
|
CONFIG_FILE = File.join(Config::PATH,'database.yml')
|
41
41
|
|
42
|
-
# Default database configuration
|
43
|
-
DEFAULT_CONFIG = "sqlite3://" + File.join(Config::PATH,'scandb.db')
|
44
|
-
|
45
42
|
# Default log path
|
46
43
|
DEFAULT_LOG_PATH = File.join(Config::PATH,'scandb.log')
|
47
44
|
|
48
45
|
# Default log level
|
49
46
|
DEFAULT_LOG_LEVEL = :info
|
50
47
|
|
48
|
+
# Default database configuration
|
49
|
+
DEFAULT_CONFIG = "sqlite3://" + File.join(Config::PATH,'scandb.db')
|
50
|
+
|
51
51
|
#
|
52
52
|
# Returns the Database configuration that is stored in the
|
53
53
|
# +CONFIG_FILE+. Defaults to +DEFAULT_CONFIG+ if +CONFIG_FILE+ does not
|
@@ -103,7 +103,7 @@ module ScanDB
|
|
103
103
|
#
|
104
104
|
def Database.setup(configuration=Database.config,&block)
|
105
105
|
Database.setup_log
|
106
|
-
DataMapper.setup(
|
106
|
+
DataMapper.setup(Model::REPOSITORY_NAME, configuration)
|
107
107
|
|
108
108
|
block.call if block
|
109
109
|
|
@@ -118,10 +118,8 @@ module ScanDB
|
|
118
118
|
model.relationships.each_value { |r| r.child_key if r.child_model == model }
|
119
119
|
end
|
120
120
|
|
121
|
-
DataMapper.auto_upgrade!
|
121
|
+
DataMapper.auto_upgrade!(Model::REPOSITORY_NAME)
|
122
122
|
return nil
|
123
123
|
end
|
124
|
-
|
125
|
-
Database.setup
|
126
124
|
end
|
127
125
|
end
|
data/lib/scandb/model.rb
CHANGED
@@ -21,6 +21,8 @@
|
|
21
21
|
#++
|
22
22
|
#
|
23
23
|
|
24
|
+
require 'scandb/database'
|
25
|
+
|
24
26
|
require 'dm-core'
|
25
27
|
require 'dm-serializer'
|
26
28
|
|
@@ -28,11 +30,18 @@ module ScanDB
|
|
28
30
|
module Model
|
29
31
|
include DataMapper::Types
|
30
32
|
|
33
|
+
# Name of the DataMapper repository
|
34
|
+
REPOSITORY_NAME = :scandb
|
35
|
+
|
31
36
|
def self.included(base)
|
32
37
|
base.module_eval do
|
33
38
|
include DataMapper::Resource
|
34
39
|
include DataMapper::AutoMigrations
|
35
40
|
|
41
|
+
def self.default_repository_name
|
42
|
+
Model::REPOSITORY_NAME
|
43
|
+
end
|
44
|
+
|
36
45
|
property :id, Serial
|
37
46
|
end
|
38
47
|
end
|
data/lib/scandb/nmap.rb
CHANGED
@@ -40,7 +40,7 @@ module ScanDB
|
|
40
40
|
#
|
41
41
|
def Nmap.import_xml(path,&block)
|
42
42
|
doc = XML::Document.file(path)
|
43
|
-
|
43
|
+
host_count = 0
|
44
44
|
|
45
45
|
doc.find("/nmaprun/host[status[@state='up']]").each do |host|
|
46
46
|
ip = host.find_first("address[@addr and @addrtype='ipv4']")['addr']
|
@@ -98,12 +98,12 @@ module ScanDB
|
|
98
98
|
end
|
99
99
|
|
100
100
|
new_host.save
|
101
|
+
host_count += 1
|
101
102
|
|
102
103
|
block.call(new_host) if block
|
103
|
-
hosts << new_host
|
104
104
|
end
|
105
105
|
|
106
|
-
return
|
106
|
+
return host_count
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#
|
2
|
+
#--
|
3
|
+
# ScanDB - A library for importing and analyzing information generated by
|
4
|
+
# various network scanning utilities.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2008 Hal Brodigan (postmodern.mod3 at gmail.com)
|
7
|
+
#
|
8
|
+
# This program is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License along
|
19
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
20
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
21
|
+
#++
|
22
|
+
#
|
23
|
+
|
24
|
+
require 'scandb/database'
|
25
|
+
|
26
|
+
module ScanDB
|
27
|
+
Database.setup
|
28
|
+
end
|
data/lib/scandb/runner.rb
CHANGED
@@ -98,18 +98,24 @@ module ScanDB
|
|
98
98
|
|
99
99
|
opts.parse!(args)
|
100
100
|
|
101
|
+
Database.setup(options.database || Database.config)
|
102
|
+
|
101
103
|
if options.import
|
102
104
|
case options.import
|
103
105
|
when :nmap then
|
104
|
-
hosts = Nmap.import_xml(options.import_file)
|
106
|
+
hosts = Nmap.import_xml(options.import_file) do |host|
|
107
|
+
if options.verbose
|
108
|
+
puts ">>> Imported #{host.ip}"
|
109
|
+
end
|
110
|
+
end
|
105
111
|
|
106
|
-
case hosts
|
112
|
+
case hosts
|
107
113
|
when 0
|
108
114
|
puts "No hosts where imported."
|
109
115
|
when 1
|
110
|
-
puts "Imported #{hosts
|
116
|
+
puts "Imported #{hosts} host."
|
111
117
|
else
|
112
|
-
puts "Imported #{hosts
|
118
|
+
puts "Imported #{hosts} hosts."
|
113
119
|
end
|
114
120
|
end
|
115
121
|
else
|
data/lib/scandb/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scandb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Postmodern Modulus III
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-10-19 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -70,7 +70,7 @@ dependencies:
|
|
70
70
|
requirements:
|
71
71
|
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: 1.
|
73
|
+
version: 1.8.0
|
74
74
|
version:
|
75
75
|
description: ScanDB is a library for importing and analyzing information generated by various network scanning utilities.
|
76
76
|
email:
|
@@ -103,13 +103,14 @@ files:
|
|
103
103
|
- lib/scandb/os_match_guess.rb
|
104
104
|
- lib/scandb/host_name.rb
|
105
105
|
- lib/scandb/host.rb
|
106
|
+
- lib/scandb/persistence.rb
|
106
107
|
- lib/scandb/nmap.rb
|
107
108
|
- lib/scandb/runner.rb
|
108
109
|
- lib/scandb/scandb.rb
|
109
110
|
- lib/scandb/version.rb
|
110
111
|
- lib/scandb.rb
|
111
112
|
has_rdoc: true
|
112
|
-
homepage: http://rubyforge.org/
|
113
|
+
homepage: http://scandb.rubyforge.org/
|
113
114
|
post_install_message:
|
114
115
|
rdoc_options:
|
115
116
|
- --main
|
@@ -131,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
132
|
requirements: []
|
132
133
|
|
133
134
|
rubyforge_project: scandb
|
134
|
-
rubygems_version: 1.
|
135
|
+
rubygems_version: 1.3.0
|
135
136
|
signing_key:
|
136
137
|
specification_version: 2
|
137
138
|
summary: ScanDB is a library for importing and analyzing information generated by various network scanning utilities.
|