def get_context_from_db_entry(db_entry): """Return the context for IPA/ZIP from DB.""" try: logger.info('Analysis is already Done. Fetching data from the DB...') context = { 'version': settings.MOBSF_VER, 'title': 'Static Analysis', 'file_name': db_entry[0].FILE_NAME, 'app_name': db_entry[0].APP_NAME, 'app_type': db_entry[0].APP_TYPE, 'size': db_entry[0].SIZE, 'md5': db_entry[0].MD5, 'sha1': db_entry[0].SHA1, 'sha256': db_entry[0].SHA256, 'build': db_entry[0].BUILD, 'app_version': db_entry[0].APP_VERSION, 'sdk_name': db_entry[0].SDK_NAME, 'platform': db_entry[0].PLATFORM, 'min_os_version': db_entry[0].MIN_OS_VERSION, 'bundle_id': db_entry[0].BUNDLE_ID, 'bundle_url_types': python_list(db_entry[0].BUNDLE_URL_TYPES), 'bundle_supported_platforms': python_list(db_entry[0].BUNDLE_SUPPORTED_PLATFORMS), 'icon_found': db_entry[0].ICON_FOUND, 'info_plist': db_entry[0].INFO_PLIST, 'binary_info': python_dict(db_entry[0].BINARY_INFO), 'permissions': python_list(db_entry[0].PERMISSIONS), 'ats_analysis': python_list(db_entry[0].ATS_ANALYSIS), 'binary_analysis': python_list(db_entry[0].BINARY_ANALYSIS), 'macho_analysis': python_dict(db_entry[0].MACHO_ANALYSIS), 'ios_api': python_dict(db_entry[0].IOS_API), 'code_analysis': python_dict(db_entry[0].CODE_ANALYSIS), 'file_analysis': python_list(db_entry[0].FILE_ANALYSIS), 'libraries': python_list(db_entry[0].LIBRARIES), 'files': python_list(db_entry[0].FILES), 'urls': python_list(db_entry[0].URLS), 'domains': python_dict(db_entry[0].DOMAINS), 'emails': python_list(db_entry[0].EMAILS), 'strings': python_list(db_entry[0].STRINGS), 'firebase_urls': python_list(db_entry[0].FIREBASE_URLS), 'appstore_details': python_dict(db_entry[0].APPSTORE_DETAILS), } return context except Exception: logger.exception('Fetching from DB')
def get_context_from_db_entry(db_entry: QuerySet) -> dict: """Return the context for APK/ZIP from DB.""" try: logger.info('Analysis is already Done. Fetching data from the DB...') context = { 'version': settings.MOBSF_VER, 'title': 'Static Analysis', 'file_name': db_entry[0].FILE_NAME, 'app_name': db_entry[0].APP_NAME, 'app_type': db_entry[0].APP_TYPE, 'size': db_entry[0].SIZE, 'md5': db_entry[0].MD5, 'sha1': db_entry[0].SHA1, 'sha256': db_entry[0].SHA256, 'package_name': db_entry[0].PACKAGE_NAME, 'main_activity': db_entry[0].MAIN_ACTIVITY, 'exported_activities': db_entry[0].EXPORTED_ACTIVITIES, 'browsable_activities': python_dict(db_entry[0].BROWSABLE_ACTIVITIES), 'activities': python_list(db_entry[0].ACTIVITIES), 'receivers': python_list(db_entry[0].RECEIVERS), 'providers': python_list(db_entry[0].PROVIDERS), 'services': python_list(db_entry[0].SERVICES), 'libraries': python_list(db_entry[0].LIBRARIES), 'target_sdk': db_entry[0].TARGET_SDK, 'max_sdk': db_entry[0].MAX_SDK, 'min_sdk': db_entry[0].MIN_SDK, 'version_name': db_entry[0].VERSION_NAME, 'version_code': db_entry[0].VERSION_CODE, 'icon_hidden': db_entry[0].ICON_HIDDEN, 'icon_found': db_entry[0].ICON_FOUND, 'permissions': python_dict(db_entry[0].PERMISSIONS), 'certificate_analysis': python_dict(db_entry[0].CERTIFICATE_ANALYSIS), 'manifest_analysis': python_list(db_entry[0].MANIFEST_ANALYSIS), 'network_security': python_list(db_entry[0].NETWORK_SECURITY), 'binary_analysis': python_list(db_entry[0].BINARY_ANALYSIS), 'file_analysis': python_list(db_entry[0].FILE_ANALYSIS), 'android_api': python_dict(db_entry[0].ANDROID_API), 'code_analysis': python_dict(db_entry[0].CODE_ANALYSIS), 'niap_analysis': python_dict(db_entry[0].NIAP_ANALYSIS), 'urls': python_list(db_entry[0].URLS), 'domains': python_dict(db_entry[0].DOMAINS), 'emails': python_list(db_entry[0].EMAILS), 'strings': python_list(db_entry[0].STRINGS), 'firebase_urls': python_list(db_entry[0].FIREBASE_URLS), 'files': python_list(db_entry[0].FILES), 'exported_count': python_dict(db_entry[0].EXPORTED_COUNT), 'apkid': python_dict(db_entry[0].APKID), 'quark': python_list(db_entry[0].QUARK), 'trackers': python_dict(db_entry[0].TRACKERS), 'playstore_details': python_dict(db_entry[0].PLAYSTORE_DETAILS), 'secrets': python_list(db_entry[0].SECRETS), } return context except Exception: logger.exception('Fetching from DB')