ronin 1.0.0 → 1.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +0 -1
- data/ChangeLog.md +67 -3
- data/Gemfile +20 -12
- data/README.md +3 -5
- data/gemspec.yml +5 -5
- data/lib/ronin/address.rb +8 -3
- data/lib/ronin/arch.rb +39 -14
- data/lib/ronin/author.rb +2 -0
- data/lib/ronin/auto_load.rb +67 -0
- data/lib/ronin/campaign.rb +15 -2
- data/lib/ronin/class_methods.rb +7 -1
- data/lib/ronin/config.rb +5 -0
- data/lib/ronin/credential.rb +14 -3
- data/lib/ronin/database/database.rb +38 -12
- data/lib/ronin/database/migrations.rb +3 -1
- data/lib/ronin/database/migrations/add_created_at_column_to_targets_table.rb +48 -0
- data/lib/ronin/database/migrations/add_updated_at_column_to_campaigns_table.rb +47 -0
- data/lib/ronin/database/migrations/create_licenses_table.rb +1 -1
- data/lib/ronin/database/migrations/create_passwords_table.rb +1 -1
- data/lib/ronin/database/migrations/{create_cached_files_table.rb → create_script_paths_table.rb} +4 -4
- data/lib/ronin/database/migrations/migration.rb +3 -6
- data/lib/ronin/database/migrations/migrations.rb +3 -3
- data/lib/ronin/email_address.rb +20 -3
- data/lib/ronin/environment.rb +0 -3
- data/lib/ronin/host_name.rb +20 -6
- data/lib/ronin/host_name_ip_address.rb +2 -3
- data/lib/ronin/installation.rb +92 -23
- data/lib/ronin/ip_address.rb +31 -8
- data/lib/ronin/ip_address_mac_address.rb +2 -3
- data/lib/ronin/license.rb +1 -1
- data/lib/ronin/mac_address.rb +6 -4
- data/lib/ronin/model/class_methods.rb +4 -0
- data/lib/ronin/model/has_authors/class_methods.rb +4 -0
- data/lib/ronin/model/has_authors/has_authors.rb +4 -0
- data/lib/ronin/model/has_description/class_methods.rb +2 -0
- data/lib/ronin/model/has_description/has_description.rb +2 -0
- data/lib/ronin/model/has_license/class_methods.rb +2 -0
- data/lib/ronin/model/has_license/has_license.rb +4 -0
- data/lib/ronin/model/has_name/class_methods.rb +2 -0
- data/lib/ronin/model/has_name/has_name.rb +4 -0
- data/lib/ronin/model/has_title/class_methods.rb +2 -0
- data/lib/ronin/model/has_title/has_title.rb +2 -0
- data/lib/ronin/model/has_unique_name/class_methods.rb +2 -0
- data/lib/ronin/model/has_unique_name/has_unique_name.rb +7 -1
- data/lib/ronin/model/has_version/class_methods.rb +4 -0
- data/lib/ronin/model/has_version/has_version.rb +2 -0
- data/lib/ronin/model/model.rb +2 -0
- data/lib/ronin/model/types.rb +1 -7
- data/lib/ronin/model/types/description.rb +2 -0
- data/lib/ronin/network/mixins/esmtp.rb +40 -25
- data/lib/ronin/network/mixins/http.rb +336 -73
- data/lib/ronin/network/mixins/imap.rb +38 -25
- data/lib/ronin/network/mixins/pop3.rb +34 -21
- data/lib/ronin/network/mixins/smtp.rb +40 -25
- data/lib/ronin/network/mixins/tcp.rb +66 -41
- data/lib/ronin/network/mixins/telnet.rb +43 -30
- data/lib/ronin/network/mixins/udp.rb +59 -40
- data/lib/ronin/open_port.rb +12 -5
- data/lib/ronin/organization.rb +1 -2
- data/lib/ronin/os.rb +10 -3
- data/lib/ronin/os_guess.rb +2 -3
- data/lib/ronin/password.rb +11 -3
- data/lib/ronin/port.rb +7 -2
- data/lib/ronin/{engine/exceptions/deploy_failed.rb → repositories.rb} +4 -6
- data/lib/ronin/repository.rb +110 -37
- data/lib/ronin/ronin.rb +4 -3
- data/lib/ronin/{engine.rb → script.rb} +2 -1
- data/lib/ronin/{engine → script}/buildable.rb +43 -29
- data/lib/ronin/script/class_methods.rb +84 -0
- data/lib/ronin/{engine → script}/deployable.rb +61 -40
- data/lib/ronin/{engine → script}/exceptions.rb +4 -3
- data/lib/ronin/script/exceptions/deploy_failed.rb +27 -0
- data/lib/ronin/{engine/exceptions/not_built.rb → script/exceptions/exception.rb} +2 -2
- data/lib/ronin/{engine/exceptions/verification_failed.rb → script/exceptions/not_built.rb} +4 -2
- data/lib/ronin/script/exceptions/test_failed.rb +27 -0
- data/lib/ronin/script/instance_methods.rb +217 -0
- data/lib/ronin/script/path.rb +277 -0
- data/lib/ronin/{engine/engine.rb → script/script.rb} +52 -15
- data/lib/ronin/{engine/verifiable.rb → script/testable.rb} +97 -68
- data/lib/ronin/service.rb +1 -2
- data/lib/ronin/service_credential.rb +1 -2
- data/lib/ronin/software.rb +3 -2
- data/lib/ronin/spec/database.rb +0 -4
- data/lib/ronin/target.rb +11 -3
- data/lib/ronin/tcp_port.rb +3 -2
- data/lib/ronin/udp_port.rb +2 -0
- data/lib/ronin/ui/cli/cli.rb +6 -0
- data/lib/ronin/ui/cli/command.rb +48 -12
- data/lib/ronin/ui/cli/commands/campaigns.rb +3 -3
- data/lib/ronin/ui/cli/commands/console.rb +2 -1
- data/lib/ronin/ui/cli/commands/creds.rb +3 -3
- data/lib/ronin/ui/cli/commands/database.rb +1 -17
- data/lib/ronin/ui/cli/commands/emails.rb +3 -3
- data/lib/ronin/ui/cli/commands/hosts.rb +3 -7
- data/lib/ronin/ui/cli/commands/ips.rb +3 -7
- data/lib/ronin/ui/cli/commands/repos.rb +5 -17
- data/lib/ronin/ui/cli/commands/urls.rb +3 -3
- data/lib/ronin/ui/cli/model_command.rb +82 -97
- data/lib/ronin/ui/cli/resources_command.rb +89 -0
- data/lib/ronin/ui/cli/script_command.rb +115 -0
- data/lib/ronin/ui/console.rb +17 -3
- data/lib/ronin/ui/output/helpers.rb +18 -0
- data/lib/ronin/ui/output/output.rb +20 -1
- data/lib/ronin/ui/output/terminal/color.rb +10 -0
- data/lib/ronin/ui/output/terminal/raw.rb +10 -0
- data/lib/ronin/ui/shell.rb +2 -0
- data/lib/ronin/url.rb +47 -12
- data/lib/ronin/url_query_param.rb +4 -0
- data/lib/ronin/url_scheme.rb +3 -3
- data/lib/ronin/user_name.rb +2 -0
- data/lib/ronin/version.rb +1 -1
- data/lib/ronin/web_credential.rb +6 -3
- data/spec/arch_spec.rb +3 -3
- data/spec/classes/my_script.rb +21 -0
- data/spec/helpers/repos/{test1 → installed}/ronin.yml +1 -1
- data/spec/helpers/repos/{hello/cache → installed/scripts}/.keep +0 -0
- data/spec/helpers/repos/local/lib/init.rb +1 -0
- data/spec/helpers/repos/{hello → local}/lib/stuff/another_test.rb +0 -0
- data/spec/helpers/repos/{hello → local}/lib/stuff/test.rb +0 -0
- data/spec/helpers/repos/{random → local}/ronin.yml +1 -1
- data/spec/helpers/repos/{random/cache → local/scripts}/.keep +0 -0
- data/spec/helpers/repos/{hello → remote}/ronin.yml +1 -1
- data/spec/helpers/repos/remote/scripts/.keep +0 -0
- data/spec/helpers/repos/{test2 → scripts}/ronin.yml +0 -0
- data/spec/helpers/repos/scripts/scripts/cached/cached.rb +10 -0
- data/spec/helpers/repos/scripts/scripts/cached/missing.rb +10 -0
- data/spec/helpers/repos/scripts/scripts/cached/modified.rb +10 -0
- data/spec/helpers/repos/scripts/scripts/cached/unmodified.rb +10 -0
- data/spec/helpers/repos/scripts/scripts/failures/exceptions.rb +11 -0
- data/spec/helpers/repos/{test2/cache/cacheable_model → scripts/scripts/failures}/load_errors.rb +3 -1
- data/spec/helpers/repos/{test2/cache/cacheable_model → scripts/scripts/failures}/name_errors.rb +1 -0
- data/spec/helpers/repos/scripts/scripts/failures/no_method_errors.rb +10 -0
- data/spec/helpers/repos/scripts/scripts/failures/syntax_errors.rb +11 -0
- data/spec/helpers/repos/scripts/scripts/failures/validation_errors.rb +11 -0
- data/spec/helpers/repos/scripts/scripts/my_scripts/test.rb +16 -0
- data/spec/model/spec_helper.rb +0 -2
- data/spec/repository_spec.rb +61 -81
- data/spec/ronin_spec.rb +2 -2
- data/spec/{engine → script}/buildable_spec.rb +9 -9
- data/spec/script/classes/buildable_class.rb +15 -0
- data/spec/script/classes/deployable_class.rb +13 -0
- data/spec/{engine/classes/engine_class.rb → script/classes/script_class.rb} +3 -3
- data/spec/{engine/classes/verifiable_class.rb → script/classes/testable_class.rb} +5 -5
- data/spec/{engine → script}/deployable_spec.rb +10 -10
- data/spec/{cached_file_spec.rb → script/path_spec.rb} +33 -72
- data/spec/script/script_spec.rb +130 -0
- data/spec/script/testable_spec.rb +117 -0
- data/spec/spec_helper.rb +15 -13
- metadata +114 -139
- data/lib/ronin/cached_file.rb +0 -247
- data/lib/ronin/engine/class_methods.rb +0 -135
- data/lib/ronin/engine/instance_methods.rb +0 -97
- data/lib/ronin/model/cacheable.rb +0 -21
- data/lib/ronin/model/cacheable/cacheable.rb +0 -273
- data/lib/ronin/model/cacheable/class_methods.rb +0 -60
- data/lib/ronin/ui/cli/engine_command.rb +0 -106
- data/spec/engine/classes/buildable_class.rb +0 -15
- data/spec/engine/classes/deployable_class.rb +0 -13
- data/spec/engine/engine_spec.rb +0 -55
- data/spec/engine/verifiable_spec.rb +0 -117
- data/spec/helpers/repos/hello/lib/init.rb +0 -1
- data/spec/helpers/repos/test1/cache/cacheable_model/one.rb +0 -15
- data/spec/helpers/repos/test2/cache/cacheable_model/exceptions.rb +0 -7
- data/spec/helpers/repos/test2/cache/cacheable_model/no_method_errors.rb +0 -9
- data/spec/helpers/repos/test2/cache/cacheable_model/syntax_errors.rb +0 -7
- data/spec/helpers/repos/test2/cache/cacheable_model/two.rb +0 -15
- data/spec/helpers/repos/test2/cache/cacheable_model/validation_errors.rb +0 -9
- data/spec/model/cacheable_spec.rb +0 -96
- data/spec/model/models/cacheable_model.rb +0 -13
data/lib/ronin/class_methods.rb
CHANGED
@@ -36,8 +36,14 @@ module Ronin
|
|
36
36
|
#
|
37
37
|
# @since 1.0.0
|
38
38
|
#
|
39
|
+
# @api semipublic
|
40
|
+
#
|
39
41
|
def const_missing(name)
|
40
|
-
|
42
|
+
begin
|
43
|
+
Ronin.send(:const_missing,name)
|
44
|
+
rescue NameError
|
45
|
+
super(name)
|
46
|
+
end
|
41
47
|
end
|
42
48
|
end
|
43
49
|
end
|
data/lib/ronin/config.rb
CHANGED
@@ -27,6 +27,7 @@ module Ronin
|
|
27
27
|
#
|
28
28
|
module Config
|
29
29
|
include DataPaths
|
30
|
+
extend DataPaths::Finders
|
30
31
|
|
31
32
|
# The users home directory
|
32
33
|
HOME = Env.home
|
@@ -61,6 +62,8 @@ module Ronin
|
|
61
62
|
# Config.load :sql
|
62
63
|
# # => true
|
63
64
|
#
|
65
|
+
# @api semipublic
|
66
|
+
#
|
64
67
|
def Config.load(name=nil)
|
65
68
|
path = if name
|
66
69
|
CONFIG_DIR.join("#{name}.rb").expand_path
|
@@ -80,6 +83,8 @@ module Ronin
|
|
80
83
|
# @return [Pathname]
|
81
84
|
# The full path within {TMP_DIR}.
|
82
85
|
#
|
86
|
+
# @api semipublic
|
87
|
+
#
|
83
88
|
def Config.tmp_dir(sub_path=nil)
|
84
89
|
if sub_path
|
85
90
|
sub_path = File.expand_path(File.join('',sub_path))
|
data/lib/ronin/credential.rb
CHANGED
@@ -18,11 +18,10 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
require 'ronin/model'
|
21
|
+
require 'ronin/user_name'
|
22
|
+
require 'ronin/password'
|
21
23
|
|
22
24
|
module Ronin
|
23
|
-
autoload :UserName, 'ronin/user_name'
|
24
|
-
autoload :Password, 'ronin/password'
|
25
|
-
|
26
25
|
#
|
27
26
|
# Represents Credentials used to access services or websites.
|
28
27
|
#
|
@@ -50,6 +49,8 @@ module Ronin
|
|
50
49
|
#
|
51
50
|
# @since 1.0.0
|
52
51
|
#
|
52
|
+
# @api public
|
53
|
+
#
|
53
54
|
def self.for_user(name)
|
54
55
|
all('user_name.name' => name)
|
55
56
|
end
|
@@ -65,6 +66,8 @@ module Ronin
|
|
65
66
|
#
|
66
67
|
# @since 1.0.0
|
67
68
|
#
|
69
|
+
# @api public
|
70
|
+
#
|
68
71
|
def self.with_password(password)
|
69
72
|
all('password.clear_text' => password)
|
70
73
|
end
|
@@ -77,6 +80,8 @@ module Ronin
|
|
77
80
|
#
|
78
81
|
# @since 1.0.0
|
79
82
|
#
|
83
|
+
# @api public
|
84
|
+
#
|
80
85
|
def user
|
81
86
|
self.user_name.name if self.user_name
|
82
87
|
end
|
@@ -89,6 +94,8 @@ module Ronin
|
|
89
94
|
#
|
90
95
|
# @since 1.0.0
|
91
96
|
#
|
97
|
+
# @api public
|
98
|
+
#
|
92
99
|
def clear_text
|
93
100
|
self.password.clear_text if self.password
|
94
101
|
end
|
@@ -101,6 +108,8 @@ module Ronin
|
|
101
108
|
#
|
102
109
|
# @since 1.0.0
|
103
110
|
#
|
111
|
+
# @api public
|
112
|
+
#
|
104
113
|
def to_s
|
105
114
|
"#{self.user_name}:#{self.password}"
|
106
115
|
end
|
@@ -121,6 +130,8 @@ module Ronin
|
|
121
130
|
#
|
122
131
|
# @since 1.0.0
|
123
132
|
#
|
133
|
+
# @api public
|
134
|
+
#
|
124
135
|
def to_ary
|
125
136
|
[self.user_name.name, self.password.clear_text]
|
126
137
|
end
|
@@ -62,6 +62,8 @@ module Ronin
|
|
62
62
|
#
|
63
63
|
# @since 1.0.0
|
64
64
|
#
|
65
|
+
# @api private
|
66
|
+
#
|
65
67
|
def Database.repositories
|
66
68
|
if @repositories.empty?
|
67
69
|
@repositories[:default] = DEFAULT_REPOSITORY
|
@@ -93,8 +95,10 @@ module Ronin
|
|
93
95
|
#
|
94
96
|
# @since 1.0.0
|
95
97
|
#
|
98
|
+
# @api semipublic
|
99
|
+
#
|
96
100
|
def Database.repository?(name)
|
97
|
-
|
101
|
+
repositories.has_key?(name.to_sym)
|
98
102
|
end
|
99
103
|
|
100
104
|
#
|
@@ -108,13 +112,15 @@ module Ronin
|
|
108
112
|
#
|
109
113
|
# @since 1.0.0
|
110
114
|
#
|
115
|
+
# @api private
|
116
|
+
#
|
111
117
|
def Database.save
|
112
118
|
yield if block_given?
|
113
119
|
|
114
120
|
File.open(CONFIG_FILE,'w') do |file|
|
115
121
|
hash = {}
|
116
122
|
|
117
|
-
|
123
|
+
repositories.each do |name,value|
|
118
124
|
hash[name.to_s] = value.to_s
|
119
125
|
end
|
120
126
|
|
@@ -143,10 +149,12 @@ module Ronin
|
|
143
149
|
# @return [true]
|
144
150
|
# Specifies that the log has been setup.
|
145
151
|
#
|
152
|
+
# @api private
|
153
|
+
#
|
146
154
|
def Database.setup_log(options={})
|
147
|
-
path = (
|
148
|
-
stream = (
|
149
|
-
level = (
|
155
|
+
path = options.fetch(:path,DEFAULT_LOG_PATH)
|
156
|
+
stream = options.fetch(:stream,File.new(path,'w+'))
|
157
|
+
level = options.fetch(:level,DEFAULT_LOG_LEVEL)
|
150
158
|
|
151
159
|
@log = DataMapper::Logger.new(stream,level)
|
152
160
|
return true
|
@@ -161,6 +169,8 @@ module Ronin
|
|
161
169
|
# @return [Boolean]
|
162
170
|
# Specifies wether or not the Database is setup.
|
163
171
|
#
|
172
|
+
# @api semipublic
|
173
|
+
#
|
164
174
|
def Database.setup?(name=:default)
|
165
175
|
repository = DataMapper.repository(name)
|
166
176
|
|
@@ -175,8 +185,10 @@ module Ronin
|
|
175
185
|
# Specifies whether the Database was migrated or is currently
|
176
186
|
# not setup.
|
177
187
|
#
|
188
|
+
# @api semipublic
|
189
|
+
#
|
178
190
|
def Database.upgrade!
|
179
|
-
if
|
191
|
+
if setup?
|
180
192
|
Migrations.migrate_up!
|
181
193
|
else
|
182
194
|
false
|
@@ -188,17 +200,25 @@ module Ronin
|
|
188
200
|
#
|
189
201
|
# @see Database.upgrade!
|
190
202
|
#
|
203
|
+
# @api semipublic
|
204
|
+
#
|
191
205
|
def Database.setup
|
192
206
|
# setup the database log
|
193
|
-
|
207
|
+
unless @log
|
208
|
+
if ENV['DEBUG']
|
209
|
+
setup_log(:stream => STDERR, :level => :debug)
|
210
|
+
else
|
211
|
+
setup_log
|
212
|
+
end
|
213
|
+
end
|
194
214
|
|
195
215
|
# setup the database repositories
|
196
|
-
|
216
|
+
repositories.each do |name,uri|
|
197
217
|
DataMapper.setup(name,uri)
|
198
218
|
end
|
199
219
|
|
200
220
|
# apply any new migrations to the database
|
201
|
-
|
221
|
+
upgrade!
|
202
222
|
end
|
203
223
|
|
204
224
|
#
|
@@ -215,10 +235,12 @@ module Ronin
|
|
215
235
|
#
|
216
236
|
# @since 1.0.0
|
217
237
|
#
|
238
|
+
# @api public
|
239
|
+
#
|
218
240
|
def Database.repository(name,&block)
|
219
241
|
name = name.to_sym
|
220
242
|
|
221
|
-
unless
|
243
|
+
unless repository?(name)
|
222
244
|
raise(UnknownRepository,"unknown database repository #{name}")
|
223
245
|
end
|
224
246
|
|
@@ -242,10 +264,12 @@ module Ronin
|
|
242
264
|
#
|
243
265
|
# @since 1.0.0
|
244
266
|
#
|
267
|
+
# @api private
|
268
|
+
#
|
245
269
|
def Database.clear(name)
|
246
270
|
name = name.to_sym
|
247
271
|
|
248
|
-
unless
|
272
|
+
unless repository?(name)
|
249
273
|
raise(UnknownRepository,"unknown database repository #{name}")
|
250
274
|
end
|
251
275
|
|
@@ -268,10 +292,12 @@ module Ronin
|
|
268
292
|
#
|
269
293
|
# @since 1.0.0
|
270
294
|
#
|
295
|
+
# @api public
|
296
|
+
#
|
271
297
|
def Database.map
|
272
298
|
results = []
|
273
299
|
|
274
|
-
|
300
|
+
repositories.each_key do |name|
|
275
301
|
DataMapper.repository(name) do
|
276
302
|
result = yield
|
277
303
|
results << result unless result.nil?
|
@@ -43,5 +43,7 @@ require 'ronin/database/migrations/create_countries_table'
|
|
43
43
|
require 'ronin/database/migrations/create_organizations_table'
|
44
44
|
require 'ronin/database/migrations/create_campaigns_table'
|
45
45
|
require 'ronin/database/migrations/create_targets_table'
|
46
|
-
require 'ronin/database/migrations/
|
46
|
+
require 'ronin/database/migrations/create_script_paths_table'
|
47
47
|
require 'ronin/database/migrations/create_repositories_table'
|
48
|
+
require 'ronin/database/migrations/add_updated_at_column_to_campaigns_table'
|
49
|
+
require 'ronin/database/migrations/add_created_at_column_to_targets_table'
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
|
+
#
|
4
|
+
# This file is part of Ronin.
|
5
|
+
#
|
6
|
+
# Ronin is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# Ronin is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with Ronin. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'ronin/database/migrations/create_targets_table'
|
21
|
+
require 'ronin/database/migrations/migrations'
|
22
|
+
require 'ronin/campaign'
|
23
|
+
require 'ronin/target'
|
24
|
+
|
25
|
+
module Ronin
|
26
|
+
module Database
|
27
|
+
module Migrations
|
28
|
+
migration(
|
29
|
+
:add_created_at_column_to_targets_table,
|
30
|
+
:needs => :create_targets_table
|
31
|
+
) do
|
32
|
+
up do
|
33
|
+
modify_table :ronin_targets do
|
34
|
+
add_column :created_at, Time
|
35
|
+
end
|
36
|
+
|
37
|
+
# set the updated_at column to the created_at of the Campaign
|
38
|
+
Target.each do |target|
|
39
|
+
target.update(:created_at => target.campaign.created_at)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
down do
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
|
+
#
|
4
|
+
# This file is part of Ronin.
|
5
|
+
#
|
6
|
+
# Ronin is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# Ronin is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with Ronin. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'ronin/database/migrations/create_campaigns_table'
|
21
|
+
require 'ronin/database/migrations/migrations'
|
22
|
+
require 'ronin/campaign'
|
23
|
+
|
24
|
+
module Ronin
|
25
|
+
module Database
|
26
|
+
module Migrations
|
27
|
+
migration(
|
28
|
+
:add_updated_at_column_to_campaigns_table,
|
29
|
+
:needs => :create_campaigns_table
|
30
|
+
) do
|
31
|
+
up do
|
32
|
+
modify_table :ronin_campaigns do
|
33
|
+
add_column :updated_at, Time
|
34
|
+
end
|
35
|
+
|
36
|
+
# set the updated_at column to created_at
|
37
|
+
Campaign.each do |campaign|
|
38
|
+
campaign.update(:updated_at => campaign.created_at)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
down do
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -28,7 +28,7 @@ module Ronin
|
|
28
28
|
column :id, Integer, :serial => true
|
29
29
|
column :name, String, :not_null => true
|
30
30
|
column :description, Text, :not_null => true
|
31
|
-
column :url, String
|
31
|
+
column :url, String, :length => 256
|
32
32
|
end
|
33
33
|
|
34
34
|
create_index :ronin_licenses, :name, :unique => true
|
@@ -26,7 +26,7 @@ module Ronin
|
|
26
26
|
up do
|
27
27
|
create_table :ronin_passwords do
|
28
28
|
column :id, Integer, :serial => true
|
29
|
-
column :clear_text, String, :not_null => true
|
29
|
+
column :clear_text, String, :length => 256, :not_null => true
|
30
30
|
end
|
31
31
|
|
32
32
|
create_index :ronin_passwords, :clear_text, :unique => true
|
data/lib/ronin/database/migrations/{create_cached_files_table.rb → create_script_paths_table.rb}
RENAMED
@@ -24,21 +24,21 @@ module Ronin
|
|
24
24
|
module Database
|
25
25
|
module Migrations
|
26
26
|
migration(
|
27
|
-
:
|
27
|
+
:create_script_paths_table,
|
28
28
|
:needs => :create_repositories_table
|
29
29
|
) do
|
30
30
|
up do
|
31
|
-
create_table :
|
31
|
+
create_table :ronin_script_paths do
|
32
32
|
column :id, Integer, :serial => true
|
33
33
|
column :path, FilePath, :not_null => true
|
34
34
|
column :timestamp, Time, :not_null => true
|
35
|
-
column :
|
35
|
+
column :class_name, String, :not_null => true
|
36
36
|
column :repository_id, Integer, :not_null => true
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
down do
|
41
|
-
drop_table :
|
41
|
+
drop_table :ronin_script_paths
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -50,15 +50,12 @@ module Ronin
|
|
50
50
|
# @option options [Array, Symbol] :needs ([])
|
51
51
|
# Other migrations that are dependencies of the migration.
|
52
52
|
#
|
53
|
-
# @api
|
53
|
+
# @api private
|
54
54
|
#
|
55
55
|
def initialize(name,options={},&block)
|
56
|
-
options =
|
57
|
-
:verbose => UI::Output.verbose?,
|
58
|
-
:needs => []
|
59
|
-
)
|
56
|
+
options[:verbose] = UI::Output.verbose?
|
60
57
|
|
61
|
-
@needs =
|
58
|
+
@needs = Array(options.delete(:needs)).uniq
|
62
59
|
|
63
60
|
super(0,name,options,&block)
|
64
61
|
end
|
@@ -34,7 +34,7 @@ module Ronin
|
|
34
34
|
#
|
35
35
|
# @since 1.0.1
|
36
36
|
#
|
37
|
-
# @api
|
37
|
+
# @api private
|
38
38
|
#
|
39
39
|
def self.migrations
|
40
40
|
@migrations ||= Graph.new
|
@@ -146,7 +146,7 @@ module Ronin
|
|
146
146
|
#
|
147
147
|
# @since 1.0.1
|
148
148
|
#
|
149
|
-
# @api
|
149
|
+
# @api private
|
150
150
|
#
|
151
151
|
def self.migrate_up!(position_or_name=nil)
|
152
152
|
self.migrations.upto(position_or_name) do |migration|
|
@@ -171,7 +171,7 @@ module Ronin
|
|
171
171
|
#
|
172
172
|
# @since 1.0.1
|
173
173
|
#
|
174
|
-
# @api
|
174
|
+
# @api private
|
175
175
|
#
|
176
176
|
def self.migrate_down!(position_or_name=nil)
|
177
177
|
self.migrations.downto(position_or_name) do |migration|
|