CalebFenton/dex-oracle

View on GitHub

Showing 136 of 136 total issues

Class has too many lines. [213/100]
Open

class Driver
  include Logging

  UNESCAPES = {
    'a' => "\x07", 'b' => "\x08", 't' => "\x09",
Severity: Minor
Found in lib/dex-oracle/driver.rb by rubocop

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Class has too many lines. [133/100]
Open

class Undexguard < Plugin
  attr_reader :optimizations

  include Logging
  include CommonRegex

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method main has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    public static void main(String[] args) {
        boolean multipleTargets = args.length < 2 && args[0].startsWith("@");
        if (args.length < 1 && !multipleTargets) {
            showUsage();
            System.exit(-1);
Severity: Minor
Found in driver/src/main/java/org/cf/oracle/Driver.java - About 3 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

Assignment Branch Condition size for install is too high. [28.91/15]
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 by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for prepare is too high. [24.04/15]
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 by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for unescape is too high. [22.36/15]
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 by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method parse_methods has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_methods
    @methods = []
    method_signature = nil
    in_method = false
    body = nil
Severity: Minor
Found in lib/dex-oracle/smali_file.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

Assignment Branch Condition size for decrypt_multi_bytes is too high. [20.71/15]
Open

  def decrypt_multi_bytes(method)
    target_to_contexts = {}
    target_id_to_output = {}
    matches = method.body.scan(MULTI_BYTES_DECRYPT)
    @optimizations[:string_decrypts] += matches.size if matches

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for process is too high. [19.95/15]
Open

  def process
    method_to_target_to_contexts = {}
    @methods.each do |method|
      logger.info("Undexguarding #{method.descriptor} - stage 1/2")
      target_to_contexts = {}

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method main has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static void main(String[] args) {
        boolean multipleTargets = args.length < 2 && args[0].startsWith("@");
        if (args.length < 1 && !multipleTargets) {
            showUsage();
            System.exit(-1);
Severity: Major
Found in driver/src/main/java/org/cf/oracle/Driver.java - About 2 hrs to fix

    Assignment Branch Condition size for drive is too high. [17.03/15]
    Open

      def drive(cmd, batch = false)
        return @cache[cmd] if @cache.key?(cmd)
    
        full_cmd = "shell \"#{cmd}\"; echo $?"
        full_output = adb(full_cmd)
    Severity: Minor
    Found in lib/dex-oracle/driver.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for pull_batch_outputs is too high. [17.15/15]
    Open

      def pull_batch_outputs
        output_file = Tempfile.new(['oracle-output', '.json'])
        logger.debug('Pulling batch results from device ...')
        adb("pull #{@driver_dir}/od-output.json #{output_file.path}")
        adb("shell rm #{@driver_dir}/od-output.json")
    Severity: Minor
    Found in lib/dex-oracle/driver.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for validate_output is too high. [16.4/15]
    Open

      def validate_output(full_cmd, full_output)
        output_lines = full_output.split(/\r?\n/)
        exit_code = output_lines.last.to_i
        if exit_code != 0
          # Non zero exit code would only imply adb command itself was flawed
    Severity: Minor
    Found in lib/dex-oracle/driver.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for divine is too high. [16.19/15]
    Open

      def divine
        puts "Optimizing #{@methods.size} methods over #{@smali_files.size} Smali files."
        made_changes = process_plugins
        @smali_files.each(&:update) if made_changes
        optimizations = {}
    Severity: Minor
    Found in lib/oracle.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Cyclomatic complexity for install is too high. [7/6]
    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 by rubocop

    This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

    Assignment Branch Condition size for lookup_classes is too high. [15.03/15]
    Open

      def lookup_classes(method)
        target_to_contexts = {}
        target_id_to_output = {}
        matches = method.body.scan(CONST_CLASS_REGEX)
        @optimizations[:class_lookups] += matches.size

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for parse is too high. [15.81/15]
    Open

      def parse(file_path)
        logger.debug("Parsing: #{file_path} ...")
        @content = File.open(file_path, 'r:UTF-8', &:read)
        @class = @content[CLASS, 1]
        @super = @content[SUPER, 1]
    Severity: Minor
    Found in lib/dex-oracle/smali_file.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for apply_outputs is too high. [15.94/15]
    Open

      def self.apply_outputs(target_id_to_output, method_to_target_to_contexts, modifier, filter = nil)
        made_changes = false
        method_to_target_to_contexts.each do |method, target_to_contexts|
          target_to_contexts.each do |target, contexts|
            status, output = target_id_to_output[target[:id]]
    Severity: Minor
    Found in lib/dex-oracle/plugin.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

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

      def self.apply_outputs(target_id_to_output, method_to_target_to_contexts, modifier, filter = nil)
        made_changes = false
        method_to_target_to_contexts.each do |method, target_to_contexts|
          target_to_contexts.each do |target, contexts|
            status, output = target_id_to_output[target[:id]]
    Severity: Minor
    Found in lib/dex-oracle/plugin.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 parseTarget has a Cognitive Complexity of 12 (exceeds 5 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

    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

    Severity
    Category
    Status
    Source
    Language