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/port.rb
CHANGED
@@ -18,10 +18,9 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
require 'ronin/model'
|
21
|
+
require 'ronin/open_port'
|
21
22
|
|
22
23
|
module Ronin
|
23
|
-
autoload :OpenPort, 'ronin/open_port'
|
24
|
-
|
25
24
|
#
|
26
25
|
# Represents a TCP or UDP port.
|
27
26
|
#
|
@@ -56,6 +55,8 @@ module Ronin
|
|
56
55
|
#
|
57
56
|
# @since 1.0.0
|
58
57
|
#
|
58
|
+
# @api public
|
59
|
+
#
|
59
60
|
def to_i
|
60
61
|
self.number.to_i
|
61
62
|
end
|
@@ -68,6 +69,8 @@ module Ronin
|
|
68
69
|
#
|
69
70
|
# @since 1.0.0
|
70
71
|
#
|
72
|
+
# @api public
|
73
|
+
#
|
71
74
|
def to_s
|
72
75
|
"#{self.number}/#{self.protocol}"
|
73
76
|
end
|
@@ -80,6 +83,8 @@ module Ronin
|
|
80
83
|
#
|
81
84
|
# @since 1.0.0
|
82
85
|
#
|
86
|
+
# @api public
|
87
|
+
#
|
83
88
|
def inspect
|
84
89
|
"#<#{self.class}: #{self}>"
|
85
90
|
end
|
@@ -17,9 +17,7 @@
|
|
17
17
|
# along with Ronin. If not, see <http://www.gnu.org/licenses/>.
|
18
18
|
#
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
20
|
+
require 'ronin/repository'
|
21
|
+
require 'ronin/bootstrap'
|
22
|
+
|
23
|
+
Ronin::Repository.activate!
|
data/lib/ronin/repository.rb
CHANGED
@@ -19,6 +19,7 @@
|
|
19
19
|
|
20
20
|
require 'ronin/exceptions/duplicate_repository'
|
21
21
|
require 'ronin/exceptions/repository_not_found'
|
22
|
+
require 'ronin/script/path'
|
22
23
|
require 'ronin/model/has_license'
|
23
24
|
require 'ronin/model/has_authors'
|
24
25
|
require 'ronin/model'
|
@@ -29,8 +30,6 @@ require 'data_paths'
|
|
29
30
|
require 'yaml'
|
30
31
|
|
31
32
|
module Ronin
|
32
|
-
autoload :CachedFile, 'ronin/cached_file'
|
33
|
-
|
34
33
|
class Repository
|
35
34
|
|
36
35
|
include Model
|
@@ -56,8 +55,8 @@ module Ronin
|
|
56
55
|
# Repository `data/` directory
|
57
56
|
DATA_DIR = 'data'
|
58
57
|
|
59
|
-
#
|
60
|
-
|
58
|
+
# Directories containing {Script}s
|
59
|
+
SCRIPT_DIRS = %w[scripts cache]
|
61
60
|
|
62
61
|
# The primary key of the repository
|
63
62
|
property :id, Serial
|
@@ -95,8 +94,8 @@ module Ronin
|
|
95
94
|
# Description of the repository
|
96
95
|
property :description, Text
|
97
96
|
|
98
|
-
# The
|
99
|
-
has 0..n, :
|
97
|
+
# The script paths from the repository
|
98
|
+
has 0..n, :script_paths, :model => 'Script::Path'
|
100
99
|
|
101
100
|
# The `bin/` directory
|
102
101
|
attr_reader :bin_dir
|
@@ -107,8 +106,8 @@ module Ronin
|
|
107
106
|
# The `data/` directory
|
108
107
|
attr_reader :data_dir
|
109
108
|
|
110
|
-
#
|
111
|
-
attr_reader :
|
109
|
+
# Directories containing {Script}s.
|
110
|
+
attr_reader :script_dirs
|
112
111
|
|
113
112
|
#
|
114
113
|
# Creates a new {Repository} object.
|
@@ -132,13 +131,15 @@ module Ronin
|
|
132
131
|
# @yieldparam [Repository] repo
|
133
132
|
# The newly created repository.
|
134
133
|
#
|
134
|
+
# @api private
|
135
|
+
#
|
135
136
|
def initialize(attributes={})
|
136
137
|
super(attributes)
|
137
138
|
|
138
139
|
@bin_dir = self.path.join(BIN_DIR)
|
139
140
|
@lib_dir = self.path.join(LIB_DIR)
|
140
141
|
@data_dir = self.path.join(DATA_DIR)
|
141
|
-
@
|
142
|
+
@script_dirs = SCRIPT_DIRS.map { |dir| self.path.join(dir) }
|
142
143
|
|
143
144
|
@activated = false
|
144
145
|
|
@@ -168,6 +169,8 @@ module Ronin
|
|
168
169
|
#
|
169
170
|
# @since 1.0.0
|
170
171
|
#
|
172
|
+
# @api private
|
173
|
+
#
|
171
174
|
def Repository.find(name)
|
172
175
|
name, domain = name.to_s.split('/',2)
|
173
176
|
|
@@ -202,6 +205,8 @@ module Ronin
|
|
202
205
|
#
|
203
206
|
# @since 1.0.0
|
204
207
|
#
|
208
|
+
# @api private
|
209
|
+
#
|
205
210
|
def Repository.add!(options={})
|
206
211
|
unless options.has_key?(:path)
|
207
212
|
raise(ArgumentError,"the :path option was not given")
|
@@ -232,7 +237,7 @@ module Ronin
|
|
232
237
|
if repo.save
|
233
238
|
# cache any files from within the `cache/` directory of the
|
234
239
|
# repository
|
235
|
-
repo.
|
240
|
+
repo.cache_scripts!
|
236
241
|
end
|
237
242
|
|
238
243
|
return repo
|
@@ -263,6 +268,8 @@ module Ronin
|
|
263
268
|
#
|
264
269
|
# @since 1.0.0
|
265
270
|
#
|
271
|
+
# @api private
|
272
|
+
#
|
266
273
|
def Repository.install!(options={})
|
267
274
|
unless options[:uri]
|
268
275
|
raise(ArgumentError,":uri must be passed to Repository.install")
|
@@ -301,7 +308,7 @@ module Ronin
|
|
301
308
|
if repo.save
|
302
309
|
# cache any files from within the `cache/` directory of the
|
303
310
|
# repository
|
304
|
-
repo.
|
311
|
+
repo.cache_scripts!
|
305
312
|
end
|
306
313
|
|
307
314
|
return repo
|
@@ -318,6 +325,8 @@ module Ronin
|
|
318
325
|
#
|
319
326
|
# @since 1.0.0
|
320
327
|
#
|
328
|
+
# @api private
|
329
|
+
#
|
321
330
|
def Repository.update!
|
322
331
|
Repository.each do |repo|
|
323
332
|
# update the repositories contents
|
@@ -341,6 +350,8 @@ module Ronin
|
|
341
350
|
# @example Uninstall the repository with the given name and domain.
|
342
351
|
# Repository.uninstall!('postmodern-repo/github.com')
|
343
352
|
#
|
353
|
+
# @api private
|
354
|
+
#
|
344
355
|
def Repository.uninstall!(name)
|
345
356
|
Repository.find(name).uninstall!
|
346
357
|
end
|
@@ -355,6 +366,8 @@ module Ronin
|
|
355
366
|
#
|
356
367
|
# @since 1.0.0
|
357
368
|
#
|
369
|
+
# @api private
|
370
|
+
#
|
358
371
|
def Repository.activate!
|
359
372
|
Repository.each { |repo| repo.activate! }
|
360
373
|
end
|
@@ -369,6 +382,8 @@ module Ronin
|
|
369
382
|
#
|
370
383
|
# @since 1.0.0
|
371
384
|
#
|
385
|
+
# @api private
|
386
|
+
#
|
372
387
|
def Repository.deactivate!
|
373
388
|
Repository.reverse_each { |repo| repo.deactivate! }
|
374
389
|
end
|
@@ -381,6 +396,8 @@ module Ronin
|
|
381
396
|
#
|
382
397
|
# @since 1.0.0
|
383
398
|
#
|
399
|
+
# @api private
|
400
|
+
#
|
384
401
|
def local?
|
385
402
|
self.domain == LOCAL_DOMAIN
|
386
403
|
end
|
@@ -393,6 +410,8 @@ module Ronin
|
|
393
410
|
#
|
394
411
|
# @since 1.0.0
|
395
412
|
#
|
413
|
+
# @api private
|
414
|
+
#
|
396
415
|
def remote?
|
397
416
|
self.domain != LOCAL_DOMAIN
|
398
417
|
end
|
@@ -405,6 +424,8 @@ module Ronin
|
|
405
424
|
#
|
406
425
|
# @since 1.0.0
|
407
426
|
#
|
427
|
+
# @api private
|
428
|
+
#
|
408
429
|
def executables
|
409
430
|
scripts = []
|
410
431
|
|
@@ -420,13 +441,25 @@ module Ronin
|
|
420
441
|
#
|
421
442
|
# All paths within the `cache/` directory of the repository.
|
422
443
|
#
|
423
|
-
# @
|
424
|
-
#
|
444
|
+
# @yield [path]
|
445
|
+
# If a block is given, it will be passed each matching path.
|
446
|
+
#
|
447
|
+
# @yieldparam [Pathname] path
|
448
|
+
# A matching path.
|
449
|
+
#
|
450
|
+
# @return [Enumerator]
|
451
|
+
# If no block is given, an Enumerator object will be returned.
|
425
452
|
#
|
426
453
|
# @since 1.0.0
|
427
454
|
#
|
428
|
-
|
429
|
-
|
455
|
+
# @api private
|
456
|
+
#
|
457
|
+
def each_script(&block)
|
458
|
+
return enum_for(:each_script) unless block
|
459
|
+
|
460
|
+
@script_dirs.each do |dir|
|
461
|
+
Pathname.glob(dir.join('**','*.rb'),&block)
|
462
|
+
end
|
430
463
|
end
|
431
464
|
|
432
465
|
#
|
@@ -435,6 +468,8 @@ module Ronin
|
|
435
468
|
# @return [Boolean]
|
436
469
|
# Specifies whether the repository has been activated.
|
437
470
|
#
|
471
|
+
# @api private
|
472
|
+
#
|
438
473
|
def activated?
|
439
474
|
@activated == true
|
440
475
|
end
|
@@ -443,12 +478,17 @@ module Ronin
|
|
443
478
|
# Activates the repository by adding the {#lib_dir} to the `$LOAD_PATH`
|
444
479
|
# global variable.
|
445
480
|
#
|
481
|
+
# @api private
|
482
|
+
#
|
446
483
|
def activate!
|
447
484
|
# add the data/ directory
|
448
|
-
|
485
|
+
register_data_path(@data_dir) if @data_dir.directory?
|
486
|
+
|
487
|
+
if @lib_dir.directory?
|
488
|
+
# ensure all paths added to $LOAD_PATH are Strings
|
489
|
+
path = @lib_dir.to_s
|
449
490
|
|
450
|
-
|
451
|
-
$LOAD_PATH << @lib_dir unless $LOAD_PATH.include?(@lib_dir)
|
491
|
+
$LOAD_PATH << path unless $LOAD_PATH.include?(path)
|
452
492
|
end
|
453
493
|
|
454
494
|
# load the lib/init.rb file
|
@@ -463,17 +503,38 @@ module Ronin
|
|
463
503
|
# De-activates the repository by removing the {#lib_dir} from the
|
464
504
|
# `$LOAD_PATH` global variable.
|
465
505
|
#
|
506
|
+
# @api private
|
507
|
+
#
|
466
508
|
def deactivate!
|
467
|
-
|
509
|
+
unregister_data_paths
|
468
510
|
|
469
|
-
$LOAD_PATH.delete(@lib_dir)
|
511
|
+
$LOAD_PATH.delete(@lib_dir.to_s)
|
470
512
|
|
471
513
|
@activated = false
|
472
514
|
return true
|
473
515
|
end
|
474
516
|
|
475
517
|
#
|
476
|
-
#
|
518
|
+
# Finds a cached script.
|
519
|
+
#
|
520
|
+
# @param [String] sub_path
|
521
|
+
# The sub-path within the repository to search for.
|
522
|
+
#
|
523
|
+
# @return [Script::Path, nil]
|
524
|
+
# The matching script path.
|
525
|
+
#
|
526
|
+
# @since 1.1.0
|
527
|
+
#
|
528
|
+
# @api private
|
529
|
+
#
|
530
|
+
def find_script(sub_path)
|
531
|
+
paths = @script_dirs.map { |dir| File.join(dir,sub_path) }
|
532
|
+
|
533
|
+
return script_paths.first(:path => paths)
|
534
|
+
end
|
535
|
+
|
536
|
+
#
|
537
|
+
# Clears the {#script_paths} and re-saves the cached files within the
|
477
538
|
# `cache/` directory.
|
478
539
|
#
|
479
540
|
# @return [Repository]
|
@@ -481,18 +542,20 @@ module Ronin
|
|
481
542
|
#
|
482
543
|
# @since 1.0.0
|
483
544
|
#
|
484
|
-
|
485
|
-
|
545
|
+
# @api private
|
546
|
+
#
|
547
|
+
def cache_scripts!
|
548
|
+
clean_scripts!
|
486
549
|
|
487
|
-
|
488
|
-
self.
|
550
|
+
each_script do |path|
|
551
|
+
self.script_paths.new(:path => path).cache
|
489
552
|
end
|
490
553
|
|
491
554
|
return self
|
492
555
|
end
|
493
556
|
|
494
557
|
#
|
495
|
-
# Syncs the {#
|
558
|
+
# Syncs the {#script_paths} of the repository, and adds any new cached
|
496
559
|
# files.
|
497
560
|
#
|
498
561
|
# @return [Repository]
|
@@ -500,23 +563,25 @@ module Ronin
|
|
500
563
|
#
|
501
564
|
# @since 1.0.0
|
502
565
|
#
|
503
|
-
|
566
|
+
# @api private
|
567
|
+
#
|
568
|
+
def sync_scripts!
|
504
569
|
# activates the repository before caching it's objects
|
505
570
|
activate!
|
506
571
|
|
507
|
-
new_paths =
|
572
|
+
new_paths = each_script.to_a
|
508
573
|
|
509
|
-
self.
|
574
|
+
self.script_paths.each do |script_path|
|
510
575
|
# filter out pre-existing paths within the `cached/` directory
|
511
|
-
new_paths.delete(
|
576
|
+
new_paths.delete(script_path.path)
|
512
577
|
|
513
578
|
# sync the cached file and catch any exceptions
|
514
|
-
|
579
|
+
script_path.sync
|
515
580
|
end
|
516
581
|
|
517
582
|
# cache the new paths within the `cache/` directory
|
518
583
|
new_paths.each do |path|
|
519
|
-
self.
|
584
|
+
self.script_paths.new(:path => path).cache
|
520
585
|
end
|
521
586
|
|
522
587
|
# deactivates the repository
|
@@ -526,15 +591,17 @@ module Ronin
|
|
526
591
|
end
|
527
592
|
|
528
593
|
#
|
529
|
-
# Deletes any {#
|
594
|
+
# Deletes any {#script_paths} associated with the repository.
|
530
595
|
#
|
531
596
|
# @return [Repository]
|
532
597
|
# The cleaned repository.
|
533
598
|
#
|
534
599
|
# @since 1.0.0
|
535
600
|
#
|
536
|
-
|
537
|
-
|
601
|
+
# @api private
|
602
|
+
#
|
603
|
+
def clean_scripts!
|
604
|
+
self.script_paths.clear
|
538
605
|
return self
|
539
606
|
end
|
540
607
|
|
@@ -554,6 +621,8 @@ module Ronin
|
|
554
621
|
#
|
555
622
|
# @since 1.0.0
|
556
623
|
#
|
624
|
+
# @api private
|
625
|
+
#
|
557
626
|
def update!
|
558
627
|
local_repo = Pullr::LocalRepository.new(
|
559
628
|
:path => self.path,
|
@@ -569,7 +638,7 @@ module Ronin
|
|
569
638
|
# save the repository
|
570
639
|
if save
|
571
640
|
# syncs the cached files of the repository
|
572
|
-
|
641
|
+
sync_scripts!
|
573
642
|
end
|
574
643
|
|
575
644
|
yield self if block_given?
|
@@ -591,13 +660,15 @@ module Ronin
|
|
591
660
|
#
|
592
661
|
# @since 1.0.0
|
593
662
|
#
|
663
|
+
# @api private
|
664
|
+
#
|
594
665
|
def uninstall!
|
595
666
|
deactivate!
|
596
667
|
|
597
668
|
FileUtils.rm_rf(self.path) if self.installed?
|
598
669
|
|
599
670
|
# destroy any cached files first
|
600
|
-
|
671
|
+
clean_scripts!
|
601
672
|
|
602
673
|
# remove the repository from the database
|
603
674
|
destroy if saved?
|
@@ -621,6 +692,8 @@ module Ronin
|
|
621
692
|
#
|
622
693
|
# Loads the metadata from {METADATA_FILE} within the repository.
|
623
694
|
#
|
695
|
+
# @api private
|
696
|
+
#
|
624
697
|
def initialize_metadata
|
625
698
|
metadata_path = self.path.join(METADATA_FILE)
|
626
699
|
|
data/lib/ronin/ronin.rb
CHANGED
@@ -18,11 +18,10 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
require 'ronin/class_methods'
|
21
|
-
|
22
|
-
require 'open_namespace'
|
21
|
+
require 'ronin/auto_load'
|
23
22
|
|
24
23
|
module Ronin
|
25
|
-
include
|
24
|
+
include AutoLoad
|
26
25
|
|
27
26
|
#
|
28
27
|
# Includes {ClassMethods} when {Ronin} is included.
|
@@ -32,6 +31,8 @@ module Ronin
|
|
32
31
|
#
|
33
32
|
# @since 1.0.0
|
34
33
|
#
|
34
|
+
# @api private
|
35
|
+
#
|
35
36
|
def self.included(base)
|
36
37
|
base.send :extend, ClassMethods
|
37
38
|
end
|