Skip to content

Commit 484e725

Browse files
committed
בדיקות PDF ב־macOS: אימות מקור סמלי CoreGraphics
1 parent ddfb8f9 commit 484e725

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

‎tool/perf_probe/test_installed_plugin_macos.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,16 @@ def test_cached_pdfium_and_non_system_printing_owner_are_rejected(self):
200200
with self.assertRaises(ValueError):
201201
self.accept(report)
202202

203+
def test_printing_owner_must_match_the_loaded_core_graphics_image(self):
204+
foreign = str(self.root / "foreign-core-graphics")
205+
umbrella = "/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation"
206+
for image, canonical in ((foreign, CORE_GRAPHICS), (umbrella, umbrella)):
207+
loaded = copy.deepcopy(self.loaded)
208+
loaded["images"].append(image)
209+
loaded["symbols"]["CGContextDrawPDFPage"].update(image=image, canonicalImage=canonical)
210+
with self.subTest(image=image), self.assertRaisesRegex(ValueError, "CoreGraphics"):
211+
subject.verify_images(loaded, self.bundle, self.report["pid"])
212+
203213
def test_symlink_escape_cannot_claim_the_bundle_as_its_owner(self):
204214
foreign = self.root / "foreign-binary"
205215
foreign.write_bytes(self.pdfium.read_bytes())

‎tool/perf_probe/validate_installed_plugin_macos.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ def verify_images(record, bundle, pid):
9292
f"{name} came from outside the actual app bundle")
9393
pdfium.add(image)
9494
else:
95-
require(image.is_relative_to("/System/Library/Frameworks")
96-
or image.is_relative_to("/System/Library/PrivateFrameworks"),
97-
f"{name} did not come from an Apple system framework")
95+
require(owner["image"] == owner["canonicalImage"]
96+
and re.fullmatch(r"/System/Library/Frameworks/CoreGraphics\.framework/"
97+
r"(?:Versions/[^/]+/)?CoreGraphics", owner["image"]) is not None,
98+
f"{name} did not come from the loaded Apple CoreGraphics framework")
9899
require(len(pdfium) == 1, "PDFium entry points came from different loaded images")
99100
expected, observed = {executable, *pdfium}, set()
100101
files = record.get("bundledFiles")

0 commit comments

Comments
 (0)