Title: Security & Code Quality: Add Admin Authorization Tests and Enforce Code Formatting - #202
Merged
Merged
Conversation
|
@wandooadzer-cmyk 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! 🚀 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary This PR implements critical security improvements and code quality enforcement for the Soroban contract, addressing multiple audit findings from the additional audit report.
Changes Made
Added comprehensive test coverage to verify that only authorized admins can perform sensitive setup operations:
test_unauthorized_init_gold_trustline - Verifies non-admin users cannot initialize gold trustline configuration
test_unauthorized_initialize_soroswap - Verifies non-admin users cannot initialize Soroswap router configuration
test_initialize_already_initialized - Ensures contract cannot be re-initialized after setup
test_admin_can_init_gold_trustline - Positive test confirming admin can successfully initialize gold trustline
test_admin_can_initialize_soroswap - Positive test confirming admin can successfully initialize Soroswap
These tests follow existing project patterns and use proper auth mocking with env.mock_auths() to simulate real authorization scenarios.
Added cargo fmt --all -- --check to the CI pipeline in .github/workflows/ci.yml. This ensures:
All Rust code adheres to standard formatting before merging
Consistent code style across the codebase
Improved maintainability and readability
Automated enforcement prevents unformatted code from reaching main
Impact
Security: Prevents unauthorized access to sensitive contract configuration
Maintainability: Enforces consistent code formatting across the project
Production Readiness: Addresses critical audit findings before deployment
Testing The new admin authorization tests can be verified with:
bash
cd smasage/contracts
cargo test
Closes
Closes #184 - Unauthorized admin setup tests
Closes #172 - Admin authorization test coverage
Closes #167 - Security audit remediation
Closes #162 - Code formatting enforcement