ronin 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/History.txt +13 -0
  2. data/Manifest.txt +19 -17
  3. data/README.txt +9 -9
  4. data/Rakefile +1 -1
  5. data/bin/ronin +2 -2
  6. data/lib/ronin/author.rb +1 -1
  7. data/lib/ronin/cache/extension.rb +4 -12
  8. data/lib/ronin/cache/extension_cache.rb +1 -3
  9. data/lib/ronin/cache/overlay.rb +3 -3
  10. data/lib/ronin/cache/overlay_cache.rb +21 -15
  11. data/lib/ronin/chars/char_set.rb +6 -12
  12. data/lib/ronin/code/reference.rb +142 -0
  13. data/lib/ronin/code/symbol_table.rb +90 -0
  14. data/lib/ronin/context.rb +1 -1
  15. data/lib/ronin/database.rb +12 -3
  16. data/lib/ronin/extensions/string.rb +49 -0
  17. data/lib/ronin/formatting/extensions/text/string.rb +10 -5
  18. data/lib/ronin/object_context.rb +3 -9
  19. data/lib/ronin/pending_context.rb +8 -0
  20. data/lib/ronin/platform.rb +2 -2
  21. data/lib/ronin/product.rb +2 -2
  22. data/lib/ronin/program/command.rb +203 -0
  23. data/lib/ronin/program/commands/add.rb +71 -0
  24. data/lib/ronin/{runner/program → program}/commands/help.rb +14 -16
  25. data/lib/ronin/program/commands/install.rb +64 -0
  26. data/lib/ronin/program/commands/list.rb +79 -0
  27. data/lib/ronin/{runner/program/commands/update.rb → program/commands/remove.rb} +18 -18
  28. data/lib/ronin/{runner/program/commands/remove.rb → program/commands/uninstall.rb} +17 -19
  29. data/lib/ronin/{runner/program/commands/uninstall.rb → program/commands/update.rb} +17 -21
  30. data/lib/ronin/{runner/program → program}/commands.rb +9 -9
  31. data/lib/ronin/{runner/program → program}/exceptions/unknown_command.rb +2 -4
  32. data/lib/ronin/{runner.rb → program/exceptions.rb} +1 -1
  33. data/lib/ronin/{runner/program → program}/options.rb +4 -8
  34. data/lib/ronin/program/program.rb +168 -0
  35. data/lib/ronin/{runner/program/exceptions.rb → program.rb} +2 -1
  36. data/lib/ronin/rpc/client.rb +1 -1
  37. data/lib/ronin/version.rb +1 -1
  38. data/spec/code/reference_spec.rb +72 -0
  39. data/spec/code/symbol_table_spec.rb +35 -0
  40. data/spec/extensions/string_spec.rb +88 -4
  41. data/spec/formatting/text_spec.rb +2 -2
  42. data/spec/helpers.rb +0 -0
  43. metadata +25 -23
  44. data/lib/ronin/runner/program/command.rb +0 -204
  45. data/lib/ronin/runner/program/commands/add.rb +0 -73
  46. data/lib/ronin/runner/program/commands/install.rb +0 -65
  47. data/lib/ronin/runner/program/commands/list.rb +0 -81
  48. data/lib/ronin/runner/program/program.rb +0 -175
  49. data/lib/ronin/runner/program/runner.rb +0 -35
  50. data/lib/ronin/runner/program.rb +0 -26
@@ -196,9 +196,7 @@ module Ronin
196
196
  # Cache all objects loaded from the specified _path_.
197
197
  #
198
198
  def ObjectContext.cache_objects(path)
199
- ObjectContext.load_objects(path).each do |obj|
200
- obj.cache
201
- end
199
+ ObjectContext.load_objects(path).each { |obj| obj.cache }
202
200
  end
203
201
 
204
202
  #
@@ -210,9 +208,7 @@ module Ronin
210
208
  paths = Dir[File.join(directory,'**','*.rb')]
