ronin 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. data.tar.gz.sig +2 -0
  2. data/History.txt +43 -0
  3. data/Manifest.txt +27 -10
  4. data/README.txt +2 -1
  5. data/Rakefile +12 -11
  6. data/TODO.txt +8 -0
  7. data/bin/{ronin-ls → ronin-list} +2 -2
  8. data/bin/{ronin-rm → ronin-remove} +2 -2
  9. data/lib/ronin/cacheable.rb +25 -4
  10. data/lib/ronin/code/reference.rb +0 -9
  11. data/lib/ronin/code/symbol_table.rb +5 -5
  12. data/lib/ronin/code/token.rb +1 -1
  13. data/lib/ronin/database/database.rb +3 -1
  14. data/lib/ronin/extensions/kernel.rb +25 -3
  15. data/lib/ronin/formatting/extensions/binary/file.rb +60 -0
  16. data/lib/ronin/formatting/extensions/text.rb +1 -0
  17. data/lib/ronin/formatting/extensions/text/array.rb +67 -0
  18. data/lib/ronin/model.rb +1 -40
  19. data/lib/ronin/{has_license.rb → model/has_description.rb} +16 -18
  20. data/lib/ronin/model/has_license.rb +53 -0
  21. data/lib/ronin/model/has_name.rb +49 -0
  22. data/lib/ronin/model/has_version.rb +46 -0
  23. data/lib/ronin/model/model.rb +64 -0
  24. data/lib/ronin/network/extensions/http/net.rb +580 -99
  25. data/lib/ronin/network/http.rb +54 -6
  26. data/lib/ronin/os.rb +7 -7
  27. data/lib/ronin/platform/extension.rb +4 -6
  28. data/lib/ronin/platform/maintainer.rb +1 -1
  29. data/lib/ronin/platform/object_cache.rb +10 -2
  30. data/lib/ronin/platform/overlay_cache.rb +1 -1
  31. data/lib/ronin/platform/platform.rb +5 -3
  32. data/lib/ronin/platform/ronin.rb +3 -3
  33. data/lib/ronin/scanners.rb +25 -0
  34. data/lib/ronin/scanners/exceptions.rb +24 -0
  35. data/lib/ronin/scanners/exceptions/unknown_category.rb +29 -0
  36. data/lib/ronin/scanners/scanner.rb +239 -0
  37. data/lib/ronin/sessions/http.rb +548 -7
  38. data/lib/ronin/{translators.rb → templates.rb} +1 -1
  39. data/lib/ronin/templates/erb.rb +56 -0
  40. data/lib/ronin/ui/command_line/command_line.rb +10 -1
  41. data/lib/ronin/ui/command_line/commands/{ls.rb → list.rb} +1 -1
  42. data/lib/ronin/ui/command_line/commands/{rm.rb → remove.rb} +1 -1
  43. data/lib/ronin/ui/command_line/commands/uninstall.rb +2 -2
  44. data/lib/ronin/ui/console.rb +66 -17
  45. data/lib/ronin/ui/shell.rb +16 -36
  46. data/lib/ronin/version.rb +1 -1
  47. data/spec/cacheable_spec.rb +1 -1
  48. data/spec/code/classes/thing.rb +4 -0
  49. data/spec/code/reference_spec.rb +4 -0
  50. data/spec/code/symbol_table_spec.rb +5 -1
  51. data/spec/extensions/kernel_spec.rb +45 -5
  52. data/spec/extensions/string_spec.rb +4 -0
  53. data/spec/formatting/binary/integer_spec.rb +3 -3
  54. data/spec/formatting/binary/string_spec.rb +5 -5
  55. data/spec/formatting/digest/string_spec.rb +5 -9
  56. data/spec/formatting/http/string_spec.rb +5 -9
  57. data/spec/formatting/text/array_spec.rb +64 -0
  58. data/spec/formatting/text/string_spec.rb +3 -3
  59. data/spec/model/classes/licensed_model.rb +12 -0
  60. data/spec/{has_license_spec.rb → model/has_license_spec.rb} +5 -5
  61. data/spec/network/http_spec.rb +197 -0
  62. data/spec/os_spec.rb +2 -5
  63. data/spec/platform/maintainer_spec.rb +30 -0
  64. data/spec/platform/ronin_spec.rb +2 -2
  65. data/spec/scanners/classes/another_scanner.rb +16 -0
  66. data/spec/scanners/classes/example_scanner.rb +22 -0
  67. data/spec/scanners/scanner_spec.rb +148 -0
  68. data/spec/spec_helper.rb +1 -1
  69. data/spec/templates/classes/uses_erb.rb +11 -0
  70. data/spec/templates/erb_spec.rb +20 -0
  71. data/static/ronin/platform/overlay.xsl +128 -49
  72. metadata +83 -30
  73. metadata.gz.sig +0 -0
  74. data/lib/ronin/translators/translator.rb +0 -75
  75. data/spec/classes/licensed_model.rb +0 -12
  76. data/spec/translators/translator_spec.rb +0 -61
