Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key vault secret reference for secure string module param #1571

Merged
merged 31 commits into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c7d1d59
Key Vault Secret reference for secure string module parameter
miqm Mar 7, 2021
5069644
Merge remote-tracking branch 'upstream/main' into feature/keyvault-re…
miqm Mar 8, 2021
c3ad045
Merge remote-tracking branch 'upstream/main' into feature/params-key-…
miqm Mar 11, 2021
e807dd1
Tests updated
miqm Mar 11, 2021
9529eab
Avoiding conflicts
miqm Mar 11, 2021
f442ede
Merge remote-tracking branch 'upstream/main' into feature/params-key-…
miqm Mar 11, 2021
a44a051
Type checking improved
miqm Mar 12, 2021
42612a4
Merge remote-tracking branch 'upstream/main' into feature/params-key-…
miqm Mar 15, 2021
ab421f4
Merge remote-tracking branch 'origin/main' into feature/params-key-va…
anthony-c-martin Apr 10, 2021
7d720e7
Fix up tests
anthony-c-martin Apr 10, 2021
c456a4e
Fix decorator completion diagnostics
miqm Apr 11, 2021
d25d836
Merge remote-tracking branch 'upstream/main' into feature/params-key-…
miqm Apr 13, 2021
5bf851d
Merge remote-tracking branch 'upstream/main' into feature/params-key-…
miqm Apr 16, 2021
cbbfd6a
Merge remote-tracking branch 'upstream/main' into feature/params-key-…
miqm Apr 20, 2021
5af3791
Minor fixes
miqm Apr 20, 2021
e8ffe5f
Update test baselines
Apr 20, 2021
9557bf9
Checking diagnostic messages in scenario tests.
miqm Apr 21, 2021
4b4742e
Merge remote-tracking branch 'upstream/main' into feature/params-key-…
miqm Apr 29, 2021
79b5858
Changed logic from Type assignment checking to a function placement v…
miqm Apr 30, 2021
791158b
Module Params resource type checking in Emitter
miqm Apr 30, 2021
53152db
Merge remote-tracking branch 'upstream/main' into feature/params-key-…
miqm Apr 30, 2021
85bee27
Testing key vault reference usage in a module loop
miqm Apr 30, 2021
6196b67
Merge remote-tracking branch 'upstream/main' into feature/params-key-…
miqm May 1, 2021
7c01e01
Tests fix
miqm May 1, 2021
300d20b
Removed leftover from old way
miqm May 1, 2021
34fbd08
Merge remote-tracking branch 'upstream/main' into feature/params-key-…
miqm May 5, 2021
2d334d4
Merge remote-tracking branch 'upstream/main' into feature/params-key-…
miqm May 6, 2021
0d93980
Post-review fixes. Added SecureObject to confusing error message. Ext…
miqm May 6, 2021
d91dfbe
Removed saving matched overload. Placement Flags need to be consisten…
miqm May 6, 2021
29dd3fd
Merge remote-tracking branch 'upstream/main' into feature/params-key-…
miqm May 11, 2021
36b09af
Removed FunctionPlacementFlags
miqm May 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Removed FunctionPlacementFlags
  • Loading branch information
miqm committed May 11, 2021
commit 36b09afd0a931eaa2be33e0369d625231d983032
2 changes: 1 addition & 1 deletion src/Bicep.Core/Emit/FunctionPlacementValidatorVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public override void VisitFunctionCallSyntax(FunctionCallSyntax syntax)