211
209
 
212
210
  paths.each do |path|
213
- ObjectContext.load_objects(path).each do |obj|
214
- obj.cache
215
- end
211
+ ObjectContext.load_objects(path).each { |obj| obj.cache }
216
212
  end
217
213
 
218
214
  return nil
@@ -234,9 +230,7 @@ module Ronin
234
230
  objects.each { |obj| obj.mirror }
235
231
  end
236
232
 
237
- paths.each do |path|
238
- ObjectContext.cache_objects(path)
239
- end
233
+ paths.each { |path| ObjectContext.cache_objects(path) }
240
234
 
241
235
  return nil
242
236
  end
@@ -38,5 +38,13 @@ module Ronin
38
38
  @blocks = {}
39
39
  end
40
40
 
41
+ #
42
+ # Iterates over each block in the pending context, passing their name
43
+ # and value to the given _block_.
44
+ #
45
+ def each_block(&block)
46
+ @blocks.each(&block)
47
+ end
48
+
41
49
  end
42
50
  end
@@ -32,10 +32,10 @@ module Ronin
32
32
  property :id, Serial
33
33
 
34
34
  # Name of the Operating System
35
- property :os, String
35
+ property :os, String, :index => true
36
36
 
37
37
  # Version of the Operating System
38
- property :version, String
38
+ property :version, String, :index => true
39
39
 
40
40
  # Validates
41
41
  validates_present :os, :version
data/lib/ronin/product.rb CHANGED
@@ -33,10 +33,10 @@ module Ronin
33
33
  property :id, Serial
34
34
 
35
35
  # Name
36
- property :name, String
36
+ property :name, String, :index => true
37
37
 
38
38
  # Version
39
- property :version, String
39
+ property :version, String, :index => true
40
40
 
41
41
  # Venders
42
42
  property :vendor, String
