forked from keylime/keylime
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
verifier: convert (v)tpm_policy in DB from string to JSONPickleType
We now enforce that the (v)tpm_policy should be a JSON object which then is converted to a dict. This also fixes the issue were tpm_policy.keys() was called even when tpm_policy was a string. Signed-off-by: Thore Sommer <[email protected]>
- Loading branch information
Showing
3 changed files
with
55 additions
and
11 deletions.
There are no files selected for viewing
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
49 changes: 49 additions & 0 deletions
49
keylime/migrations/versions/f35cdd35eb83_move_v_tpm_policy_to_jsonpickletype.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,49 @@ | ||
"""Move (v)tpm_policy to JSONPickleType | ||
Revision ID: f35cdd35eb83 | ||
Revises: 7d5db1a6ffb0 | ||
Create Date: 2021-08-02 15:26:34.427156 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
import keylime | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'f35cdd35eb83' | ||
down_revision = '7d5db1a6ffb0' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(engine_name): | ||
globals()["upgrade_%s" % engine_name]() | ||
|
||
|
||
def downgrade(engine_name): | ||
globals()["downgrade_%s" % engine_name]() | ||
|
||
|
||
def upgrade_registrar(): | ||
pass | ||
|
||
|
||
def downgrade_registrar(): | ||
pass | ||
|
||
|
||
def upgrade_cloud_verifier(): | ||
with op.batch_alter_table('verifiermain') as batch_op: | ||
batch_op.alter_column('tpm_policy', existing_type=sa.String(1000), | ||
type_=keylime.db.verifier_db.JSONPickleType(), existing_nullable=True) | ||
batch_op.alter_column('vtpm_policy', existing_type=sa.String(1000), | ||
type_=keylime.db.verifier_db.JSONPickleType(), existing_nullable=True) | ||
|
||
|
||
def downgrade_cloud_verifier(): | ||
with op.batch_alter_table('verifiermain') as batch_op: | ||
batch_op.alter_column('tpm_policy', type_=sa.String(1000), | ||
existing_type=keylime.db.verifier_db.JSONPickleType(), existing_nullable=True) | ||
batch_op.alter_column('vtpm_policy', type_=sa.String(1000), | ||
existing_type=keylime.db.verifier_db.JSONPickleType(), existing_nullable=True) |
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