data/spec/os_spec.rb CHANGED
@@ -3,14 +3,11 @@ require 'ronin/os'
3
3
  require 'helpers/database'
4
4
 
5
5
  describe OS do
6
- it "should require os and version attributes" do
6
+ it "should require a name" do
7
7
  @os = OS.new
8
8
  @os.should_not be_valid
9
9
 
10
10
  @os.name = 'test'
11
- @os.should_not be_valid
12
-
13
- @os.version = '0.0.1'
14
11
  @os.should be_valid
15
12
  end
16
13
 
@@ -19,6 +16,6 @@ describe OS do
19
16
  end
20
17
 
21
18
  it "should provide methods for creating OSes with versions" do
22
- OS.linux_version('2.6.11').should be_valid
19
+ OS.linux('2.6.11').should be_valid
23
20
  end
24
21
  end
@@ -0,0 +1,30 @@
1
+ require 'ronin/platform/maintainer'
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Platform::Maintainer do
6
+ before(:all) do
7
+ @named = Platform::Maintainer.new('anonymous')
8
+ @name_with_email = Platform::Maintainer.new('anonymous','anonymous@example.com')
9
+ end
10
+
11
+ describe "to_s" do
12
+ it "should return the name when their is no email" do
13
+ @named.to_s.should == 'anonymous'
14
+ end
15
+
16
+ it "should return the name and email when both are present" do
17
+ @name_with_email.to_s.should == 'anonymous <anonymous@example.com>'
18
+ end
19
+ end
20
+
21
+ describe "inspect" do
22
+ it "should return the name when their is no email" do
23
+ @named.inspect.should == '#<Ronin::Platform::Maintainer: anonymous>'
24
+ end
25
+
26
+ it "should return the name and email when both are present" do
27
+ @name_with_email.inspect.should == '#<Ronin::Platform::Maintainer: anonymous <anonymous@example.com>>'
28
+ end
29
+ end
30
+ end
@@ -21,7 +21,7 @@ describe Ronin do
21
21
  end
22
22
 
23
23
  it "should provide transparent access to extensions via methods" do
24
- ext = Ronin.hello
24
+ ext = hello
25
25
 
26
26
  ext.should_not be_nil
27
27
  ext.name.should == 'hello'
@@ -29,6 +29,6 @@ describe Ronin do
29
29
  end
30
30
 
31
31
  it "should raise NoMethodError when accessing missing extensions" do
32
- lambda { Ronin.nothing }.should raise_error(NoMethodError)
32
+ lambda { self.nothing }.should raise_error(NoMethodError)
33
33
  end
34
34
  end
