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

#13619 secure parameter linter fix #13717

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -201,5 +201,32 @@ public void HandlesSyntaxErrors(int diagnosticCount, string text)
AssertLinterRuleDiagnostics(SecureParameterDefaultRule.Code, text, diagnosticCount, new Options(OnCompileErrors.Ignore));
}

[DataRow(0, @"
@secure()
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()
param param2 string = param1
")]
[DataTestMethod]
public void ParameterReassignment_TestPasses(int diagnosticCount, string text)
{
AssertLinterRuleDiagnostics(SecureParameterDefaultRule.Code, text, diagnosticCount);
}

}
}
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,6 +35,11 @@ override public IEnumerable<IDiagnostic> AnalyzeInternal(SemanticModel model, Di
// Empty string - okay
continue;
}
else if (model.GetTypeInfo(defaultValue).ValidationFlags.HasFlag(TypeSymbolValidationFlags.IsSecure))
{
// has @secure attribute - okay
continue;
}
else if (defaultValue is ObjectSyntax objectSyntax && !objectSyntax.Properties.Any())
{
// Empty object - okay
Expand Down