Add 7 adversarial PDF fixtures exercising Phase 1 error-recovery paths: - xref_30pct_bad_offsets.pdf: 100 objects, 30 bad xref offsets - missing_mediabox_all_pages.pdf: 10 pages, no /MediaBox at any level - missing_endobj.pdf: object 5 missing endobj marker - truncated_mid_stream.pdf: FlateDecode stream truncated mid-decompression - int_overflow_bbox.pdf: /BBox value 99999999999999999 (i32 overflow) - nested_failure.pdf: every page has at least one diagnostic - combined_failures.pdf: combines multiple failure modes (keystone INV-8 test) Each fixture has a sibling .expected_diagnostics.json file with threshold counts (>= not == per EC-07/EC-09 to tolerate drift). Integration test harness (error_recovery_integration.rs): - assert_diagnostic_count_at_least() helper for threshold checking - assert_no_panic() helper using std::panic::catch_unwind for INV-8 - Individual test functions for each fixture - Cumulative test_inv_8_no_panics_across_all_fixtures() All 8 tests pass. INV-8 verified: zero panics across all fixtures. Closes: pdftract-4w0v4
56 lines
1.5 KiB
Python
56 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Generate combined_failures.pdf - combines multiple failure modes."""
|
|
|
|
# This PDF combines:
|
|
# 1. Truncated EOF (missing %%EOF marker or truncated)
|
|
# 2. Missing /MediaBox
|
|
# 3. Integer overflow in /Length
|
|
# 4. Circular reference
|
|
|
|
PDF_CONTENT = b"""%PDF-1.4
|
|
1 0 obj
|
|
<< /Type /Catalog /Pages 2 0 R >>
|
|
endobj
|
|
2 0 obj
|
|
<< /Type /Pages /Kids [3 0 R 4 0 R] /Count 2 >>
|
|
endobj
|
|
3 0 obj
|
|
% Page 1: Missing MediaBox + integer overflow in Contents length
|
|
<< /Type /Page /Parent 2 0 R /Contents 5 0 R /Resources << >> >>
|
|
endobj
|
|
4 0 obj
|
|
% Page 2: Circular reference (Contents points to itself)
|
|
<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents 4 0 R /Resources << >> >>
|
|
endobj
|
|
5 0 obj
|
|
% Stream with integer overflow in /Length
|
|
<< /Length 999999999999999999 /Filter /FlateDecode >>
|
|
stream
|
|
This is a test stream that is shorter than the declared length.
|
|
endstream
|
|
endobj
|
|
xref
|
|
0 6
|
|
0000000000 65535 f
|
|
0000000009 00000 n
|
|
0000000058 00000 n
|
|
0000000131 00000 n
|
|
0000000258 00000 n
|
|
0000000395 00000 n
|
|
trailer
|
|
<< /Size 6 /Root 1 0 R >>
|
|
startxref
|
|
550
|
|
% Note: Truncated EOF - missing %%EOF marker
|
|
"""
|
|
|
|
with open('combined_failures.pdf', 'wb') as f:
|
|
f.write(PDF_CONTENT)
|
|
|
|
print("Generated combined_failures.pdf")
|
|
print("Combines multiple failure modes:")
|
|
print("1. Truncated EOF (missing %%EOF marker)")
|
|
print("2. Missing /MediaBox on page 1")
|
|
print("3. Integer overflow in /Length of object 5")
|
|
print("4. Circular reference on page 2")
|
|
print("Expected: >= 1 page extracted, ~5+ diagnostics, no panic")
|