ronin 0.2.0 → 0.2.1
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 +21 -0
- data/Manifest.txt +17 -6
- data/README.txt +3 -2
- data/Rakefile +1 -0
- data/bin/ronin-add +12 -0
- data/bin/ronin-console +12 -0
- data/bin/ronin-ext +12 -0
- data/bin/ronin-help +12 -0
- data/bin/ronin-install +12 -0
- data/bin/ronin-ls +12 -0
- data/bin/ronin-overlay +12 -0
- data/bin/ronin-rm +12 -0
- data/bin/ronin-uninstall +12 -0
- data/bin/ronin-update +12 -0
- data/lib/ronin/extensions/string.rb +5 -3
- data/lib/ronin/platform/extension.rb +8 -2
- data/lib/ronin/platform/overlay.rb +16 -32
- data/lib/ronin/ui.rb +1 -1
- data/lib/ronin/ui/command_line.rb +1 -1
- data/lib/ronin/ui/command_line/command.rb +42 -60
- data/lib/ronin/ui/command_line/command_line.rb +28 -50
- data/lib/ronin/ui/command_line/commands/add.rb +41 -40
- data/lib/ronin/ui/command_line/commands/{default.rb → console.rb} +28 -21
- data/lib/ronin/ui/command_line/commands/{extension.rb → ext.rb} +25 -27
- data/lib/ronin/ui/command_line/commands/help.rb +26 -28
- data/lib/ronin/ui/command_line/commands/install.rb +32 -32
- data/lib/ronin/ui/command_line/commands/ls.rb +123 -0
- data/lib/ronin/ui/command_line/commands/overlay.rb +115 -114
- data/lib/ronin/ui/command_line/commands/{remove.rb → rm.rb} +27 -29
- data/lib/ronin/ui/command_line/commands/uninstall.rb +27 -29
- data/lib/ronin/ui/command_line/commands/update.rb +28 -30
- data/lib/ronin/ui/command_line/options.rb +0 -12
- data/lib/ronin/ui/command_line/param_parser.rb +34 -14
- data/lib/ronin/ui/console.rb +1 -0
- data/lib/ronin/ui/diagnostics.rb +5 -19
- data/lib/ronin/ui/{command_line/commands.rb → verbose.rb} +19 -11
- data/lib/ronin/version.rb +1 -1
- data/spec/arch_spec.rb +24 -24
- data/spec/chars/chars_spec.rb +49 -13
- data/spec/extensions/string_spec.rb +6 -6
- data/spec/spec_helper.rb +1 -1
- data/spec/ui/command_line/helpers/example_command.rb +21 -0
- data/spec/ui/command_line/param_parser_spec.rb +9 -18
- data/spec/ui/verbose_spec.rb +17 -0
- metadata +39 -8
- data/lib/ronin/ui/command_line/commands/list.rb +0 -122
- data/spec/ui/diagnostics_spec.rb +0 -17
@@ -0,0 +1,123 @@
|
|
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/ui/command_line/command'
|
25
|
+
require 'ronin/platform/overlay'
|
26
|
+
|
27
|
+
module Ronin
|
28
|
+
module UI
|
29
|
+
module CommandLine
|
30
|
+
module Commands
|
31
|
+
class LS < Command
|
32
|
+
|
33
|
+
def defaults
|
34
|
+
@cache = nil
|
35
|
+
@verbose = false
|
36
|
+
end
|
37
|
+
|
38
|
+
def define_options(opts)
|
39
|
+
opts.usage = '[NAME ...] [options]'
|
40
|
+
|
41
|
+
opts.options do
|
42
|
+
opts.on('-C','--cache DIR','Specify an alternate overlay cache') do |dir|
|
43
|
+
@cache = dir
|
44
|
+
end
|
45
|
+
|
46
|
+
opts.on('-v','--verbose','Enable verbose output') do
|
47
|
+
@verbose = true
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
opts.arguments(
|
52
|
+
'NAME' => 'Overlay to display'
|
53
|
+
)
|
54
|
+
|
55
|
+
opts.summary %{
|
56
|
+
Display all or the specified repositories within the Overlay
|
57
|
+
cache
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
def arguments(*args)
|
62
|
+
Platform.load_overlays(@cache) if @cache
|
63
|
+
|
64
|
+
if args.empty?
|
65
|
+
# list all overlays by name
|
66
|
+
Platform.overlays.each_overlay do |overlay|
|
67
|
+
puts " #{overlay}"
|
68
|
+
end
|
69
|
+
|
70
|
+
return
|
71
|
+
end
|
72
|
+
|
73
|
+
# list specified overlays
|
74
|
+
args.each do |name|
|
75
|
+
overlay = Platform.overlays.get(name)
|
76
|
+
|
77
|
+
puts "[ #{overlay.name} ]\n\n"
|
78
|
+
|
79
|
+
puts " Path: #{overlay.path}"
|
80
|
+
puts " Media: #{overlay.media}" if overlay.media
|
81
|
+
puts " URI: #{overlay.uri}" if overlay.uri
|
82
|
+
|
83
|
+
if @verbose
|
84
|
+
putc "\n"
|
85
|
+
|
86
|
+
if overlay.title
|
87
|
+
puts " Title: #{overlay.title}"
|
88
|
+
end
|
89
|
+
|
90
|
+
if overlay.source
|
91
|
+
puts " Source URI: #{overlay.source}"
|
92
|
+
end
|
93
|
+
|
94
|
+
if overlay.source_view
|
95
|
+
puts " Source View: #{overlay.source_view}"
|
96
|
+
end
|
97
|
+
|
98
|
+
if overlay.website
|
99
|
+
puts " Website: #{overlay.website}"
|
100
|
+
end
|
101
|
+
|
102
|
+
unless overlay.extensions.empty?
|
103
|
+
puts " Extensions:\n\n"
|
104
|
+
overlay.extensions.each { |ext| puts " #{ext}" }
|
105
|
+
putc "\n"
|
106
|
+
end
|
107
|
+
|
108
|
+
if overlay.description
|
109
|
+
puts " Description:\n\n #{overlay.description}\n\n"
|
110
|
+
else
|
111
|
+
putc "\n"
|
112
|
+
end
|
113
|
+
else
|
114
|
+
putc "\n"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -26,162 +26,163 @@ require 'ronin/platform/overlay'
|
|
26
26
|
require 'ronin/version'
|
27
27
|
|
28
28
|
require 'fileutils'
|
29
|
-
require '
|
29
|
+
require 'nokogiri'
|
30
30
|
|
31
31
|
module Ronin
|
32
32
|
module UI
|
33
33
|
module CommandLine
|
34
|
-
|
34
|
+
module Commands
|
35
|
+
class Overlay < Command
|
36
|
+
|
37
|
+
include Nokogiri
|
38
|
+
|
39
|
+
def defaults
|
40
|
+
@title = nil
|
41
|
+
@source = nil
|
42
|
+
@source_view = nil
|
43
|
+
@website = nil
|
44
|
+
@license = nil
|
45
|
+
@maintainers = []
|
46
|
+
@description = nil
|
47
|
+
end
|
35
48
|
|
36
|
-
|
49
|
+
def define_options(opts)
|
50
|
+
opts.usage = '[options] PATH'
|
37
51
|
|
38
|
-
|
52
|
+
opts.options do
|
53
|
+
opts.on('-t','--title NAME','Name of the Overlay') do |title|
|
54
|
+
@title = title
|
55
|
+
end
|
39
56
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
@source_view = nil
|
44
|
-
@website = nil
|
45
|
-
@license = nil
|
46
|
-
@maintainers = []
|
47
|
-
@description = nil
|
57
|
+
opts.on('-S','--source URL','The URL where the source of the Overlay will be hosted') do |url|
|
58
|
+
@source = url
|
59
|
+
end
|
48
60
|
|
49
|
-
|
50
|
-
|
61
|
+
opts.on('-V','--source-view URL','The URL for viewing the contents of the Overlay') do |url|
|
62
|
+
@source_view = url
|
63
|
+
end
|
51
64
|
|
52
|
-
|
53
|
-
|
65
|
+
opts.on('-U','--website URL','The URL of the website of the Overlay') do |url|
|
66
|
+
@website = url
|
67
|
+
end
|
54
68
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
69
|
+
opts.on('-L','--license LICENSE','The license of the contents of the Overlay') do |license|
|
70
|
+
@license = license
|
71
|
+
end
|
59
72
|
|
60
|
-
|
61
|
-
|
62
|
-
|
73
|
+
opts.on('-m','--maintainer "NAME <EMAIL>"','Name of a maintainer of the Overlay') do |text|
|
74
|
+
name = text.scan(/^[^<]+[^<\s]/).first
|
75
|
+
email = text.scan(/<([^<>]+)>\s*$/).first
|
63
76
|
|
64
|
-
|
65
|
-
@source_view = url
|
66
|
-
end
|
77
|
+
email = email.first if email
|
67
78
|
|
68
|
-
|
69
|
-
|
70
|
-
end
|
79
|
+
@maintainers << {:name => name, :email => email}
|
80
|
+
end
|
71
81
|
|
72
|
-
|
73
|
-
|
82
|
+
opts.on('-D','--description TEXT','The description for the Overlay') do |text|
|
83
|
+
@description = text
|
84
|
+
end
|
74
85
|
end
|
75
86
|
|
76
|
-
opts.
|
77
|
-
|
78
|
-
|
87
|
+
opts.arguments(
|
88
|
+
'PATH' => 'The PATH of the Overlay to be created'
|
89
|
+
)
|
79
90
|
|
80
|
-
|
81
|
-
|
82
|
-
@maintainers << {:name => name, :email => email}
|
83
|
-
end
|
84
|
-
|
85
|
-
opts.on('-D','--description TEXT','The description for the Overlay') do |text|
|
86
|
-
@description = text
|
87
|
-
end
|
91
|
+
opts.summary('Create an empty Overlay at the specified PATH')
|
88
92
|
end
|
89
93
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
opts.summary('Create an empty Overlay at the specified PATH')
|
95
|
-
end
|
94
|
+
def arguments(*args)
|
95
|
+
unless args.length == 1
|
96
|
+
fail('only one Overlay path maybe specified')
|
97
|
+
end
|
96
98
|
|
97
|
-
|
98
|
-
unless args.length == 1
|
99
|
-
fail('only one Overlay path maybe specified')
|
100
|
-
end
|
99
|
+
path = File.expand_path(args.first)
|
101
100
|
|
102
|
-
|
101
|
+
@title ||= File.basename(path).gsub(/[_\s]+/,' ').capitalize
|
102
|
+
@source_view ||= @source
|
103
|
+
@website ||= @source_view
|
103
104
|
|
104
|
-
|
105
|
-
|
106
|
-
|
105
|
+
FileUtils.mkdir_p(path)
|
106
|
+
FileUtils.mkdir_p(File.join(path,'lib'))
|
107
|
+
FileUtils.mkdir_p(File.join(path,'objects'))
|
107
108
|
|
108
|
-
|
109
|
-
|
110
|
-
|
109
|
+
File.open(File.join(path,Platform::Overlay::METADATA_FILE),'w') do |file|
|
110
|
+
doc = XML::Document.new
|
111
|
+
doc << XML::ProcessingInstruction.new(
|
112
|
+
doc,
|
113
|
+
'xml-stylesheet',
|
114
|
+
'type="text/xsl" href="http://ronin.rubyforge.org/dist/overlay.xsl"'
|
115
|
+
)
|
111
116
|
|
112
|
-
|
113
|
-
|
114
|
-
doc.add(XMLDecl.new)
|
115
|
-
doc.add(Instruction.new('xml-stylesheet','type="text/xsl" href="http://ronin.rubyforge.org/dist/overlay.xsl"'))
|
117
|
+
root = XML::Node.new('ronin-overlay',doc)
|
118
|
+
root['version'] = Ronin::VERSION
|
116
119
|
|
117
|
-
|
118
|
-
|
120
|
+
title_tag = XML::Node.new('title',doc)
|
121
|
+
title_tag << XML::Text.new(@title,doc)
|
122
|
+
root << title_tag
|
119
123
|
|
120
|
-
|
121
|
-
|
122
|
-
|
124
|
+
if @source
|
125
|
+
source_tag = XML::Node.new('source',doc)
|
126
|
+
source_tag << XML::Text.new(@source,doc)
|
127
|
+
root << source_tag
|
128
|
+
end
|
123
129
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
130
|
+
if @source_view
|
131
|
+
source_view_tag = XML::Node.new('source-view',doc)
|
132
|
+
source_view_tag << XML::Text.new(@source_view,doc)
|
133
|
+
root << source_view_tag
|
134
|
+
end
|
129
135
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
136
|
+
if @website
|
137
|
+
url_tag = XML::Node.new('website',doc)
|
138
|
+
url_tag << XML::Text.new(@website,doc)
|
139
|
+
root << url_tag
|
140
|
+
end
|
135
141
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
142
|
+
if @license
|
143
|
+
license_tag = XML::Node.new('license',doc)
|
144
|
+
license_tag << XML::Text.new(@license,doc)
|
145
|
+
root << license_tag
|
146
|
+
end
|
141
147
|
|
142
|
-
|
143
|
-
|
144
|
-
license_tag.text = @license
|
145
|
-
root.add_element(license_tag)
|
146
|
-
end
|
148
|
+
unless @maintainers.empty?
|
149
|
+
maintainers_tag = XML::Node.new('maintainers',doc)
|
147
150
|
|
148
|
-
|
149
|
-
|
151
|
+
@maintainers.each do |author|
|
152
|
+
if (author[:name] || author[:email])
|
153
|
+
maintainer_tag = XML::Node.new('maintainer',doc)
|
150
154
|
|
151
|
-
|
152
|
-
|
153
|
-
|
155
|
+
if author[:name]
|
156
|
+
name_tag = XML::Node.new('name',doc)
|
157
|
+
name_tag << XML::Text.new(author[:name],doc)
|
158
|
+
maintainer_tag << name_tag
|
159
|
+
end
|
154
160
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
161
|
+
if author[:email]
|
162
|
+
email_tag = XML::Node.new('email',doc)
|
163
|
+
email_tag << XML::Text.new(author[:email],doc)
|
164
|
+
maintainer_tag << email_tag
|
165
|
+
end
|
160
166
|
|
161
|
-
|
162
|
-
email_tag = Element.new('email')
|
163
|
-
email_tag.text = author[:email]
|
164
|
-
maintainer_tag.add_element(email_tag)
|
167
|
+
maintainers_tag << maintainer_tag
|
165
168
|
end
|
166
|
-
|
167
|
-
maintainers_tag.add_element(maintainer_tag)
|
168
169
|
end
|
170
|
+
|
171
|
+
root << maintainers_tag
|
169
172
|
end
|
170
173
|
|
171
|
-
|
172
|
-
|
174
|
+
if @description
|
175
|
+
description_tag = XML::Node.new('description',doc)
|
176
|
+
description_tag << XML::Text.new(@description,doc)
|
177
|
+
root << description_tag
|
178
|
+
end
|
173
179
|
|
174
|
-
|
175
|
-
|
176
|
-
description_tag.text = @description
|
177
|
-
root.add_element(description_tag)
|
180
|
+
doc << root
|
181
|
+
doc.write_xml_to(file)
|
178
182
|
end
|
179
|
-
|
180
|
-
doc.add_element(root)
|
181
|
-
doc.write(file,2)
|
182
183
|
end
|
183
|
-
end
|
184
184
|
|
185
|
+
end
|
185
186
|
end
|
186
187
|
end
|
187
188
|
end
|
@@ -27,47 +27,45 @@ require 'ronin/platform/overlay'
|
|
27
27
|
module Ronin
|
28
28
|
module UI
|
29
29
|
module CommandLine
|
30
|
-
|
30
|
+
module Commands
|
31
|
+
class RM < Command
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
@verbose = false
|
37
|
-
|
38
|
-
super
|
39
|
-
end
|
33
|
+
def defaults
|
34
|
+
@cache = nil
|
35
|
+
@verbose = false
|
36
|
+
end
|
40
37
|
|
41
|
-
|
42
|
-
|
38
|
+
def define_options(opts)
|
39
|
+
opts.usage = 'NAME [...] [options]'
|
43
40
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
41
|
+
opts.options do
|
42
|
+
opts.on('-C','--cache DIR','Specify an alternate overlay cache') do |dir|
|
43
|
+
@cache = dir
|
44
|
+
end
|
48
45
|
|
49
|
-
|
50
|
-
|
46
|
+
opts.on('-v','--verbose','Enable verbose output') do
|
47
|
+
@verbose = true
|
48
|
+
end
|
51
49
|
end
|
52
|
-
end
|
53
50
|
|
54
|
-
|
55
|
-
|
56
|
-
|
51
|
+
opts.arguments(
|
52
|
+
'NAME' => 'The overlay to remove'
|
53
|
+
)
|
57
54
|
|
58
|
-
|
59
|
-
|
55
|
+
opts.summary('Remove the specified repositories')
|
56
|
+
end
|
60
57
|
|
61
|
-
|
62
|
-
|
58
|
+
def arguments(*args)
|
59
|
+
Platform.load_overlays(@cache) if @cache
|
63
60
|
|
64
|
-
|
65
|
-
|
66
|
-
|
61
|
+
args.each do |name|
|
62
|
+
Platform.remove(name) do |overlay|
|
63
|
+
puts "Removing #{overlay.name.dump} ..."
|
64
|
+
end
|
67
65
|
end
|
68
66
|
end
|
69
|
-
end
|
70
67
|
|
68
|
+
end
|
71
69
|
end
|
72
70
|
end
|
73
71
|
end
|