Benign openbsd Download

print/py-pypdf 6.18.1

PDF auto-executes JavaScript on document openCoinbase wallet brand reference

Evidence

Python imports the hashlib library lines 1–16
1"""Test the pypdf._encryption module."""
2import hashlib
3import os
4import re
5import secrets
6import subprocess
7import sys
8from io import BytesIO
9from typing import NoReturn
10
11import pytest
12
13import pypdf
14from pypdf import PasswordType, PdfReader, PdfWriter
15from pypdf._crypt_providers import crypt_provider
16from pypdf._crypt_provid
pytest fixture or mark reference lines 22–33
22:42pycryptodome"
23HAS_AES = USE_CRYPTOGRAPHY or USE_PYCRYPTODOME
24
25
26@pytest.mark.parametrize(
27 ("name", "requires_aes"),
28 [
5 lines
Python decrypt method call lines 72–108
5 lines
77 Encrypted PDFs are handled correctly.
78
79 This test function ensures that:
80 - If PyCryptodome or cryptography is not available and required, a DependencyError is raised
81 - Encrypted PDFs are identified correctly
82 - Decryption works for encrypted PDFs
83 - Metadata is properly extracted from the decrypted PDF
84 """
85 inputfile = RESOURCE_ROOT / "encryption" / name
86 if requires_aes and not HAS_AES:
87 with pytest.raises(DependencyError) as exc:
88 ipdf = pypdf.PdfReader(inputfile)
89 ipdf.decrypt("asdfzxcv")
90 dd = dict(ipdf.metadata)
91 assert exc.value.args[0] == _DEPENDENCY_ERROR_STR
92 return
93 ipdf = pypdf.PdfReader(inputfile)
94 if str(inputfile).endswith("unencrypted.pdf"):
95 assert not ipdf.is_encrypted
96 else:
97 assert ipdf.is_encrypted
98 ipdf.decrypt("asdfzxcv")
99 assert len(ipdf.pages) == 1
100 dd = dict(ipdf.metadata)
101 # remove empty value entry
102 dd = {x[0]: x[1] for x in dd.items() if x[1]}
103 assert dd == {
104 "/Author": "cheng",
105 "/CreationDate": "D:20220414132421+05'24'",
106 "/Creator": "WPS Writer",
107 "/ModDate": "D:20220414132421+05'24'",
108 "/SourceModifie
pytest test framework lines 117–124
117:78.pdf
118 ("r6-both-passwords.pdf", "foo", "bar"),
119 ],
120)
121@pytest.mark.skipif(not HAS_AES, reason="No AES implementation")
122def test_pdf_with_both_passwords(name, user_passwd, owner_passwd):
123 """
124 PDFs with both user and owner passwords are h
PASSWORD credential label lines 133–145
133:24der(inputfile)
134 assert ipdf.is_encrypted
135 assert ipdf.decrypt(user_passwd) == PasswordType.USER_PASSWORD
136 assert ipdf.decrypt(owner_passwd) == PasswordType.OWNER_PASSWORD
137 assert len(ipdf.pages) == 1
138
7 lines

Showing the top 5 files — 6 more files (127 regions) not shown.

No evidence locations were recorded for this file. Raw result

Keyboard shortcuts on this page: j for the next sample, k for the previous one, x to go back to the feed, d to download the original bytes, r to re-queue the sample for analysis.