Survey completed and categorized all 17 generator scripts across 7 fixture subdirectories. KEEP (10): - Active fixture generators for scanned, encoding, forms, security, malformed, and vector test fixtures - All actively maintained (May-July 2025) - Core infrastructure for OCR, encoding, and security testing DELETE (5): - Redundant Python/Rust duplicates (prefer Python for encoding, Rust for security) - Orphaned Makefile dependency file - Superseded implementations RELOCATE (2): - convert_to_scanned.sh → tools/ (general-purpose utility) - regenerate.sh → tools/ or DELETE (incomplete stub) Full categorization with rationale: /tmp/generator_categorization.md Closes: bf-1iefu
3.2 KiB
3.2 KiB
bf-5ucbr: Capture pdftract debug logs on JavaScript PDF
Task Summary
Capture pdftract debug logs on JavaScript PDF fixture and preserve the output for verification.
Execution
PDF File Used
- File:
tests/fixtures/security/embedded-js.pdf - Size: 1.1K
- Contains: JavaScript action with
app.alert("pwn")in catalog.openaction
Commands Executed
# Attempt 1: With debug logging and combined output
RUST_LOG=debug cargo run --bin pdftract -- extract tests/fixtures/security/embedded-js.pdf --json - 2>&1 | tee notes/bf-5ucbr-pdftract-debug.log
# Attempt 2: With trace logging, separated stdout/stderr
RUST_LOG=trace cargo run --bin pdftract -- extract tests/fixtures/security/embedded-js.pdf --json - > /tmp/js_output.json 2> notes/bf-5ucbr-pdftract-debug-stderr.log
Results
pdftract Version: Built from current main branch (dev profile, unoptimized debuginfo)
Execution Status: ✅ SUCCESS - pdftract ran successfully on the JavaScript PDF fixture
JavaScript Detection: Successfully detected 1 JavaScript action:
{
"javascript_actions": [
{
"code_excerpt": "app.alert(\"pwn\")",
"location": "catalog.openaction"
}
],
"metadata": {
"diagnostics": [
"Detected 1 JavaScript action(s) in PDF document. JavaScript was NOT executed."
]
}
}
Logging Observation: ⚠️ RUST_LOG environment variable does not produce debug output. The pdftract CLI (main.rs) does not initialize any logging framework (env_logger, tracing, etc.). While serve.rs uses tracing for HTTP server logging, the CLI extraction commands don't implement structured logging.
Output Captured:
- JSON extraction result:
/tmp/js_output.json - Log capture:
notes/bf-5ucbr-pdftract-debug.log(27 lines - JSON output only) - Stderr log:
notes/bf-5ucbr-pdftract-debug-stderr.log(0 lines - no debug output)
Key Findings
- JavaScript Detection Working: pdftract successfully identifies JavaScript in PDFs and reports code excerpts and locations
- No Execution: JavaScript is detected but NOT executed (security feature confirmed working)
- Logging Gap: The CLI lacks debug logging infrastructure - RUST_LOG has no effect outside of serve mode
- Extraction Success: The PDF extraction pipeline completes successfully on JavaScript-containing files
Verification
- ✅ pdftract runs successfully on JavaScript PDF fixture
- ✅ Output captured to files (
notes/bf-5ucbr-pdftract-debug.log,/tmp/js_output.json) - ✅ Debug logging level (RUST_LOG=debug) was attempted (though not implemented in CLI)
- ✅ Log capture preserved for verification
Recommendations for Future Debug Logging
If debug logging is needed for CLI commands, consider:
- Add
env_logger::init()inmain.rsconditioned on RUST_LOG environment variable - Or migrate CLI to use
tracingframework (already used inserve.rs) - Add debug log statements at key extraction pipeline points
Files Generated
notes/bf-5ucbr-pdftract-debug.log- Combined stdout/stderr capture (JSON output)notes/bf-5ucbr-pdftract-debug-stderr.log- Stderr-only capture (empty - no debug logs)/tmp/js_output.json- JSON extraction result (temporary file)