@@ -0,0 +1,203 @@
1
+ #
2
+ #--
3
+ # Ronin - A Ruby platform designed for information security and data
4
+ # exploration tasks.
5
+ #
6
+ # Copyright (c) 2006-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
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/program/options'
25
+ require 'ronin/program/program'
26
+ require 'ronin/extensions/meta'
27
+
28
+ module Ronin
29
+ module Program
30
+ class Command
31
+
32
+ #
33
+ # Creates a new Command object. If a _block_ is given,
34
+ # it will be passed newly created Command object.
35
+ #
36
+ def initialize(&block)
37
+ @options = nil
38
+
39
+ block.call(self) if block
40
+ end
41
+
42
+ #
43
+ # Returns the name of the command.
44
+ #
45
+ def Command.command_name
46
+ ''
47
+ end
48
+
49
+ #
50
+ # Returns the short names of the command.
51
+ #
52
+ def Command.command_short_names
53
+ []
54
+ end
55
+
56
+ #
57
+ # Returns all the names of the command.
58
+ #
59
+ def self.command_names
60
+ [self.command_name] + self.command_short_names
61
+ end
62
+
63
+ #
64
+ # Creates a new command object and runs it with the
65
+ # given _args_.
66
+ #
67
+ def self.run(*args)
68
+ self.new.run(*args)
69
+ end
70
+
71
+ #
72
+ # Prints the help information for the command.
73
+ #
74
+ def self.help
75
+ self.new.help
76
+ end
77
+
78
+ #
79
+ # Returns the name of the command.
80
+ #
81
+ def command_name
82
+ self.class.command_name
83
+ end
84
+
85
+ #
86
+ # Returns the short names of the command.
87
+ #
88
+ def command_short_names
89
+ self.class.command_short_names
90
+ end
91
+
92
+ #
93
+ # Returns all the names of the command.
94
+ #
95
+ def command_names
96
+ self.class.command_names
97
+ end
98
+
99
+ #
100
+ # Runs the command with the given _args_. If a _block_ is
101
+ # given, it will be called after the specified _args_ have
102
+ # been parsed and the command has run.
103
+ #
104
+ def run(*args,&block)
105
+ arguments(*(options.parse(args)))
106
+
107
+ @options = nil
108
+
109
+ block.call if block
110
+ return self
111
+ end
112
+
113
+ #
114
+ # Prints the help information for the command.
115
+ #
116
+ def help
117
+ options.help
118
+ return self
119
+ end
120
+
121
+ #
122
+ # Returns the String form of the command.
123
+ #
124
+ def to_s
125
+ names.join(', ')
126
+ end
127
+
128
+ protected
129
+
130
+ #
131
+ # Registers the command with the specified _name_ and the given
132
+ # _short_names_.
133
+ #
134
+ def self.command(name,*short_names)
135
+ name = name.to_s
136
+ short_names = short_names.map { |short_name| short_name.to_s }
137
+
138
+ meta_def(:command_name) { name }
139
+ meta_def(:command_short_names) { short_names }
140
+
141
+ # register the command
142
+ Program.commands << self unless Program.commands.include?(self)
143
+
144
+ # register the command by name
145
+ Program.commands_by_name[name] = self
146
+
147
+ # register the command by it's short_names
148
+ short_names.each do |short_name|
149
+ Program.commands_by_name[short_name] = self
150
+ end
151
+
152
+ return self
153
+ end
154
+
155
+ #
156
+ # Defines the options of the command with the specified _usage_ and
157
+ # _block_.
158
+ #
159
+ def self.options(usage=nil,&block)
160
+ class_def(:options) do
161
+ @options ||= Options.command(:ronin,self.command_name,usage,&block)
162
+ end
163
+
164
+ return self
165
+ end
166
+
167
+ #
168
+ # Returns the options of the command.
169
+ #
170
+ def options
171
+ @options ||= Options.command(:ronin,command_name)
172
+ end
173
+
174
+ #
175
+ # See Program.error.
176
+ #
177
+ def error(message)
178
+ Program.error(message)
179
+ end
180
+
181
+ #
182
+ # See Program.success.
183
+ #
184
+ def success(&block)
185
+ Program.success(&block)
186
+ end
187
+
188
+ #
189
+ # See Program.fail.
190
+ #
191
+ def fail(*messages,&block)
192
+ Program.fail(*messages,&block)
193
+ end
194
+
195
+ #
196
+ # Processes the additional arguments specified by _args_.
197
+ #
198
+ def arguments(*args)
199
+ end
200
+
201
+ end
202
+ end
203
+ end
@@ -0,0 +1,71 @@
1
+ #
2
+ #--
3
+ # Ronin - A Ruby platform designed for information security and data
4
+ # exploration tasks.
5
+ #
6
+ # Copyright (c) 2006-2007 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/program/command'
25
+ require 'ronin/cache/overlay'
26
+
27
+ module Ronin
28
+ module Program
29
+ class AddCommand < Command
30
+
31
+ command :add
32
+
33
+ options('PATH [options]') do |opts|
34
+ opts.settings.media = nil
35
+ opts.settings.uri = nil
36
+
37
+ opts.options do
38
+ opts.on('-m','--media MEDIA','Spedify the media-type of the repository') do |media|
39
+ opts.settings.media = media
40
+ end
41
+
42
+ opts.on('-U','--uri URI','Specify the source URI of the repository') do |uri|
43
+ opts.settings.uri = uri
44
+ end
45
+ end
46
+
47
+ opts.arguments do
48
+ opts.arg('PATH','Add the repository located at the specified PATH')
49
+ end
50
+
51
+ opts.summary('Add a local repository located at the specified PATH to the repository cache')
52
+
53
+ end
54
+
55
+ def arguments(*args)
56
+ unless args.length==1
57
+ fail('add: only one repository path maybe specified')
58
+ end
59
+
60
+ path = args.first
61
+
62
+ Cache::Overlay.save_cache do
63
+ Cache::Overlay.add(path,options.settings.media,options.settings.uri) do |repo|
64
+ puts "Overlay #{repo} added."
65
+ end
66
+ end
67
+ end
68
+
69
+ end
70
+ end
71
+ end
@@ -21,32 +21,30 @@
21
21
  #++
