Skip to content

Commit

Permalink
bytes into base64 modified
Browse files Browse the repository at this point in the history
  • Loading branch information
michalkrzem committed Dec 2, 2024
1 parent a536f95 commit acd8587
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/models/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
15 changes: 11 additions & 4 deletions src/tasks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import base64
from typing import List, Optional, cast, Dict
import logging
from rq import get_current_job, Queue # type: ignore
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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})
Expand Down

0 comments on commit acd8587

Please sign in to comment.