cloudstack/usage
Wei Zhou 67b60385af
Apple FR68: New database encryption cipher (#214)
* Rough start swapping DB Encryption, add CLI PoC

* Enhance EncryptionCLI to have command line parsing

* Refactor new encryption behind AeadBase64Encryptor for every use

* Add comment about encryption passwords

* EncryptionSecretKeyChanger - use reflection to find all encrypted tables

Over the years this hasn't been updated properly. Use reflection to find
the tables with encrypted fields. This will also ensure any plugins in
the classpath that add tables will get their encrypted fields updated as well.

Table vpn_users has encrypted columns [password]
Table sslcerts has encrypted columns [password, key]
Table user_view has encrypted columns [secret_key]
Table account_details has encrypted columns [value]
Table domain_details has encrypted columns [value]
Table s2s_customer_gateway has encrypted columns [ipsec_psk]
Table ucs_manager has encrypted columns [password]
Table vm_instance has encrypted columns [vnc_password]
Table passphrase has encrypted columns [passphrase]
Table keystore has encrypted columns [key]
Table external_stratosphere_ssp_credentials has encrypted columns [password]
Table storage_pool has encrypted columns [user_info]
Table remote_access_vpn has encrypted columns [ipsec_psk]
Table user has encrypted columns [secret_key]
Table oobm has encrypted columns [password]

* Apple FR68: add new class CloudStackEncryptor

* Apple FR68: add interface com.cloud.utils.crypt.Encryptor

* Apple FR68: update com.cloud.utils.EncryptionUtil

* Apple FR68: add cloudstack-utils.jar to cloudstack-common package

* Apple FR68: use cloudstack-utils.jar in scripts

* Apple FR68: revert replace.properties to original version

* Apple FR68: update EncryptionSecretKeyChanger

* Apple FR68: Add EncryptorVersion to CloudStackEncryptor

* Apple FR68: Update com.cloud.utils.crypt.EncryptionCLI

* Apple FR68: Remove check on EncryptionSecretKeyChecker.useEncryption in CloudStackEncryptor

* Apple FR68: update EncryptionSecretKeyChanger part2

* Apple FR68: update EncryptionSecretKeyChanger part3 (force update)

* Apple FR68: move cloud-migrate-databases.in to deprecated and recreate it with java command

* Apple FR68: update EncryptionSecretKeyChanger part4 (add skip-database-migration)

* Apple FR68: set encryptor in first encryption in CloudStackEncryptor

* Apple FR68: save db.cloud.encryptor.version in db.properties

* Apple FR68: update EncryptionSecretKeyChanger part4 (clear db.cloud.encryptor.version)

* Apple FR68: load and save db.cloud.encryptor.version in db.properties

* Apple FR68: Add caller class name in debug messages

* Apple FR68: consider non-exist tables and columns

* Apple FR68: skip tables if no data exists

* Apple FR68: remove GeneralSecurityException from code

* Apple FR68: hide value with Asterisks in CloudStackEncryptor

* Apple FR68: log an error message when fail to load 'init'

* Apple FR68: remove setup/bindir/cloud-migrate-databases.deprecated.in which I think it is not needed

* Apple FR68: add new encryptor version to EncryptionSecretKeyChanger

* Apple FR68: use System.exit(1) in EncryptionSecretKeyChanger

* Apple FR68: check arguments in cloudstack-migrate-databases

* Apple FR68: remove all org.jasypt.* in code

* Apple FR68: initilize database encryptors by getting 'init'

* Apple FR68: migrate server.properties

* Apple FR68: load new management key from environment variable CLOUD_SECRET_KEY_NEW

* Apple FR68: fix unable to load 'init' in fresh installation

* Apple FR68: fix 'Rolling back the transaction' in txn.close

* Apple FR68: improve logging in cloudstack-migrate-databases

* Apple FR68: hide value with Asterisks in other encryptors

* Apple FR68: System.exit(1) if fail to migrate server.properties

* Apple FR68: migrate values from cluster_details,user_vm_details,etc

* Apple FR68: refactor EncryptionSecretKeyChanger

* Apple FR68: update user_vm_deploy_as_is_details values

* Apple FR68: update image_store.url (if protocol is cifs) and storage_pool.path (if pool_type is SMB)

* Apple FR68: minor improvement EncryptionSecretKeyChanger

* Apple FR68: add unit test EncryptionSecretKeyChangerTest

* Apple FR68: support encryption type 'env' in cloudstack-setup-databases to get env "CLOUD_SECRET_KEY" before passed value

* Apple FR68: rename Encryptor to Base64Encryptor

* Apple FR68: Backport community PR 6542

* Apple FR68: code optimization

* Apple FR68: use Options and StringUtils

* Apple FR68: add license headers

* Apple FR68: refactor CloudStackEncryptor as per Daan's review

* Apple FR68: refactor DatabaseUpgradeChecker as per Daan's review

* Apple FR68: show error message in usage.log if fail to get encrypted configurations

* Apple FR68: load new MS key from env before migration

* Apple FR68: return 1 if fail to parse arguments of EncryptionCLI

* Apple FR68: fix code smells

* Apple FR68: fix code smells (part2)

* Apple FR68: revert FOOTER of cloudstack-migrate-databases to use \n

* Apple FR68: update help message of cloudstack-setup-databases

* Apple FR68: fix code smells (part3)

* Apple FR68: make changes as per suggestions

* Apple FR68: migrate database if new encryptor version is set to different

Testing result: (assume db.cloud.encryptor.version=V1)

(1) migrate only db.properties (same db key, same db encryptor version)
Command: /usr/bin/cloudstack-migrate-databases -m mgmtkey -d dbkey -n newmgmtkey -v V1
Changes: db.cloud.encrypt.secret is encrypted by V2 (always)
         db.cloud.encryptor.version=V1
         cloudstack database is not migrated

(2) migrate only db.properties (same db key, new db encryptorversion)
Command: /usr/bin/cloudstack-migrate-databases -m mgmtkey -d dbkey -n newmgmtkey -v V2 --skip-database-migration
Changes: db.cloud.encrypt.secret is encrypted by V2 (always)
         db.cloud.encryptor.version=V2
         cloudstack database is not migrated (mostly on secondary management servers)

(3) migrate only db.properties (same db key, db encryptor version is not set)
Command: /usr/bin/cloudstack-migrate-databases -m mgmtkey -d dbkey -n newmgmtkey
Changes: db.cloud.encrypt.secret is encrypted by V2 (always)
         db.cloud.encryptor.version=V1
         cloudstack database is not migrated

(4) migrate only db.properties (different db key, same db encryptor version)
Command: /usr/bin/cloudstack-migrate-databases -m mgmtkey -d dbkey -n newmgmtkey -e newdbkey -v V1 --skip-database-migration
Changes: db.cloud.encrypt.secret is encrypted by V2 (always)
         db.cloud.encryptor.version=V1
         cloudstack database is not migrated (mostly on secondary management servers)

(5) migrate only db.properties (different db key, new db version)
Command: /usr/bin/cloudstack-migrate-databases -m mgmtkey -d dbkey -n newmgmtkey -e newdbkey -v V2 --skip-database-migration
Changes: db.cloud.encrypt.secret is encrypted by V2 (always)
         db.cloud.encryptor.version=V2
         cloudstack database is not migrated (mostly on secondary management servers)

(6) migrate only db.properties (different db key, db encryptor version is not set)
Command: /usr/bin/cloudstack-migrate-databases -m mgmtkey -d dbkey -n newmgmtkey -e newdbkey --skip-database-migration
Changes: db.cloud.encrypt.secret is encrypted by V2 (always)
         db.cloud.encryptor.version=V1
         cloudstack database is not migrated (mostly on secondary management servers)

(7) migrate db.properties and database (same db key, same db encryptor version)
Command: /usr/bin/cloudstack-migrate-databases -m mgmtkey -d dbkey -n newmgmtkey -v V1 --force-database-migration
Changes: db.cloud.encrypt.secret is encrypted by V2 (always)
         db.cloud.encryptor.version=V1
         cloudstack database is migrated using encryptor V1

(8) migrate db.properties and database (same db key, new db encryptor version)
Command: /usr/bin/cloudstack-migrate-databases -m mgmtkey -d dbkey -n newmgmtkey -v V2
Changes: db.cloud.encrypt.secret is encrypted by V2 (always)
         db.cloud.encryptor.version=V2
         cloudstack database is migrated using encryptor V2

(9) migrate db.properties and database (same db key, db encryptor version is not set)
Command: /usr/bin/cloudstack-migrate-databases -m mgmtkey -d dbkey -n newmgmtkey --force-database-migration
Changes: db.cloud.encrypt.secret is encrypted by V2 (always)
         db.cloud.encryptor.version=V1
         cloudstack database is migrated using encryptor V1

(10) migrate db.properties and database (different db key, same db encryptor version)
Command: /usr/bin/cloudstack-migrate-databases -m mgmtkey -d dbkey -n newmgmtkey -e newdbkey -v V1
Changes: db.cloud.encrypt.secret is encrypted by V2 (always)
         db.cloud.encryptor.version=V1
         cloudstack database is migrated using encryptor V1

(11) migrate db.properties and database (different db key, new db encryptor version)
Command: /usr/bin/cloudstack-migrate-databases -m mgmtkey -d dbkey -n newmgmtkey -e newdbkey -v V2
Changes: db.cloud.encrypt.secret is encrypted by V2 (always)
         db.cloud.encryptor.version=V2
         cloudstack database is migrated using encryptor V2

(12) migrate db.properties and database (different db key, db encryptor version is not set)
Command: /usr/bin/cloudstack-migrate-databases -m mgmtkey -d dbkey -n newmgmtkey -e newdbkey
Changes: db.cloud.encrypt.secret is encrypted by V2 (always)
         db.cloud.encryptor.version=V1
         cloudstack database is migrated using encryptor V1

* smoke test: fix test_primary_storage.py

* smoke test: Do NOT run tests in test_primary_storage.py in parallel

This also fixes an issue in detachvolume

'Failed to detach volume Test Volume-yyyyyy from VM VM-zzzzzz; com.cloud.exception.InternalErrorException: Could not detach volume. Probably the VM is in boot state at the moment'

* Update PR7003: rename method

---------

Co-authored-by: Marcus Sorensen <mls@apple.com>
2023-01-31 13:18:28 +01:00
..
conf add date to usage server logs 2018-10-06 17:20:17 +01:00
src Apple FR68: New database encryption cipher (#214) 2023-01-31 13:18:28 +01:00
pom.xml Updating pom.xml version numbers for release 4.16.1.0 2022-02-25 19:01:16 +05:30