-
Notifications
You must be signed in to change notification settings - Fork 1k
[GDS] Add configurable validation limits for trust list file read/write operations #3411
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
base: master
Are you sure you want to change the base?
Conversation
|
|
Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
|
@copilot please add Tests |
Add TrustListValidationTest with tests for: - Normal-sized trust lists (verify basic functionality) - Trust lists exceeding 16MB limit (verify BadEncodingLimitsExceeded error) - Trust lists just under limit (~15MB) (verify boundary condition) Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
Added comprehensive tests in TrustListValidationTest.cs:
Tests cover both server-side and client-side validation with proper error handling. Commit: d40437c |
|
@copilot please update the PR Description based on the Code Changes in my last two commits in this branch |
Updated PR description to reflect the changes from commits db9ba94 and 796a230: Key additions:
The PR description now accurately reflects all code changes including configurability improvements and comprehensive test enhancements. |
Proposed changes
Trust list file operations lacked size validation, allowing unbounded memory allocation. Added configurable limits with overflow protection on both server and client sides, along with comprehensive tests to verify the validation logic.
Server-side (TrustList.cs)
maxTrustListSizeparameter (defaults to 1MB when config is 0)m_totalBytesProcessedduring Read/Write operationsBadEncodingLimitsExceededwhen exceededm_lockServer-side (ConfigurationNodeManager.cs)
MaxTrustListSizefrom application configuration to TrustList constructorClient-side (GlobalDiscoveryServerClient.cs & ServerPushConfigurationClient.cs)
maxTrustListSizeparameterReadTrustListAsyncandUpdateTrustListAsyncaccept optional size limit parameterServiceResultExceptionwithBadEncodingLimitsExceededwhen exceededTests (TrustListValidationTest.cs)
BadEncodingLimitsExceededusing dynamic size calculationGetEncodedSize()helper method for accurate trust list size calculation in testsTest Infrastructure Updates
GlobalDiscoveryTestServerto accept and configuremaxTrustListSizeTestUtils.StartGDSAsyncto support optionalmaxTrustListSizeparameterSecurity benefits
MaxTrustListSizefrom application configurationRelated Issues
Related to discussion in #3271
Types of changes
Checklist
Further comments
Optional constructor and method parameters maintain backward compatibility. Existing configurations with
MaxTrustListSize = 0receive 1MB default limit. Client-side methods accept optional size limits, defaulting to 1MB when not specified, allowing per-operation customization.Tests use dynamic size calculation with
GetEncodedSize()helper to accurately test boundary conditions. The comprehensive test suite covers normal operation, error conditions when limits are exceeded, boundary cases at exact limits, and scenarios with custom server-side configuration. All tests use the existing GDS test infrastructure and follow established patterns.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.