ronin 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +95 -0
- data/Manifest.txt +55 -25
- data/README.txt +64 -52
- data/Rakefile +21 -14
- data/bin/ronin +1 -1
- data/bin/ronin-add +1 -1
- data/bin/ronin-console +1 -1
- data/bin/ronin-help +1 -1
- data/bin/ronin-install +1 -1
- data/bin/ronin-list +1 -1
- data/bin/ronin-remove +1 -1
- data/bin/ronin-uninstall +1 -1
- data/bin/ronin-update +1 -1
- data/lib/ronin.rb +2 -4
- data/lib/ronin/arch.rb +66 -21
- data/lib/ronin/author.rb +27 -18
- data/lib/ronin/cacheable.rb +63 -23
- data/lib/ronin/code/emittable.rb +1 -4
- data/lib/ronin/code/reference.rb +2 -5
- data/lib/ronin/code/symbol_table.rb +1 -4
- data/lib/ronin/code/token.rb +1 -4
- data/lib/ronin/config.rb +31 -10
- data/lib/ronin/database.rb +1 -4
- data/lib/ronin/database/database.rb +42 -23
- data/lib/ronin/database/exceptions.rb +1 -4
- data/lib/ronin/database/exceptions/invalid_config.rb +1 -4
- data/lib/ronin/environment.rb +1 -5
- data/lib/ronin/extensions.rb +1 -5
- data/lib/ronin/extensions/array.rb +8 -6
- data/lib/ronin/extensions/file.rb +9 -4
- data/lib/ronin/extensions/ip_addr.rb +33 -13
- data/lib/ronin/extensions/kernel.rb +44 -9
- data/lib/ronin/extensions/meta.rb +1 -4
- data/lib/ronin/extensions/string.rb +8 -7
- data/lib/ronin/extensions/uri.rb +1 -4
- data/lib/ronin/extensions/uri/http.rb +1 -48
- data/lib/ronin/extensions/uri/query_params.rb +27 -8
- data/lib/ronin/formatting.rb +1 -4
- data/lib/ronin/formatting/binary.rb +1 -4
- data/lib/ronin/formatting/digest.rb +1 -4
- data/lib/ronin/formatting/extensions.rb +1 -4
- data/lib/ronin/formatting/extensions/binary.rb +1 -4
- data/lib/ronin/formatting/extensions/binary/file.rb +3 -28
- data/lib/ronin/formatting/extensions/binary/integer.rb +31 -12
- data/lib/ronin/formatting/extensions/binary/string.rb +59 -36
- data/lib/ronin/formatting/extensions/digest.rb +1 -4
- data/lib/ronin/formatting/extensions/digest/string.rb +31 -9
- data/lib/ronin/formatting/extensions/http.rb +1 -4
- data/lib/ronin/formatting/extensions/http/string.rb +16 -9
- data/lib/ronin/formatting/extensions/text.rb +1 -4
- data/lib/ronin/formatting/extensions/text/array.rb +17 -7
- data/lib/ronin/formatting/extensions/text/string.rb +70 -27
- data/lib/ronin/formatting/http.rb +1 -4
- data/lib/ronin/formatting/text.rb +1 -4
- data/lib/ronin/license.rb +72 -65
- data/lib/ronin/model.rb +1 -4
- data/lib/ronin/model/has_description.rb +37 -8
- data/lib/ronin/model/has_license.rb +12 -8
- data/lib/ronin/model/has_name.rb +10 -7
- data/lib/ronin/model/has_version.rb +14 -4
- data/lib/ronin/model/model.rb +71 -14
- data/lib/ronin/network.rb +1 -4
- data/lib/ronin/network/esmtp.rb +1 -4
- data/lib/ronin/network/extensions.rb +1 -4
- data/lib/ronin/network/extensions/esmtp.rb +1 -4
- data/lib/ronin/network/extensions/esmtp/net.rb +49 -21
- data/lib/ronin/network/extensions/http.rb +1 -4
- data/lib/ronin/network/extensions/http/net.rb +319 -531
- data/lib/ronin/network/extensions/imap.rb +1 -4
- data/lib/ronin/network/extensions/imap/net.rb +50 -23
- data/lib/ronin/network/extensions/pop3.rb +1 -4
- data/lib/ronin/network/extensions/pop3/net.rb +40 -17
- data/lib/ronin/network/extensions/smtp.rb +1 -4
- data/lib/ronin/network/extensions/smtp/net.rb +49 -21
- data/lib/ronin/network/extensions/tcp.rb +1 -4
- data/lib/ronin/network/extensions/tcp/net.rb +234 -31
- data/lib/ronin/network/extensions/telnet.rb +1 -4
- data/lib/ronin/network/extensions/telnet/net.rb +83 -51
- data/lib/ronin/network/extensions/udp.rb +1 -4
- data/lib/ronin/network/extensions/udp/net.rb +164 -27
- data/lib/ronin/{sessions.rb → network/helpers.rb} +10 -13
- data/lib/ronin/network/helpers/esmtp.rb +129 -0
- data/lib/ronin/{sessions/session.rb → network/helpers/helper.rb} +25 -17
- data/lib/ronin/network/helpers/http.rb +444 -0
- data/lib/ronin/network/helpers/imap.rb +115 -0
- data/lib/ronin/network/helpers/pop3.rb +110 -0
- data/lib/ronin/network/helpers/smtp.rb +123 -0
- data/lib/ronin/network/helpers/tcp.rb +309 -0
- data/lib/ronin/network/helpers/telnet.rb +158 -0
- data/lib/ronin/network/helpers/udp.rb +197 -0
- data/lib/ronin/network/http.rb +3 -156
- data/lib/ronin/network/http/exceptions.rb +1 -4
- data/lib/ronin/network/http/exceptions/unknown_request.rb +1 -4
- data/lib/ronin/network/http/http.rb +214 -0
- data/lib/ronin/network/http/proxy.rb +308 -0
- data/lib/ronin/network/imap.rb +7 -6
- data/lib/ronin/network/pop3.rb +7 -6
- data/lib/ronin/network/smtp.rb +1 -4
- data/lib/ronin/network/smtp/email.rb +34 -18
- data/lib/ronin/network/smtp/smtp.rb +19 -7
- data/lib/ronin/network/tcp.rb +1 -4
- data/lib/ronin/network/telnet.rb +25 -12
- data/lib/ronin/network/udp.rb +1 -4
- data/lib/ronin/os.rb +43 -21
- data/lib/ronin/path.rb +29 -9
- data/lib/ronin/platform.rb +1 -4
- data/lib/ronin/platform/exceptions.rb +1 -4
- data/lib/ronin/platform/exceptions/extension_not_found.rb +1 -4
- data/lib/ronin/platform/exceptions/overlay_cached.rb +1 -4
- data/lib/ronin/platform/exceptions/overlay_not_found.rb +1 -4
- data/lib/ronin/platform/extension.rb +195 -52
- data/lib/ronin/platform/extension_cache.rb +60 -24
- data/lib/ronin/platform/maintainer.rb +15 -8
- data/lib/ronin/platform/object_cache.rb +29 -8
- data/lib/ronin/platform/overlay.rb +82 -26
- data/lib/ronin/platform/overlay_cache.rb +179 -56
- data/lib/ronin/platform/platform.rb +154 -58
- data/lib/ronin/platform/ronin.rb +38 -11
- data/lib/ronin/product.rb +17 -17
- data/lib/ronin/rpc.rb +1 -4
- data/lib/ronin/rpc/call.rb +1 -4
- data/lib/ronin/rpc/client.rb +1 -4
- data/lib/ronin/rpc/console.rb +1 -4
- data/lib/ronin/rpc/exceptions.rb +1 -4
- data/lib/ronin/rpc/exceptions/not_implemented.rb +1 -4
- data/lib/ronin/rpc/exceptions/response_missing.rb +1 -4
- data/lib/ronin/rpc/response.rb +1 -4
- data/lib/ronin/rpc/service.rb +1 -4
- data/lib/ronin/rpc/shell.rb +1 -4
- data/lib/ronin/scanners.rb +1 -4
- data/lib/ronin/scanners/exceptions.rb +1 -4
- data/lib/ronin/scanners/exceptions/unknown_category.rb +1 -4
- data/lib/ronin/scanners/scanner.rb +82 -26
- data/lib/ronin/static.rb +1 -4
- data/lib/ronin/static/finders.rb +1 -4
- data/lib/ronin/static/static.rb +16 -7
- data/lib/ronin/templates.rb +2 -4
- data/lib/ronin/templates/erb.rb +24 -10
- data/lib/ronin/templates/template.rb +130 -0
- data/lib/ronin/ui.rb +2 -6
- data/lib/ronin/ui/command_line.rb +1 -4
- data/lib/ronin/ui/command_line/command.rb +137 -68
- data/lib/ronin/ui/command_line/command_line.rb +52 -29
- data/lib/ronin/ui/command_line/commands/add.rb +39 -67
- data/lib/ronin/ui/command_line/commands/console.rb +23 -27
- data/lib/ronin/ui/command_line/commands/help.rb +10 -29
- data/lib/ronin/ui/command_line/commands/install.rb +31 -56
- data/lib/ronin/ui/command_line/commands/list.rb +34 -52
- data/lib/ronin/ui/command_line/commands/remove.rb +12 -32
- data/lib/ronin/ui/command_line/commands/uninstall.rb +11 -31
- data/lib/ronin/ui/command_line/commands/update.rb +15 -35
- data/lib/ronin/ui/command_line/exceptions.rb +1 -4
- data/lib/ronin/ui/command_line/exceptions/unknown_command.rb +1 -4
- data/lib/ronin/ui/console.rb +54 -23
- data/lib/ronin/ui/hexdump.rb +1 -4
- data/lib/ronin/ui/hexdump/extensions.rb +1 -4
- data/lib/ronin/ui/hexdump/extensions/file.rb +8 -6
- data/lib/ronin/ui/hexdump/extensions/kernel.rb +4 -5
- data/lib/ronin/ui/hexdump/hexdump.rb +8 -5
- data/lib/ronin/{sessions/exceptions.rb → ui/output.rb} +3 -5
- data/lib/ronin/ui/output/handler.rb +121 -0
- data/lib/ronin/ui/output/helpers.rb +110 -0
- data/lib/ronin/ui/output/output.rb +144 -0
- data/lib/ronin/ui/shell.rb +38 -12
- data/lib/ronin/version.rb +2 -5
- data/lib/ronin/{sessions/exceptions/variable_missing.rb → yard.rb} +2 -10
- data/lib/ronin/{ronin.rb → yard/handlers.rb} +5 -15
- data/lib/ronin/yard/handlers/ruby.rb +27 -0
- data/lib/ronin/yard/handlers/ruby/base.rb +27 -0
- data/lib/ronin/yard/handlers/ruby/belongs_to_handler.rb +45 -0
- data/lib/ronin/yard/handlers/ruby/eval_block_handler.rb +18 -0
- data/lib/ronin/yard/handlers/ruby/has_handler.rb +49 -0
- data/lib/ronin/yard/handlers/ruby/legacy.rb +26 -0
- data/lib/ronin/yard/handlers/ruby/legacy/belongs_to_handler.rb +41 -0
- data/lib/ronin/yard/handlers/ruby/legacy/eval_block_handler.rb +19 -0
- data/lib/ronin/yard/handlers/ruby/legacy/has_handler.rb +34 -0
- data/lib/ronin/yard/handlers/ruby/legacy/metaclass_eval_handler.rb +21 -0
- data/lib/ronin/yard/handlers/ruby/legacy/property_handler.rb +41 -0
- data/lib/ronin/yard/handlers/ruby/legacy/scanner_handler.rb +61 -0
- data/lib/ronin/yard/handlers/ruby/metaclass_eval_handler.rb +18 -0
- data/lib/ronin/yard/handlers/ruby/property_handler.rb +45 -0
- data/lib/ronin/yard/handlers/ruby/scanner_handler.rb +66 -0
- data/spec/author_spec.rb +3 -3
- data/spec/extensions/classes/some_class.rb +2 -0
- data/spec/extensions/kernel_spec.rb +17 -0
- data/spec/extensions/uri/http_spec.rb +0 -31
- data/spec/formatting/binary/integer_spec.rb +4 -0
- data/spec/formatting/text/string_spec.rb +96 -0
- data/spec/license_spec.rb +6 -6
- data/spec/model/classes/basic_model.rb +13 -0
- data/spec/model/classes/custom_model.rb +17 -0
- data/spec/model/classes/described_model.rb +10 -0
- data/spec/model/has_description_spec.rb +42 -0
- data/spec/model/has_license_spec.rb +18 -4
- data/spec/model/model_spec.rb +68 -0
- data/spec/network/helpers/classes/test_helper.rb +11 -0
- data/spec/network/helpers/classes/uses_test_helper.rb +10 -0
- data/spec/network/helpers/helper_spec.rb +25 -0
- data/spec/network/{http_spec.rb → http/http_spec.rb} +0 -0
- data/spec/network/http/proxy_spec.rb +116 -0
- data/spec/os_spec.rb +4 -4
- data/spec/platform/extension_cache_spec.rb +14 -0
- data/spec/platform/extension_spec.rb +11 -0
- data/spec/platform/platform_spec.rb +8 -0
- data/spec/product_spec.rb +9 -9
- data/spec/spec_helper.rb +1 -1
- data/spec/templates/classes/{uses_erb.rb → example_erb.rb} +1 -1
- data/spec/templates/classes/example_template.rb +21 -0
- data/spec/templates/erb_spec.rb +2 -2
- data/spec/templates/helpers/static.rb +5 -0
- data/spec/templates/helpers/static/templates/_relative.erb +1 -0
- data/spec/templates/helpers/static/templates/example.erb +1 -0
- data/spec/templates/template_spec.rb +41 -0
- data/spec/ui/command_line/classes/test_command.rb +23 -0
- data/spec/ui/command_line/command_spec.rb +31 -0
- data/spec/ui/output_spec.rb +29 -0
- data/static/ronin/platform/overlay.xsl +135 -114
- data/tasks/spec.rb +1 -0
- data/tasks/yard.rb +18 -0
- metadata +98 -59
- metadata.gz.sig +0 -0
- data/TODO.txt +0 -15
- data/lib/ronin/extensions/hash.rb +0 -62
- data/lib/ronin/sessions/esmtp.rb +0 -57
- data/lib/ronin/sessions/http.rb +0 -678
- data/lib/ronin/sessions/imap.rb +0 -54
- data/lib/ronin/sessions/pop3.rb +0 -52
- data/lib/ronin/sessions/smtp.rb +0 -57
- data/lib/ronin/sessions/tcp.rb +0 -100
- data/lib/ronin/sessions/telnet.rb +0 -55
- data/lib/ronin/sessions/udp.rb +0 -73
- data/lib/ronin/ui/command_line/options.rb +0 -136
- data/lib/ronin/ui/diagnostics.rb +0 -66
- data/lib/ronin/ui/verbose.rb +0 -58
- data/spec/extensions/hash_spec.rb +0 -38
- data/spec/sessions/classes/test_session.rb +0 -11
- data/spec/sessions/classes/uses_test_session.rb +0 -10
- data/spec/sessions/session_spec.rb +0 -25
- data/spec/ui/verbose_spec.rb +0 -17
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'yard/handlers/ruby/legacy/base'
|
2
|
+
|
3
|
+
module YARD
|
4
|
+
module Handlers
|
5
|
+
module Ruby
|
6
|
+
module Legacy
|
7
|
+
class MetaclassEvalHandler < Base
|
8
|
+
|
9
|
+
handles /(\A|\.)metaclass_eval(\s+|\()/
|
10
|
+
|
11
|
+
def process
|
12
|
+
if statement.block
|
13
|
+
parse_block(:namespace => namespace, :scope => :class)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'yard'
|
2
|
+
|
3
|
+
module YARD
|
4
|
+
module Handlers
|
5
|
+
module Ruby
|
6
|
+
module Legacy
|
7
|
+
class PropertyHandler < Base
|
8
|
+
|
9
|
+
handles /\Aproperty\s/
|
10
|
+
|
11
|
+
def process
|
12
|
+
nobj = namespace
|
13
|
+
mscope = scope
|
14
|
+
name = statement.tokens[2,1].to_s[1..-1]
|
15
|
+
|
16
|
+
register MethodObject.new(nobj, name, :class) do |o|
|
17
|
+
o.visibility = :public
|
18
|
+
o.source = statement.source
|
19
|
+
o.signature = "def #{nobj}.#{name}(repository=nil)"
|
20
|
+
o.parameters = [['repository', 'nil']]
|
21
|
+
end
|
22
|
+
|
23
|
+
register MethodObject.new(nobj, name, mscope) do |o|
|
24
|
+
o.visibility = :public
|
25
|
+
o.source = statement.source
|
26
|
+
o.signature = "def #{name}"
|
27
|
+
end
|
28
|
+
|
29
|
+
register MethodObject.new(nobj, "#{name}=", mscope) do |o|
|
30
|
+
o.visibility = :public
|
31
|
+
o.source = statement.source
|
32
|
+
o.signature = "def #{name}=(value)"
|
33
|
+
o.parameters = [['value', nil]]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
#
|
2
|
+
# Ronin - A Ruby platform for exploit development and security research.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'yard'
|
22
|
+
|
23
|
+
module YARD
|
24
|
+
module Handlers
|
25
|
+
module Ruby
|
26
|
+
module Legacy
|
27
|
+
class ScannerHandler < Base
|
28
|
+
|
29
|
+
handles /\Ascanner(\s+|\()/
|
30
|
+
|
31
|
+
def process
|
32
|
+
nobj = namespace
|
33
|
+
mscope = scope
|
34
|
+
name = statement.tokens[2,1].to_s[1..-1]
|
35
|
+
|
36
|
+
register MethodObject.new(nobj, "first_#{name}", mscope) do |o|
|
37
|
+
o.visibility = :public
|
38
|
+
o.source = statement.source
|
39
|
+
o.signature = "def first_#{name}(options=true)"
|
40
|
+
o.parameters = [['options', 'true']]
|
41
|
+
end
|
42
|
+
|
43
|
+
register MethodObject.new(nobj, "has_#{name}?", mscope) do |o|
|
44
|
+
o.visibility = :public
|
45
|
+
o.source = statement.source
|
46
|
+
o.signature = "def has_#{name}?(options=true)"
|
47
|
+
o.parameters = [['options', 'true']]
|
48
|
+
end
|
49
|
+
|
50
|
+
register MethodObject.new(nobj, "#{name}_scan", mscope) do |o|
|
51
|
+
o.visibility = :public
|
52
|
+
o.source = statement.source
|
53
|
+
o.signature = "def #{name}_scan(options=true,&block)"
|
54
|
+
o.parameters = [['options', 'true'], ['&block', nil]]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'yard'
|
2
|
+
|
3
|
+
module YARD
|
4
|
+
module Handlers
|
5
|
+
module Ruby
|
6
|
+
class MetaclassEvalHandler < YARD::Handlers::Ruby::Base
|
7
|
+
|
8
|
+
handles method_call(:metaclass_eval)
|
9
|
+
|
10
|
+
def process
|
11
|
+
if (block = statement.jump(:brace_block, :do_block).last)
|
12
|
+
parse_block(block, :namespace => namespace, :scope => :class)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'yard'
|
2
|
+
|
3
|
+
require 'ronin/yard/handlers/ruby/base'
|
4
|
+
|
5
|
+
module YARD
|
6
|
+
module Handlers
|
7
|
+
module Ruby
|
8
|
+
class PropertyHandler < Base
|
9
|
+
|
10
|
+
handles method_call(:property)
|
11
|
+
|
12
|
+
def process
|
13
|
+
nobj = effected_namespace
|
14
|
+
mscope = scope
|
15
|
+
name = statement.parameters[0].last
|
16
|
+
|
17
|
+
if name.type == :symbol
|
18
|
+
name = name.source[1..-1]
|
19
|
+
|
20
|
+
register MethodObject.new(nobj, name, :class) do |o|
|
21
|
+
o.visibility = :public
|
22
|
+
o.source = statement.source
|
23
|
+
o.signature = "def #{nobj}.#{name}(repository=nil)"
|
24
|
+
o.parameters = [['repository', 'nil']]
|
25
|
+
end
|
26
|
+
|
27
|
+
register MethodObject.new(nobj, name, mscope) do |o|
|
28
|
+
o.visibility = :public
|
29
|
+
o.source = statement.source
|
30
|
+
o.signature = "def #{name}"
|
31
|
+
end
|
32
|
+
|
33
|
+
register MethodObject.new(nobj, "#{name}=", mscope) do |o|
|
34
|
+
o.visibility = :public
|
35
|
+
o.source = statement.source
|
36
|
+
o.signature = "def #{name}=(value)"
|
37
|
+
o.parameters = [['value', nil]]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#
|
2
|
+
# Ronin - A Ruby platform for exploit development and security research.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'yard'
|
22
|
+
|
23
|
+
module YARD
|
24
|
+
module Handlers
|
25
|
+
module Ruby
|
26
|
+
class ScannerHandler < Base
|
27
|
+
|
28
|
+
handles method_call(:scanner)
|
29
|
+
|
30
|
+
def process
|
31
|
+
obj = statement.parameters(false).first
|
32
|
+
nobj = namespace
|
33
|
+
mscope = scope
|
34
|
+
name = case obj.type
|
35
|
+
when :symbol_literal
|
36
|
+
obj.jump(:ident, :op, :kw, :const).source
|
37
|
+
when :string_literal
|
38
|
+
obj.jump(:string_content).source
|
39
|
+
end
|
40
|
+
|
41
|
+
register MethodObject.new(nobj, "first_#{name}", mscope) do |o|
|
42
|
+
o.visibility = :public
|
43
|
+
o.source = statement.source
|
44
|
+
o.signature = "def first_#{name}(options=true)"
|
45
|
+
o.parameters = [['options', 'true']]
|
46
|
+
end
|
47
|
+
|
48
|
+
register MethodObject.new(nobj, "has_#{name}?", mscope) do |o|
|
49
|
+
o.visibility = :public
|
50
|
+
o.source = statement.source
|
51
|
+
o.signature = "def has_#{name}?(options=true)"
|
52
|
+
o.parameters = [['options', 'true']]
|
53
|
+
end
|
54
|
+
|
55
|
+
register MethodObject.new(nobj, "#{name}_scan", mscope) do |o|
|
56
|
+
o.visibility = :public
|
57
|
+
o.source = statement.source
|
58
|
+
o.signature = "def #{name}_scan(options=true,&block)"
|
59
|
+
o.parameters = [['options', 'true'], ['&block', nil]]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/spec/author_spec.rb
CHANGED
@@ -3,8 +3,8 @@ require 'ronin/author'
|
|
3
3
|
require 'helpers/database'
|
4
4
|
|
5
5
|
describe Author do
|
6
|
-
it "should have a
|
7
|
-
|
8
|
-
|
6
|
+
it "should have a String representation" do
|
7
|
+
author = Author.new(:name => 'test')
|
8
|
+
author.to_s.should == 'test'
|
9
9
|
end
|
10
10
|
end
|
@@ -56,4 +56,21 @@ describe Kernel do
|
|
56
56
|
}.should_not raise_error(StandardError)
|
57
57
|
end
|
58
58
|
end
|
59
|
+
|
60
|
+
describe "require_within" do
|
61
|
+
it "should require paths from within a directory" do
|
62
|
+
Object.const_defined?('SomeClass').should_not == true
|
63
|
+
|
64
|
+
require_within 'extensions/classes', 'some_class'
|
65
|
+
|
66
|
+
Object.const_defined?('SomeClass').should == true
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should prevent directory traversal" do
|
70
|
+
lambda {
|
71
|
+
require_within 'extensions/classes',
|
72
|
+
File.join('..','classes','some_class')
|
73
|
+
}.should raise_error(LoadError)
|
74
|
+
end
|
75
|
+
end
|
59
76
|
end
|
@@ -6,35 +6,4 @@ describe URI::HTTP do
|
|
6
6
|
it "should include QueryParams" do
|
7
7
|
URI::HTTP.include?(URI::QueryParams).should == true
|
8
8
|
end
|
9
|
-
|
10
|
-
it "should have explodable query params" do
|
11
|
-
@url = URI('http://search.dhgate.com/search.do?dkp=1&searchkey=yarn&catalog=')
|
12
|
-
|
13
|
-
@urls = @url.explode_query_params('x')
|
14
|
-
@urls.each do |param,new_url|
|
15
|
-
new_url.query_params[param].should == 'x'
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should only explode query params with specified params" do
|
20
|
-
@params = ['dkp', 'catalog']
|
21
|
-
@url = URI('http://search.dhgate.com/search.do?dkp=1&searchkey=yarn&catalog=')
|
22
|
-
|
23
|
-
@urls = @url.explode_query_params('x', :included => @params)
|
24
|
-
@urls.each do |param,new_url|
|
25
|
-
@params.include?(param).should == true
|
26
|
-
new_url.query_params[param].should == 'x'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should not explode query params with certain params" do
|
31
|
-
@params = ['searchkey']
|
32
|
-
@url = URI('http://search.dhgate.com/search.do?dkp=1&searchkey=yarn&catalog=')
|
33
|
-
|
34
|
-
@urls = @url.explode_query_params('x', :excluded => @params)
|
35
|
-
@urls.each do |param,new_url|
|
36
|
-
@params.include?(param).should == false
|
37
|
-
new_url.query_params[param].should == 'x'
|
38
|
-
end
|
39
|
-
end
|
40
9
|
end
|
@@ -25,6 +25,54 @@ describe String do
|
|
25
25
|
"_#{c}"
|
26
26
|
}.should == "_h_e_l_l_o"
|
27
27
|
end
|
28
|
+
|
29
|
+
it "should format specific bytes in a String" do
|
30
|
+
@string.format_chars(:included => [104, 108]) { |c|
|
31
|
+
c.upcase
|
32
|
+
}.should == 'HeLLo'
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should not format specific bytes in a String" do
|
36
|
+
@string.format_chars(:excluded => [101, 111]) { |c|
|
37
|
+
c.upcase
|
38
|
+
}.should == 'HeLLo'
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should format ranges of bytes in a String" do
|
42
|
+
@string.format_chars(:included => (104..108)) { |c|
|
43
|
+
c.upcase
|
44
|
+
}.should == 'HeLLo'
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should not format ranges of bytes in a String" do
|
48
|
+
@string.format_chars(:excluded => (104..108)) { |c|
|
49
|
+
c.upcase
|
50
|
+
}.should == 'hEllO'
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should format specific chars in a String" do
|
54
|
+
@string.format_chars(:included => ['h', 'l']) { |c|
|
55
|
+
c.upcase
|
56
|
+
}.should == 'HeLLo'
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should not format specific bytes in a String" do
|
60
|
+
@string.format_chars(:excluded => ['e', 'o']) { |c|
|
61
|
+
c.upcase
|
62
|
+
}.should == 'HeLLo'
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should format ranges of chars in a String" do
|
66
|
+
@string.format_chars(:included => ('h'..'l')) { |c|
|
67
|
+
c.upcase
|
68
|
+
}.should == 'HeLLo'
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should not format ranges of chars in a String" do
|
72
|
+
@string.format_chars(:excluded => ('h'..'l')) { |c|
|
73
|
+
c.upcase
|
74
|
+
}.should == 'hEllO'
|
75
|
+
end
|
28
76
|
end
|
29
77
|
|
30
78
|
describe "format_bytes" do
|
@@ -33,6 +81,54 @@ describe String do
|
|
33
81
|
sprintf("%%%x",b)
|
34
82
|
}.should == "%68%65%6c%6c%6f"
|
35
83
|
end
|
84
|
+
|
85
|
+
it "should format specific bytes in a String" do
|
86
|
+
@string.format_bytes(:included => [104, 108]) { |b|
|
87
|
+
b - 32
|
88
|
+
}.should == 'HeLLo'
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should not format specific bytes in a String" do
|
92
|
+
@string.format_bytes(:excluded => [101, 111]) { |b|
|
93
|
+
b - 32
|
94
|
+
}.should == 'HeLLo'
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should format ranges of bytes in a String" do
|
98
|
+
@string.format_bytes(:included => (104..108)) { |b|
|
99
|
+
b - 32
|
100
|
+
}.should == 'HeLLo'
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should not format ranges of bytes in a String" do
|
104
|
+
@string.format_bytes(:excluded => (104..108)) { |b|
|
105
|
+
b - 32
|
106
|
+
}.should == 'hEllO'
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should format specific chars in a String" do
|
110
|
+
@string.format_bytes(:included => ['h', 'l']) { |b|
|
111
|
+
b - 32
|
112
|
+
}.should == 'HeLLo'
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should not format specific bytes in a String" do
|
116
|
+
@string.format_bytes(:excluded => ['e', 'o']) { |b|
|
117
|
+
b - 32
|
118
|
+
}.should == 'HeLLo'
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should format ranges of chars in a String" do
|
122
|
+
@string.format_bytes(:included => ('h'..'l')) { |b|
|
123
|
+
b - 32
|
124
|
+
}.should == 'HeLLo'
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should not format ranges of chars in a String" do
|
128
|
+
@string.format_bytes(:excluded => ('h'..'l')) { |b|
|
129
|
+
b - 32
|
130
|
+
}.should == 'hEllO'
|
131
|
+
end
|
36
132
|
end
|
37
133
|
|
38
134
|
describe "random_case" do
|