Skip to content

Commit

Permalink
Amended as per suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlloyduk authored and David Lloyd committed Mar 28, 2024
1 parent b8b21e1 commit 3ee6379
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Expand Up @@ -203,13 +203,27 @@ public void HandlesSyntaxErrors(int diagnosticCount, string text)

[DataRow(0, @"
@secure()
output param1 string
param param1 string
@secure()
param param2 string = param1
")]
[DataRow(0, @"
@secure()
param param1 string = ''
@secure()
param param2 string = param1
")]
[DataRow(1, @"
@secure()
param param1 string = 'abc'
@secure()
output param2 string = param1
param param2 string = param1
")]
[DataTestMethod]
public void VariableAssignment_TestPasses(int diagnosticCount, string text)
public void ParameterReassignment_TestPasses(int diagnosticCount, string text)
{
AssertLinterRuleDiagnostics(SecureParameterDefaultRule.Code, text, diagnosticCount);
}
Expand Down
Expand Up @@ -5,6 +5,7 @@
using Bicep.Core.Diagnostics;
using Bicep.Core.Semantics;
using Bicep.Core.Syntax;
using Bicep.Core.TypeSystem;

namespace Bicep.Core.Analyzers.Linter.Rules
{
Expand Down Expand Up @@ -34,9 +35,9 @@ override public IEnumerable<IDiagnostic> AnalyzeInternal(SemanticModel model, Di
// Empty string - okay
continue;
}
else if (defaultValue is VariableAccessSyntax variableAccessSyntax)
else if (model.GetTypeInfo(defaultValue).ValidationFlags.HasFlag(TypeSymbolValidationFlags.IsSecure))
{
// Variable - okay
// has @secure attribute - okay
continue;
}
else if (defaultValue is ObjectSyntax objectSyntax && !objectSyntax.Properties.Any())
Expand Down

0 comments on commit 3ee6379

Please sign in to comment.