CalebFenton/dex-oracle

View on GitHub

Showing 136 of 136 total issues

Block has too many lines. [37/25]
Open

optparse = OptionParser.new do |opts|
  opts.banner = "Usage: #{File.basename(__FILE__)} [opts] <APK / DEX / Smali Directory>"
  opts.on('-h', '--help', 'Display this screen') do
    puts opts
    exit
Severity: Minor
Found in bin/dex-oracle by rubocop

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Method filter_methods has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def self.filter_methods(smali_files, include_types, exclude_types)
    methods = []
    smali_files.each do |smali_file|
      smali_file.methods.each do |method|
        if include_types
Severity: Minor
Found in lib/oracle.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 build_argument has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def build_argument(parameter, argument)
    if parameter[0] == 'L'
      java_type = parameter[1..-2].tr('/', '.')
      if java_type == 'java.lang.String'
        # Need to unescape smali string to get the actual string
Severity: Minor
Found in lib/dex-oracle/driver.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 smaliToJavaClass has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private static Class<?> smaliToJavaClass(String className) throws ClassNotFoundException {
        if (className.equals("I")) {
            return int.class;
        } else if (className.equals("V")) {
            return void.class;
Severity: Minor
Found in driver/src/main/java/org/cf/oracle/options/TargetParser.java - 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 prepare has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def prepare(input)
    if File.directory?(input)
      @temp_dir = false
      @temp_dex = true
      @dir = input
Severity: Minor
Found in lib/dex-oracle/smali_input.rb - About 1 hr to fix

    Method parseTarget has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static void parseTarget(Gson gson, InvocationTarget target) throws ClassNotFoundException, NoSuchMethodException {
            String[] args = target.getArgumentStrings();
            Class<?>[] parameterTypes = new Class[args.length];
            Object[] methodArguments = new Object[parameterTypes.length];
            for (int i = 0; i < parameterTypes.length; i++) {
    Severity: Minor
    Found in driver/src/main/java/org/cf/oracle/options/TargetParser.java - About 1 hr to fix

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

        def decrypt_strings(method)
          target_to_contexts = {}
          matches = method.body.scan(STRING_DECRYPT)
          @optimizations[:string_lookups] += matches.size if matches
          matches.each do |original, _, str_index, class_name, method_signature, out_reg|
      Severity: Major
      Found in lib/dex-oracle/plugins/indexed_string_lookup.rb and 2 other locations - About 55 mins to fix
      lib/dex-oracle/plugins/indexed_class_lookup.rb on lines 53..65
      lib/dex-oracle/plugins/undexguard.rb on lines 101..113

      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 46.

      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

        def decrypt_classes(method)
          target_to_contexts = {}
          matches = method.body.scan(CLASS_DECRYPT)
          @optimizations[:class_lookups] += matches.size if matches
          matches.each do |original, _, class_index, class_name, method_signature, out_reg|
      Severity: Major
      Found in lib/dex-oracle/plugins/indexed_class_lookup.rb and 2 other locations - About 55 mins to fix
      lib/dex-oracle/plugins/indexed_string_lookup.rb on lines 45..57
      lib/dex-oracle/plugins/undexguard.rb on lines 101..113

      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 46.

      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

        def lookup_strings_1int(method)
          target_to_contexts = {}
          matches = method.body.scan(STRING_LOOKUP_1INT)
          @optimizations[:string_lookups] += matches.size if matches
          matches.each do |original, _, arg1, class_name, method_signature, out_reg|
      Severity: Major
      Found in lib/dex-oracle/plugins/undexguard.rb and 2 other locations - About 55 mins to fix
      lib/dex-oracle/plugins/indexed_class_lookup.rb on lines 53..65
      lib/dex-oracle/plugins/indexed_string_lookup.rb on lines 45..57

      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 46.

      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

        def process
          method_to_target_to_contexts = {}
          @methods.each do |method|
            logger.info("Decrypting indexed strings #{method.descriptor}")
            target_to_contexts = {}
      Severity: Major
      Found in lib/dex-oracle/plugins/indexed_string_lookup.rb and 2 other locations - About 55 mins to fix
      lib/dex-oracle/plugins/bitwise_antiskid.rb on lines 29..42
      lib/dex-oracle/plugins/string_decryptor.rb on lines 27..40

      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 45.

      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

      Block has too many lines. [32/25]
      Open

      Gem::Specification.new do |s|
        s.name     = 'dex-oracle'
        s.version  = DexOracle::VERSION.dup
        s.date     = '2018-12-13'
        s.license = 'MIT'
      Severity: Minor
      Found in dex-oracle.gemspec by rubocop

      This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

      Method install has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def install(dex)
          has_java = Utility.which('java')
          raise 'Unable to find Java on the path.' unless has_java
      
          begin
      Severity: Minor
      Found in lib/dex-oracle/driver.rb - About 55 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

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

        def process
          method_to_target_to_contexts = {}
          @methods.each do |method|
            logger.info("Decrypting Bitwise Anti-Skid #{method.descriptor}")
            target_to_contexts = {}
      Severity: Major
      Found in lib/dex-oracle/plugins/bitwise_antiskid.rb and 2 other locations - About 55 mins to fix
      lib/dex-oracle/plugins/indexed_string_lookup.rb on lines 27..40
      lib/dex-oracle/plugins/string_decryptor.rb on lines 27..40

      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 45.

      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 get_driver_dir has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def get_driver_dir
          # On some older devices, /data/local is world writable
          # But on other devices, it's /data/local/tmp
          %w(/data/local /data/local/tmp).each do |dir|
            stdout = adb("shell -x ls #{dir}")
      Severity: Minor
      Found in lib/dex-oracle/driver.rb - About 55 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

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

        def process
          method_to_target_to_contexts = {}
          @methods.each do |method|
            logger.info("Decrypting strings #{method.descriptor}")
            target_to_contexts = {}
      Severity: Major
      Found in lib/dex-oracle/plugins/string_decryptor.rb and 2 other locations - About 55 mins to fix
      lib/dex-oracle/plugins/bitwise_antiskid.rb on lines 29..42
      lib/dex-oracle/plugins/indexed_string_lookup.rb on lines 27..40

      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 45.

      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 unescape has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def unescape(str)
          str.gsub(UNESCAPE_REGEX) do
            if Regexp.last_match[1]
              if Regexp.last_match[1] == '\\'
                Regexp.last_match[1]
      Severity: Minor
      Found in lib/dex-oracle/driver.rb - About 45 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

      Method process_plugins has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def process_plugins
          made_changes = false
          loop do
            sweep_changes = false
            Plugin.plugins.each do |p|
      Severity: Minor
      Found in lib/oracle.rb - About 45 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

      Avoid parameter lists longer than 5 parameters. [10/5]
      Open

          matches.each do |original, iv_str, out_reg, iv_class_name, iv_method_signature, iv2_str, iv2_class_name, iv2_method_signature, dec_class_name, dec_method_signature|

      This cop checks for methods with too many parameters. The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count.

      Method plugin_classes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.plugin_classes
          Dir["#{File.dirname(__FILE__)}/plugins/*.rb"].each { |f| require f }
          classes = []
          Object.constants.each do |klass|
            const = Kernel.const_get(klass) unless klass == :TimeoutError
      Severity: Minor
      Found in lib/dex-oracle/plugin.rb - About 45 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

      Avoid parameter lists longer than 5 parameters. [10/5]
      Open

          matches.each do |original, _, arg1, _, arg2, _, arg3, class_name, method_signature, out_reg|

      This cop checks for methods with too many parameters. The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count.

      Severity
      Category
      Status
      Source
      Language