Skip to content

Database missing columns when updating Mobsf version 3.9.7 to 4.3.0 #2486

@JonasNotredame

Description

@JonasNotredame

ENVIRONMENT

OS and Version: MacOS 15.3
Python Version: 3.12.8
MobSF Version: from 3.9.7 to 4.3.0

EXPLANATION OF THE ISSUE

So i am using a volume mounted to my container. This data should be kept, so when i created a new container with the new image(v4.3.0) and mounted the volume. The container runs but if i open mobsf and try to scan or try to navigate to recent scans i get an error code 500.
Now i checked the logs of the container and saw the following error... 2 columns(SCAN_LOGS and SBOM) are missing...
So is the migration not executed correctly? Is there a bug in the new image?

[ERROR] 30/Jan/2025 10:38:10 - Adding Scan URL to Database
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 105, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/backends/sqlite3/base.py", line 354, in execute
    return super().execute(query, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: no such column: SCAN_LOGS
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/home/mobsf/Mobile-Security-Framework-MobSF/mobsf/MobSF/views/scanning.py", line 30, in add_to_recent_scan
    new_db_obj.save()
  File "/usr/local/lib/python3.12/site-packages/django/db/models/base.py", line 892, in save
    self.save_base(
  File "/usr/local/lib/python3.12/site-packages/django/db/models/base.py", line 998, in save_base
    updated = self._save_table(
              ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/models/base.py", line 1130, in _save_table
    updated = self._do_update(
              ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/models/base.py", line 1195, in _do_update
    return filtered._update(values) > 0
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/models/query.py", line 1278, in _update
    return query.get_compiler(self.db).execute_sql(CURSOR)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/models/sql/compiler.py", line 2003, in execute_sql
    cursor = super().execute_sql(result_type)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/models/sql/compiler.py", line 1574, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 79, in execute
    return self._execute_with_wrappers(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 100, in _execute
    with self.db.wrap_database_errors:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 105, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/backends/sqlite3/base.py", line 354, in execute
    return super().execute(query, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.OperationalError: no such column: SCAN_LOGS

STEPS TO REPRODUCE THE ISSUE

1. Create old container: podman run -d \
  --name old_mobsf_container \
  -p 8000:8000 \
  -v {path_to_volume}/volume_mobsf:/home/mobsf/.MobSF \
  docker.io/opensecurity/mobile-security-framework-mobsf:v3.9.7    
2. Scan an application so the volume has data in it
3. Create new container: podman run -d \
  --name new_mobsf_container \
  -p 8000:8000 \
  -e MOBSF_DEBUG=1 \
  -v {path_to_volume}/volume_mobsf:/home/mobsf/.MobSF \
  docker.io/opensecurity/mobile-security-framework-mobsf:v4.3.0 
4. Try to scan application or try to go to recent scans, internal error will pop up.

LOG FILE


[OperationalError at _recent_scans_.pdf](https://github.com/user-attachments/files/18620253/OperationalError.at._recent_scans_.pdf)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions