-
Notifications
You must be signed in to change notification settings - Fork 819
fix: skip secure params lint for type aliases #19796
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,6 +125,136 @@ public void AllowedListExceptions(bool shouldPass, string bicep) | |
| CompileAndTest(bicep, shouldPass ? 0 : 1); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void Unsecure_user_defined_type_reference_with_secret_name_is_flagged() | ||
| { | ||
| CompileAndTest(""" | ||
| type ContainerAppSecretType = { | ||
| name: string | ||
| value: string | ||
| } | ||
|
|
||
| type ContainerAppSecretListType = { | ||
| secureList: ContainerAppSecretType[] | ||
| } | ||
|
|
||
| param containerAppSecrets ContainerAppSecretListType | ||
| """, 1); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void Unsecure_user_defined_string_type_reference_with_secret_name_is_flagged() | ||
| { | ||
| CompileAndTest(""" | ||
| type SecureStringType = string | ||
|
|
||
| param password SecureStringType | ||
| """, 1); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void Secure_user_defined_type_reference_with_secret_name_is_not_flagged() | ||
| { | ||
| CompileAndTest(""" | ||
| @secure() | ||
| type SecureStringType = string | ||
|
|
||
| param password SecureStringType | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't seem like the right behavior - this should still be flagged
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 80867b9. User-defined type references with secret-like parameter names are flagged again unless the referenced alias resolves to a secure declared type. |
||
| """, 0); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void Secure_user_defined_object_type_reference_with_secret_name_is_not_flagged() | ||
| { | ||
| CompileAndTest(""" | ||
| type ContainerAppSecretType = { | ||
| name: string | ||
| value: string | ||
| } | ||
|
|
||
| @secure() | ||
| type ContainerAppSecretListType = { | ||
| secureList: ContainerAppSecretType[] | ||
| } | ||
|
|
||
| param containerAppSecrets ContainerAppSecretListType | ||
| """, 0); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void Imported_type_reference_with_secret_name_uses_secure_flag_from_imported_type() | ||
| { | ||
| var options = new Options(AdditionalFiles: [("types.bicep", """ | ||
| @export() | ||
| type SecureStringType = string | ||
|
|
||
| @export() | ||
| @secure() | ||
| type ActuallySecureStringType = string | ||
| """)]); | ||
|
|
||
| AssertLinterRuleDiagnostics(SecretsInParamsMustBeSecureRule.Code, """ | ||
| import { SecureStringType, ActuallySecureStringType } from './types.bicep' | ||
|
|
||
| param password SecureStringType | ||
| param securePassword ActuallySecureStringType | ||
| """, 1, options); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void Wildcard_imported_type_reference_with_secret_name_uses_secure_flag_from_imported_type() | ||
| { | ||
| var options = new Options(AdditionalFiles: [("types.bicep", """ | ||
| @export() | ||
| type SecureStringType = string | ||
|
|
||
| @export() | ||
| @secure() | ||
| type ActuallySecureStringType = string | ||
| """)]); | ||
|
|
||
| AssertLinterRuleDiagnostics(SecretsInParamsMustBeSecureRule.Code, """ | ||
| import * as types from './types.bicep' | ||
|
|
||
| param password types.SecureStringType | ||
| param securePassword types.ActuallySecureStringType | ||
| """, 1, options); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void Direct_object_with_secret_name_is_still_flagged() | ||
| { | ||
| CompileAndTest(""" | ||
| param containerAppSecrets object | ||
| """, 1); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void User_defined_type_reference_defaulting_to_secure_param_is_still_flagged() | ||
| { | ||
| CompileAndTest(""" | ||
| @secure() | ||
| param secureParam string | ||
|
|
||
| type SecureStringType = string | ||
|
|
||
| param insecureParam SecureStringType = secureParam | ||
| """, 1); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void Codefix_marks_local_type_alias_as_secure() | ||
| => AssertCodeFix(SecretsInParamsMustBeSecureRule.Code, "Mark type as secure", """ | ||
| type SecureStringType = string | ||
|
|
||
| param pass|word SecureStringType | ||
| """, """ | ||
| @secure() | ||
| type SecureStringType = string | ||
|
|
||
| param password SecureStringType | ||
| """); | ||
|
|
||
| [TestMethod] | ||
| public void FullExample() | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Despite the name, this is not marked as
@secure()and should continue to be flaggedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 80867b9. This unannotated alias case now produces the
secure-secrets-in-paramsdiagnostic; only@secure()type aliases are skipped.