# Buggy code
def create_db_entry(
    app_dic, man_data_dic, man_an_dic, code_an_dic, cert_dic, bin_anal, apk_id
) -> None:
    """Create a new DB-Entry for APK/ZIP"""
    try:
        static_db = StaticAnalyzerAndroid(
            TITLE="Static Analysis",
            APP_NAME=app_dic["app_name"],
            SIZE=app_dic["size"],
            MD5=app_dic["md5"],
            SHA1=app_dic["sha1"],
            SHA256=app_dic["sha256"],
            PACKAGENAME=man_data_dic["packagename"],
            MAINACTIVITY=man_data_dic["mainactivity"],
            TARGET_SDK=man_data_dic["target_sdk"],
            MAX_SDK=man_data_dic["max_sdk"],
            MIN_SDK=man_data_dic["min_sdk"],
            ANDROVERNAME=man_data_dic["androvername"],
            ANDROVER=man_data_dic["androver"],
            MANIFEST_ANAL=man_an_dic["manifest_anal"],
            PERMISSIONS=man_an_dic["permissons"],
            BIN_ANALYSIS=bin_anal,
            FILES=app_dic["files"],
            CERTZ=app_dic["certz"],
            ICON_HIDDEN=app_dic["icon_hidden"],
            ICON_FOUND=app_dic["icon_found"],
            ACTIVITIES=man_data_dic["activities"],
            RECEIVERS=man_data_dic["receivers"],
            PROVIDERS=man_data_dic["providers"],
            SERVICES=man_data_dic["services"],
            LIBRARIES=man_data_dic["libraries"],
            BROWSABLE=man_an_dic["browsable_activities"],
            CNT_ACT=man_an_dic["cnt_act"],
            CNT_PRO=man_an_dic["cnt_pro"],
            CNT_SER=man_an_dic["cnt_ser"],
            CNT_BRO=man_an_dic["cnt_bro"],
            CERT_INFO=cert_dic["cert_info"],
            ISSUED=cert_dic["issued"],
            SHA256DIGEST=cert_dic["sha256Digest"],
            API=code_an_dic["api"],
            DANG=code_an_dic["findings"],
            URLS=code_an_dic["urls"],
            DOMAINS=code_an_dic["domains"],
            EMAILS=code_an_dic["emails"],
            STRINGS=app_dic["strings"],
            ZIPPED=app_dic["zipped"],
            MANI=app_dic["mani"],
            EXPORTED_ACT=man_an_dic["exported_act"],
            E_ACT=man_an_dic["exported_cnt"]["act"],
            E_SER=man_an_dic["exported_cnt"]["ser"],
            E_BRO=man_an_dic["exported_cnt"]["bro"],
            E_CNT=man_an_dic["exported_cnt"]["cnt"],
            APK_ID=apk_id,
        )
        static_db.save()
    except:
        PrintException("[ERROR] Saving to 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 create_db_entry(
    app_dic, man_data_dic, man_an_dic, code_an_dic, cert_dic, bin_anal, apk_id
) -> None:
    """Create a new DB-Entry for APK/ZIP"""
    try:
        static_db = StaticAnalyzerAndroid(
            TITLE="Static Analysis",
            APP_NAME=app_dic["app_name"],
            SIZE=app_dic["size"],
            MD5=app_dic["md5"],
            SHA1=app_dic["sha1"],
            SHA256=app_dic["sha256"],
            PACKAGENAME=man_data_dic["packagename"],
            MAINACTIVITY=man_data_dic["mainactivity"],
            TARGET_SDK=man_data_dic["target_sdk"],
            MAX_SDK=man_data_dic["max_sdk"],
            MIN_SDK=man_data_dic["min_sdk"],
            ANDROVERNAME=man_data_dic["androvername"],
            ANDROVER=man_data_dic["androver"],
            MANIFEST_ANAL=man_an_dic["manifest_anal"],
            PERMISSIONS=man_an_dic["permissons"],
            BIN_ANALYSIS=bin_anal,
            FILES=app_dic["files"],
            CERTZ=app_dic["certz"],
            ICON_HIDDEN=app_dic["icon_hidden"],
            ICON_FOUND=app_dic["icon_found"],
            ACTIVITIES=man_data_dic["activities"],
            RECEIVERS=man_data_dic["receivers"],
            PROVIDERS=man_data_dic["providers"],
            SERVICES=man_data_dic["services"],
            LIBRARIES=man_data_dic["libraries"],
            BROWSABLE=man_an_dic["browsable_activities"],
            CNT_ACT=man_an_dic["cnt_act"],
            CNT_PRO=man_an_dic["cnt_pro"],
            CNT_SER=man_an_dic["cnt_ser"],
            CNT_BRO=man_an_dic["cnt_bro"],
            CERT_INFO=cert_dic["cert_info"],
            ISSUED=cert_dic["issued"],
            SHA256DIGEST=cert_dic["sha256Digest"],
            API=code_an_dic["api"],
            DANG=code_an_dic["findings"],
            URLS=code_an_dic["urls"],
            DOMAINS=code_an_dic["domains"],
            EMAILS=code_an_dic["emails"],
            STRINGS=app_dic["strings"],
            ZIPPED=app_dic["zipped"],
            MANI=app_dic["mani"],
            EXPORTED_ACT=man_an_dic["exported_act"],
            E_ACT=man_an_dic["exported_cnt"]["act"],
            E_SER=man_an_dic["exported_cnt"]["ser"],
            E_BRO=man_an_dic["exported_cnt"]["bro"],
            E_CNT=man_an_dic["exported_cnt"]["cnt"],
            APK_ID=apk_id,
        )
        static_db.save()
    except:
        PrintException("Saving to DB")