@@ -0,0 +1,16 @@
1
+ require 'scanners/classes/example_scanner'
2
+
3
+ class AnotherScanner < ExampleScanner
4
+
5
+ scanner(:test1) do |target,results|
6
+ results.call(1)
7
+ end
8
+
9
+ scanner(:test3) do |target,results|
10
+ results.call(3)
11
+ end
12
+
13
+ scanner(:fail) do |target,results|
14
+ end
15
+
16
+ end
@@ -0,0 +1,22 @@
1
+ require 'ronin/scanners/scanner'
2
+
3
+ class ExampleScanner
4
+
5
+ include Ronin::Scanners::Scanner
6
+
7
+ scanner(:test1) do |target,results|
8
+ results.call(1)
9
+ end
10
+
11
+ scanner(:test2) do |target,results|
12
+ results.call(2)
13
+ end
14
+
15
+ scanner(:test2) do |target,results|
16
+ results.call(4)
17
+ end
18
+
19
+ scanner(:fail) do |target,results|
20
+ end
21
+
22
+ end
@@ -0,0 +1,148 @@
1
+ require 'ronin/scanners/scanner'
2
+
3
+ require 'spec_helper'
4
+ require 'scanners/classes/example_scanner'
5
+ require 'scanners/classes/another_scanner'
6
+
7
+ describe Scanners::Scanner do
8
+ before(:all) do
9
+ @example_scanner = ExampleScanner.new
10
+ @another_scanner = AnotherScanner.new
11
+ end
12
+
13
+ it "should register scanner tests with a class" do
14
+ ExampleScanner.scanners.should_not be_empty
15
+ end
16
+
17
+ it "should group multiple scanner tests into categories by name" do
18
+ ExampleScanner.scanners[:test2].length.should == 2
19
+ end
20
+
21
+ it "should separate scanner tests between inherited classes" do
22
+ ExampleScanner.scanners[:test1].length.should == 1
23
+ ExampleScanner.scanners[:fail].length.should == 1
24
+ ExampleScanner.scanners[:test3].should be_nil
25
+
26
+ AnotherScanner.scanners[:test1].length.should == 1
27
+ AnotherScanner.scanners[:test3].length.should == 1
28
+ AnotherScanner.scanners[:fail].length.should == 1
29
+ end
30
+
31
+ it "should specify if the scanner defines a certain category of tests" do
32
+ ExampleScanner.scans_for?(:test1).should == true
33
+ AnotherScanner.scans_for?(:test2).should == true
34
+ end
35
+
36
+ it "should return all scanner tests within a category" do
37
+ tests = ExampleScanner.scanners_in(:test2)
38
+
39
+ tests.length.should == 2
40
+ tests.all? { |test| test.kind_of?(Proc) }.should == true
41
+ end
42
+
43
+ it "should specify the category names of all tests" do
44
+ ExampleScanner.scans_for.should == Set[:test1, :test2, :fail]
45
+ AnotherScanner.scans_for.should == Set[:test1, :test2, :test3, :fail]
46
+ end
47
+
48
+ it "should scan each target and return the discovered results" do
49
+ @example_scanner.scan.should == {
50
+ :test1 => [1],
51
+ :test2 => [2, 4],
52
+ :fail => []
53
+ }
54
+
55
+ @another_scanner.scan.should == {
56
+ :test1 => [1, 1],
57
+ :test2 => [2, 4],
58
+ :test3 => [3],
59
+ :fail => []
60
+ }
61
+ end
62
+
63
+ it "should scan each target and pass back results" do
64
+ results = {:test1 => [1], :test2 => [2, 4]}
65
+
66
+ @example_scanner.scan do |category,result|
67
+ results.has_key?(category).should == true
68
+ results[category].include?(result).should == true
69
+ end
70
+ end
71
+
72
+ it "should allow for the scanning for specific categories" do
73
+ @example_scanner.scan(:test1 => true).should == {:test1 => [1]}
74
+
75
+ @another_scanner.scan(:test1 => true, :test3 => true).should == {
76
+ :test1 => [1, 1],
77
+ :test3 => [3]
78
+ }
79
+ end
80
+
81
+ it "should return an empty Array for a failed scan" do
82
+ @example_scanner.scan(:fail => true).should == {:fail => []}
83
+ end
84
+
85
+ it "should not scan a category if the category information is false" do
86
+ @example_scanner.scan(:test1 => false).should == {}
87
+ end
88
+
89
+ it "should not scan a category if the category information is nil" do
90
+ @example_scanner.scan(:test1 => nil).should == {}
91
+ end
92
+
93
+ it "should raise an UnknownCategory for unknown scan categories" do
94
+ lambda {
95
+ @example_scanner.scan(:test3 => true)
96
+ }.should raise_error(Scanners::UnknownCategory)
97
+ end
98
+
99
+ describe "convenience methods" do
100
+ describe "category scan" do
101
+ it "should define the convenience method" do
102
+ ExampleScanner.method_defined?(:test1_scan).should == true
103
+ end
104
+
105
+ it "should return an Array of results" do
106
+ @example_scanner.test1_scan.should == [1]
107
+ end
108
+
109
+ it "should pass back results if a block is given" do
110
+ @example_scanner.test1_scan do |result|
111
+ result.should == 1
112
+ end
113
+ end
114
+
115
+ it "should return an empty Array for failed scans" do
116
+ @example_scanner.fail_scan.should == []
117
+ end
118
+ end
119
+
120
+ describe "first result" do
121
+ it "should define the convenience method" do
122
+ ExampleScanner.method_defined?(:first_test1).should == true
123
+ end
124
+
125
+ it "should define the convenience method" do
126
+ @example_scanner.first_test2.should == 2
127
+ end
128
+
129
+ it "should return nil when there is no first result" do
130
+ @example_scanner.first_fail.should be_nil
131
+ end
132
+ end
133
+
134
+ describe "has results" do
135
+ it "should define the convenience method" do
136
+ ExampleScanner.method_defined?(:has_test1?).should == true
137
+ end
138
+
139
+ it "should return true if there was a first result" do
140
+ @example_scanner.has_test1?.should == true
141
+ end
142
+
143
+ it "should return false if a scan has no results" do
144
+ @example_scanner.has_fail?.should == false
145
+ end
146
+ end
147
+ end
148
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'rubygems'
2
- gem 'rspec', '>=1.1.3'
2
+ gem 'rspec', '>=1.1.12'
3
3
  require 'spec'
4
4
 
5
5
  require 'ronin/version'
@@ -0,0 +1,11 @@
1
+ require 'ronin/templates/erb'
2
+
3
+ class UsesErb
4
+
5
+ include Ronin::Templates::Erb
6
+
7
+ attr_accessor :x
8
+
9
+ attr_accessor :y
10
+
11
+ end
@@ -0,0 +1,20 @@
1
+ require 'ronin/templates/erb'
2
+
3
+ require 'spec_helper'
4
+ require 'templates/classes/uses_erb'
5
+
6
+ describe Templates::Erb do
7
+ before(:all) do
8
+ @uses_erb= UsesErb.new
9
+ @uses_erb.x = 2
10
+ @uses_erb.y = 3
11
+ end
12
+
13
+ it "should render inline ERB templates" do
14
+ @uses_erb.erb(%{<%= 'hello' %>}).should == 'hello'
15
+ end
16
+
17
+ it "should render ERB templates using the binding of the object" do
18
+ @uses_erb.erb(%{<%= @x %> <%= @y %>}).should == '2 3'
19
+ end
20
+ end
@@ -5,19 +5,42 @@
5
5
  <xsl:template match="/ronin-overlay">
6
6
  <html>
7
7
  <head>
8
- <title>Ronin Overlay :: <xsl:value-of select="/ronin-overlay/name/." /></title>
8
+ <title>Ronin Overlay :: <xsl:value-of select="/ronin-overlay/title/." /></title>
9
9
  <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
10
10
  <style type="text/css">
11
11
  body {
12
+ font-family: sans-serif;
13
+ font-size: 0.9em;
14
+ margin: 0;
15
+ padding: 0;
12
16
  }
13
17
 
14
18
  #overlay {
15
- margin: 0.5em;
16
- padding: 0.2em;
19
+ margin: 1em;
20
+ padding: 1em;
17
21
  border: 20px solid black;
18
22
  }
19
23
 
20
- #overlay-name {
24
+ #overlay p {
25
+ margin: 0.125em;
26
+ padding: 0;
27
+ }
28
+
29
+ #overlay strong {
30
+ margin-right: 1em;
31
+ }
32
+
33
+ #overlay a {
34
+ color: black;
35
+ font-weight: bold;
36
+ text-decoration: none;
37
+ }
38
+
39
+ #overlay a:hover {
40
+ color: #BD0000;
41
+ }
42
+
43
+ #overlay-title {
21
44
  }
22
45
 
23
46
  #overlay-license {
@@ -28,76 +51,132 @@
28
51
 
29
52
  #overlay-description {
30
53
  }
54
+ </style>
55
+ <style type="text/css" media="print">
56
+ #overlay {
57
+ border: none;
58
+ }
31
59
 
32
- #overlay-description blockquote {
60
+ #overlay a {
61
+ font-weight: normal;
33
62
  }
34
63
  </style>
35
- <script type="text/javascript" src="http://ronin.rubyforge.org/scripts/jquery.min.js"></script>
36
- <script type="text/javascript" src="http://ronin.rubyforge.org/scripts/jquery.expander.js"></script>
37
- <script type="text/javascript">
38
- $(document).ready(function() {
39
- $("#overlay-description/blockquote").expander({
40
- expandText: '[ more ]',
41
- userCollapseText: '[ less ]'
42
- });
43
- });
44
- </script>
45
64
  </head>
46
65
 
47
66
  <body>
48
- <div id="overlay">
67
+ <table id="overlay">
49
68
  <xsl:apply-templates />
50
- </div>
69
+ </table>
51
70
  </body>
52
71
  </html>
53
72
  </xsl:template>
54
73
 
