Conversation
Signed-off-by: Jiaxiao (mossaka) Zhou <duibao55328@gmail.com>
Test Coverage Report
Coverage ThresholdsThe project has the following coverage thresholds configured:
Coverage report generated by `npm run test:coverage` |
There was a problem hiding this comment.
Pull request overview
This PR adds wildcard domain support to the domain allowlist functionality. Users can now specify patterns like *.github.com or api-*.example.com in addition to plain domains like github.com.
Key changes:
- Adds a new
domain-patterns.tsmodule with wildcard pattern parsing, validation, and regex conversion - Updates Squid configuration generation to use both
dstdomainACLs (for plain domains) anddstdom_regexACLs (for wildcard patterns) - Adds CLI validation for domain patterns with comprehensive error messages for overly broad patterns
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/domain-patterns.ts | New module providing wildcard pattern detection, regex conversion, validation, and pattern matching utilities |
| src/domain-patterns.test.ts | Comprehensive test suite for the new domain pattern utilities covering edge cases and validation |
| src/squid-config.ts | Updated to parse domains into plain/pattern categories, generate separate ACL types, and combine them in http_access rules |
| src/squid-config.test.ts | Added test coverage for wildcard patterns, ACL generation, and mixed domain/pattern scenarios |
| src/cli.ts | Updated help text to document wildcard syntax and added validation for domain patterns before execution |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Skip if this is a wildcard pattern | ||
| if (isWildcardPattern(domain)) return true; | ||
|
|
||
| // Check if this domain is a subdomain of another plain domain in the list | ||
| return !arr.some((otherDomain, otherIndex) => { | ||
| if (index === otherIndex) return false; | ||
| if (isWildcardPattern(otherDomain)) return false; |
There was a problem hiding this comment.
The checks for isWildcardPattern(domain) and isWildcardPattern(otherDomain) are unnecessary here. At this point, plainDomains only contains plain domains (no wildcards) since they were already separated by parseDomainList(). These checks will always return false and can be removed.
| // Skip if this is a wildcard pattern | |
| if (isWildcardPattern(domain)) return true; | |
| // Check if this domain is a subdomain of another plain domain in the list | |
| return !arr.some((otherDomain, otherIndex) => { | |
| if (index === otherIndex) return false; | |
| if (isWildcardPattern(otherDomain)) return false; | |
| // Check if this domain is a subdomain of another plain domain in the list | |
| return !arr.some((otherDomain, otherIndex) => { | |
| if (index === otherIndex) return false; |
|
@copilot update documentation for this one and resolve comments |
* Initial plan * fix: remove redundant wildcard checks and update docs Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
Signed-off-by: Jiaxiao (mossaka) Zhou duibao55328@gmail.com