private void VerifyModuleSecureParameterFunctionPlacement(FunctionCallSyntaxBase syntax)
{
if (semanticModel.GetSymbolInfo(syntax) is FunctionSymbol functionSymbol && functionSymbol.PlacementFlags.HasFlag(FunctionPlacementFlags.ModuleSecureParameterOnly))
if (semanticModel.GetSymbolInfo(syntax) is FunctionSymbol functionSymbol && functionSymbol.FunctionFlags.HasFlag(FunctionFlags.ModuleSecureParameterOnly))
{
// we can check placement only for funtions that were matched and has a proper placement flag
var (_, levelUpSymbol) = syntaxRecorder.Skip(1).FirstOrDefault();
Expand Down
5 changes: 1 addition & 4 deletions src/Bicep.Core/Semantics/FunctionOverload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ public class FunctionOverload
{
public delegate TypeSymbol ReturnTypeBuilderDelegate(IEnumerable<FunctionArgumentSyntax> arguments);

public FunctionOverload(string name, string description, ReturnTypeBuilderDelegate returnTypeBuilder, TypeSymbol returnType, IEnumerable<FixedFunctionParameter> fixedParameters, VariableFunctionParameter? variableParameter, FunctionFlags flags = FunctionFlags.Default, FunctionPlacementFlags placementFlags = FunctionPlacementFlags.Default)
public FunctionOverload(string name, string description, ReturnTypeBuilderDelegate returnTypeBuilder, TypeSymbol returnType, IEnumerable<FixedFunctionParameter> fixedParameters, VariableFunctionParameter? variableParameter, FunctionFlags flags = FunctionFlags.Default)
{
this.Name = name;
this.Description = description;
this.ReturnTypeBuilder = returnTypeBuilder;
this.FixedParameters = fixedParameters.ToImmutableArray();
this.VariableParameter = variableParameter;
this.Flags = flags;
this.PlacementFlags = placementFlags;

this.MinimumArgumentCount = this.FixedParameters.Count(fp => fp.Required) + (this.VariableParameter?.MinimumCount ?? 0);
this.MaximumArgumentCount = this.VariableParameter == null ? this.FixedParameters.Length : (int?)null;
Expand All @@ -46,8 +45,6 @@ public FunctionOverload(string name, string description, ReturnTypeBuilderDelega

public FunctionFlags Flags { get; }

public FunctionPlacementFlags PlacementFlags { get; }

public string TypeSignature { get; }

public IEnumerable<string> ParameterTypeSignatures => this.FixedParameters
Expand Down
12 changes: 1 addition & 11 deletions src/Bicep.Core/Semantics/FunctionOverloadBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ public FunctionOverloadBuilder(string name)

protected FunctionFlags Flags { get; private set; }

public FunctionPlacementFlags PlacementFlags { get; private set; }

public FunctionOverload Build()
{
this.Validate();
Expand All @@ -52,8 +50,7 @@ public virtual FunctionOverload BuildInternal() =>
this.ReturnType,
this.FixedParameters.ToImmutable(),
this.VariableParameter,
this.Flags,
this.PlacementFlags);
this.Flags);

public FunctionOverloadBuilder WithDescription(string description)
{
Expand Down Expand Up @@ -103,13 +100,6 @@ public FunctionOverloadBuilder WithFlags(FunctionFlags flags)
return this;
}

public FunctionOverloadBuilder WithPlacementFlags(FunctionPlacementFlags flags)
{
this.PlacementFlags = flags;

return this;
}

protected virtual void Validate()
{
// required params can only be at the beginning
Expand Down
10 changes: 0 additions & 10 deletions src/Bicep.Core/Semantics/FunctionSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ public FunctionSymbol(string name, IEnumerable<FunctionOverload> overloads)
// we should catch this as early as possible
throw new ArgumentException("Inconsistent function flags found on overloads");
}

PlacementFlags = Overloads.First().PlacementFlags;

if (Overloads.Skip(1).Any(fo => fo.PlacementFlags != PlacementFlags))
{
// we should catch this as early as possible
throw new ArgumentException("Inconsistent placement flags found on overloads");
}
}

public override void Accept(SymbolVisitor visitor) => visitor.VisitFunctionSymbol(this);
Expand All @@ -38,7 +30,5 @@ public FunctionSymbol(string name, IEnumerable<FunctionOverload> overloads)
public ImmutableArray<FunctionOverload> Overloads { get; }

public FunctionFlags FunctionFlags { get; }
public FunctionPlacementFlags PlacementFlags { get; }

}
}
2 changes: 1 addition & 1 deletion src/Bicep.Core/TypeSystem/Az/AzResourceTypeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ private static IEnumerable<FunctionOverload> GetBicepMethods(ResourceTypeReferen
.WithDescription("Gets a reference to a key vault secret, which can be provided to a secure string module parameter")
.WithRequiredParameter("secretName", LanguageConstants.String, "Secret Name")
.WithOptionalParameter("secretVersion", LanguageConstants.String, "Secret Version")
.WithPlacementFlags(FunctionPlacementFlags.ModuleSecureParameterOnly)
.WithFlags(FunctionFlags.ModuleSecureParameterOnly)
.Build();
break;
}
Expand Down
5 changes: 5 additions & 0 deletions src/Bicep.Core/TypeSystem/FunctionFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public enum FunctionFlags
/// </summary>
OutputDecorator = 1 << 6,

/// <summary>
/// The function can be used in direct assignment to a module parameter with @secure decorator
/// </summary>
ModuleSecureParameterOnly = 1 << 7,

/// <summary>
/// The function can be used a resource or module decorator.
/// </summary>
Expand Down
23 changes: 0 additions & 23 deletions src/Bicep.Core/TypeSystem/FunctionPlacementFlags.cs

This file was deleted.