Tighten AdditionalAllowedDomains API contract#450
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the AdditionalAllowedDomains allowlist plumbing in Microsoft.Teams.Apps by clarifying the API contract and preventing post-construction mutation of caller-provided domain lists from affecting service URL validation behavior.
Changes:
- Clarifies
AppOptions.AdditionalAllowedDomainsdocumentation (hostnames only;["*"]disables validation). - Makes
Appdefensively materialize/copyAdditionalAllowedDomainsat construction time. - Adds unit tests to guard against regressions involving mutable/lazy enumerables.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| Tests/Microsoft.Teams.Apps.Tests/AppTests.cs | Adds tests asserting AdditionalAllowedDomains is materialized/defensively copied. |
| Libraries/Microsoft.Teams.Apps/AppOptions.cs | Updates XML docs for AdditionalAllowedDomains contract and sentinel behavior. |
| Libraries/Microsoft.Teams.Apps/App.cs | Changes internal storage to a materialized list via ToList() to prevent caller-side mutations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Follow-up to the allowlist feature (shipped via #418). No runtime behavior change for correct callers. Adds hardening informed by review feedback on the sibling Python PR (microsoft/teams.py#404):
AppOptions.AdditionalAllowedDomainsXML doc now documents that entries must be bare hostnames matched exactly (case-insensitive); wildcard patterns like"*.example.com", URL suffixes, and full URLs are NOT supported.["*"]is the sole wildcard, used as a disable-validation sentinel.Appno longer stores the caller'sIEnumerable<string>by reference. A post-construction mutation of the collection would previously have changed validator behavior at runtime; now it is isolated.