22
22
  #
23
23
 
24
- require 'ronin/runner/program/command'
24
+ require 'ronin/program/command'
25
25
 
26
26
  module Ronin
27
- module Runner
28
- module Program
29
- class HelpCommand < Command
27
+ module Program
28
+ class HelpCommand < Command
30
29
 
31
- command :help
30
+ command :help
32
31
 
33
- options('[COMMAND]') do |opts|
34
- opts.arguments do
35
- opts.arg('COMMAND','The command to view')
36
- end
37
-
38
- opts.summary('View a list of supported commands or information on a specific command')
32
+ options('[COMMAND]') do |opts|
33
+ opts.arguments do
34
+ opts.arg('COMMAND','The command to view')
39
35
  end
40
36
 
41
- def arguments(*args)
42
- unless args.length<=1
43
- fail('help: only one command maybe specified')
44
- end
37
+ opts.summary('View a list of supported commands or information on a specific command')
38
+ end
45
39
 
46
- success { Program.help(args.first) }
40
+ def arguments(*args)
41
+ unless args.length<=1
42
+ fail('help: only one command maybe specified')
47
43
  end
48
44
 
45
+ success { Program.help(args.first) }
49
46
  end
47
+
50
48
  end
51
49
  end
52
50
  end
@@ -0,0 +1,64 @@
1
+ #
2
+ #--
3
+ # Ronin - A Ruby platform designed for information security and data
4
+ # exploration tasks.
5
+ #
6
+ # Copyright (c) 2006-2007 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/program/command'
25
+ require 'ronin/cache/overlay'
26
+
27
+ module Ronin
28
+ module Program
29
+ class InstallCommand < Command
30
+
31
+ command :install
32
+
33
+ options('URI [options]') do |opts|
34
+ opts.settings.media = nil
35
+ opts.settings.uri = nil
36
+
37
+ opts.options do
38
+ opts.on('-m','--media [MEDIA]','Spedify the media-type of the repository') do |media|
39
+ options.settings.media = media
40
+ end
41
+ end
42
+
43
+ opts.arguments do
44
+ opts.arg('URI','The URI of the repository to install')
45
+ end
46
+
47
+ opts.summary('Installs the repository located at the specified URI')
48
+ end
49
+
50
+ def arguments(args)
51
+ unless args.length==1
52
+ fail('install: only one repository URI maybe specified')
53
+ end
54
+
55
+ Cache::Overlay.save_cache do
56
+ Cache::Overlay.install(:uri => args.first, :media => options.settings.media) do |repo|
57
+ puts "Overlay #{repo} has been installed."
58
+ end
59
+ end
60
+ end
61
+
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,79 @@
1
+ #
2
+ #--
3
+ # Ronin - A Ruby platform designed for information security and data
4
+ # exploration tasks.
5
+ #
6
+ # Copyright (c) 2006-2007 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/program/command'
25
+ require 'ronin/cache/overlay'
26
+
27
+ module Ronin
28
+ module Program
29
+ class ListCommand < Command
30
+
31
+ command :list, :ls
32
+
33
+ options('[NAME ...] [options]') do |opts|
34
+ opts.options
35
+
36
+ opts.arguments do
37
+ opts.arg('NAME','Overlay to display')
38
+ end
39
+
40
+ opts.summary('Display all or the specified repositories within the repository cache')
41
+ end
42
+
43
+ def arguments(*args)
44
+ if args.empty?
45
+ # list all repositories by name
46
+ Cache::Overlay.each do |repo|
47
+ puts " #{repo}"
48
+ end
49
+ else
50
+ # list specified repositories
51
+ args.each do |name|
52
+ repo = Cache::Overlay.get(name)
53
+
54
+ puts "[ #{repo} ]\n\n"
55
+
56
+ puts " path: #{repo.path}" if options.settings.verbose
57
+ puts " media: #{repo.media}"
58
+ puts " uri: #{repo.uri}" if repo.uri
59
+
60
+ if repo.description
61
+ puts " description:\n\n #{repo.description}"
62
+ end
63
+
64
+ puts "\n"
65
+
66
+ if options.settings.verbose
67
+ puts " extensions:\n\n"
68
+
69
+ repo.each_extension do |ext|
70
+ puts " #{ext}"
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+
77
+ end
78
+ end
79
+ end
@@ -21,35 +21,35 @@
21
21
  #++
