deadfinder 1.3.6 → 1.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c209ef1731010129da940409a782e283301d1b0c80c61b38367fec3cdc73365
4
- data.tar.gz: 1d68364a7cba83bb2e651a91344ca2e3b1a75731c7acd5fae6ac0be51e35310d
3
+ metadata.gz: a1b1e8adb1c31f04447ae9749c8164032cbdb58337d888335b368be7c3c8f591
4
+ data.tar.gz: 6c4bc4c51080f5855aefd09024b7a73a6841f54fc450940874896d326cbb7fd4
5
5
  SHA512:
6
- metadata.gz: 87fbf3c5bd6a2c786211449b0dd51ca5c428ab791649440f3601afef3c632d969dc1495e6d7c5d2bc141cab4bb07d1fc1293a67cddc03e22d64b3a223ab05837
7
- data.tar.gz: 10028b1b527f28359e4dc8288f01389218e73aade4855caa857716436b8f7dd33daa40b7708461fd82b2d17c3b9dff84dd12eea0cbbd3129bfabbb76f39224ef
6
+ metadata.gz: a6483451fc8ad4eb51481e05aa2ebb914d15c07441f8fd515ce464cb5899b9ffa300bcb55c5facb9e445db77b93c797336b26a750a51934456dfd3e913df6605
7
+ data.tar.gz: 32dc309bf2e8dc87e745e3c4f2e5ffb86cfff934638f7914165a4456b49098dc791bceab30696b78ee6ff5213204091c350c16c374f15c37c4604f33cf8b608b
@@ -36,4 +36,8 @@ class Logger
36
36
  def self.found(text)
37
37
  puts " ✘ #{text}".colorize(:red) unless silent?
38
38
  end
39
+
40
+ def self.verbose(text)
41
+ puts ' ➜ '.colorize(:yellow) + text.to_s.colorize(:light_yellow) unless silent?
42
+ end
39
43
  end
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- VERSION = '1.3.6'
3
+ VERSION = '1.4.1'
data/lib/deadfinder.rb CHANGED
@@ -9,7 +9,6 @@ require 'deadfinder/logger'
9
9
  require 'deadfinder/version'
10
10
  require 'concurrent-edge'
11
11
  require 'sitemap-parser'
12
- require 'set'
13
12
  require 'json'
14
13
 
15
14
  Channel = Concurrent::Channel
@@ -24,7 +23,9 @@ class DeadFinderRunner
24
23
  'timeout' => 10,
25
24
  'output' => '',
26
25
  'headers' => [],
27
- 'silent' => true
26
+ 'silent' => true,
27
+ 'verbose' => false,
28
+ 'include30x' => false
28
29
  }
29
30
  end
30
31
 
@@ -77,14 +78,26 @@ class DeadFinderRunner
77
78
  CacheSet[j] = true
78
79
  begin
79
80
  CacheQue[j] = true
80
- URI.open(j, read_timeout: options['timeout'])
81
- rescue StandardError => e
82
- if e.to_s.include? '404 Not Found'
83
- Logger.found "[#{e}] #{j}"
81
+ uri = URI.parse(j)
82
+
83
+ # Create HTTP request with timeout and headers
84
+ http = Net::HTTP.new(uri.host, uri.port)
85
+ http.use_ssl = (uri.scheme == 'https')
86
+ http.read_timeout = options['timeout'].to_i if options['timeout']
87
+
88
+ request = Net::HTTP::Get.new(uri.request_uri)
89
+ response = http.request(request)
90
+ status_code = response.code.to_i
91
+ Logger.verbose "Status Code: #{status_code} for #{j}" if options['verbose']
92
+
93
+ if status_code >= 400 || (status_code >= 300 && options['include30x'])
94
+ Logger.found "[#{status_code} #{response.message}] #{j}"
84
95
  CacheQue[j] = false
85
96
  Output[target] ||= []
86
97
  Output[target] << j
87
98
  end
99
+ rescue StandardError => e
100
+ Logger.verbose "[#{e}] #{j}" if options['verbose']
88
101
  end
89
102
  end
90
103
  results << j
@@ -160,11 +173,13 @@ def gen_output(options)
160
173
  end
161
174
 
162
175
  class DeadFinder < Thor
176
+ class_option :include30x, aliases: :r, default: false, type: :boolean, desc: 'Include 30x redirections'
163
177
  class_option :concurrency, aliases: :c, default: 50, type: :numeric, desc: 'Number of concurrency'
164
178
  class_option :timeout, aliases: :t, default: 10, type: :numeric, desc: 'Timeout in seconds'
165
179
  class_option :output, aliases: :o, default: '', type: :string, desc: 'File to write JSON result'
166
180
  class_option :headers, aliases: :H, default: [], type: :array, desc: 'Custom HTTP headers to send with request'
167
181
  class_option :silent, aliases: :s, default: false, type: :boolean, desc: 'Silent mode'
182
+ class_option :verbose, aliases: :v, default: false, type: :boolean, desc: 'Verbose mode'
168
183
 
169
184
  desc 'pipe', 'Scan the URLs from STDIN. (e.g cat urls.txt | deadfinder pipe)'
170
185
  def pipe
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deadfinder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.6
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - hahwul
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-26 00:00:00.000000000 Z
11
+ date: 2024-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -198,7 +198,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
198
198
  requirements:
199
199
  - - ">="
200
200
  - !ruby/object:Gem::Version
201
- version: '0'
201
+ version: 3.3.0
202
202
  required_rubygems_version: !ruby/object:Gem::Requirement
203
203
  requirements:
204
204
  - - ">="