You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Split security review rules by path and add audit prompt - #6068
Reworks the Copilot code review security rules so that they are more likely to be applied, and adds an audit prompt for existing code, which review cannot cover.
Why. The existing security profile is one file of about thirty dense, multi-sentence bullets that loads for every path. GitHub's guidance for code review instructions is short, imperative, specific rules, and it warns that long files are partly overlooked. The profile also describes boundaries in general terms and names few of the types a reviewer sees in a diff.
What changes.
.github/instructions/fhir-security.instructions.md becomes a short core file: the authorization invariant, ten change patterns to flag, a do-not-flag list, input/output limits, and how to write an actionable finding. It still applies to every path.
Four new path-specific files load only for matching code: search, bulk and background operations, bundles and conditional operations, and SMART scopes with the request surface. Each rule names the trigger in the code, for example a new ISearchService consumer, a new FhirRequestContext { IsBackgroundTask = true }, a branch on KnownResourceTypes.All, or CheckAccess(DataActions.All) used as authorization.
.github/prompts/securityVariantSweep.prompt.md is an agent prompt for auditing existing code against the same rules. Pull request review only sees changed lines.
.github/REVIEWING.md documents the file split and a close-out process for security fixes: fix and test, sweep for siblings, update the rules.
.github/labeler.yml adds Area-Authorization to pull requests that touch the core authorization paths.
Not changed. No runtime behavior. No workflow, trigger, or merge requirement. REVIEW.md and copilot-instructions.md only have their pointers updated. Every topic in the previous profile is carried into one of the five files.
Affected layers. Review instructions and repository configuration only. No product or test code. Providers and FHIR versions: N/A.
Related issues
Relates to AB#213099, the original code-review guidance story used by #6023.
Testing
Acceptance criterion
Implemented in
Evidence and result
Copilot code review loads the new path-specific files
.github/instructions/security-*.instructions.md
Review run 44212418564 at 1b9970c logged [customInstructions] Built 7 custom instruction(s): copilot-instructions.md, fhir-security.instructions.md, security-bundles-conditional.instructions.md, security-smart-scopes.instructions.md, AGENTS.md, CLAUDE.md, REVIEW.md. At that commit the PR still contained a unit test under Features/Security/Authorization/, since removed, and those two path-specific files are the ones whose selectors matched it. The search and background files were not loaded because no changed file matched them, so their selectors are still unexercised. With the test removed, this PR changes no file under src/, so later runs load only the core file.
The new rules catch more than the old profile
Instruction files
none. Needs the controlled comparison described in REVIEWING.md against known pre-fix commits
Area-Authorization label is applied by path
.github/labeler.yml
none. The labeler reads its configuration from the base branch, so this can only be observed after merge
Assumptions and limits: the applyTo globs were written against the current directory layout. Only the two selectors noted above have been exercised by a review run. No tests were run, because the PR changes no product or test code.
FHIR Team Checklist
Update the title of the PR to be succinct and less than 65 characters
Add a milestone to the PR for the sprint that it is merged (i.e. add S47)
Tag the PR with the type of update: Bug, Build, Dependencies, Enhancement, New-Feature or Documentation
Tag the PR with Open source, Azure API for FHIR (CosmosDB or common code) or Azure Healthcare APIs (SQL or common code) to specify where this change is intended to be released.
Tag the PR with Schema Version backward compatible or Schema Version backward incompatible or Schema Version unchanged if this adds or updates Sql script which is/is not backward compatible with the code.
When changing or adding behavior, if your code modifies the system design or changes design assumptions, please create and include an ADR.
Replace the single all-paths security profile with a short core file and
four path-specific files, so each review loads rules that match the code
being changed. Rules are short, imperative, and tied to types and
patterns a reviewer can find in a diff.
Add a variant sweep prompt for auditing existing code, a close-out
process for security fixes, and an Area-Authorization path label.
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Fail the build when a new type is constructed with ISearchService, so a
new path to stored resources that bypasses SearchResourceHandler gets a
deliberate authorization review.
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The split drops existing security checks, excludes relevant implementation paths from rule selectors, and incorrectly requires claims that some supported authorization modes do not need.
This PR reorganizes security review guidance for the FHIR server into core and path-specific rules, adds a guard test for new search-service consumers, and documents follow-up audits. It does not change runtime behavior.
Changes:
Splits security guidance into five instruction files and updates review documentation.
Adds a shared unit test that checks core-assembly ISearchService consumers against a 27-type baseline.
Adds a security audit prompt and path-based authorization labeling.
…lectors
Limit claim refusal to what the active scope kind requires. Restore the file/archive containment and output encoding checks. Add definition, schema, module, and conformance paths to the rule selectors. Add a do-not-flag list and guidance for writing an actionable finding.
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The instruction globs omit middleware registration, $everything, and historical-read implementation paths, so changes confined to those files would bypass previously global security review checks.
No open issues 🎉
2 previously missed issues
In code that hasn't changed since last review
Include $everything and version-read paths in the selector
Please include the $everything and version-read implementation paths in this selector. src/Microsoft.Health.Fhir.Shared.Core/Features/Operations/Everything/PatientEverythingService.cs implements expansion and continuation handling, and src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Get/GetResourceHandler.cs handles historical version reads, but neither matches these globs. A PR changing only either file therefore won't load the corresponding search rules (4, 9, and 10), which previously applied through the all-path profile. The background/bundle rules selected for those paths do not retain those checks.
Please include the middleware-registration path in this glob. src/Microsoft.Health.Fhir.Shared.Api/Registration/FhirServerServiceCollectionExtensions.cs:282–350 composes the request pipeline, including UseFhirRequestContextAuthentication(), but matches none of these patterns. A PR that only changes that ordering therefore will not load this file's authentication and middleware-order checks. Those checks previously applied globally.
Load the search rules for $everything, $member-match, resource reads, and Cosmos query and storage code. Load the identity rules for pipeline registration and the development identity provider.
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because selector gaps leave policy definitions, Azure storage connections, and conditional authorization helpers outside their targeted security-review guidance.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The security-review control changes need maintainer verification of instruction loading and a controlled detection comparison, neither of which is established by the supplied evidence.
Non-clinical scopes are correctly ignored; the rule flags widening of clinical scopes. Restore the synthetic-data, no-live-probe, and untrusted-code safeguards from the previous profile.
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
The test only caught a new type taking ISearchService in its constructor.
It did not cover new calls inside existing consumers, and the core review
rules already ask the same question of a new consumer.
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed to weigh an overbroad profile-edit permission requirement and a labeling gap that leaves SMART scope authorization changes unclassified.
Brendan Kowitz (brendankowitz)
changed the title
Split security review rules by path and add guard test
Split security review rules by path and add audit prompt
Nov 18, 2026
Read-only exports are authorized with read and export access; EditProfileDefinitions only covers creating, updating, or deleting profile-defining resources.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed to evaluate a selector gap that leaves changes to the SMART export authorization boundary without the expected Area-Authorization label.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because the split security-instruction selectors omit previously covered shared conditional lookups and search-parameter disabling operations, leaving relevant security rules unloaded.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because the scope-rejection guidance conflicts with documented and tested behavior permitting withdrawal of an unenforceable scope when another scope still authorizes access.
SmartScopeFhirAuthorizationService is a static helper that
RoleBasedFhirAuthorizationService intersects with role actions, not a
parallel service, so the rule now describes the intersection. The scope
rejection rule is split into malformed input and unenforceable scopes.
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because the split’s rule selectors omit relevant authentication and scope-handling implementations, leaving security guidance coverage incomplete.
The reason will be displayed to describe this comment to others. Learn more.
🟢 Approval recommended
No active review issues block approval of the security-guidance reorganization.
No open issues 🎉
Review effort: Balanced
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
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.
Description
Reworks the Copilot code review security rules so that they are more likely to be applied, and adds an audit prompt for existing code, which review cannot cover.
Why. The existing security profile is one file of about thirty dense, multi-sentence bullets that loads for every path. GitHub's guidance for code review instructions is short, imperative, specific rules, and it warns that long files are partly overlooked. The profile also describes boundaries in general terms and names few of the types a reviewer sees in a diff.
What changes.
.github/instructions/fhir-security.instructions.mdbecomes a short core file: the authorization invariant, ten change patterns to flag, a do-not-flag list, input/output limits, and how to write an actionable finding. It still applies to every path.ISearchServiceconsumer, anew FhirRequestContext { IsBackgroundTask = true }, a branch onKnownResourceTypes.All, orCheckAccess(DataActions.All)used as authorization..github/prompts/securityVariantSweep.prompt.mdis an agent prompt for auditing existing code against the same rules. Pull request review only sees changed lines..github/REVIEWING.mddocuments the file split and a close-out process for security fixes: fix and test, sweep for siblings, update the rules..github/labeler.ymladdsArea-Authorizationto pull requests that touch the core authorization paths.Not changed. No runtime behavior. No workflow, trigger, or merge requirement.
REVIEW.mdandcopilot-instructions.mdonly have their pointers updated. Every topic in the previous profile is carried into one of the five files.Affected layers. Review instructions and repository configuration only. No product or test code. Providers and FHIR versions: N/A.
Related issues
Relates to AB#213099, the original code-review guidance story used by #6023.
Testing
.github/instructions/security-*.instructions.md[customInstructions] Built 7 custom instruction(s):copilot-instructions.md,fhir-security.instructions.md,security-bundles-conditional.instructions.md,security-smart-scopes.instructions.md,AGENTS.md,CLAUDE.md,REVIEW.md. At that commit the PR still contained a unit test underFeatures/Security/Authorization/, since removed, and those two path-specific files are the ones whose selectors matched it. The search and background files were not loaded because no changed file matched them, so their selectors are still unexercised. With the test removed, this PR changes no file undersrc/, so later runs load only the core file.REVIEWING.mdagainst known pre-fix commitsArea-Authorizationlabel is applied by path.github/labeler.ymlAssumptions and limits: the
applyToglobs were written against the current directory layout. Only the two selectors noted above have been exercised by a review run. No tests were run, because the PR changes no product or test code.FHIR Team Checklist
Semver Change (docs)
Skip
🤖 Generated with Claude Code