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
Next Next commit
Minor fixes
  • Loading branch information
miqm committed Apr 20, 2021
commit 5af379189e8b3dc5037746b207878bd6ed78f597
4 changes: 2 additions & 2 deletions src/Bicep.Core/Diagnostics/DiagnosticBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,12 +1001,12 @@ public ErrorDiagnostic VariableLoopsRuntimeDependencyNotAllowed(IEnumerable<stri
public ErrorDiagnostic FunctionOnlyValidInModuleParameterAssignment(string functionName) => new(
TextSpan,
"BCP176",
$"Function \"{functionName}\" is not valid at this location. It can only be used in assigning value to a module parameter.");
$"Function \"{functionName}\" is not valid at this location. It can only be used when assigning a value to a module parameter.");

public ErrorDiagnostic TypeNotValidInStringInterpolation(TypeSymbol type) => new(
TextSpan,
"BCP177",
$"Type \"{type.Name}\" cannot be used inside String interpolation.");
$"Type \"{type.Name}\" cannot be used inside string interpolation.");
}

public static DiagnosticBuilderInternal ForPosition(TextSpan span)
Expand Down
2 changes: 1 addition & 1 deletion src/Bicep.Core/LanguageConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public static class LanguageConstants

public const string ParameterAllowedPropertyName = "allowed";
public const string ParameterDefaultPropertyName = "default";
public const string ParameterModifierSecureName = "secure";

public const string ModuleParamsPropertyName = "params";
public const string ModuleOutputsPropertyName = "outputs";
Expand Down Expand Up @@ -126,7 +127,6 @@ public static TypeSymbol CreateParameterModifierType(TypeSymbol primitiveType, T
return new ObjectType($"ParameterModifier<{allowedValuesType.Name}>", TypeSymbolValidationFlags.Default, CreateParameterModifierProperties(primitiveType, allowedValuesType), additionalPropertiesType: null);
}

public const string ParameterModifierSecureName = "secure";
private static IEnumerable<TypeProperty> CreateParameterModifierProperties(TypeSymbol primitiveType, TypeSymbol allowedValuesType)
{
/*
Expand Down
6 changes: 2 additions & 4 deletions src/Bicep.Core/Syntax/ObjectSyntaxExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ public static ObjectSyntax DeepMerge(this ObjectSyntax? sourceObject, ObjectSynt
: mergedObject);
}

public static DecoratorSyntax? SafeGetDecoaratorByName(this StatementSyntax syntax, string name)
{
return syntax.Decorators.FirstOrDefault(d => d.Expression is FunctionCallSyntax func && string.Equals(func.Name.IdentifierName, name, System.StringComparison.OrdinalIgnoreCase));
}
public static DecoratorSyntax? SafeGetDecoratorByName(this StatementSyntax syntax, string name) =>
syntax.Decorators.FirstOrDefault(d => d.Expression is FunctionCallSyntaxBase func && string.Equals(func.Name.IdentifierName, name, LanguageConstants.IdentifierComparison));
}
}
4 changes: 2 additions & 2 deletions src/Bicep.Core/Syntax/ParameterDeclarationSyntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public TypeSymbol GetAssignedType(ITypeManager typeManager, ArraySyntax? allowed
assignedType = UnionType.Create(allowedItemTypes);
}
else if ((Modifier is ObjectSyntax modifierSyntax && IsBooleanTrue(modifierSyntax.SafeGetPropertyByName(LanguageConstants.ParameterModifierSecureName)?.Value)) ||
(this.SafeGetDecoaratorByName(LanguageConstants.ParameterModifierSecureName) is not null))
(this.SafeGetDecoratorByName(LanguageConstants.ParameterModifierSecureName) is not null))
{
//parameter can accept either LooseString (see below) or reference to key vault secret
assignedType = LanguageConstants.SecureString;
Expand All @@ -103,7 +103,7 @@ public TypeSymbol GetAssignedType(ITypeManager typeManager, ArraySyntax? allowed
{
assignedType = new TypedArrayType(UnionType.Create(allowedItemTypes), TypeSymbolValidationFlags.Default);
}

return assignedType;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Bicep.Core/TypeSystem/Az/AzResourceTypeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private static IEnumerable<FunctionOverload> GetTypeBicepFunctions(ResourceTypeR
case "microsoft.keyvault/vaults":
yield return new FunctionOverloadBuilder("getSecret")
.WithReturnType(LanguageConstants.KeyVaultSecretReference)
.WithDescription("References a secret from this key vault to be binded to a secure string module parameter")
.WithDescription("Gets a reference to a key vault secret, which can be provided to a secure string module parameter")
.WithFlags(FunctionFlags.ModuleParamsAssignmentOnly)
.WithRequiredParameter("secretName", LanguageConstants.String, "Secret Name")
.WithOptionalParameter("secretVersion", LanguageConstants.String, "Secret Version")
Expand Down Expand Up @@ -272,4 +272,4 @@ public bool HasType(ResourceTypeReference typeReference)
public IEnumerable<ResourceTypeReference> GetAvailableTypes()
=> availableResourceTypes;
}
}
}