forked from kevoreilly/CAPEv2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
peepdf update and test (kevoreilly#2491)
- Loading branch information
Showing
2 changed files
with
52 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from lib.cuckoo.common.integrations.peepdf import peepdf_parse | ||
|
||
data_dir = Path(__file__).parent / "data" / "malware" | ||
pdf_path = data_dir / "ad6cedb0d1244c1d740bf5f681850a275c4592281cdebb491ce533edd9d6a77d" | ||
|
||
expected_result = { | ||
"Info": { | ||
"Creator": "Scribus 1.3.3.12", | ||
"Producer": "Scribus PDF Library 1.3.3.12", | ||
"Author": "" | ||
}, | ||
"Dates": [], | ||
"Keywords": {}, | ||
"JSStreams": [ | ||
{ | ||
"Object ID": 13, | ||
"Offset": 872, | ||
"Size": 1255, | ||
} | ||
], | ||
"All_URLs": [] | ||
} | ||
|
||
pdfresult = {"Info": {}, "Dates": [], "Keywords": {}, "JSStreams": [], "All_URLs": []} | ||
|
||
|
||
@pytest.mark.skipif(not data_dir.exists(), reason="Required data file is not present") | ||
class TestPeepdf: | ||
"""Class to test peepdf_parse.""" | ||
@pytest.mark.skipif( | ||
not pdf_path.exists(), | ||
reason="Required data file is not present", | ||
) | ||
def test_peepdf_parse_valid_pdf(self): | ||
"""Test parsing a valid PDF sample.""" | ||
result = peepdf_parse(str(pdf_path), pdfresult) | ||
del result["JSStreams"][0]["Data"] | ||
|
||
assert result == expected_result |