Migrate OpenCVE v1 data
Overview
To enhance development speed and make it easier to add new features, OpenCVE has undergone a major refactor in the transition from v1 to v2.
Specifically, we moved from the Flask framework to Django and replaced Celery with Airflow for asynchronous tasks. These updates enable faster development and a more flexible foundation for the platform.
While OpenCVE still uses a PostgreSQL database, the structural differences between the v1 and v2 stacks result in changes to the database format. To assist users in upgrading, we’ve created a migration script to transfer data from v1 to v2.
Migration Script Explanation
The migration script helps users transition their data from v1 to v2 by transferring the following information:
- User data, including emails, passwords, and usernames
- User tags
- User subscriptions, both vendor and product subscriptions
Info
It’s important to mention that data migration from v1 to v2 does not include old reports due to significant changes in report structure.
Since v2 introduces the new concepts of organizations and projects, which did not exist in v1, the migration script automatically creates a default organization and project for each user:
- Each organization is named based on the username with
-org
appended. For example, if the username in v1 wasjohn
, the organization created during the import is namedjohn-org
. - A default project named
OpenCVEv1
is also created for each user.
Additionally, a notification of type email is set up for each user based on their notification preferences from v1 (minimum CVSS score and event types).
Running the Script
To run the migration script, follow these steps.
First, add the OpenCVE v1 database URI in the OPENCVE_V1_DATABASE
variable of the .env
file. This will allow the migration script to access your v1 data.
# opencve/conf/.env
...
OPENCVE_V1_DATABASE=postgresql://username:password@host:5432/opencve_v1
Then execute the import_from_v1
command to start the data migration process:
$ ./manage.py import_from_v1
Starting the migration of OpenCVE v1 users
Found 1234 users to migrate, adding them in database...
User john (john@doe.com) migrated
...
Once the migration completes, your users data from OpenCVE v1 will be successfully imported into OpenCVE v2.