ronin-web 1.0.0.beta2 → 1.0.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67b858bfc218967ff56b0f90ccc1a3abc78c707cd160c3b2800731882df26066
4
- data.tar.gz: 533b6cbdbd94ad449e404985b649f07903ae62f560d5887173dfafc8d9f6cad4
3
+ metadata.gz: 37043413378124ed9793dc5393fe121be29e770f55e0cf93db3bbf91b59927d0
4
+ data.tar.gz: 5a77f64778e370b2d8f8c0f2df6838aa62719551a2021c6a0bbd5a9a4ba15ef1
5
5
  SHA512:
6
- metadata.gz: e276c68bc6f0b6d7c6e7f8c267d08c16d92eb7dfd386a52537d7da8c87c74ad0a7ca5586ba522adca971a8269c20adea43ee7ae962c1cd09b5f90883a8f67842
7
- data.tar.gz: bb3b259a383a2ce62b91fef94bb70493a267ede5dd24c26970ffaf9bb3b303fdeaafd376e90fecbbe0dff721d12dba69afcb1f2b019cae2f483f177cd23d6e7d
6
+ metadata.gz: b03fec155874e2c399db5991d03089a15c1c2193c3af3ba7c501c1c26ccd48c8fc6baaa650cda1c53508e43c5bbaed757cc7223279d494e635553f369202777e
7
+ data.tar.gz: 1a163daa3263ef36c36baa1d867a7add8678742743fb5a830ba10cbfbfcb05bd9c18b97d186538220f599298bc81c3a0b7861dabb4f9a69c1813ca34b0701936
@@ -21,10 +21,7 @@ jobs:
21
21
  uses: ruby/setup-ruby@v1
22
22
  with:
23
23
  ruby-version: ${{ matrix.ruby }}
24
- - name: Install libsqlite3
25
- run: |
26
- sudo apt update -y && \
27
- sudo apt install -y --no-install-recommends --no-install-suggests libsqlite3-dev libxml2-dev libxslt1-dev
24
+ bundler-cache: true
28
25
  - name: Install dependencies
29
26
  run: bundle install --jobs 4 --retry 3
30
27
  - name: Run tests
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![CI](https://github.com/ronin-rb/ronin-web/actions/workflows/ruby.yml/badge.svg)](https://github.com/ronin-rb/ronin-web/actions/workflows/ruby.yml)
4
4
  [![Code Climate](https://codeclimate.com/github/ronin-rb/ronin-web.svg)](https://codeclimate.com/github/ronin-rb/ronin-web)
5
+ [![Gem Version](https://badge.fury.io/rb/ronin-web.svg)](https://badge.fury.io/rb/ronin-web)
5
6
 
6
7
  * [Source](https://github.com/ronin-rb/ronin-web)
7
8
  * [Issues](https://github.com/ronin-rb/ronin-web/issues)
@@ -147,8 +148,6 @@ puts doc.to_xml
147
148
 
148
149
  * [Ruby] >= 3.0.0
149
150
  * [nokogiri] ~> 1.4
150
- * [libxml2]
151
- * [libxslt1]
152
151
  * [nokogiri-ext] ~> 0.1
153
152
  * [nokogiri-diff] ~> 0.2
154
153
  * [mechanize] ~> 2.0
@@ -201,8 +200,6 @@ along with ronin-web. If not, see <https://www.gnu.org/licenses/>.
201
200
  [nokogiri]: https://nokogiri.org/
202
201
  [nokogiri-ext]: https://github.com/postmodern/nokogiri-ext#readme
203
202
  [nokogiri-diff]: https://github.com/postmodern/nokogiri-diff#readme
204
- [libxml2]: http://xmlsoft.org/
205
- [libxslt1]: http://xmlsoft.org/XSLT/
206
203
  [mechanize]: https://github.com/sparklemotion/mechanize#readme
207
204
  [open_namespace]: https://github.com/postmodern/open_namespace#readme
208
205
  [ronin-support]: https://github.com/ronin-rb/ronin-support#readme
data/gemspec.yml CHANGED
@@ -41,7 +41,7 @@ dependencies:
41
41
  open_namespace: ~> 0.4
42
42
  # Ronin dependencies:
43
43
  ronin-support: ~> 1.0.0.beta2
44
- ronin-web-server: ~> 0.1.0.beta1
44
+ ronin-web-server: ~> 0.1.0.beta3
45
45
  ronin-web-spider: ~> 0.1.0.beta2
46
46
  ronin-web-user_agents: ~> 0.1.0.beta1
47
47
  ronin-core: ~> 0.1.0.beta1
@@ -45,7 +45,7 @@ module Ronin
45
45
  #
46
46
  # @api private
47
47
  #
48
- class Proxy < Command
48
+ class ReverseProxy < Command
49
49
 
50
50
  include Core::CLI::Logging
51
51
 
@@ -142,7 +142,14 @@ module Ronin
142
142
  end
143
143
 
144
144
  log_info "Starting proxy server on #{options[:host]}:#{options[:port]} ..."
145
- proxy.run!(host: options[:host], port: options[:port])
145
+
146
+ begin
147
+ proxy.run!(host: options[:host], port: options[:port])
148
+ rescue Errno::EADDRINUSE => error
149
+ log_error(error.message)
150
+ exit(1)
151
+ end
152
+
146
153
  log_info "shutting down ..."
147
154
  end
148
155
 
@@ -144,7 +144,13 @@ module Ronin
144
144
  end
145
145
 
146
146
  log_info "Starting web server listening on #{App.host}:#{App.port} ..."
147
- App.run!
147
+ begin
148
+ App.run!
149
+ rescue Errno::EADDRINUSE => error
150
+ log_error(error.message)
151
+ exit(1)
152
+ end
153
+
148
154
  log_info "Shutting down ..."
149
155
  end
150
156
 
@@ -49,7 +49,7 @@ module Ronin
49
49
  # -P, --proxy PROXY Sets the proxy to use.
50
50
  # -H, --header NAME: VALUE Sets a default header
51
51
  # --host-header NAME=VALUE Sets a default header
52
- # -u chrome_linux|chrome_macos|chrome_windows|chrome_iphone|chrome_ipad|chrome_android|firefox_linux|firefox_macos|firefox_windows|firefox_iphone|firefox_ipad|firefox_android|safari_macos|safari_iphone|safari_ipad|edge,
52
+ # -u chrome-linux|chrome-macos|chrome-windows|chrome-iphone|chrome-ipad|chrome-android|firefox-linux|firefox-macos|firefox-windows|firefox-iphone|firefox-ipad|firefox-android|safari-macos|safari-iphone|safari-ipad|edge,
53
53
  # --user-agent The User-Agent to use
54
54
  # -U, --user-agent-string STRING The User-Agent string to use
55
55
  # -R, --referer URL Sets the Referer URL
@@ -83,6 +83,7 @@ module Ronin
83
83
  # --print-status Print the status codes for each URL
84
84
  # --print-headers Print response headers for each URL
85
85
  # --print-header NAME Prints a specific header
86
+ # --history FILE The history file
86
87
  # --archive DIR Archive every visited page to the DIR
87
88
  # --git-archive DIR Archive every visited page to the git repository
88
89
  # -X, --xpath XPATH Evaluates the XPath on each HTML page
@@ -183,7 +184,11 @@ module Ronin
183
184
 
184
185
  option :user_agent, short: '-u',
185
186
  value: {
186
- type: Support::Network::HTTP::UserAgents::ALIASES.keys
187
+ type: Hash[
188
+ Support::Network::HTTP::UserAgents::ALIASES.keys.map { |key|
189
+ [key.to_s.tr('_','-'), key]
190
+ }
191
+ ]
187
192
  },
188
193
  desc: 'The User-Agent to use' do |name|
189
194
  @user_agent = name
@@ -386,7 +391,7 @@ module Ronin
386
391
  },
387
392
  desc: 'Spiders the website, starting at the URL'
388
393
 
389
- option :print_verbose, desc: 'Print the status codes for each URL'
394
+ option :print_stauts, desc: 'Print the status codes for each URL'
390
395
 
391
396
  option :print_headers, desc: 'Print response headers for each URL'
392
397
 
@@ -396,6 +401,12 @@ module Ronin
396
401
  },
397
402
  desc: 'Prints a specific header'
398
403
 
404
+ option :history, value: {
405
+ type: String,
406
+ usage: 'FILE'
407
+ },
408
+ desc: 'The history file'
409
+
399
410
  option :archive, value: {
400
411
  type: String,
401
412
  usage: 'DIR'
@@ -548,6 +559,10 @@ module Ronin
548
559
  Web::Spider::GitArchive.open(options[:git_archive])
549
560
  end
550
561
 
562
+ history_file = if options[:history]
563
+ File.open(options[:history],'w')
564
+ end
565
+
551
566
  agent = new_agent do |agent|
552
567
  agent.every_page do |page|
553
568
  print_page(page)
@@ -557,39 +572,12 @@ module Ronin
557
572
  print_verbose "failed to request #{url}"
558
573
  end
559
574
 
560
- if options[:print_hosts]
561
- agent.every_host do |host|
562
- print_verbose "spidering new host #{host}"
563
- end
564
- end
565
-
566
- if options[:print_certs]
567
- agent.every_cert do |cert|
568
- print_verbose "encountered new certificate for #{cert.subject.common_name}"
569
- end
570
- end
571
-
572
- if options[:print_js_strings]
573
- agent.every_js_string do |string|
574
- print_content string
575
- end
576
- end
577
-
578
- if options[:print_html_comments]
579
- agent.every_html_comment do |comment|
580
- print_content comment
581
- end
582
- end
575
+ define_printing_callbacks(agent)
583
576
 
584
- if options[:print_js_comments]
585
- agent.every_js_comment do |comment|
586
- print_content comment
587
- end
588
- end
589
-
590
- if options[:print_comments]
591
- agent.every_comment do |comment|
592
- print_content comment
577
+ if history_file
578
+ agent.every_page do |page|
579
+ history_file.puts(page.url)
580
+ history_file.flush
593
581
  end
594
582
  end
595
583
 
@@ -626,6 +614,54 @@ module Ronin
626
614
  puts
627
615
  end
628
616
  end
617
+ ensure
618
+ if options[:history]
619
+ history_file.close
620
+ end
621
+ end
622
+
623
+ #
624
+ # Defines callbacks that print information.
625
+ #
626
+ # @param [Ronin::Web::Spider::Agent] agent
627
+ # The newly created agent.
628
+ #
629
+ def define_printing_callbacks(agent)
630
+ if options[:print_hosts]
631
+ agent.every_host do |host|
632
+ print_verbose "spidering new host #{host}"
633
+ end
634
+ end
635
+
636
+ if options[:print_certs]
637
+ agent.every_cert do |cert|
638
+ print_verbose "encountered new certificate for #{cert.subject.common_name}"
639
+ end
640
+ end
641
+
642
+ if options[:print_js_strings]
643
+ agent.every_js_string do |string|
644
+ print_content string
645
+ end
646
+ end
647
+
648
+ if options[:print_html_comments]
649
+ agent.every_html_comment do |comment|
650
+ print_content comment
651
+ end
652
+ end
653
+
654
+ if options[:print_js_comments]
655
+ agent.every_js_comment do |comment|
656
+ print_content comment
657
+ end
658
+ end
659
+
660
+ if options[:print_comments]
661
+ agent.every_comment do |comment|
662
+ print_content comment
663
+ end
664
+ end
629
665
  end
630
666
 
631
667
  #
@@ -713,7 +749,7 @@ module Ronin
713
749
  # @param [Spidr::Page] page
714
750
  # A spidered page.
715
751
  #
716
- def print_verbose(page)
752
+ def print_status(page)
717
753
  if page.code < 300
718
754
  print "#{colors.bright_green(page.code)} "
719
755
  elsif page.code < 400
@@ -750,7 +786,7 @@ module Ronin
750
786
  # A spidered page.
751
787
  #
752
788
  def print_page(page)
753
- print_verbose(page) if options[:print_verbose]
789
+ print_status(page) if options[:print_status]
754
790
  print_url(page)
755
791
 
756
792
  if options[:print_headers]
@@ -20,6 +20,6 @@
20
20
  module Ronin
21
21
  module Web
22
22
  # ronin-web Version
23
- VERSION = '1.0.0.beta2'
23
+ VERSION = '1.0.0.beta4'
24
24
  end
25
25
  end
data/lib/ronin/web.rb CHANGED
@@ -240,7 +240,7 @@ module Ronin
240
240
  # @param [Array, Hash] parameters
241
241
  # Additional parameters for the GET request.
242
242
  #
243
- # param [Hash] headers
243
+ # @param [Hash] headers
244
244
  # Additional headers for the GET request.
245
245
  #
246
246
  # @yield [page]
@@ -282,7 +282,7 @@ module Ronin
282
282
  # @param [Array, Hash] parameters
283
283
  # Additional parameters for the GET request.
284
284
  #
285
- # param [Hash] headers
285
+ # @param [Hash] headers
286
286
  # Additional headers for the GET request.
287
287
  #
288
288
  # @yield [body]
@@ -22,7 +22,7 @@ The project directory to create\.
22
22
  .LP
23
23
  .TP
24
24
  \fB--port\fR \fIPORT\fP
25
- The port the webpp will listen on by default\. Defaults to \fB3000\fR\.
25
+ The port the webapp will listen on by default\. Defaults to \fB3000\fR\.
26
26
  .LP
27
27
  .TP
28
28
  \fB--ruby-version\fR \fIVERSION\fP
@@ -16,7 +16,7 @@ Generates a new `ronin-web-server` based webapp.
16
16
  ## OPTIONS
17
17
 
18
18
  `--port` *PORT*
19
- The port the webpp will listen on by default. Defaults to `3000`.
19
+ The port the webapp will listen on by default. Defaults to `3000`.
20
20
 
21
21
  `--ruby-version` *VERSION*
22
22
  The desired ruby version for the project Defaults to the current ruby version.
@@ -47,7 +47,7 @@ Sets a default header\.
47
47
  Sets a default header\.
48
48
  .LP
49
49
  .HP
50
- \fB-u\fR, \fB--user-agent\fR chrome\[ru]linux\[or]chrome\[ru]macos\[or]chrome\[ru]windows\[or]chrome\[ru]iphone\[or]chrome\[ru]ipad\[or]chrome\[ru]android\[or]firefox\[ru]linux\[or]firefox\[ru]macos\[or]firefox\[ru]windows\[or]firefox\[ru]iphone\[or]firefox\[ru]ipad\[or]firefox\[ru]android\[or]safari\[ru]macos\[or]safari\[ru]iphone\[or]safari\[ru]ipad\[or]edge
50
+ \fB-u\fR, \fB--user-agent\fR chrome\-linux\[or]chrome\-macos\[or]chrome\-windows\[or]chrome\-iphone\[or]chrome\-ipad\[or]chrome\-android\[or]firefox\-linux\[or]firefox\-macos\[or]firefox\-windows\[or]firefox\-iphone\[or]firefox\-ipad\[or]firefox\-android\[or]safari\-macos\[or]safari\-iphone\[or]safari\-ipad\[or]edge
51
51
  The \fBUser-Agent\fR to use\.
52
52
  .LP
53
53
  .TP
@@ -179,6 +179,10 @@ Print response headers for each URL\.
179
179
  Prints a specific header\.
180
180
  .LP
181
181
  .TP
182
+ \fB--history\fR \fIFILE\fP
183
+ Sets the history file to write every visited URL to\.
184
+ .LP
185
+ .TP
182
186
  \fB--archive\fR \fIDIR\fP
183
187
  Archive every visited page to the \fIDIR\fP\.
184
188
  .LP
@@ -34,7 +34,7 @@ Spiders a website.
34
34
  `--host-header` *NAME*=*VALUE*
35
35
  Sets a default header.
36
36
 
37
- `-u`, `--user-agent` chrome_linux|chrome_macos|chrome_windows|chrome_iphone|chrome_ipad|chrome_android|firefox_linux|firefox_macos|firefox_windows|firefox_iphone|firefox_ipad|firefox_android|safari_macos|safari_iphone|safari_ipad|edge
37
+ `-u`, `--user-agent` chrome-linux|chrome-macos|chrome-windows|chrome-iphone|chrome-ipad|chrome-android|firefox-linux|firefox-macos|firefox-windows|firefox-iphone|firefox-ipad|firefox-android|safari-macos|safari-iphone|safari-ipad|edge
38
38
  The `User-Agent` to use.
39
39
 
40
40
  `-U`, `--user-agent-string` *STRING*
@@ -133,6 +133,9 @@ Spiders a website.
133
133
  `--print-header` *NAME*
134
134
  Prints a specific header.
135
135
 
136
+ `--history` *FILE*
137
+ Sets the history file to write every visited URL to.
138
+
136
139
  `--archive` *DIR*
137
140
  Archive every visited page to the *DIR*.
138
141
 
data/ronin-web.gemspec CHANGED
@@ -26,6 +26,8 @@ Gem::Specification.new do |gem|
26
26
  gem.files = `git ls-files`.split($/)
27
27
  gem.files = glob[gemspec['files']] if gemspec['files']
28
28
  gem.files += Array(gemspec['generated_files'])
29
+ # exclude test files from the packages gem
30
+ gem.files -= glob[gemspec['test_files'] || 'spec/{**/}*']
29
31
 
30
32
  gem.executables = gemspec.fetch('executables') do
31
33
  glob['bin/*'].map { |path| File.basename(path) }
@@ -33,7 +35,6 @@ Gem::Specification.new do |gem|
33
35
  gem.default_executable = gem.executables.first if Gem::VERSION < '1.7.'
34
36
 
35
37
  gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
36
- gem.test_files = glob[gemspec['test_files'] || 'spec/{**/}*_spec.rb']
37
38
  gem.extra_rdoc_files = glob[gemspec['extra_doc_files'] || '*.{txt,md}']
38
39
 
39
40
  gem.require_paths = Array(gemspec.fetch('require_paths') {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ronin-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta2
4
+ version: 1.0.0.beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Postmodern
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-09 00:00:00.000000000 Z
11
+ date: 2023-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.1.0.beta1
103
+ version: 0.1.0.beta3
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.1.0.beta1
110
+ version: 0.1.0.beta3
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: ronin-web-spider
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -245,12 +245,6 @@ files:
245
245
  - man/ronin-web.1
246
246
  - man/ronin-web.1.md
247
247
  - ronin-web.gemspec
248
- - spec/cli/ruby_shell_spec.rb
249
- - spec/html_spec.rb
250
- - spec/mechanize_spec.rb
251
- - spec/spec_helper.rb
252
- - spec/web_spec.rb
253
- - spec/xml_spec.rb
254
248
  homepage: https://github.com/ronin-rb/ronin-web#readme
255
249
  licenses:
256
250
  - GPL-3.0
@@ -274,9 +268,4 @@ rubygems_version: 3.3.26
274
268
  signing_key:
275
269
  specification_version: 4
276
270
  summary: A collection of common web security commands and libraries.
277
- test_files:
278
- - spec/cli/ruby_shell_spec.rb
279
- - spec/html_spec.rb
280
- - spec/mechanize_spec.rb
281
- - spec/web_spec.rb
282
- - spec/xml_spec.rb
271
+ test_files: []
@@ -1,14 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/web/cli/ruby_shell'
3
-
4
- describe Ronin::Web::CLI::RubyShell do
5
- describe "#initialize" do
6
- it "must default #name to 'ronin-web'" do
7
- expect(subject.name).to eq('ronin-web')
8
- end
9
-
10
- it "must default #context to Ronin::Web" do
11
- expect(subject.context).to be(Ronin::Web)
12
- end
13
- end
14
- end
data/spec/html_spec.rb DELETED
@@ -1,43 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/web/html'
3
-
4
- describe Ronin::Web::HTML do
5
- describe ".parse" do
6
- let(:html) do
7
- <<~HTML
8
- <html>
9
- <body>Hello</body>
10
- </html>
11
- HTML
12
- end
13
-
14
- it "must parse an HTML String and return a Nokogiri::HTML::Document" do
15
- doc = subject.parse(html)
16
-
17
- expect(doc).to be_kind_of(Nokogiri::HTML::Document)
18
- expect(doc.at('body').inner_text).to eq("Hello")
19
- end
20
-
21
- context "when given a block" do
22
- it "must yield the Nokogiri::HTML::Document object" do
23
- expect { |b|
24
- subject.parse(html,&b)
25
- }.to yield_with_args(Nokogiri::HTML::Document)
26
- end
27
- end
28
- end
29
-
30
- describe ".build" do
31
- it "must build an HTML document" do
32
- doc = subject.build do
33
- html {
34
- body {
35
- div { text("hello") }
36
- }
37
- }
38
- end
39
-
40
- expect(doc.to_html).to include("<html><body><div>hello</div></body></html>")
41
- end
42
- end
43
- end
@@ -1,72 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/web/mechanize'
3
-
4
- describe Ronin::Web::Mechanize do
5
- describe "#initialize" do
6
- context "when Ronin::Support::Network::HTTP.user_agent is set" do
7
- let(:user_agent) { 'test' }
8
-
9
- before { Ronin::Support::Network::HTTP.user_agent = user_agent }
10
-
11
- it "should set #user_agent to Ronin::Support::Network::HTTP.user_agent" do
12
- expect(subject.user_agent).to eq(user_agent)
13
- end
14
-
15
- after { Ronin::Support::Network::HTTP.user_agent = nil }
16
- end
17
-
18
- context "when the :user_agent option is given" do
19
- context "and it's a String" do
20
- let(:user_agent) { 'test2' }
21
-
22
- subject { described_class.new(user_agent: user_agent) }
23
-
24
- it "should set #user_agent to the custom User-Agent string" do
25
- expect(subject.user_agent).to eq(user_agent)
26
- end
27
- end
28
-
29
- context "and it's a Symbol" do
30
- let(:user_agent) { :chrome_linux }
31
- let(:expected_user_agent) do
32
- Ronin::Support::Network::HTTP::UserAgents[user_agent]
33
- end
34
-
35
- subject { described_class.new(user_agent: user_agent) }
36
-
37
- it "should set #user_agent to the custom User-Agent alias" do
38
- expect(subject.user_agent).to eq(expected_user_agent)
39
- end
40
- end
41
- end
42
-
43
- let(:host) { '127.0.0.1' }
44
- let(:port) { 8080 }
45
- let(:proxy) { URI::HTTP.build(host: host, port: port) }
46
-
47
- context "when Ronin::Support::Network::HTTP.proxy is set" do
48
- before { Ronin::Support::Network::HTTP.proxy = proxy }
49
-
50
- it "should set #proxy_addr and #proxy_port to Ronin::Support::Network::HTTP.proxy" do
51
- expect(subject.proxy_addr).to eq(
52
- Ronin::Support::Network::HTTP.proxy.host
53
- )
54
-
55
- expect(subject.proxy_port).to eq(
56
- Ronin::Support::Network::HTTP.proxy.port
57
- )
58
- end
59
-
60
- after { Ronin::Support::Network::HTTP.proxy = nil }
61
- end
62
-
63
- context "when the :proxy option is given" do
64
- subject { described_class.new(proxy: proxy) }
65
-
66
- it "should set #proxy_addr and #proxy_port to the custom proxy" do
67
- expect(subject.proxy_addr).to eq(host)
68
- expect(subject.proxy_port).to eq(port)
69
- end
70
- end
71
- end
72
- end
data/spec/spec_helper.rb DELETED
@@ -1,8 +0,0 @@
1
- require 'rspec'
2
- require 'simplecov'
3
-
4
- SimpleCov.start
5
-
6
- RSpec.configure do |specs|
7
- specs.filter_run_excluding :network
8
- end
data/spec/web_spec.rb DELETED
@@ -1,97 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/web'
3
-
4
- describe Ronin::Web do
5
- let(:url) { 'https://example.com/' }
6
-
7
- it "should have a VERSION constant" do
8
- expect(subject.const_defined?('VERSION')).to eq(true)
9
- end
10
-
11
- describe ".html" do
12
- it "should be able to parse HTML" do
13
- doc = subject.html(%{
14
- <html>
15
- <body>Hello</body>
16
- </html>
17
- })
18
-
19
- expect(doc.at('body').inner_text).to eq("Hello")
20
- end
21
- end
22
-
23
- describe ".build_html" do
24
- it "should be able to build HTML documents" do
25
- doc = subject.build_html do
26
- html {
27
- body {
28
- div { text("hello") }
29
- }
30
- }
31
- end
32
-
33
- expect(doc.to_html).to include("<html><body><div>hello</div></body></html>")
34
- end
35
- end
36
-
37
- describe ".xml" do
38
- it "should be able to parse XML" do
39
- doc = subject.xml(%{
40
- <?xml version="1.0"?>
41
- <root>
42
- <stuff>Hello</stuff>
43
- </root>
44
- })
45
-
46
- expect(doc.at('stuff').inner_text).to eq("Hello")
47
- end
48
- end
49
-
50
- describe ".build_xml" do
51
- it "should be able to build XML documents" do
52
- doc = subject.build_xml do
53
- root {
54
- stuff(name: 'bla') { text("hello") }
55
- }
56
- end
57
-
58
- expect(doc.to_xml).to include("<root>\n <stuff name=\"bla\">hello</stuff>\n</root>")
59
- end
60
- end
61
-
62
- describe ".open", :network do
63
- it "must open URLs as temporary files" do
64
- file = subject.open(url)
65
-
66
- expect(file).to be_kind_of(StringIO)
67
- expect(file.read).to include("Example Domain")
68
- end
69
- end
70
-
71
- describe ".agent" do
72
- it "must return a #{described_class}::Mechanize object" do
73
- expect(subject.agent).to be_kind_of(described_class::Mechanize)
74
- end
75
-
76
- it "must return the same object each time" do
77
- expect(subject.agent).to be(subject.agent)
78
- end
79
- end
80
-
81
- describe ".get", :network do
82
- it "should be able to get Mechanize pages" do
83
- page = subject.get(url)
84
-
85
- expect(page.class).to eq(Mechanize::Page)
86
- expect(page.uri).to eq(URI(url))
87
- end
88
- end
89
-
90
- describe ".get_body", :network do
91
- it "should be able to get the bodies of Mechanize pages" do
92
- body = subject.get_body(url)
93
-
94
- expect(body).to include("Example Domain")
95
- end
96
- end
97
- end
data/spec/xml_spec.rb DELETED
@@ -1,42 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/web/xml'
3
-
4
- describe Ronin::Web::XML do
5
- describe ".parse" do
6
- let(:xml) do
7
- <<~XML
8
- <?xml version="1.0"?>
9
- <root>
10
- <stuff>Hello</stuff>
11
- </root>
12
- XML
13
- end
14
-
15
- it "must parse an XML String and return a Nokogiri::XML::Document" do
16
- doc = subject.parse(xml)
17
-
18
- expect(doc).to be_kind_of(Nokogiri::XML::Document)
19
- expect(doc.at('stuff').inner_text).to eq("Hello")
20
- end
21
-
22
- context "when given a block" do
23
- it "must yield the Nokogiri::XML::Document object" do
24
- expect { |b|
25
- subject.parse(xml,&b)
26
- }.to yield_with_args(Nokogiri::XML::Document)
27
- end
28
- end
29
- end
30
-
31
- describe ".build" do
32
- it "must build an XML document" do
33
- doc = subject.build do
34
- root {
35
- stuff(name: 'bla') { text("hello") }
36
- }
37
- end
38
-
39
- expect(doc.to_xml).to include("<root>\n <stuff name=\"bla\">hello</stuff>\n</root>")
40
- end
41
- end
42
- end