bcoles/ssrf_proxy

View on GitHub

Showing 31 of 31 total issues

Method send_uri has a Cognitive Complexity of 155 (exceeds 5 allowed). Consider refactoring.
Open

    def send_uri(uri, method: 'GET', headers: {}, body: '')
      uri = uri.to_s
      body = body.to_s
      headers = {} unless headers.is_a?(Hash)

Severity: Minor
Found in lib/ssrf_proxy/http.rb - About 3 days to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

File http.rb has 974 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module SSRFProxy
  #
  # SSRFProxy::HTTP object takes information required to connect
  # to a HTTP(S) server vulnerable to Server-Side Request Forgery
  # (SSRF) and issue arbitrary HTTP requests via the vulnerable
Severity: Major
Found in lib/ssrf_proxy/http.rb - About 2 days to fix

    Method guess_status has a Cognitive Complexity of 84 (exceeds 5 allowed). Consider refactoring.
    Open

        def guess_status(response)
          result = {}
          # response status code returned by php-simple-proxy and php-json-proxy
          if response =~ /"status":{"http_code":([\d]+)}/
            result['code'] = $1
    Severity: Minor
    Found in lib/ssrf_proxy/http.rb - About 1 day to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method send_uri has 318 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def send_uri(uri, method: 'GET', headers: {}, body: '')
          uri = uri.to_s
          body = body.to_s
          headers = {} unless headers.is_a?(Hash)
    
    
    Severity: Major
    Found in lib/ssrf_proxy/http.rb - About 1 day to fix

      Method guess_status has 208 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def guess_status(response)
            result = {}
            # response status code returned by php-simple-proxy and php-json-proxy
            if response =~ /"status":{"http_code":([\d]+)}/
              result['code'] = $1
      Severity: Major
      Found in lib/ssrf_proxy/http.rb - About 1 day to fix

        Method initialize has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize(url: nil,
                           file: nil,
                           proxy: nil,
                           ssl: false,
                           method: 'GET',
        Severity: Minor
        Found in lib/ssrf_proxy/http.rb - About 6 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method initialize has 149 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def initialize(url: nil,
                           file: nil,
                           proxy: nil,
                           ssl: false,
                           method: 'GET',
        Severity: Major
        Found in lib/ssrf_proxy/http.rb - About 5 hrs to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  elsif response =~ /\[Errno 101\] Network is unreachable/
                    result['code'] = 502
                    result['message'] = 'Bad Gateway'
                  elsif response =~ /\[Errno 104\] Connection reset by peer/
                    result['code'] = 502
          Severity: Major
          Found in lib/ssrf_proxy/http.rb and 1 other location - About 4 hrs to fix
          lib/ssrf_proxy/http.rb on lines 1260..1293

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 143.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  if response =~ /HTTPError: HTTP Error 400: Bad Request/
                    result['code'] = 400
                    result['message'] = 'Bad Request'
                  elsif response =~ /HTTPError: HTTP Error 401: Unauthorized/
                    result['code'] = 401
          Severity: Major
          Found in lib/ssrf_proxy/http.rb and 1 other location - About 4 hrs to fix
          lib/ssrf_proxy/http.rb on lines 1224..1257

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 143.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Method send_request has 103 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def send_request(request)
                response_error = { 'uri' => '',
                                   'duration' => '0',
                                   'http_version' => '1.0',
                                   'headers' => "Server: #{@banner}\n",
          Severity: Major
          Found in lib/ssrf_proxy/server.rb - About 4 hrs to fix

            Method send_http_request has 83 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def send_http_request(url, method, headers, body)
                  # use upstream proxy
                  if @proxy.nil?
                    http = Net::HTTP::Proxy(nil).new(
                      @url.host,
            Severity: Major
            Found in lib/ssrf_proxy/http.rb - About 3 hrs to fix

              Method send_request has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                  def send_request(request)
                    response_error = { 'uri' => '',
                                       'duration' => '0',
                                       'http_version' => '1.0',
                                       'headers' => "Server: #{@banner}\n",
              Severity: Minor
              Found in lib/ssrf_proxy/server.rb - About 2 hrs to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Method send_http_request has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                  def send_http_request(url, method, headers, body)
                    # use upstream proxy
                    if @proxy.nil?
                      http = Net::HTTP::Proxy(nil).new(
                        @url.host,
              Severity: Minor
              Found in lib/ssrf_proxy/http.rb - About 2 hrs to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                    rescue SSRFProxy::HTTP::Error::InvalidResponse => e
                      logger.info(e.message)
                      error_msg = 'Response <- 503'
                      error_msg << " <- PROXY[#{@ssrf.proxy.host}:#{@ssrf.proxy.port}]" unless @ssrf.proxy.nil?
                      error_msg << " <- SSRF[#{@ssrf.url.host}:#{@ssrf.url.port}] <- URI[#{uri}]"
              Severity: Major
              Found in lib/ssrf_proxy/server.rb and 2 other locations - About 2 hrs to fix
              lib/ssrf_proxy/server.rb on lines 307..343
              lib/ssrf_proxy/server.rb on lines 320..343

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 91.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                    rescue SSRFProxy::HTTP::Error::ConnectionFailed => e
                      logger.info(e.message)
                      error_msg = 'Response <- 503'
                      error_msg << " <- PROXY[#{@ssrf.proxy.host}:#{@ssrf.proxy.port}]" unless @ssrf.proxy.nil?
                      error_msg << " <- SSRF[#{@ssrf.url.host}:#{@ssrf.url.port}] <- URI[#{uri}]"
              Severity: Major
              Found in lib/ssrf_proxy/server.rb and 2 other locations - About 2 hrs to fix
              lib/ssrf_proxy/server.rb on lines 294..343
              lib/ssrf_proxy/server.rb on lines 320..343

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 91.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                    rescue SSRFProxy::HTTP::Error::ConnectionTimeout => e
                      logger.info(e.message)
                      error_msg = 'Response <- 504'
                      error_msg << " <- PROXY[#{@ssrf.proxy.host}:#{@ssrf.proxy.port}]" unless @ssrf.proxy.nil?
                      error_msg << " <- SSRF[#{@ssrf.url.host}:#{@ssrf.url.port}] <- URI[#{uri}]"
              Severity: Major
              Found in lib/ssrf_proxy/server.rb and 2 other locations - About 2 hrs to fix
              lib/ssrf_proxy/server.rb on lines 294..343
              lib/ssrf_proxy/server.rb on lines 307..343

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 91.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Method initialize has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  def initialize(ssrf, interface = '127.0.0.1', port = 8081)
                    @banner = 'SSRF Proxy'
                    @server = nil
                    @logger = ::Logger.new(STDOUT).tap do |log|
                      log.progname = 'ssrf-proxy-server'
              Severity: Minor
              Found in lib/ssrf_proxy/server.rb - About 1 hr to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Method initialize has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def initialize(ssrf, interface = '127.0.0.1', port = 8081)
                    @banner = 'SSRF Proxy'
                    @server = nil
                    @logger = ::Logger.new(STDOUT).tap do |log|
                      log.progname = 'ssrf-proxy-server'
              Severity: Minor
              Found in lib/ssrf_proxy/server.rb - About 1 hr to fix

                Method run_rules has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def run_rules(url, rules)
                      str = url.to_s
                      return str if rules.nil?
                      rules.each do |rule|
                        case rule
                Severity: Minor
                Found in lib/ssrf_proxy/http.rb - About 1 hr to fix

                  Method handle_connection has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def handle_connection(socket)
                        start_time = Time.now
                        _, port, host = socket.peeraddr
                        logger.debug("Client #{host}:#{port} connected")
                        request = socket.read
                  Severity: Minor
                  Found in lib/ssrf_proxy/server.rb - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language