rapid7/metasploit-framework

View on GitHub
lib/msf/core/payload/apk.rb

Summary

Maintainability
F
3 days
Test Coverage

Method backdoor_apk has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
Open

  def backdoor_apk(apkfile, raw_payload, signature = true, manifest = true, apk_data = nil, service = true)
    unless apk_data || apkfile && File.readable?(apkfile)
      usage
      raise RuntimeError, "Invalid template: #{apkfile}"
    end
Severity: Minor
Found in lib/msf/core/payload/apk.rb - About 7 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 backdoor_apk has 162 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def backdoor_apk(apkfile, raw_payload, signature = true, manifest = true, apk_data = nil, service = true)
    unless apk_data || apkfile && File.readable?(apkfile)
      usage
      raise RuntimeError, "Invalid template: #{apkfile}"
    end
Severity: Major
Found in lib/msf/core/payload/apk.rb - About 6 hrs to fix

    Method find_hook_point has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

      def find_hook_point(manifest)
        return unless manifest
    
        package = manifest.xpath('//manifest').first['package']
    
    
    Severity: Minor
    Found in lib/msf/core/payload/apk.rb - About 5 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

    File apk.rb has 323 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'rex/text'
    require 'tmpdir'
    require 'nokogiri'
    require 'fileutils'
    require 'optparse'
    Severity: Minor
    Found in lib/msf/core/payload/apk.rb - About 3 hrs to fix

      Method extract_cert_data_from_apk_file has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def extract_cert_data_from_apk_file(path)
          orig_cert_data = []
      
          # extract signing scheme v1 (JAR signing) certificate
          # v1 signing is optional to support older versions of Android (pre Android 11)
      Severity: Minor
      Found in lib/msf/core/payload/apk.rb - About 1 hr to fix

        Method fix_manifest has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def fix_manifest(tempdir, package, main_service, main_broadcast_receiver)
            #Load payload's manifest
            payload_manifest = parse_manifest("#{tempdir}/payload/AndroidManifest.xml")
            payload_permissions = payload_manifest.xpath("//manifest/uses-permission")
        
        
        Severity: Minor
        Found in lib/msf/core/payload/apk.rb - About 1 hr to fix

          Method extract_cert_data_from_apk_file has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def extract_cert_data_from_apk_file(path)
              orig_cert_data = []
          
              # extract signing scheme v1 (JAR signing) certificate
              # v1 signing is optional to support older versions of Android (pre Android 11)
          Severity: Minor
          Found in lib/msf/core/payload/apk.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 find_hook_point has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def find_hook_point(manifest)
              return unless manifest
          
              package = manifest.xpath('//manifest').first['package']
          
          
          Severity: Minor
          Found in lib/msf/core/payload/apk.rb - About 1 hr to fix

            Method backdoor_apk has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def backdoor_apk(apkfile, raw_payload, signature = true, manifest = true, apk_data = nil, service = true)
            Severity: Minor
            Found in lib/msf/core/payload/apk.rb - About 45 mins to fix

              Method fix_manifest has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def fix_manifest(tempdir, package, main_service, main_broadcast_receiver)
                  #Load payload's manifest
                  payload_manifest = parse_manifest("#{tempdir}/payload/AndroidManifest.xml")
                  payload_permissions = payload_manifest.xpath("//manifest/uses-permission")
              
              
              Severity: Minor
              Found in lib/msf/core/payload/apk.rb - About 35 mins 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

              There are no issues that match your filters.

              Category
              Status