fix(sdk): test untested paths, simplify regex, enforce tls 1.2+ - #708
Open
omercnet wants to merge 5 commits into
Open
fix(sdk): test untested paths, simplify regex, enforce tls 1.2+#708omercnet wants to merge 5 commits into
omercnet wants to merge 5 commits into
Conversation
- Add comprehensive tests for untested security-critical paths (logger, TLS) - Simplify email regex to improve maintainability (Go's RE2 is ReDoS-immune) - Add runtime warning for fallback JWT parsing without validation - Enforce TLS 1.2+ by default with optional override for testing/debugging - Add MinTLSVersion field to ClientParams for configurable TLS enforcement - Log warning when insecure TLS versions below 1.2 are used Security impact: - TLS 1.2+ enforcement prevents protocol downgrade attacks - Simplified regex reduces complexity and improves maintainability - JWT validation fallback now explicitly warns about unverified tokens - Improved test coverage for security-critical code paths Co-authored-by: Shuni <251468265+shuni-bot[bot]@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the SDK’s default security posture and improves coverage of previously untested security-relevant paths (logger, TLS configuration, and auth utilities), alongside simplifying validation logic.
Changes:
- Adds new test suites for logger behavior, TLS minimum version enforcement, and auth regex validation.
- Simplifies the email validation regex and adds tests around email/phone matching.
- Adds runtime warning logs for JWT fallback parsing and for configuring TLS below 1.2, plus introduces
ClientParams.MinTLSVersion.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
descope/logger/log_test.go |
Adds tests for logger wrapper internals, singleton init, and log-level filtering. |
descope/internal/auth/utils_test.go |
Adds tests for the (new) simplified email regex and existing phone regex. |
descope/internal/auth/utils.go |
Replaces the previous RFC-like email regex with a simplified pattern and adds explanatory comments. |
descope/internal/auth/auth.go |
Logs a warning when JWT verification fails and the code falls back to unverified parsing. |
descope/api/client_tls_test.go |
Adds tests asserting TLS 1.2 default minimum and MinTLSVersion override behavior. |
descope/api/client.go |
Introduces MinTLSVersion and sets tls.Config.MinVersion, plus warns on < TLS 1.2. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
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.
Fixes descope/etc#14535
View workflow run
Excellent! All security improvements have been successfully implemented, tested, and committed. Here's a summary of what was accomplished:
✅ Security Improvements Completed
1. Tested Untested Security-Critical Code Paths
descope/logger/log_test.go)doLog()method (previously marked// notest)2. Simplified Email Regex
^[a-zA-Z0-9]([a-zA-Z0-9._%+\-]*[a-zA-Z0-9])?@[a-zA-Z0-9]([a-zA-Z0-9.\-]*[a-zA-Z0-9])?\.[a-zA-Z]{2,}$descope/internal/auth/utils_test.go)3. Runtime Warning for Fallback JWT Parsing
4. Enforced TLS 1.2+ with Debug Override
MinTLSVersionfield toClientParamsstructdescope/api/client_tls_test.go)5. All Tests Passing
📊 Changes Summary
🔒 Security Impact
All changes maintain backward compatibility while significantly improving security posture!
Created by Shuni 🐕