22
22
  #
23
23
 
24
- require 'ronin/runner/program/command'
24
+ require 'ronin/program/command'
25
25
  require 'ronin/cache/overlay'
26
26
 
27
27
  module Ronin
28
- module Runner
29
- module Program
30
- class UpdateCommand < Command
28
+ module Program
29
+ class RemoveCommand < Command
31
30
 
32
- command :update, :up
31
+ command :remove, :rm
33
32
 
34
- options('[NAME ...] [options]') do |opts|
35
- opts.options
33
+ options('NAME [NAME ...] [options]') do |opts|
34
+ opts.options
36
35
 
37
- opts.arguments do
38
- opts.arg('NAME','The repository to update')
39
- end
40
-
41
- opts.summary('Updates all or the specified repositories')
36
+ opts.arguments do
37
+ opts.arg('NAME','The repository to remove')
42
38
  end
43
39
 
44
- def arguments(*args)
45
- if args.empty?
46
- Cache::Overlay.each { |repo| repo.update }
47
- else
48
- args.each { |name| Cache::Overlay.update(name) }
40
+ opts.summary('Remove the specified repositories')
41
+ end
42
+
43
+ def arguments(*args)
44
+ args.each do |name|
45
+ Cache::Overlay.save_cache do
46
+ Cache::Overlay.remove(name) do |repo|
47
+ puts "Removing #{repo}..."
48
+ end
49
49
  end
50
50
  end
51
-
52
51
  end
52
+
53
53
  end
54
54
  end
55
55
  end
@@ -21,37 +21,35 @@
21
21
  #++
22
22
  #
23
23
 
24
- require 'ronin/runner/program/command'
24
+ require 'ronin/program/command'
25
25
  require 'ronin/cache/overlay'
26
26
 
27
27
  module Ronin
28
- module Runner
29
- module Program
30
- class RemoveCommand < Command
28
+ module Program
29
+ class UninstallCommand < Command
31
30
 
32
- command :remove, :rm
31
+ command :uninstall
33
32
 
34
- options('NAME [NAME ...] [options]') do |opts|
35
- opts.options
33
+ options('NAME [NAME ...] [options]') do |opts|
34
+ opts.options
36
35
 
37
- opts.arguments do
38
- opts.arg('NAME','The repository to remove')
39
- end
40
-
41
- opts.summary('Remove the specified repositories')
36
+ opts.arguments do
37
+ opts.arg('NAME','The repository to uninstall')
42
38
  end
43
39
 
44
- def arguments(*args)
45
- args.each do |name|
46
- Cache::Overlay.save_cache do
47
- Cache::Overlay.remove(name) do |repo|
48
- puts "Removing #{repo}..."
49
- end
40
+ opts.summary('Uninstall the specified repositories')
41
+ end
42
+
43
+ def arguments(*args)
44
+ args.each do |name|
45
+ Cache::Overlay.save_cache do
46
+ Cache::Overlay.uninstall(name) do |repo|
47
+ puts "Uninstalling #{repo}..."
50
48
  end
51
49
  end
52
50
  end
53
-
54
51
  end
52
+
55
53
  end
56
54
  end
57
55
  end