TR_PDF_rename

Crates.ioTR_PDF_rename
lib.rsTR_PDF_rename
version0.2.7
created_at2024-07-03 10:47:02.10283+00
updated_at2025-08-25 16:32:52.735167+00
descriptionReads security transaction statements (as pdf) from neo-broker Trade Republic and renames them as transactiondate_ordertype_name.
homepagehttps://crates.io/crates/TR_PDF_rename
repositoryhttps://github.com/ArdentEmpiricist/TR_PDF_Rename
max_upload_size
id1290421
size65,871
Hendrik Lux (ArdentEmpiricist)

documentation

https://docs.rs/crate/TR_PDF_rename/latest

README

Rust Clippy check Crates.io License

Trade Republic PDF Rename

A secure and robust tool that renames Trade Republic PDF documents to a structured, machine-readable format:

yyyy_mm_dd_[TYPE]_[ISIN]_[ASSET].pdf

Features

  • Automated PDF Processing: Recursively processes all PDF files in a directory
  • Intelligent Document Type Recognition: Supports various Trade Republic document types
  • ISIN Validation: Validates and includes ISIN codes when available
  • Security-Hardened: Input validation, path sanitization, and protection against common attack vectors
  • Safe File Operations: Prevents directory traversal attacks and validates all file paths
  • Comprehensive Error Handling: Graceful handling of malformed PDFs and edge cases

Supported Document Types

  • Kauf - Purchase transactions
  • Kauf_Sparplan - Savings plan purchases
  • Kauf_Saveback - Saveback purchases
  • Verkauf - Sale transactions
  • Dividende - Dividend payments
  • Zinsen - Interest payments
  • Zinszahlung - Interest payouts
  • Kapitalmaßnahme - Corporate actions
  • Depottransfer - Depot transfers
  • Depotauszug - Account statements
  • Steuerliche_Optimierung - Tax optimization

Installation & Usage

Build from Source

git clone https://github.com/ArdentEmpiricist/TR_PDF_Rename.git
cd TR_PDF_Rename
cargo build --release

Run

./target/release/tr_pdf_rename <path_to_folder>

Example

./target/release/tr_pdf_rename ~/Documents/TradeRepublic/

Security Features

This tool implements several security measures to ensure safe operation:

Input Validation

  • File Size Limits: Rejects files larger than 100MB to prevent DoS attacks
  • Path Validation: Ensures all operations stay within the target directory
  • Character Sanitization: Removes dangerous characters from filenames
  • Length Limits: Validates filename and path lengths

Safe File Operations

  • Directory Traversal Protection: Prevents ../ attacks through path canonicalization
  • Extension Validation: Validates file extensions to prevent malicious files
  • ISIN Validation: Proper validation of ISIN codes using checksum verification

Error Handling

  • Graceful Degradation: Continues processing other files if one fails
  • Input Sanitization: Removes control characters and Unicode exploits
  • Memory Safety: Uses #![forbid(unsafe_code)] for guaranteed memory safety

Testing

Run the comprehensive test suite including security tests:

cargo test

Run with verbose output:

cargo test -- --nocapture

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Implement your changes with tests
  4. Ensure all tests pass
  5. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Commit count: 124

cargo fmt