Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 8, 2025

POST Policy E2E Tests and Bug Fixes

Completed Tasks:

  • Research AWS S3 POST Policy specification and understand policy validation requirements
  • Add E2E tests for POST object with policy (both v2 and v4 signatures)
    • Test basic POST object upload with valid policy
    • Test policy condition validation (bucket, key, content-length, etc.)
    • Test policy expiration
    • Test invalid policy scenarios
  • Implement policy validation logic in s3s
    • Create POST policy data model (expiration, conditions)
    • Parse and decode base64 policy
    • Validate policy expiration
    • Validate policy conditions against actual request
  • All unit tests passing
  • Code review completed and feedback addressed
  • Merged main branch
  • CI format and checks passing

Summary:

Added comprehensive POST Policy validation to s3s:

  1. E2E Tests: Created 6 test cases covering basic upload, conditions, content-length-range, starts-with, expired policy, and invalid bucket
  2. Policy Validation: Implemented full POST policy parsing and validation including expiration and condition checking
  3. Integration: Integrated policy validation into both v2 and v4 signature verification flows
  4. Conditions Supported:
    • Exact match ({"field": "value"} or ["eq", "$field", "value"])
    • Starts with (["starts-with", "$field", "prefix"])
    • Content length range (["content-length-range", min, max])

The implementation validates policies against actual request data, preventing unauthorized uploads that don't match policy constraints.

Recent Updates:

  • Merged latest main branch with upstream changes
  • Fixed clippy warning (unused import)
  • All CI checks passing
Original prompt

This section details on the original issue you should resolve

<issue_title>POST Policy</issue_title>
<issue_description>Tasks:

  1. Add e2e tests to check if s3s supports POST policy correctly.
  2. If there is any bug, try to fix.
  3. Make sure the CI passes before committing changes.

Related:

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 5 commits December 8, 2025 04:57
- Created comprehensive E2E tests for POST object with policy validation
- Tests cover: basic upload, conditions, content-length-range, starts-with, expired policy, invalid bucket
- Added required dependencies: time, serde_json, hmac, sha2, hex

Co-authored-by: Nugine <[email protected]>
- Created post_policy module to parse and validate POST policies
- Added policy expiration validation
- Added policy condition validation (exact match, starts-with, content-length-range)
- Integrated policy validation into signature verification (v2 and v4)
- Validates policy conditions against actual POST request data
- Added serde_json dependency to s3s crate

Co-authored-by: Nugine <[email protected]>
- Fixed doc comment formatting (use backticks instead of quotes)
- Removed unused self parameters from static methods
- Fixed format string inlining warnings in tests
- Fixed needless borrow warnings

Co-authored-by: Nugine <[email protected]>
- Increased ops::call limit from 1600 to 1650 bytes
- Increased S3Service::call limit from 3000 to 3050 bytes
- Increased S3Service::call_owned limit from 3300 to 3350 bytes
- These increases are due to the added Option<PostPolicy> field

Co-authored-by: Nugine <[email protected]>
- Return EntityTooSmall when file_size < min
- Return EntityTooLarge when file_size > max
- Previously always returned EntityTooSmall for both cases

Co-authored-by: Nugine <[email protected]>
Copilot AI changed the title [WIP] Add e2e tests for checking POST policy support Add POST Policy validation for browser-based S3 uploads Dec 8, 2025
Copilot AI requested a review from Nugine December 8, 2025 05:29
@Nugine
Copy link
Collaborator

Nugine commented Dec 14, 2025

@copilot

  1. Merge main branch
  2. Run CI format and checks
  3. Fix the failures

Copilot AI and others added 2 commits December 14, 2025 09:36
- Merged origin/main into copilot/add-e2e-tests-for-post-policy
- Removed unused import of s3_error macro (already available via #[macro_use])
- All tests and clippy checks passing

Co-authored-by: Nugine <[email protected]>
Copy link
Contributor Author

Copilot AI commented Dec 14, 2025

@copilot

  1. Merge main branch
  2. Run CI format and checks
    ...

Done! Merged main branch and fixed the unused import issue. All CI format checks and clippy now pass. Commit: 582cb9b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

POST Policy

2 participants