Skip to content

Commit

Permalink
models:file - add root field (ignored in database)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoCampinoti94 committed Oct 30, 2023
1 parent aa55639 commit 80e3853
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions acacore/models/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,34 @@ class File(ACABase):
signature: Optional[str]
warning: Optional[str] = None
action: Optional[Action] = None
root: Optional[Path] = Field(None, ignore=True)

def get_checksum(self, root: Optional[Path] = None) -> str:
self.checksum = file_checksum(self.get_absolute_path(root))
def get_checksum(self) -> str:
self.checksum = file_checksum(self.get_absolute_path(self.root))
return self.checksum

def identify(self, sf: Siegfried, root: Optional[Path] = None) -> SiegfriedFile:
def identify(self, sf: Siegfried) -> SiegfriedFile:
"""Identify the file using `siegfried`.
Args:
sf (Siegfried): A Siegfried class object
root: Root for relative path
Returns:
SiegfriedFile: A dataclass object containing the results from the identification
"""
return sf.identify(self.get_absolute_path(root)).files[0]
return sf.identify(self.get_absolute_path(self.root)).files[0]

def identify_custom(self, custom_sigs: list[CustomSignature], root: Optional[Path] = None) -> CustomSignature:
def identify_custom(self, custom_sigs: list[CustomSignature]) -> CustomSignature:
"""Uses the BOF and EOF to try to determine a ACAUID for the file.
The custom_sigs list should be found on the `reference_files` repo.
If no match can be found, the method does nothing.
Args:
custom_sigs: A list of the custom_signatures that the file should be checked against
root: Root for relative path
"""
bof = get_bof(self.get_absolute_path(root)).hex()
eof = get_eof(self.get_absolute_path(root)).hex()
bof = get_bof(self.get_absolute_path(self.root)).hex()
eof = get_eof(self.get_absolute_path(self.root)).hex()
signature: Optional[CustomSignature] = None

# We have to go through all the signatures in order to check their BOF en EOF with the file.
Expand Down Expand Up @@ -102,7 +101,7 @@ def name(self) -> str:
"""
return self.relative_path.name

def ext(self) -> str:
def suffix(self) -> str:
"""
Get the file extension.
Expand Down

0 comments on commit 80e3853

Please sign in to comment.