<commit_before>=begin
                  Arachni
  Copyright (c) 2010 Tasos "Zapotek" Laskos <<EMAIL>>

  This is free software; you can copy and distribute and modify
  this program under the term of the GPL v2.0 License
  (See LICENSE file for details)

=end

module Arachni

module UI

#
# XML-RPC deamon Output module
#
# Provides a command line output interface to the framework.
#
# It basically classifies and buffers all system messages until it's time to
# flush the buffer and send them over the wire.
#
# @author: Tasos "Zapotek" Laskos
#                                      <<EMAIL>>
#                                      <<EMAIL>>
# @version: 0.1
#
module Output

    # verbosity flag
    #
    # if it's on verbose messages will be enabled
    @@verbose = false

    # debug flag
    #
    # if it's on debugging messages will be enabled
    @@debug   = false

    # only_positives flag
    #
    # if it's on status messages will be disabled
    @@only_positives  = false

    @@buffer ||= []

    #
    # Empties the output buffer and returns all messages.
    #
    # Messages are classified by their type.
    #
    # @return   [Array<Hash>]
    #
    def flush_buffer
        buf = @@buffer.dup
        @@buffer.clear
        return buf
    end

    # Prints an error message
    #
    # It ignores all flags, error messages will be output under all
    # circumstances.
    #
    # @param    [String]    error string
    # @return    [void]
    #
    def print_error( str = '' )
        @@buffer << { :error => str }
        print_color( '[-]', 31, str, $stderr )
    end

    # Prints a status message
    #
    # Obeys {@@only_positives}
    #
    # @see #only_positives?
    # @see #only_positives!
    #
    # @param    [String]    status string
    # @return    [void]
    #
    def print_status( str = '' )
        if @@only_positives then return end
        @@buffer << { :status => str }
    end

    # Prints an info message
    #
    # Obeys {@@only_positives}
    #
    # @see #only_positives?
    # @see #only_positives!
    #
    # @param    [String]    info string
    # @return    [void]
    #
    def print_info( str = '' )
        if @@only_positives then return end
        @@buffer << { :info => str }
    end

    # Prints a good message, something that went very very right,
    # like the discovery of a vulnerability
    #
    # Disregards all flags.
    #
    # @param    [String]    ok string
    # @return    [void]
    #
    def print_ok( str = '' )
        @@buffer << { :ok => str }
    end

    # Prints a debugging message
    #
    # Obeys {@@debug}
    #
    # @see #debug?
    # @see #debug!
    #
    # @param    [String]    debugging string
    # @return    [void]
    #
    def print_debug( str = '' )
        if !@@debug then return end
        @@buffer << { :debug => str }

        print_color( '[!]', 36, str, $stderr )
    end

    # Pretty prints an object, used for debugging,
    # needs some improvement but it'll do for now
    #
    # Obeys {@@debug}
    #
    # @see #debug?
    # @see #debug!
    #
    # @param    [Object]
    # @return    [void]
    #
    def print_debug_pp( obj = nil )
        if !@@debug then return end
        pp obj
    end

    # Prints the backtrace of an exception
    #
    # Obeys {@@debug}
    #<commit_msg>print_debug(): removed it from the output buffer, debugging messages should remain local<commit_after>=begin
                  Arachni
  Copyright (c) 2010 Tasos "Zapotek" Laskos <<EMAIL>>

  This is free software; you can copy and distribute and modify
  this program under the term of the GPL v2.0 License
  (See LICENSE file for details)

=end

module Arachni

module UI

#
# XML-RPC deamon Output module
#
# Provides a command line output interface to the framework.
#
# It basically classifies and buffers all system messages until it's time to
# flush the buffer and send them over the wire.
#
# @author: Tasos "Zapotek" Laskos
#                                      <<EMAIL>>
#                                      <<EMAIL>>
# @version: 0.1
#
module Output

    # verbosity flag
    #
    # if it's on verbose messages will be enabled
    @@verbose = false

    # debug flag
    #
    # if it's on debugging messages will be enabled
    @@debug   = false

    # only_positives flag
    #
    # if it's on status messages will be disabled
    @@only_positives  = false

    @@buffer ||= []

    #
    # Empties the output buffer and returns all messages.
    #
    # Messages are classified by their type.
    #
    # @return   [Array<Hash>]
    #
    def flush_buffer
        buf = @@buffer.dup
        @@buffer.clear
        return buf
    end

    # Prints an error message
    #
    # It ignores all flags, error messages will be output under all
    # circumstances.
    #
    # @param    [String]    error string
    # @return    [void]
    #
    def print_error( str = '' )
        @@buffer << { :error => str }
        print_color( '[-]', 31, str, $stderr )
    end

    # Prints a status message
    #
    # Obeys {@@only_positives}
    #
    # @see #only_positives?
    # @see #only_positives!
    #
    # @param    [String]    status string
    # @return    [void]
    #
    def print_status( str = '' )
        if @@only_positives then return end
        @@buffer << { :status => str }
    end

    # Prints an info message
    #
    # Obeys {@@only_positives}
    #
    # @see #only_positives?
    # @see #only_positives!
    #
    # @param    [String]    info string
    # @return    [void]
    #
    def print_info( str = '' )
        if @@only_positives then return end
        @@buffer << { :info => str }
    end

    # Prints a good message, something that went very very right,
    # like the discovery of a vulnerability
    #
    # Disregards all flags.
    #
    # @param    [String]    ok string
    # @return    [void]
    #
    def print_ok( str = '' )
        @@buffer << { :ok => str }
    end

    # Prints a debugging message
    #
    # Obeys {@@debug}
    #
    # @see #debug?
    # @see #debug!
    #
    # @param    [String]    debugging string
    # @return    [void]
    #
    def print_debug( str = '' )
        if !@@debug then return end
        print_color( '[!]', 36, str, $stderr )
    end

    # Pretty prints an object, used for debugging,
    # needs some improvement but it'll do for now
    #
    # Obeys {@@debug}
    #
    # @see #debug?
    # @see #debug!
    #
    # @param    [Object]
    # @return    [void]
    #
    def print_debug_pp( obj = nil )
        if !@@debug then return end
        pp obj
    end

    # Prints the backtrace of an exception
    #
    # Obeys {@@debug}
    #
{'fraction_non_alphanumeric': 0.10504959422903516, 'fraction_numerical': 0.0036068530207394047, 'mean_word_length': 1.861134995700774, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2193308', 'n_tokens_mistral': 2190, 'n_tokens_neox': 2062, 'n_words': 694}