Emit an error diagnostic when a secure output is dereferenced indirectly#17453
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces error diagnostics for indirect secure output accesses to block unsupported module output dereferences. Key changes include updating type resolution for module unions, adding new abstract members to syntax classes for property/array access, and implementing a new diagnostic in the emit limitation calculation along with corresponding integration tests.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Bicep.Core/TypeSystem/TypeHelper.cs | Added union type handling logic to resolve secure module output accesses |
| src/Bicep.Core/Syntax/PropertyAccessSyntax.cs | Overrode IndexExpression to point to the property name |
| src/Bicep.Core/Syntax/ArrayAccessSyntax.cs | Updated IndexExpression to override the base definition |
| src/Bicep.Core/Syntax/AccessExpressionSyntax.cs | Introduced an abstract IndexExpression property |
| src/Bicep.Core/Emit/EmitLimitationCalculator.cs | Added logic to block indirectly referenced secure output accesses |
| src/Bicep.Core/Diagnostics/DiagnosticBuilder.cs | Added a new diagnostic for secure outputs accessed via indirect module ref |
| src/Bicep.Core.IntegrationTests/SecureOutputsTests.cs | Added tests to verify that indirect secure output references are blocked |
| null when unionType.Members.All(t => t.Type is ModuleType) && | ||
| CreateTypeUnion(unionType.Members.Select(t => ((ModuleType)t.Type).Body)) is UnionType bodyUnion |
There was a problem hiding this comment.
[nitpick] Consider extracting the complex null pattern condition into a helper method for improved readability and maintainability.
| null when unionType.Members.All(t => t.Type is ModuleType) && | |
| CreateTypeUnion(unionType.Members.Select(t => ((ModuleType)t.Type).Body)) is UnionType bodyUnion | |
| null when IsModuleTypeUnionWithBody(unionType, out var bodyUnion) |
| continue; | ||
| } | ||
|
|
||
| diagnostics.Write(DiagnosticBuilder.ForPosition(accessExpr.IndexExpression) |
There was a problem hiding this comment.
[nitpick] The condition chain in BlockSecureOutputAccessOnIndirectReference is complex; consider refactoring nested checks into separate helper methods to enhance clarity and ease of future modifications.
|
Test this change out locally with the following install scripts (Action run 16469365259) VSCode
Azure CLI
|
Dotnet Test Results 90 files - 45 90 suites - 45 37m 55s ⏱️ - 24m 48s Results for commit e7cb98d. ± Comparison against base commit eb21df0. This pull request removes 1910 and adds 646 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
# Conflicts: # src/Bicep.Core/Diagnostics/DiagnosticBuilder.cs
Resolves #16992
Indirect references to module outputs don't support compilation to the
listOutputsWithSecureValuesfunction due to a combination of limitations in the compiler and the backend. This PR adds an error diagnostic to expressions that will cause a deployment error today.Microsoft Reviewers: Open in CodeFlow