Skip to content

Commit

Permalink
load gzipped rd, see capa-testfiles#245
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-tz committed Jul 31, 2024
1 parent a8d849e commit 3982356
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions capa/render/result_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import capa.features.freeze.features as frzf
from capa.rules import RuleSet
from capa.engine import MatchResults
from capa.helpers import assert_never
from capa.helpers import assert_never, load_json_from_path


class FrozenModel(BaseModel):
Expand Down Expand Up @@ -668,4 +668,5 @@ def to_capa(self) -> Tuple[Metadata, Dict]:

@classmethod
def from_file(cls, path: Path) -> "ResultDocument":
return cls.model_validate_json(path.read_text(encoding="utf-8"))
report = load_json_from_path(path)
return cls.model_validate(report)
5 changes: 4 additions & 1 deletion tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1537,4 +1537,7 @@ def a076114_rd():
@pytest.fixture
def dynamic_a0000a6_rd():
# python -m capa.main tests/data/dynamic/cape/v2.2/0000a65749f5902c4d82ffa701198038f0b4870b00a27cfca109f8f933476d82.json --json > tests/data/rd/0000a65749f5902c4d82ffa701198038f0b4870b00a27cfca109f8f933476d82.json
return get_result_doc(CD / "data" / "rd" / "0000a65749f5902c4d82ffa701198038f0b4870b00a27cfca109f8f933476d82.json")
# gzip tests/data/rd/0000a65749f5902c4d82ffa701198038f0b4870b00a27cfca109f8f933476d82.json
return get_result_doc(
CD / "data" / "rd" / "0000a65749f5902c4d82ffa701198038f0b4870b00a27cfca109f8f933476d82.json.gz"
)

0 comments on commit 3982356

Please sign in to comment.