Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions dissect/target/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import os
import pathlib
import stat
import warnings
from collections import defaultdict
from typing import TYPE_CHECKING, Any, BinaryIO, Callable, Iterator, Optional, Type

Expand Down Expand Up @@ -67,15 +66,6 @@ def __init__(
def __repr__(self) -> str:
return f"<{self.__class__.__name__}>"

@classmethod
@property
def __fstype__(cls) -> str:
warnings.warn(
"The __fstype__ attribute is deprecated and will be removed in dissect.target 3.15. Use __type__ instead",
category=DeprecationWarning,
)
return cls.__type__

def path(self, *args) -> fsutil.TargetPath:
"""Instantiate a new path-like object on this filesystem."""
return fsutil.TargetPath(self, *args)
Expand Down
40 changes: 0 additions & 40 deletions dissect/target/helpers/hashutil.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
from __future__ import annotations

import hashlib
import warnings
from typing import TYPE_CHECKING, BinaryIO, Union

from flow.record import Record

from dissect.target.exceptions import FileNotFoundError

if TYPE_CHECKING:
from hashlib._hashlib import HASH

from dissect.target.target import Target

BUFFER_SIZE = 32768


Expand Down Expand Up @@ -52,36 +45,3 @@ def custom(fh: BinaryIO, algos: list[Union[str, HASH]]) -> tuple[str]:
ctx = algos

return _hash(fh, ctx)


def hash_uri(target: Target, path: str) -> tuple[str, str]:
"""Hash the target path."""
warnings.warn(
(
"The hash_uri() function is deprecated, and will be removed in dissect.target 3.15. "
"Use target.fs.hash() instead"
),
DeprecationWarning,
)

if path is None:
raise FileNotFoundError()

path = str(target.resolve(path))
return (path, target.fs.hash(path))


def hash_uri_records(target: Target, record: Record) -> Record:
"""Hash uri paths inside the record."""

from dissect.target.helpers.record_modifier import Modifier, get_modifier_function

warnings.warn(
(
"The hash_uri_records() function is deprecated, and will be removed in dissect.target 3.15. "
"Use hash_path_records() instead"
),
DeprecationWarning,
)
func = get_modifier_function(Modifier.HASH)
return func(target, record)
31 changes: 0 additions & 31 deletions tests/helpers/test_hashutil.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from pathlib import Path
from unittest.mock import Mock, patch

import pytest

import dissect.target.helpers.hashutil as hashutil
from dissect.target import Target
from dissect.target.exceptions import FileNotFoundError

HASHES = ("CAFEF00D" * 4, "F4CEF001" * 5, "DEADBEEF" * 8)

Expand All @@ -28,32 +26,3 @@ def test_common() -> None:
assert len(output[0]) == 32
assert len(output[1]) == 40
assert len(output[2]) == 64


def test_hash_uri_records() -> None:
with pytest.deprecated_call():
with patch("dissect.target.helpers.record_modifier.get_modifier_function", autospec=True) as modifier_func:
target = Mock()
record = Mock()
hashutil.hash_uri_records(target, record)
modifier_func.assert_called_with("hash")
modifier_func.return_value(target, record)


def test_hash_uri(mock_target: Target) -> None:
"""Determine hash functions"""
path = "/test/path"
with (
pytest.deprecated_call(),
patch.object(mock_target, "resolve", side_effect=resolve_func),
):
output = hashutil.hash_uri(mock_target, path)

assert output[0] == str(resolve_func(path))
assert output[1] == HASHES


def test_hash_uri_none() -> None:
"""Determine hash functions"""
with pytest.deprecated_call(), pytest.raises(FileNotFoundError):
hashutil.hash_uri(Mock(), None)