# Buggy code
def get_context_from_db_entry_ios(db_entry):
    """Return the context for IOS ZIP from DB"""
    try:
        logger.info("Analysis is already Done. Fetching data from the DB...")
        context = {
            "title": db_entry[0].TITLE,
            "file_name": db_entry[0].FILE_NAME,
            "size": db_entry[0].SIZE,
            "md5": db_entry[0].MD5,
            "sha1": db_entry[0].SHA1,
            "sha256": db_entry[0].SHA256,
            "plist": db_entry[0].INFOPLIST,
            "bin_name": db_entry[0].BINNAME,
            "id": db_entry[0].IDF,
            "build": db_entry[0].BUILD,
            "version": db_entry[0].VERSION,
            "sdk": db_entry[0].SDK,
            "pltfm": db_entry[0].PLTFM,
            "min": db_entry[0].MINX,
            "files": python_list(db_entry[0].FILES),
            "file_analysis": python_list(db_entry[0].SFILESX),
            "api": python_dict(db_entry[0].API),
            "insecure": python_dict(db_entry[0].CODEANAL),
            "urls": python_list(db_entry[0].URLnFile),
            "domains": python_dict(db_entry[0].DOMAINS),
            "emails": python_list(db_entry[0].EmailnFile),
            "permissions": python_list(db_entry[0].PERMISSIONS),
            "insecure_connections": python_list(db_entry[0].INSECCON),
            "bundle_name": db_entry[0].BUNDLE_NAME,
            "bundle_url_types": python_list(db_entry[0].BUNDLE_URL_TYPES),
            "bundle_supported_platforms": python_list(
                db_entry[0].BUNDLE_SUPPORTED_PLATFORMS
            ),
            "bundle_localizations": python_list(db_entry[0].BUNDLE_LOCALIZATIONS),
        }
        return context
    except:
        PrintException("[ERROR] Fetching from DB")


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def get_context_from_db_entry_ios(db_entry):
    """Return the context for IOS ZIP from DB"""
    try:
        logger.info("Analysis is already Done. Fetching data from the DB...")
        context = {
            "title": db_entry[0].TITLE,
            "file_name": db_entry[0].FILE_NAME,
            "size": db_entry[0].SIZE,
            "md5": db_entry[0].MD5,
            "sha1": db_entry[0].SHA1,
            "sha256": db_entry[0].SHA256,
            "plist": db_entry[0].INFOPLIST,
            "bin_name": db_entry[0].BINNAME,
            "id": db_entry[0].IDF,
            "build": db_entry[0].BUILD,
            "version": db_entry[0].VERSION,
            "sdk": db_entry[0].SDK,
            "pltfm": db_entry[0].PLTFM,
            "min": db_entry[0].MINX,
            "files": python_list(db_entry[0].FILES),
            "file_analysis": python_list(db_entry[0].SFILESX),
            "api": python_dict(db_entry[0].API),
            "insecure": python_dict(db_entry[0].CODEANAL),
            "urls": python_list(db_entry[0].URLnFile),
            "domains": python_dict(db_entry[0].DOMAINS),
            "emails": python_list(db_entry[0].EmailnFile),
            "permissions": python_list(db_entry[0].PERMISSIONS),
            "insecure_connections": python_list(db_entry[0].INSECCON),
            "bundle_name": db_entry[0].BUNDLE_NAME,
            "bundle_url_types": python_list(db_entry[0].BUNDLE_URL_TYPES),
            "bundle_supported_platforms": python_list(
                db_entry[0].BUNDLE_SUPPORTED_PLATFORMS
            ),
            "bundle_localizations": python_list(db_entry[0].BUNDLE_LOCALIZATIONS),
        }
        return context
    except:
        PrintException("Fetching from DB")