def setUpClass(cls):
        cls.db_helper = DefinitionsDatabaseManager(
            cls.DB_FILE_PATH, cls.DB_CREATION_SCRIPT_PATH,
            cls.DEFAULT_DATA_TYPES_SCRIPT_PATH,
            cls.DEFAULT_DATA_SOURCE_TYPES_SCRIPT_PATH,
            cls.DEFAULT_OPERATIONS_SCRIPT_PATH)

        cls.ds_aosp_email = DataSource('Application',
                                       {'package_name': 'com.android.email'})
        cls.ds_facebook = DataSource('Application',
                                     {'package_name': 'com.facebook.katana'})
        cls.ds_aosp_sms = DataSource(
            'Application', {'package_name': 'com.android.providers.telephony'})
        cls.bad_ds = DataSource('Application', {})
        cls.dv_info = DeviceInfo('3.0.0', 'GT-I9300')

        cls.op_info_email_aosp_email = OperationInfo('EmailMessageAOSPEmail',
                                                     'EmailMessage',
                                                     cls.ds_aosp_email,
                                                     ['GT-I9300'],
                                                     [('2.3.7', '5.1.1')])
        cls.op_info_image_aosp_email = OperationInfo('ImageFileAOSPEmail',
                                                     'ImageFile',
                                                     cls.ds_aosp_email,
                                                     ['GT-I9300'],
                                                     [('2.3.7', '5.1.1')])
        cls.op_info_image_facebook = OperationInfo('ImageFileFacebook',
                                                   'ImageFile',
                                                   cls.ds_facebook,
                                                   ['GT-I9300', 'XT1053'],
                                                   [('2.3.7', '5.1.1')])
        cls.op_info_sms_aosp_sms = OperationInfo('SmsMessageAOSPSms',
                                                 'SmsMessage', cls.ds_aosp_sms,
                                                 ['GT-I9300', 'LG-D820'],
                                                 [('2.0', '4.4.4')])
Ejemplo n.º 2
0
    def test_sms_inspector(self):
        success = load_data_set('HTC_Evo_3D')
        self.assertTrue(success)

        operations = [
            'SmsMessageAOSPSms', 'ContactFacebook', 'ContactWhatsApp',
            'ContactAOSPAgenda'
        ]
        device_info = DeviceInfo('4.3', 'GT-i9300')
        self.coordinator.execute_operations(operations, device_info,
                                            self.results_dir_path)

        for dir_name in os.listdir(self.results_dir_path):
            self.assertTrue(
                os.path.exists(
                    os.path.join(self.results_dir_path, dir_name,
                                 EXTRACTED_DATA_DIR_NAME)))
            self.assertTrue(
                os.path.exists(
                    os.path.join(self.results_dir_path, dir_name,
                                 INSPECTED_DATA_FILE_NAME)))
            self.assertTrue(
                os.path.exists(
                    os.path.join(self.results_dir_path, dir_name,
                                 SOURCE_DATA_FILE_NAME)))
Ejemplo n.º 3
0
    def parse_execute_args(self, arg_line):
        """
        :param arg_line: string
        :rtype: (list[string], DeviceInfo)
        """
        parser = ArgumentParser()
        parser.add_argument('--operations', '-op', nargs='+')
        parser.add_argument('--model', '-m')
        parser.add_argument('--version', '-v')
        parser.add_argument('--html', action='store_true')

        args, unknown = parser.parse_known_args(shlex.split(arg_line))

        di = None
        html_output = False

        if args.operations is None:
            raise ValueError("The parameter 'operations' is required.")

        ops = args.operations

        if args.version and not self.android_version_pattern.match(
                args.version):
            raise ValueError('The Android version is not valid.')

        if args.model and args.version:
            di = DeviceInfo(args.version, args.model)

        if args.html:
            html_output = True

        return ops, di, html_output
Ejemplo n.º 4
0
    def test_use_case_batch_mode(self):
        ids = ['EmailMessageAOSPEmail']
        device_info = DeviceInfo('5.1', 'XT1053')
        results_dir_path = os.path.join('test', 'results')
        simple_output = True

        self.coordinator.execute_operations(ids, device_info, results_dir_path,
                                            simple_output)
Ejemplo n.º 5
0
    def parse_list_args(self, arg_line):
        """
        :type arg_line: string
        :rtype: (string, DataSource, DeviceInfo)
        """
        dt = None
        ds = None
        di = None

        parser = ArgumentParser()
        parser.add_argument('--data_type', '-dt')
        parser.add_argument('--source_type', '-st')
        parser.add_argument('--source_params', '-sp', nargs='*')
        parser.add_argument('--model', '-m')
        parser.add_argument('--version', '-v')

        args, unknown = parser.parse_known_args(shlex.split(arg_line))

        if args.data_type:
            dt = args.data_type

        if args.source_type:
            ds = DataSource(args.source_type, {})

        if args.source_params:
            params = {}

            for p in args.source_params:
                if ':' not in p:
                    raise ValueError(
                        "The parameter 'source_params' is a whitespace separated list of pairs param_name:param_value."
                    )

                p_split = re.search('(.*):(.*)', p)
                params[p_split.group(1)] = p_split.group(2)

            ds.info = params

        if args.model and args.version:
            if not self.android_version_pattern.match(args.version):
                raise ValueError('The Android version is not valid.')

            di = DeviceInfo(args.version, args.model)
            di.os_version = args.version

        return dt, ds, di
    def test_add_operation(self):
        op_name = 'newOperation'
        dt_name = 'EmailMessage'
        dst_name = 'Application'
        param_values = {'package': 'com.example.email'}
        inspector_name = 'new_op_inspector'
        dev_models = ['GT-i9300']
        os_versions = [('2.2.0', '4.4.4')]

        ds = DataSource(dst_name, param_values)
        dev_info = DeviceInfo('4.3', dev_models[0])

        self.db_helper.add_operation(op_name, dt_name, dst_name,
                                     inspector_name, param_values, dev_models,
                                     os_versions)

        result = self.db_helper.query_operations_info(dt_name, ds, dev_info)

        self.assertEqualList(
            result,
            [OperationInfo(op_name, dt_name, ds, dev_models, os_versions)])
Ejemplo n.º 7
0
    def parse_set_device_info_args(self, arg_line):
        """
        :type arg_line: string
        :rtype: DeviceInfo
        """
        parser = ArgumentParser()
        parser.add_argument('--version', '-v')
        parser.add_argument('--model', '-m')

        args, unknown = parser.parse_known_args(shlex.split(arg_line))

        if args.model is None:
            raise ValueError("The parameter 'model' is required.")

        if args.version is None:
            raise ValueError("The parameter 'version' is required.")

        if not self.android_version_pattern.match(args.version):
            raise ValueError('The Android version is not valid.')

        return DeviceInfo(args.version, args.model)
Ejemplo n.º 8
0
 def setUp(self):
     self.extractor = MockedApplicationExtractor()
     self.inspector = MockedEmailInspector()
     self.param_values = {'package_name': 'com.android.email'}
     self.device_info = DeviceInfo('4.4.4', 'XT1053')
     self.data_dir_path = tempfile.mkdtemp()
Ejemplo n.º 9
0
 def setUp(self):
     self.device_info = DeviceInfo('4.4.4', 'XT1053')