-
Notifications
You must be signed in to change notification settings - Fork 0
Release/3.0.0 #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Release/3.0.0 #45
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8e58420
feat: add security changes
HungKNguyen 32ae3f8
Update docs/MIGRATION.md
HungKNguyen ad96107
Update docs/MIGRATION.md
HungKNguyen 211377e
Rename FileInputWithUrl to FileInput, add UrlFileInput alias
nickwinder c92f342
Fix rotate and delete_pages with negative page indices
nickwinder fa0b849
Fix ruff per-file-ignores and remove unused variable in test
nickwinder b7d220a
Sort __all__ in __init__.py
nickwinder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Changelog | ||
|
|
||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [Unreleased] | ||
|
|
||
| ## [3.0.0] - 2026-01-30 | ||
|
|
||
| ### Security | ||
|
|
||
| - **CRITICAL**: Removed client-side URL fetching to prevent SSRF vulnerabilities | ||
| - URLs are now passed to the server for secure server-side fetching | ||
| - Restricted `sign()` method to local files only (API limitation) | ||
|
|
||
| ### Changed | ||
|
|
||
| - **BREAKING**: `sign()` only accepts local files (paths, bytes, file objects) - no URLs | ||
| - **BREAKING**: Most methods now accept `FileInputWithUrl` - URLs passed to server | ||
| - **BREAKING**: Removed client-side PDF parsing - leverage API's negative index support | ||
| - Methods like `rotate()`, `split()`, `deletePages()` now support negative indices (-1 = last page) | ||
| - All methods except `sign()` accept URLs that are passed securely to the server | ||
|
|
||
| ### Removed | ||
|
|
||
| - **BREAKING**: Removed `process_remote_file_input()` from public API (security risk) | ||
| - **BREAKING**: Removed `get_pdf_page_count()` from public API (client-side PDF parsing) | ||
| - **BREAKING**: Removed `is_valid_pdf()` from public API (internal use only) | ||
| - Removed ~200 lines of client-side PDF parsing code | ||
|
|
||
| ### Added | ||
|
|
||
| - SSRF protection documentation in README | ||
| - Migration guide (docs/MIGRATION.md) | ||
| - Security best practices for handling remote files | ||
| - Support for negative page indices in all page-based methods | ||
|
|
||
| ## [2.0.0] - 2025-01-09 | ||
|
|
||
| - Initial stable release with full API coverage | ||
| - Async-first design with httpx and aiofiles | ||
| - Comprehensive type hints and mypy strict mode | ||
| - Workflow builder with staged pattern | ||
| - Error hierarchy with typed exceptions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # Migration Guide: v2.x to v3.0 | ||
|
|
||
| ## Overview | ||
|
|
||
| Version 3.0.0 introduces SSRF protection and removes client-side PDF parsing. | ||
|
|
||
| ## Key Changes | ||
|
|
||
| ### 1. `sign()` No Longer Accepts URLs (API Limitation) | ||
|
|
||
| **Before (v2.x)**: | ||
| ```python | ||
| result = await client.sign('https://example.com/document.pdf', {...}) | ||
| ``` | ||
|
|
||
| **After (v3.0)** - Fetch file first: | ||
| ```python | ||
| import httpx | ||
|
|
||
| async with httpx.AsyncClient() as http: | ||
| url = 'https://example.com/document.pdf' | ||
|
|
||
| # IMPORTANT: Validate URL | ||
| if not url.startswith('https://trusted-domain.com/'): | ||
| raise ValueError('URL not from trusted domain') | ||
|
|
||
| response = await http.get(url, timeout=10.0) | ||
| response.raise_for_status() | ||
| pdf_bytes = response.content | ||
|
|
||
| result = await client.sign(pdf_bytes, {...}) | ||
| ``` | ||
|
|
||
| ### 2. Most Methods Now Accept URLs (Passed to Server) | ||
|
|
||
| Good news! These methods now support URLs passed securely to the server: | ||
HungKNguyen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - `rotate()`, `split()`, `add_page()`, `duplicate_pages()`, `delete_pages()` | ||
| - `set_page_labels()`, `set_metadata()`, `optimize()` | ||
| - `flatten()`, `apply_instant_json()`, `apply_xfdf()` | ||
| - All redaction methods | ||
| - `convert()`, `ocr()`, `watermark_*()`, `extract_*()`, `merge()`, `password_protect()` | ||
|
|
||
| **Example**: | ||
| ```python | ||
| # This now works! | ||
| result = await client.rotate('https://example.com/doc.pdf', 90, pages={'start': 0, 'end': 5}) | ||
| ``` | ||
|
|
||
| ### 3. Negative Page Indices Now Supported | ||
|
|
||
| Use negative indices for "from end" references: | ||
| - `-1` = last page | ||
| - `-2` = second-to-last page | ||
| - etc. | ||
|
|
||
| **Examples**: | ||
| ```python | ||
| # Rotate last 3 pages | ||
| await client.rotate(pdf, 90, pages={'start': -3, 'end': -1}) | ||
|
|
||
| # Delete first and last pages | ||
| await client.delete_pages(pdf, [0, -1]) | ||
|
|
||
| # Split: keep middle pages, excluding first and last | ||
| await client.split(pdf, [{'start': 1, 'end': -2}]) | ||
| ``` | ||
|
|
||
| ### 4. Removed from Public API | ||
|
|
||
| - `process_remote_file_input()` - No longer needed (URLs passed to server) | ||
| - `get_pdf_page_count()` - Use negative indices instead | ||
| - `is_valid_pdf()` - Let server validate (internal use only) | ||
|
|
||
| **Still Available:** | ||
| - `is_remote_file_input()` - Helper to detect if input is a URL (still public) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.