Skip to content

Commit

Permalink
Remove the keyed hash function for transforming block names
Browse files Browse the repository at this point in the history
  • Loading branch information
hardbyte committed Mar 22, 2021
1 parent 42a9fd2 commit df7cd53
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 37 deletions.
28 changes: 0 additions & 28 deletions backend/alembic/versions/d9e07ea2889e_add_run_secret_column.py

This file was deleted.

8 changes: 4 additions & 4 deletions backend/entityservice/database/insertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ def insert_new_project(cur, result_type, schema, access_token, project_id, num_p
result_type, uses_blocking])


def insert_new_run(db, run_id, project_id, threshold, name, type, notes='', secret=''):
def insert_new_run(db, run_id, project_id, threshold, name, type, notes=''):
sql_query = """
INSERT INTO runs
(run_id, project, name, notes, threshold, state, type, secret)
(run_id, project, name, notes, threshold, state, type)
VALUES
(%s, %s, %s, %s, %s, %s, %s, %s)
(%s, %s, %s, %s, %s, %s, %s)
RETURNING run_id;
"""
with db.cursor() as cur:
run_id = execute_returning_id(cur, sql_query,
[run_id, project_id, name, notes, threshold, 'created', type, secret])
[run_id, project_id, name, notes, threshold, 'created', type])
return run_id


Expand Down
1 change: 0 additions & 1 deletion backend/entityservice/database/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class Run(Base):

id = Column(Integer, primary_key=True)
run_id = Column(CHAR(48), nullable=False, unique=True)
secret = Column(CHAR(48), nullable=True)
project = Column(ForeignKey('projects.project_id', ondelete='CASCADE'))
name = Column(Text)
notes = Column(Text)
Expand Down
4 changes: 2 additions & 2 deletions backend/entityservice/encoding_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ def encoding_iterator(filter_stream):
return encoding_iterator(stream)


def hash_block_name(provided_block_name, key=b'pseudorandom key stored in run table'):
block_hmac_instance = blake2b(key=key, digest_size=32)
def hash_block_name(provided_block_name):
block_hmac_instance = blake2b(digest_size=32)
block_hmac_instance.update(str(provided_block_name).encode())
provided_block_name = block_hmac_instance.hexdigest()
return provided_block_name
3 changes: 1 addition & 2 deletions backend/entityservice/models/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def __init__(self, project_id, threshold, name, notes):
self.notes = notes
self.threshold = threshold
self.run_id = generate_code()
self.secret = generate_code()
logger.info("Created run id", rid=self.run_id)

with DBConn() as conn:
Expand All @@ -86,5 +85,5 @@ def from_json(data, project_id):
def save(self, conn):
logger.debug("Saving run in database", rid=self.run_id)
db.insert_new_run(db=conn, run_id=self.run_id, project_id=self.project_id, threshold=self.threshold,
name=self.name, notes=self.notes, type=self.type, secret=self.secret)
name=self.name, notes=self.notes, type=self.type)
logger.debug("New run created in DB", rid=self.run_id)

0 comments on commit df7cd53

Please sign in to comment.