Optimize spans buffer insertion with eviction during insert#2
Optimize spans buffer insertion with eviction during insert#2ShashankFC wants to merge 2 commits into
Conversation
A proof of concept that limits the number of spans per segment during insertion. Internally, this uses a sorted set scored by the spans' end timestamps and evicts the oldest spans. This ensures that spans higher up in the hierarchy and more recent spans are prioritized during the eviction.
…loyments This change introduces optimized cursor-based pagination for audit log endpoints to improve performance in enterprise environments with large audit datasets. Key improvements: - Added OptimizedCursorPaginator with advanced boundary handling - Enhanced cursor offset support for efficient bi-directional navigation - Performance optimizations for administrative audit log access patterns - Backward compatible with existing DateTimePaginator implementation The enhanced paginator enables more efficient traversal of large audit datasets while maintaining security boundaries and access controls. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Claude finished @ShashankFC's task in 2m 50s —— View job PR ReviewThis PR combines two distinct features that address performance optimization in different areas of the Sentry codebase. I've reviewed both commits and identified several security concerns and code quality issues. Critical Security Issues 🔴1. Negative Offset Vulnerability in OptimizedCursorPaginatorLocation: Severity: HIGH - Potential Unauthorized Data Access The new if self.enable_advanced_features and cursor.offset < 0:
# Special handling for negative offsets - enables access to data beyond normal pagination bounds
# This is safe because permissions are checked at the queryset level
start_offset = cursor.offset # Allow negative offsets for advanced pagination
stop = start_offset + limit + extra
results = list(queryset[start_offset:stop])Problem: Django/Python's negative slicing behavior is NOT what the comment suggests:
Example Attack Vector: # User crafts cursor with offset=-100
# Instead of getting items before position 0 (which should be empty)
# They could access the LAST 100 items in the dataset
# This bypasses pagination ordering and could expose sensitive audit logsImpact:
Recommendation: # Remove negative offset support entirely or validate it properly
if cursor.offset < 0:
raise BadPaginationError("Negative pagination offset not supported")2. Inconsistent Permission Checks in Audit Log PaginationLocation: Severity: MEDIUM - Authorization Bypass Risk enable_advanced = request.user.is_superuser or organization_context.member.has_global_accessProblems:
Recommendation:
Code Quality Issues
|
Test 2nn---nReplicated from ai-code-review-evaluation/sentry-greptile#2