@@ -30,6 +30,25 @@ def dex_file(SAMPLE_PATH_13667):
3030 os .remove (APK_NAME )
3131
3232
33+ @pytest .fixture (scope = "session" )
34+ def dex_file_pivaa (tmp_path_factory , SAMPLE_PATH_pivaa ):
35+ APK_NAME = SAMPLE_PATH_pivaa
36+ DEX_NAME = "classes.dex"
37+ DEX_DIR = tmp_path_factory .mktemp ("dex_pivaa" )
38+ DEX_PATH = str (os .path .join (DEX_DIR , "classes.dex" ))
39+
40+ with zipfile .ZipFile (APK_NAME , "r" ) as zip :
41+ zip .extract (DEX_NAME , path = DEX_DIR )
42+
43+ yield DEX_PATH
44+
45+ if os .path .exists (DEX_PATH ):
46+ os .remove (DEX_PATH )
47+
48+ if os .path .exists (DEX_PATH ):
49+ os .remove (DEX_PATH )
50+
51+
3352def __generateTestIDs (testInput : Tuple [BaseApkinfo , Literal ["DEX" , "APK" ]]):
3453 return f"{ testInput [0 ].__name__ } with { testInput [1 ]} "
3554
@@ -80,6 +99,32 @@ def apkinfo_with_R2Imp_only(request, SAMPLE_PATH_13667, dex_file):
8099 yield apkinfo
81100
82101
102+ @pytest .fixture (
103+ scope = "function" ,
104+ params = (
105+ (AndroguardImp , "DEX" ),
106+ (AndroguardImp , "APK" ),
107+ (RizinImp , "DEX" ),
108+ (RizinImp , "APK" ),
109+ (R2Imp , "DEX" ),
110+ (R2Imp , "APK" ),
111+ (ShurikenImp , "DEX" ),
112+ (ShurikenImp , "APK" ),
113+ ),
114+ ids = __generateTestIDs ,
115+ )
116+ def apkinfoPivaa (request , SAMPLE_PATH_pivaa , dex_file_pivaa ):
117+ apkinfoClass , fileType = request .param
118+
119+ fileToBeAnalyzed = SAMPLE_PATH_pivaa
120+ if fileType == "DEX" :
121+ fileToBeAnalyzed = dex_file_pivaa
122+
123+ apkinfo = apkinfoClass (fileToBeAnalyzed )
124+
125+ yield apkinfo
126+
127+
83128class TestApkinfo :
84129 def test_init_with_invalid_type (self ):
85130 filepath = None
@@ -208,6 +253,22 @@ def test_receivers(apkinfo):
208253 == "com.example.google.service.MyDeviceAdminReceiver"
209254 )
210255
256+ @staticmethod
257+ def test_providers (apkinfoPivaa ):
258+ match apkinfoPivaa .ret_type :
259+ case "DEX" :
260+ assert apkinfoPivaa .providers is None
261+ case "APK" :
262+ providers = apkinfoPivaa .providers
263+
264+ assert len (providers ) == 1
265+ assert (
266+ providers [0 ].get (
267+ "{http://schemas.android.com/apk/res/android}name"
268+ )
269+ == "com.htbridge.pivaa.handlers.VulnerableContentProvider"
270+ )
271+
211272 def test_android_apis (self , apkinfo ):
212273 api = {
213274 MethodObject (
0 commit comments