Skip to content

fix: implement comprehensive input validation and sanitization#208

Merged
Lynndabel merged 1 commit intoChianLojistics:mainfrom
Marvy247:fix/issue-155-input-validation
Apr 2, 2026
Merged

fix: implement comprehensive input validation and sanitization#208
Lynndabel merged 1 commit intoChianLojistics:mainfrom
Marvy247:fix/issue-155-input-validation

Conversation

@Marvy247
Copy link
Copy Markdown
Contributor

Summary

Closes #155

Implements comprehensive input validation and sanitization across backend handlers and frontend forms.

Changes

Backend

  • New validation.rs module with reusable helpers:
    • validate_stellar_address() — validates G... address format (56 chars, alphanumeric)
    • validate_string() — enforces non-empty + max length
    • validate_amount() — ensures positive decimal number
    • sanitize_input() — strips HTML tags to prevent XSS/injection
  • Product handler — validates id, name, category, origin_location, description length; sanitizes all free-text fields
  • Event handler — validates product_id, actor Stellar address, location, note length; enforces event_type allowlist; rejects future timestamps
  • Financial handler — validates transaction_type, currency, amount, due_date, financing_type on all write endpoints

Frontend

  • InvoiceForm — added client-side validation with inline error messages for amount (positive number) and due_date (future date required); aria attributes for accessibility

Security Impact

  • Prevents injection attacks via HTML sanitization on all free-text inputs
  • Stellar address format validation blocks malformed addresses
  • Event type allowlist prevents arbitrary string injection
  • Amount validation prevents negative/zero financial values

…cs#155)

- Add backend validation module with Stellar address, string, and amount validators
- Add input sanitization (HTML tag stripping) on all free-text fields
- Validate event_type against allowlist in event handler
- Reject future timestamps in event creation
- Add field-level validation to financial handlers (transaction, invoice, financing)
- Add client-side validation with error messages to InvoiceForm
- Rate limiting already in place via existing middleware
@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 30, 2026

@Marvy247 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Lynndabel Lynndabel merged commit d042aae into ChianLojistics:main Apr 2, 2026
4 checks passed
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.

Input Validation

2 participants