diff --git a/src/models/match.py b/src/models/match.py index 1a1816d5..3fd47df7 100644 --- a/src/models/match.py +++ b/src/models/match.py @@ -22,4 +22,4 @@ class Match(SQLModel, table=True): ) ) job: Job = Relationship(back_populates="matches") - context: Dict[str, List[str]] = Field(sa_column=Column(JSON)) + context: Dict[str, List[Dict[str, str]]] = Field(sa_column=Column(JSON)) diff --git a/src/tasks.py b/src/tasks.py index 1afc2938..9e95ed62 100644 --- a/src/tasks.py +++ b/src/tasks.py @@ -1,3 +1,4 @@ +import base64 from typing import List, Optional, cast, Dict import logging from rq import get_current_job, Queue # type: ignore @@ -73,7 +74,7 @@ def update_metadata( orig_name: str, path: str, matches: List[str], - context: Dict[str, List[Dict[str, bytes]]], + context: Dict[str, List[Dict[str, str]]], ) -> None: """Saves matches to the database, and runs appropriate metadata plugins. @@ -173,9 +174,15 @@ def execute_yara(self, job: Job, files: List[str]) -> None: ) match_context.append( { - "before": before, - "matching": matching, - "after": after, + "before": base64.b64encode( + before + ).decode("utf-8"), + "matching": base64.b64encode( + matching + ).decode("utf-8"), + "after": base64.b64encode( + after + ).decode("utf-8"), } ) context.update({str(rule): match_context})