#819 Added `raw` parameter to androguard.misc `AnalyzeDex` and AnalyzeODex…

Open Meir Komet mkomet
Coverage Reach
androguard/core/bytecodes/dvm.py androguard/core/bytecodes/axml/__init__.py androguard/core/bytecodes/axml/types.py androguard/core/bytecodes/apk.py androguard/core/bytecodes/dvm_types.py androguard/core/analysis/analysis.py androguard/core/bytecode.py androguard/core/mutf8.py androguard/core/__init__.py androguard/core/androconf.py androguard/core/api_specific_resources/__init__.py androguard/core/resources/public.py androguard/decompiler/dad/instruction.py androguard/decompiler/dad/opcode_ins.py androguard/decompiler/dad/writer.py androguard/decompiler/dad/dast.py androguard/decompiler/dad/graph.py androguard/decompiler/dad/decompile.py androguard/decompiler/dad/control_flow.py androguard/decompiler/dad/dataflow.py androguard/decompiler/dad/basic_blocks.py androguard/decompiler/dad/node.py androguard/decompiler/dad/util.py androguard/decompiler/decompiler.py androguard/cli/main.py androguard/cli/entry_points.py androguard/cli/__init__.py androguard/session.py androguard/misc.py androguard/util.py androguard/__init__.py tests/test_apk.py tests/test_dex.py tests/test_axml.py tests/test_analysis.py tests/test_entry_points.py tests/dataflow_test.py tests/parse_dex.py tests/rpo_test.py tests/test_arsc.py tests/test_session.py tests/dominator_test.py tests/test_decompiler.py tests/test_types.py tests/test_misc.py tests/test_dexcodeparsing.py tests/test_rename.py tests/test_decompilerjadx.py tests/test_strings.py tests/test_loadorder.py tests/test_annotations.py

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 1 of 1 files from the diff.

@@ -74,13 +74,14 @@
Loading
74 74
        return a, d, dx
75 75
76 76
77 -
def AnalyzeDex(filename, session=None):
77 +
def AnalyzeDex(filename, session=None, raw=False):
78 78
    """
79 79
    Analyze an android dex file and setup all stuff for a more quickly analysis !
80 80
81 81
    :param filename: the filename of the android dex file or a buffer which represents the dex file
82 82
    :type filename: string
83 83
    :param session: A session (Default None)
84 +
    :param raw: If set, ``filename`` will be used as the odex's data (bytes). Defaults to ``False``
84 85
85 86
    :rtype: return a tuple of (sha256hash, :class:`DalvikVMFormat`, :class:`Analysis`)
86 87
    """
@@ -89,19 +90,23 @@
Loading
89 90
    if not session:
90 91
        session = get_default_session()
91 92
92 -
    with open(filename, "rb") as fd:
93 -
        data = fd.read()
93 +
    if raw:
94 +
        data = filename
95 +
    else:
96 +
        with open(filename, "rb") as fd:
97 +
            data = fd.read()
94 98
95 99
    return session.addDEX(filename, data)
96 100
97 101
98 -
def AnalyzeODex(filename, session=None):
102 +
def AnalyzeODex(filename, session=None, raw=False):
99 103
    """
100 104
    Analyze an android odex file and setup all stuff for a more quickly analysis !
101 105
102 106
    :param filename: the filename of the android dex file or a buffer which represents the dex file
103 107
    :type filename: string
104 108
    :param session: The Androguard Session to add the ODex to (default: None)
109 +
    :param raw: If set, ``filename`` will be used as the odex's data (bytes). Defaults to ``False``
105 110
106 111
    :rtype: return a tuple of (sha256hash, :class:`DalvikOdexVMFormat`, :class:`Analysis`)
107 112
    """
@@ -110,8 +115,11 @@
Loading
110 115
    if not session:
111 116
        session = get_default_session()
112 117
113 -
    with open(filename, "rb") as fd:
114 -
        data = fd.read()
118 +
    if raw:
119 +
        data = filename
120 +
    else:
121 +
        with open(filename, "rb") as fd:
122 +
            data = fd.read()
115 123
116 124
    return session.addDEY(filename, data)
117 125

Learn more Showing 1 files with coverage changes found.

Changes in androguard/core/__init__.py
-2
+6
Loading file...
Files Coverage
androguard 0.01% 73.54%
tests 96.95%
Project Totals (51 files) 76.84%
Loading