Exemple #1
0
def _binary_ops(binary: str, comment: str, export_csv: str, remove: bool):
    b = Binary.get(name=binary)
    if comment is not None:
        b.comment = comment
    if export_csv is not None:
        export_csv_combined(b, export_csv)
    if remove is True:
        Binary.delete(b)
Exemple #2
0
def get_or_create_binary(path: Path, make_target=False) -> Binary:
    """import_binary creates a Binary and stores it in database

	Args:
        binary_path: the file path of the binary

	Returns: Binary
    """

    logger.info(f"retrieving binary for path {path}")
    binary = Binary.get(filepath=str(path))
    if not binary:
        if not path.is_file():
            raise FileNotFoundError
        binary = Binary(filepath=str(path), name=path.name)
    elif make_target:
        binary.is_target = True
    binary.partition()
    return binary