ronin 0.1.4 → 0.2.0
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.
- data/History.txt +50 -0
- data/Manifest.txt +31 -19
- data/README.txt +27 -19
- data/Rakefile +1 -1
- data/TODO.txt +1 -7
- data/lib/ronin.rb +1 -11
- data/lib/ronin/database/database.rb +1 -1
- data/lib/ronin/{cache/config.rb → environment.rb} +10 -8
- data/lib/ronin/formatting.rb +0 -1
- data/lib/ronin/formatting/extensions.rb +0 -1
- data/lib/ronin/formatting/extensions/binary/integer.rb +10 -0
- data/lib/ronin/formatting/extensions/binary/string.rb +11 -0
- data/lib/ronin/formatting/extensions/http/string.rb +1 -1
- data/lib/ronin/network/extensions/http/net.rb +8 -0
- data/lib/ronin/objectify/objectify.rb +0 -47
- data/lib/ronin/os.rb +89 -0
- data/lib/ronin/platform.rb +4 -77
- data/lib/ronin/{cache → platform}/exceptions.rb +2 -2
- data/lib/ronin/{cache → platform}/exceptions/extension_not_found.rb +1 -1
- data/lib/ronin/{cache → platform}/exceptions/overlay_cached.rb +1 -1
- data/lib/ronin/{cache → platform}/exceptions/overlay_not_found.rb +1 -1
- data/lib/ronin/{cache → platform}/extension.rb +68 -177
- data/lib/ronin/{cache → platform}/extension_cache.rb +9 -7
- data/lib/ronin/{cache → platform}/maintainer.rb +1 -1
- data/lib/ronin/platform/object_cache.rb +94 -0
- data/lib/ronin/platform/overlay.rb +274 -0
- data/lib/ronin/platform/overlay_cache.rb +318 -0
- data/lib/ronin/platform/platform.rb +195 -0
- data/lib/ronin/{cache → platform}/ronin.rb +7 -6
- data/lib/ronin/target.rb +5 -5
- data/lib/ronin/ui.rb +4 -1
- data/lib/ronin/ui/command_line/command_line.rb +0 -1
- data/lib/ronin/ui/command_line/commands/add.rb +21 -6
- data/lib/ronin/ui/command_line/commands/default.rb +6 -1
- data/lib/ronin/ui/command_line/commands/extension.rb +3 -3
- data/lib/ronin/ui/command_line/commands/install.rb +16 -5
- data/lib/ronin/ui/command_line/commands/list.rb +31 -8
- data/lib/ronin/ui/command_line/commands/overlay.rb +10 -9
- data/lib/ronin/ui/command_line/commands/remove.rb +16 -5
- data/lib/ronin/ui/command_line/commands/uninstall.rb +16 -5
- data/lib/ronin/ui/command_line/commands/update.rb +16 -3
- data/lib/ronin/ui/console.rb +81 -77
- data/lib/ronin/ui/diagnostics.rb +73 -0
- data/lib/ronin/version.rb +1 -1
- data/spec/chars/chars_spec.rb +1 -3
- data/spec/formatting/binary/integer_spec.rb +48 -36
- data/spec/formatting/binary/string_spec.rb +66 -4
- data/spec/os_spec.rb +24 -0
- data/spec/platform/extension_cache_spec.rb +42 -0
- data/spec/platform/extension_spec.rb +62 -0
- data/spec/platform/helpers/overlays.rb +18 -0
- data/spec/platform/helpers/overlays.yaml.erb +10 -0
- data/spec/platform/helpers/overlays/hello/hello/extension.rb +7 -0
- data/spec/platform/helpers/overlays/hello/ronin.xml +26 -0
- data/spec/platform/helpers/overlays/test1/ronin.xml +26 -0
- data/spec/platform/helpers/overlays/test1/test/extension.rb +7 -0
- data/spec/platform/helpers/overlays/test2/ronin.xml +26 -0
- data/spec/platform/helpers/overlays/test2/test/extension.rb +7 -0
- data/spec/platform/overlay_cache_spec.rb +63 -0
- data/spec/platform/platform_spec.rb +14 -0
- data/spec/platform/ronin_spec.rb +22 -0
- data/spec/target_spec.rb +1 -1
- data/spec/ui/diagnostics_spec.rb +17 -0
- metadata +34 -22
- data/lib/ronin/cache.rb +0 -27
- data/lib/ronin/cache/cache.rb +0 -78
- data/lib/ronin/cache/overlay.rb +0 -470
- data/lib/ronin/cache/overlay_cache.rb +0 -216
- data/lib/ronin/formatting/extensions/html.rb +0 -24
- data/lib/ronin/formatting/extensions/html/string.rb +0 -75
- data/lib/ronin/formatting/html.rb +0 -24
- data/spec/formatting/html_spec.rb +0 -46
- data/spec/platform_spec.rb +0 -24
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'ronin/platform/overlay_cache'
|
2
|
+
|
3
|
+
require 'platform/helpers/overlays'
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
describe Platform::OverlayCache do
|
7
|
+
before(:all) do
|
8
|
+
@cache = Platform::OverlayCache.new(overlay_cache_path)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should not be dirty by default" do
|
12
|
+
@cache.should_not be_dirty
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should not be empty" do
|
16
|
+
@cache.should_not be_empty
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should have specific overlays" do
|
20
|
+
@cache.has?('test1').should == true
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return specific overlays" do
|
24
|
+
@cache.get('test1').name.should == 'test1'
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should raise an OverlayNotFound exception when requesting missing overlays" do
|
28
|
+
lambda {
|
29
|
+
@cache.get('nothing')
|
30
|
+
}.should raise_error(Platform::OverlayNotFound)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should be able to select overlays with certain attributes" do
|
34
|
+
overlays = @cache.with do |overlay|
|
35
|
+
overlay.name =~ /^test/
|
36
|
+
end
|
37
|
+
|
38
|
+
overlays.include?(@cache.get('test1')).should == true
|
39
|
+
overlays.include?(@cache.get('test2')).should == true
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should return the paths to all the overlays" do
|
43
|
+
paths = @cache.paths
|
44
|
+
|
45
|
+
paths.length.should == 3
|
46
|
+
paths.select { |path| path =~ /(test[12]|hello)$/ }.should == paths
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should have specific extensions" do
|
50
|
+
@cache.has_extension?('test').should == true
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should have extensions" do
|
54
|
+
@cache.extensions.should == ['test', 'hello']
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should provide the paths to specific extensions" do
|
58
|
+
paths = @cache.extension_paths('test')
|
59
|
+
|
60
|
+
paths.length.should == 2
|
61
|
+
paths.select { |path| File.basename(path) == 'test' }.should == paths
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'ronin/platform/platform'
|
2
|
+
|
3
|
+
require 'platform/helpers/overlays'
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
describe Platform do
|
7
|
+
before(:all) do
|
8
|
+
Platform.load_overlays(overlay_cache_path)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be able to load custom overlay caches" do
|
12
|
+
Platform.overlays.should_not be_empty
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'ronin/platform/ronin'
|
2
|
+
|
3
|
+
require 'platform/helpers/overlays'
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
describe Ronin do
|
7
|
+
before(:all) do
|
8
|
+
Platform.load_overlays(overlay_cache_path)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should provide transparent access to extensions" do
|
12
|
+
ext = Ronin.hello
|
13
|
+
|
14
|
+
ext.should_not be_nil
|
15
|
+
ext.name.should == 'hello'
|
16
|
+
ext.greatings.should == 'hello'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should raise NoMethodError when accessing missing extensions" do
|
20
|
+
lambda { Ronin.nothing }.should raise_error(NoMethodError)
|
21
|
+
end
|
22
|
+
end
|
data/spec/target_spec.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'ronin/ui/diagnostics'
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe UI::Diagnostics do
|
6
|
+
it "should be disabled by default" do
|
7
|
+
UI::Diagnostics.should be_disabled
|
8
|
+
end
|
9
|
+
|
10
|
+
it "may be enabled and disabled" do
|
11
|
+
UI::Diagnostics.enable!
|
12
|
+
UI::Diagnostics.should be_enabled
|
13
|
+
|
14
|
+
UI::Diagnostics.disable!
|
15
|
+
UI::Diagnostics.should be_disabled
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ronin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Postmodern
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-02-06 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -110,7 +110,7 @@ dependencies:
|
|
110
110
|
requirements:
|
111
111
|
- - ">="
|
112
112
|
- !ruby/object:Gem::Version
|
113
|
-
version: 0.1.
|
113
|
+
version: 0.1.2
|
114
114
|
version:
|
115
115
|
- !ruby/object:Gem::Dependency
|
116
116
|
name: reverse-require
|
@@ -178,7 +178,6 @@ files:
|
|
178
178
|
- lib/ronin/formatting/digest.rb
|
179
179
|
- lib/ronin/formatting/binary.rb
|
180
180
|
- lib/ronin/formatting/text.rb
|
181
|
-
- lib/ronin/formatting/html.rb
|
182
181
|
- lib/ronin/formatting/http.rb
|
183
182
|
- lib/ronin/formatting/extensions.rb
|
184
183
|
- lib/ronin/formatting/extensions/digest.rb
|
@@ -188,8 +187,6 @@ files:
|
|
188
187
|
- lib/ronin/formatting/extensions/binary/string.rb
|
189
188
|
- lib/ronin/formatting/extensions/text.rb
|
190
189
|
- lib/ronin/formatting/extensions/text/string.rb
|
191
|
-
- lib/ronin/formatting/extensions/html.rb
|
192
|
-
- lib/ronin/formatting/extensions/html/string.rb
|
193
190
|
- lib/ronin/formatting/extensions/http.rb
|
194
191
|
- lib/ronin/formatting/extensions/http/string.rb
|
195
192
|
- lib/ronin/chars.rb
|
@@ -261,7 +258,7 @@ files:
|
|
261
258
|
- lib/ronin/license.rb
|
262
259
|
- lib/ronin/has_license.rb
|
263
260
|
- lib/ronin/arch.rb
|
264
|
-
- lib/ronin/
|
261
|
+
- lib/ronin/os.rb
|
265
262
|
- lib/ronin/target.rb
|
266
263
|
- lib/ronin/product.rb
|
267
264
|
- lib/ronin/objectify.rb
|
@@ -270,20 +267,22 @@ files:
|
|
270
267
|
- lib/ronin/objectify/exceptions/unknown_object_context.rb
|
271
268
|
- lib/ronin/objectify/objectify.rb
|
272
269
|
- lib/ronin/models.rb
|
273
|
-
- lib/ronin/
|
274
|
-
- lib/ronin/
|
275
|
-
- lib/ronin/
|
276
|
-
- lib/ronin/
|
277
|
-
- lib/ronin/
|
278
|
-
- lib/ronin/
|
279
|
-
- lib/ronin/
|
280
|
-
- lib/ronin/
|
281
|
-
- lib/ronin/
|
282
|
-
- lib/ronin/
|
283
|
-
- lib/ronin/
|
284
|
-
- lib/ronin/
|
285
|
-
- lib/ronin/
|
270
|
+
- lib/ronin/environment.rb
|
271
|
+
- lib/ronin/platform.rb
|
272
|
+
- lib/ronin/platform/exceptions.rb
|
273
|
+
- lib/ronin/platform/exceptions/extension_not_found.rb
|
274
|
+
- lib/ronin/platform/exceptions/overlay_cached.rb
|
275
|
+
- lib/ronin/platform/exceptions/overlay_not_found.rb
|
276
|
+
- lib/ronin/platform/maintainer.rb
|
277
|
+
- lib/ronin/platform/overlay.rb
|
278
|
+
- lib/ronin/platform/overlay_cache.rb
|
279
|
+
- lib/ronin/platform/object_cache.rb
|
280
|
+
- lib/ronin/platform/extension_cache.rb
|
281
|
+
- lib/ronin/platform/extension.rb
|
282
|
+
- lib/ronin/platform/platform.rb
|
283
|
+
- lib/ronin/platform/ronin.rb
|
286
284
|
- lib/ronin/ui.rb
|
285
|
+
- lib/ronin/ui/diagnostics.rb
|
287
286
|
- lib/ronin/ui/hexdump.rb
|
288
287
|
- lib/ronin/ui/hexdump/hexdump.rb
|
289
288
|
- lib/ronin/ui/hexdump/extensions.rb
|
@@ -327,17 +326,30 @@ files:
|
|
327
326
|
- spec/formatting/binary/integer_spec.rb
|
328
327
|
- spec/formatting/binary/string_spec.rb
|
329
328
|
- spec/formatting/digest_spec.rb
|
330
|
-
- spec/formatting/html_spec.rb
|
331
329
|
- spec/formatting/http_spec.rb
|
332
330
|
- spec/formatting/text_spec.rb
|
333
331
|
- spec/code/reference_spec.rb
|
334
332
|
- spec/code/symbol_table_spec.rb
|
335
333
|
- spec/license_spec.rb
|
336
334
|
- spec/path_spec.rb
|
337
|
-
- spec/
|
335
|
+
- spec/os_spec.rb
|
338
336
|
- spec/product_spec.rb
|
339
337
|
- spec/target_spec.rb
|
340
338
|
- spec/sessions/session_spec.rb
|
339
|
+
- spec/platform/helpers/overlays.rb
|
340
|
+
- spec/platform/helpers/overlays.yaml.erb
|
341
|
+
- spec/platform/helpers/overlays/test1/ronin.xml
|
342
|
+
- spec/platform/helpers/overlays/test1/test/extension.rb
|
343
|
+
- spec/platform/helpers/overlays/test2/ronin.xml
|
344
|
+
- spec/platform/helpers/overlays/test2/test/extension.rb
|
345
|
+
- spec/platform/helpers/overlays/hello/ronin.xml
|
346
|
+
- spec/platform/helpers/overlays/hello/hello/extension.rb
|
347
|
+
- spec/platform/extension_spec.rb
|
348
|
+
- spec/platform/overlay_cache_spec.rb
|
349
|
+
- spec/platform/extension_cache_spec.rb
|
350
|
+
- spec/platform/platform_spec.rb
|
351
|
+
- spec/platform/ronin_spec.rb
|
352
|
+
- spec/ui/diagnostics_spec.rb
|
341
353
|
- spec/ui/command_line/param_parser_spec.rb
|
342
354
|
- spec/ronin_spec.rb
|
343
355
|
- static/overlay.xsl
|
data/lib/ronin/cache.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#--
|
3
|
-
# Ronin - A Ruby platform designed for information security and data
|
4
|
-
# exploration tasks.
|
5
|
-
#
|
6
|
-
# Copyright (c) 2006-2009 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
|
19
|
-
# along with this program; if not, write to the Free Software
|
20
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
-
#++
|
22
|
-
#
|
23
|
-
|
24
|
-
require 'ronin/cache/exceptions'
|
25
|
-
require 'ronin/cache/extension'
|
26
|
-
require 'ronin/cache/overlay'
|
27
|
-
require 'ronin/cache/ronin'
|
data/lib/ronin/cache/cache.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#--
|
3
|
-
# Ronin - A Ruby platform designed for information security and data
|
4
|
-
# exploration tasks.
|
5
|
-
#
|
6
|
-
# Copyright (c) 2006-2009 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
|
19
|
-
# along with this program; if not, write to the Free Software
|
20
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
-
#++
|
22
|
-
#
|
23
|
-
|
24
|
-
require 'ronin/cache/overlay'
|
25
|
-
require 'ronin/cache/extension'
|
26
|
-
|
27
|
-
module Ronin
|
28
|
-
module Cache
|
29
|
-
#
|
30
|
-
# See Overlay.cache.
|
31
|
-
#
|
32
|
-
def Cache.overlays
|
33
|
-
Overlay.cache
|
34
|
-
end
|
35
|
-
|
36
|
-
#
|
37
|
-
# See Extension.names.
|
38
|
-
#
|
39
|
-
def Cache.extension_names
|
40
|
-
Extension.names
|
41
|
-
end
|
42
|
-
|
43
|
-
#
|
44
|
-
# See Overlay.has_extension?.
|
45
|
-
#
|
46
|
-
def Cache.has_extension?(name)
|
47
|
-
Overlay.has_extension?(name)
|
48
|
-
end
|
49
|
-
|
50
|
-
#
|
51
|
-
# Returns a +Hash+ of all loaded extensions. Extensions can be loaded
|
52
|
-
# on-the-fly by accessing the +Hash+.
|
53
|
-
#
|
54
|
-
# Cache.extensions['shellcode'] # => Cache::Extension
|
55
|
-
#
|
56
|
-
def Cache.extensions
|
57
|
-
Extension.cache
|
58
|
-
end
|
59
|
-
|
60
|
-
#
|
61
|
-
# Returns +true+ if the extension with the specified _name_ has been
|
62
|
-
# loaded, returns +false+ otherwise.
|
63
|
-
#
|
64
|
-
def Cache.extension_loaded?(name)
|
65
|
-
Extension.cache.has_extension?(name)
|
66
|
-
end
|
67
|
-
|
68
|
-
#
|
69
|
-
# See Cache.extensions.
|
70
|
-
#
|
71
|
-
def Cache.extension(name,&block)
|
72
|
-
ext = Cache.extensions[name]
|
73
|
-
|
74
|
-
block.call(ext) if block
|
75
|
-
return ext
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
data/lib/ronin/cache/overlay.rb
DELETED
@@ -1,470 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#--
|
3
|
-
# Ronin - A Ruby platform designed for information security and data
|
4
|
-
# exploration tasks.
|
5
|
-
#
|
6
|
-
# Copyright (c) 2006-2009 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
|
19
|
-
# along with this program; if not, write to the Free Software
|
20
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
-
#++
|
22
|
-
#
|
23
|
-
|
24
|
-
require 'ronin/cache/maintainer'
|
25
|
-
require 'ronin/cache/extension'
|
26
|
-
require 'ronin/cache/exceptions/extension_not_found'
|
27
|
-
require 'ronin/cache/overlay_cache'
|
28
|
-
require 'ronin/cache/config'
|
29
|
-
|
30
|
-
require 'rexml/document'
|
31
|
-
require 'repertoire'
|
32
|
-
|
33
|
-
module Ronin
|
34
|
-
module Cache
|
35
|
-
class Overlay < Repertoire::Repository
|
36
|
-
|
37
|
-
# Overlay metadata XML file name
|
38
|
-
METADATA_FILE = 'ronin.xml'
|
39
|
-
|
40
|
-
# Overlay objects directory
|
41
|
-
OBJECTS_DIR = 'objects'
|
42
|
-
|
43
|
-
# Local path to the overlay
|
44
|
-
attr_reader :path
|
45
|
-
|
46
|
-
# URI that the overlay was installed from
|
47
|
-
attr_reader :uri
|
48
|
-
|
49
|
-
# Name of the overlay
|
50
|
-
attr_reader :name
|
51
|
-
|
52
|
-
# License that the overlay contents is under
|
53
|
-
attr_reader :license
|
54
|
-
|
55
|
-
# Source URI of the overlay
|
56
|
-
attr_reader :source
|
57
|
-
|
58
|
-
# Source View URI of the overlay
|
59
|
-
attr_reader :source_view
|
60
|
-
|
61
|
-
# Website URI for the overlay
|
62
|
-
attr_reader :website
|
63
|
-
|
64
|
-
# Maintainers of the overlay
|
65
|
-
attr_reader :maintainers
|
66
|
-
|
67
|
-
# Description
|
68
|
-
attr_reader :description
|
69
|
-
|
70
|
-
#
|
71
|
-
# Creates a new Overlay object with the specified _path_, _media_type_
|
72
|
-
# and _uri_.
|
73
|
-
#
|
74
|
-
def initialize(path,media_type=nil,uri=nil,&block)
|
75
|
-
@path = File.expand_path(path)
|
76
|
-
@uri = uri
|
77
|
-
|
78
|
-
super(@path,Repertoire::Media.types[media_type])
|
79
|
-
|
80
|
-
initialize_metadata(&block)
|
81
|
-
end
|
82
|
-
|
83
|
-
#
|
84
|
-
# Load the Overlay Cache from the given _path_. If _path is not
|
85
|
-
# given, it will default to <tt>Config::REPOSITORY_CACHE_PATH</tt>.
|
86
|
-
# If a _block_ is given it will be passed the loaded Overlay Cache.
|
87
|
-
#
|
88
|
-
# Overlay.load_cache # => Cache
|
89
|
-
#
|
90
|
-
# Overlay.load_cache('/custom/cache') # => Cache
|
91
|
-
#
|
92
|
-
def Overlay.load_cache(path=Config::OVERLAY_CACHE_PATH,&block)
|
93
|
-
@@cache = OverlayCache.new(path,&block)
|
94
|
-
end
|
95
|
-
|
96
|
-
#
|
97
|
-
# Returns the current OverlayCache, or loads the default Cache
|
98
|
-
# if not already loaded.
|
99
|
-
#
|
100
|
-
def Overlay.cache
|
101
|
-
@@cache ||= load_cache
|
102
|
-
end
|
103
|
-
|
104
|
-
#
|
105
|
-
# Saves the overlay cache. If a _block_ is given, it will be passed
|
106
|
-
# the overlay cache before being saved.
|
107
|
-
#
|
108
|
-
# Overlay.save_cache # => OverlayCache
|
109
|
-
#
|
110
|
-
# Overlay.save_cahce do |cache|
|
111
|
-
# puts "Saving cache #{cache}"
|
112
|
-
# end
|
113
|
-
#
|
114
|
-
def Overlay.save_cache(&block)
|
115
|
-
Overlay.cache.save(&block)
|
116
|
-
end
|
117
|
-
|
118
|
-
#
|
119
|
-
# Returns the overlay with the specified _name_ from the overlay
|
120
|
-
# cache. If no such overlay exists, +nil+ is returned.
|
121
|
-
#
|
122
|
-
# Overlay['awesome']
|
123
|
-
#
|
124
|
-
def Overlay.[](name)
|
125
|
-
Overlay.cache[name]
|
126
|
-
end
|
127
|
-
|
128
|
-
#
|
129
|
-
# Returns +true+ if there is a overlay with the specified _name_
|
130
|
-
# in the overlay cache, returns +false+ otherwise.
|
131
|
-
#
|
132
|
-
def Overlay.exists?(name)
|
133
|
-
Overlay.cache.has_overlay?(name)
|
134
|
-
end
|
135
|
-
|
136
|
-
#
|
137
|
-
# Returns the overlay with the specified _name_ from the overlay
|
138
|
-
# cache. If no such overlay exists in the overlay cache,
|
139
|
-
# a OverlayNotFound exception will be raised.
|
140
|
-
#
|
141
|
-
def Overlay.get(name)
|
142
|
-
Overlay.cache.get_overlay(name)
|
143
|
-
end
|
144
|
-
|
145
|
-
#
|
146
|
-
# Installs the Overlay specified by _options_ into the
|
147
|
-
# <tt>Config::REPOSITORY_DIR</tt>. If a _block_ is given, it will be
|
148
|
-
# passed the newly created Overlay after it has been added to
|
149
|
-
# the Overlay cache.
|
150
|
-
#
|
151
|
-
# _options_ must contain the following key:
|
152
|
-
# <tt>:uri</tt>:: The URI of the Overlay.
|
153
|
-
#
|
154
|
-
# _options_ may contain the following key:
|
155
|
-
# <tt>:media</tt>:: The media of the Overlay.
|
156
|
-
#
|
157
|
-
def Overlay.install(options={},&block)
|
158
|
-
options = options.merge(:into => Config::REPOSITORY_DIR)
|
159
|
-
|
160
|
-
Repertoire.checkout(options) do |path,media,uri|
|
161
|
-
return Overlay.add(path,media,uri,&block)
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
#
|
166
|
-
# Adds the Overlay at the specified _path_, the given _uri_
|
167
|
-
# and given the _uri_ to the Overlay cache. If a _block is given, it
|
168
|
-
# will be passed the newly created Overlay after it has been added to
|
169
|
-
# the cache.
|
170
|
-
#
|
171
|
-
def Overlay.add(path,media=nil,uri=nil,&block)
|
172
|
-
Overlay.new(path,media,uri).add(&block)
|
173
|
-
end
|
174
|
-
|
175
|
-
#
|
176
|
-
# Updates the overlay with the specified _name_. If there is no
|
177
|
-
# overlay with the specified _name_ in the overlay cache
|
178
|
-
# a OverlayNotFound exception will be raised. If a _block_ is
|
179
|
-
# given it will be passed the updated overlay.
|
180
|
-
#
|
181
|
-
def Overlay.update(name,&block)
|
182
|
-
Overlay.get(name).update(&block)
|
183
|
-
end
|
184
|
-
|
185
|
-
#
|
186
|
-
# Removes the overlay with the specified _name_. If there is no
|
187
|
-
# overlay with the specified _name_ in the overlay cache
|
188
|
-
# a OverlayNotFound exception will be raised. If a _block_ is
|
189
|
-
# given it will be passed the overlay before removal.
|
190
|
-
#
|
191
|
-
def Overlay.remove(name,&block)
|
192
|
-
Overlay.get(name).remove(&block)
|
193
|
-
end
|
194
|
-
|
195
|
-
#
|
196
|
-
# Uninstall the overlay with the specified _name_. If there is no
|
197
|
-
# overlay with the specified _name_ in the overlay cache
|
198
|
-
# a OverlayNotFound exception will be raised. If a _block_ is
|
199
|
-
# given it will be passed the overlay before uninstalling it.
|
200
|
-
#
|
201
|
-
def Overlay.uninstall(name,&block)
|
202
|
-
Overlay.get(name).uninstall(&block)
|
203
|
-
end
|
204
|
-
|
205
|
-
#
|
206
|
-
# See OverlayCache#each_overlay.
|
207
|
-
#
|
208
|
-
def Overlay.each(&block)
|
209
|
-
Overlay.cache.each_overlay(&block)
|
210
|
-
end
|
211
|
-
|
212
|
-
#
|
213
|
-
# See OverlayCache#overlays_with?.
|
214
|
-
#
|
215
|
-
def Overlay.with(&block)
|
216
|
-
Overlay.cache.overlays_with(&block)
|
217
|
-
end
|
218
|
-
|
219
|
-
#
|
220
|
-
# Returns the overlays which contain the extension with the
|
221
|
-
# matching _name_.
|
222
|
-
#
|
223
|
-
# Overlay.with_extension?('exploits') # => [...]
|
224
|
-
#
|
225
|
-
def Overlay.with_extension(name)
|
226
|
-
Overlay.with { |repo| repo.has_extension?(name) }
|
227
|
-
end
|
228
|
-
|
229
|
-
#
|
230
|
-
# Returns +true+ if the cache has the extension with the matching
|
231
|
-
# _name_, returns +false+ otherwise.
|
232
|
-
#
|
233
|
-
def Overlay.has_extension?(name)
|
234
|
-
Overlay.each do |repo|
|
235
|
-
return true if repo.has_extension?(name)
|
236
|
-
end
|
237
|
-
|
238
|
-
return false
|
239
|
-
end
|
240
|
-
|
241
|
-
#
|
242
|
-
# Media type of the overlay.
|
243
|
-
#
|
244
|
-
def media_type
|
245
|
-
if @media
|
246
|
-
return @media.name
|
247
|
-
else
|
248
|
-
return nil
|
249
|
-
end
|
250
|
-
end
|
251
|
-
|
252
|
-
#
|
253
|
-
# Returns the path to the objects directory of the overlay.
|
254
|
-
#
|
255
|
-
def objects_dir
|
256
|
-
File.expand_path(File.join(@path,OBJECTS_DIR))
|
257
|
-
end
|
258
|
-
|
259
|
-
#
|
260
|
-
# Caches the objects contained within overlay.
|
261
|
-
#
|
262
|
-
def cache_objects
|
263
|
-
require 'ronin/models'
|
264
|
-
|
265
|
-
return Objectify.cache_objects_in(objects_dir)
|
266
|
-
end
|
267
|
-
|
268
|
-
#
|
269
|
-
# Mirror the objects contained within the overlay.
|
270
|
-
#
|
271
|
-
def mirror_objects
|
272
|
-
require 'ronin/models'
|
273
|
-
|
274
|
-
return Objectify.mirror_objects_in(objects_dir)
|
275
|
-
end
|
276
|
-
|
277
|
-
#
|
278
|
-
# Delete all objects that existed within the overlay.
|
279
|
-
#
|
280
|
-
def expunge_objects
|
281
|
-
require 'ronin/models'
|
282
|
-
|
283
|
-
return Objectify.expunge_objects_from(objects_dir)
|
284
|
-
end
|
285
|
-
|
286
|
-
#
|
287
|
-
# Adds the overlay to the overlay cache. If a _block is given,
|
288
|
-
# it will be passed the newly created Overlay after it has been
|
289
|
-
# added to the cache.
|
290
|
-
#
|
291
|
-
def add(&block)
|
292
|
-
Overlay.cache.add(self) do
|
293
|
-
cache_objects
|
294
|
-
end
|
295
|
-
|
296
|
-
block.call(self) if block
|
297
|
-
return self
|
298
|
-
end
|
299
|
-
|
300
|
-
#
|
301
|
-
# Updates the overlay and reloads it's metadata. If a _block_
|
302
|
-
# is given it will be called after the overlay has been updated.
|
303
|
-
#
|
304
|
-
def update(&block)
|
305
|
-
if media_type
|
306
|
-
Repertoire.update(:media => media_type, :path => @path, :uri => @uri)
|
307
|
-
end
|
308
|
-
|
309
|
-
mirror_objects
|
310
|
-
return load_metadata(&block)
|
311
|
-
end
|
312
|
-
|
313
|
-
#
|
314
|
-
# Removes the overlay from the overlay cache. If a _block_ is
|
315
|
-
# given, it will be passed the overlay after it has been removed.
|
316
|
-
#
|
317
|
-
def remove(&block)
|
318
|
-
Overlay.cache.remove(self)
|
319
|
-
|
320
|
-
expunge_objects
|
321
|
-
|
322
|
-
block.call(self) if block
|
323
|
-
return self
|
324
|
-
end
|
325
|
-
|
326
|
-
#
|
327
|
-
# Deletes the overlay then removes it from the overlay cache.
|
328
|
-
# If a _block_ is given, it will be passed the overlay after it
|
329
|
-
# has been uninstalled.
|
330
|
-
#
|
331
|
-
def uninstall(&block)
|
332
|
-
Repertoire.delete(@path) do
|
333
|
-
return remove(&block)
|
334
|
-
end
|
335
|
-
end
|
336
|
-
|
337
|
-
#
|
338
|
-
# Returns the paths of all extensions within the overlay.
|
339
|
-
#
|
340
|
-
def extension_paths
|
341
|
-
directories.reject { |dir| File.basename(dir) == 'objects' }
|
342
|
-
end
|
343
|
-
|
344
|
-
#
|
345
|
-
# Passes each extension path to the specified _block_.
|
346
|
-
#
|
347
|
-
def each_extension_path(&block)
|
348
|
-
extension_paths.each(&block)
|
349
|
-
end
|
350
|
-
|
351
|
-
#
|
352
|
-
# Returns the names of all extensions within the overlay.
|
353
|
-
#
|
354
|
-
def extensions
|
355
|
-
extension_paths.map { |dir| File.basename(dir) }
|
356
|
-
end
|
357
|
-
|
358
|
-
#
|
359
|
-
# Passes each extension name to the specified _block_.
|
360
|
-
#
|
361
|
-
def each_extension(&block)
|
362
|
-
extensions.each(&block)
|
363
|
-
end
|
364
|
-
|
365
|
-
#
|
366
|
-
# Returns +true+ if the overlay contains the extension with the
|
367
|
-
# specified _name_, returns +false+ otherwise.
|
368
|
-
#
|
369
|
-
def has_extension?(name)
|
370
|
-
extensions.include?(name.to_s)
|
371
|
-
end
|
372
|
-
|
373
|
-
#
|
374
|
-
# Loads an extension with the specified _name_ from the overlay.
|
375
|
-
# If a _block_ is given, it will be passed the newly created
|
376
|
-
# extension.
|
377
|
-
#
|
378
|
-
# overlay.extension('awesome')
|
379
|
-
# # => #<Ronin::Cache::Extension: ...>
|
380
|
-
#
|
381
|
-
# overlay.extension('shellcode') do |ext|
|
382
|
-
# ...
|
383
|
-
# end
|
384
|
-
#
|
385
|
-
def extension(name,&block)
|
386
|
-
name = name.to_s
|
387
|
-
|
388
|
-
unless has_extension?(name)
|
389
|
-
raise(ExtensionNotfound,"overlay #{name.dump} does not contain the extension #{name.dump}",caller)
|
390
|
-
end
|
391
|
-
|
392
|
-
return Extension.load_extension(File.join(@path,name),&block)
|
393
|
-
end
|
394
|
-
|
395
|
-
#
|
396
|
-
# Returns the +name+ of the Overlay.
|
397
|
-
#
|
398
|
-
def to_s
|
399
|
-
@name.to_s
|
400
|
-
end
|
401
|
-
|
402
|
-
protected
|
403
|
-
|
404
|
-
#
|
405
|
-
# Loads the overlay metadata from the METADATA_FILE within the
|
406
|
-
# overlay +path+. If a _block_ is given, it will be passed the
|
407
|
-
# overlay after the metadata has been loaded.
|
408
|
-
#
|
409
|
-
def initialize_metadata(&block)
|
410
|
-
metadata_path = File.join(@path,METADATA_FILE)
|
411
|
-
|
412
|
-
# set to default values
|
413
|
-
@name = File.basename(@path)
|
414
|
-
@license = nil
|
415
|
-
|
416
|
-
@source = @uri
|
417
|
-
@source_view = @source
|
418
|
-
@website = @source_view
|
419
|
-
|
420
|
-
@maintainers = []
|
421
|
-
@description = nil
|
422
|
-
|
423
|
-
if File.file?(metadata_path)
|
424
|
-
doc = REXML::Document.new(open(metadata_path))
|
425
|
-
overlay = doc.elements['/ronin-overlay']
|
426
|
-
|
427
|
-
overlay.each_element('name[.]:first') do |name|
|
428
|
-
@name = name.text.strip
|
429
|
-
end
|
430
|
-
|
431
|
-
overlay.each_element('license[.]:first') do |license|
|
432
|
-
@license = license.text.strip
|
433
|
-
end
|
434
|
-
|
435
|
-
overlay.each_element('source[.]:first') do |source|
|
436
|
-
@source = source.text.strip
|
437
|
-
end
|
438
|
-
|
439
|
-
overlay.each_element('source-view[.]:first') do |source_view|
|
440
|
-
@source_view = source_view.text.strip
|
441
|
-
end
|
442
|
-
|
443
|
-
overlay.each_element('website[.]:first') do |website|
|
444
|
-
@website = website.text.strip
|
445
|
-
end
|
446
|
-
|
447
|
-
overlay.each_element('maintainers/maintainer') do |maintainer|
|
448
|
-
if (name = maintainer.text('name'))
|
449
|
-
name.strip!
|
450
|
-
end
|
451
|
-
|
452
|
-
if (email = maintainer.text('email'))
|
453
|
-
email.strip!
|
454
|
-
end
|
455
|
-
|
456
|
-
@maintainers << Maintainer.new(name,email)
|
457
|
-
end
|
458
|
-
|
459
|
-
overlay.each_element('description[.]:first') do |description|
|
460
|
-
@description = description.text.strip
|
461
|
-
end
|
462
|
-
end
|
463
|
-
|
464
|
-
block.call(self) if block
|
465
|
-
return self
|
466
|
-
end
|
467
|
-
|
468
|
-
end
|
469
|
-
end
|
470
|
-
end
|