55
- <xsl:template match="/ronin-overlay/name">
56
- <p id="overlay-name">
57
- <strong>Name:</strong> <xsl:value-of select="." />
58
- </p>
74
+ <xsl:template match="/ronin-overlay/title">
75
+ <tr id="overlay-title">
76
+ <td valign="top">
77
+ <p><strong>Title:</strong></p>
78
+ </td>
79
+ <td valign="top">
80
+ <p><xsl:value-of select="." /></p>
81
+ </td>
82
+ </tr>
59
83
  </xsl:template>
60
84
 
61
85
  <xsl:template match="/ronin-overlay/license">
62
- <p id="overlay-license">
63
- <strong>License:</strong> <xsl:value-of select="." />
64
- </p>
86
+ <tr id="overlay-license">
87
+ <td valign="top">
88
+ <p><strong>License:</strong></p>
89
+ </td>
90
+ <td valign="top">
91
+ <p><xsl:value-of select="." /></p>
92
+ </td>
93
+ </tr>
65
94
  </xsl:template>
66
95
 
67
96
  <xsl:template match="/ronin-overlay/source">
68
- <p id="overlay-source">
69
- <strong>Source:</strong>
70
- <a>
71
- <xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
72
- <xsl:value-of select=".">
73
- </a>
74
- </p>
97
+ <tr id="overlay-source">
98
+ <td valign="top">
99
+ <p><strong>Source:</strong></p>
100
+ </td>
101
+ <td valign="top">
102
+ <p>
103
+ <a>
104
+ <xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
105
+ <xsl:value-of select="." />
106
+ </a>
107
+ </p>
108
+ </td>
109
+ </tr>
75
110
  </xsl:template>
76
111
 
77
- <xsl:template match="/ronin-overlay/source-browse">
78
- <p id="overlay-source-browse">
79
- <strong>Source Browser:</strong>
80
- <a>
81
- <xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
82
- <xsl:value-of select=".">
83
- </a>
84
- </p>
112
+ <xsl:template match="/ronin-overlay/source-view">
113
+ <tr id="overlay-source-view">
114
+ <td valign="top">
115
+ <p><strong>View Source:</strong></p>
116
+ </td>
117
+ <td valign="top">
118
+ <p>
119
+ <a>
120
+ <xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
121
+ <xsl:value-of select="." />
122
+ </a>
123
+ </p>
124
+ </td>
125
+ </tr>
85
126
  </xsl:template>
86
127
 
87
128
  <xsl:template match="/ronin-overlay/website">
88
- <p id="overlay-website">
89
- <strong>Website:</strong>
90
- <a>
91
- <xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
92
- <xsl:value-of select=".">
93
- </a>
129
+ <tr id="overlay-website">
130
+ <td valign="top">
131
+ <p><strong>Website:</strong></p>
132
+ </td>
133
+ <td valign="top">
134
+ <p>
135
+ <a>
136
+ <xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
137
+ <xsl:value-of select="." />
138
+ </a>
139
+ </p>
140
+ </td>
141
+ </tr>
142
+ </xsl:template>
143
+
144
+ <xsl:template match="/ronin-overlay/maintainers">
145
+ <tr id="overlay-maintainers">
146
+ <td valign="top">
147
+ <p><strong>Maintainers:</strong></p>
148
+ </td>
149
+ <td valign="top">
150
+ <xsl:apply-templates />
151
+ </td>
152
+ </tr>
153
+ </xsl:template>
154
+
155
+ <xsl:template match="/ronin-overlay/maintainers/maintainer">
156
+ <p class="maintainer">
157
+ <xsl:choose>
158
+ <xsl:when test="email">
159
+ <a>
160
+ <xsl:attribute name="href">mailto:<xsl:value-of select="email/." /></xsl:attribute>
161
+ <xsl:value-of select="name/." />
162
+ </a>
163
+ </xsl:when>
164
+
165
+ <xsl:otherwise>
166
+ <strong><xsl:value-of select="name/." /></strong>
167
+ </xsl:otherwise>
168
+ </xsl:choose>
94
169
  </p>
95
170
  </xsl:template>
96
171
 
97
172
  <xsl:template match="/ronin-overlay/description">
98
- <div id="overlay-description">
99
- <p><strong>Description:</strong></p>
100
- <blockquote><xsl:value-of select="." /></blockquote>
101
- </div>
173
+ <tr id="overlay-description">
174
+ <td valign="top">
175
+ <p><strong>Description:</strong></p>
176
+ </td>
177
+ <td valign="top">
178
+ <p><xsl:value-of select="." /></p>
179
+ </td>
180
+ </tr>
102
181
  </xsl:template>
103
182
  </xsl:stylesheet>