-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NAS-132265 / 25.04 / VM Device attributes should be encrypted (by Qub…
…ad786) (#14895) * Make vm devices encrypted (cherry picked from commit 5173ee7) * Merge migration --------- Co-authored-by: M. Rehan <[email protected]>
- Loading branch information
Showing
3 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...iddlewared/alembic/versions/24.10/2024-11-06_12-49_make_vm_device_attributes_encrypted.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"""Make vm device attributes encrypted | ||
Revision ID: b5829f78cec3 | ||
Revises: 8eacd2bb3e18 | ||
Create Date: 2024-11-06 12:49:18.684987+00:00 | ||
""" | ||
import json | ||
|
||
from alembic import op | ||
|
||
from middlewared.plugins.pwenc import encrypt | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'b5829f78cec3' | ||
down_revision = '8eacd2bb3e18' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
|
||
conn = op.get_bind() | ||
for device in conn.execute("SELECT * FROM vm_device").fetchall(): | ||
attributes = json.loads(device['attributes']) | ||
|
||
conn.execute( | ||
"UPDATE vm_device SET attributes = ? WHERE id = ?", | ||
(encrypt(json.dumps(attributes)), device['id']) | ||
) | ||
|
||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
pass | ||
# ### end Alembic commands ### |
20 changes: 20 additions & 0 deletions
20
src/middlewared/middlewared/alembic/versions/25.04/2024-11-07_20-25_merge.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
""" | ||
Merge | ||
Revision ID: f077d0ae123d | ||
Revises: 0ec74f350c66, b5829f78cec3 | ||
Create Date: 2024-11-07 20:25:59.547731+00:00 | ||
""" | ||
|
||
revision = 'f077d0ae123d' | ||
down_revision = ('0ec74f350c66', 'b5829f78cec3') | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
pass | ||
|
||
|
||
def downgrade(): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters