Module: Feroxbuster::Parsers::TXT

Defined in:
lib/feroxbuster/parsers/txt.rb

Overview

Parses single-line response data.

Class Method Summary collapse

Class Method Details

.parse(io) {|response| ... } ⇒ Enumerator

Parses each line of plain-text.

Parameters:

  • io (IO)

    The IO stream to parse.

Yields:

  • (response)

    The given block will be passed each parsed response.

Yield Parameters:

  • response (Response)

    The parsed response.

Returns:

  • (Enumerator)

    If no block is given, an Enumerator will be returned.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/feroxbuster/parsers/txt.rb', line 26

def self.parse(io)
  return enum_for(__method__,io) unless block_given?

  line_regexp = /^(\d{3})\s+(\w+)\s+(\d+)l\s+(\d+)w\s+(\d+)c\s+([^\s]+)/

  io.each_line do |line|
    line.chomp!

    if (match = line.match(line_regexp))
      yield Response.new(
        status:         match[1].to_i,
        method:         match[2],
        line_count:     match[3].to_i,
        word_count:     match[4].to_i,
        content_length: match[5].to_i,
        url:            match[6]
      )
    end
  end
end