Skip to content

Commit 7e9f253

Browse files
authored
Merge pull request #206413 from mumian/0729-linter-password-params
linter rule - secure-secrets-in-params
2 parents a67fede + 418698d commit 7e9f253

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

articles/azure-resource-manager/bicep/bicep-config-linter.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ The following example shows the rules that are available for configuration.
6262
"use-protectedsettings-for-commandtoexecute-secrets": {
6363
"level": "warning"
6464
},
65+
"secure-secrets-in-params": {
66+
"level": "warning"
67+
},
6568
"use-stable-resource-identifiers": {
6669
"level": "warning"
6770
},
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
title: Linter rule - secure secrets in parameters
3+
description: Linter rule - secure secrets in parameters
4+
ms.topic: conceptual
5+
ms.date: 08/01/2022
6+
---
7+
8+
# Linter rule - secure secrets in parameters
9+
10+
This rule finds parameters whose names look like secrets but without the [secure decorator](./parameters.md#decorators), for example: a parameter name contains the following keywords:
11+
12+
- password
13+
- pwd
14+
- secret
15+
- accountkey
16+
- acctkey
17+
18+
## Linter rule code
19+
20+
Use the following value in the [Bicep configuration file](bicep-config-linter.md) to customize rule settings:
21+
22+
`secure-secrets-in-params`
23+
24+
## Solution
25+
26+
Use the [secure decorator](./parameters.md#decorators) for the parameters that contain secrets. The secure decorator marks the parameter as secure. The value for a secure parameter isn't saved to the deployment history and isn't logged.
27+
28+
The following example fails this test because the parameter name may contain secrets.
29+
30+
```bicep
31+
param mypassword string
32+
```
33+
34+
You can fix it by adding the secure decorator:
35+
36+
```bicep
37+
@secure()
38+
param mypassword string
39+
```
40+
41+
## Silencing false positives
42+
43+
Sometimes this rule alerts on parameters that don't actually contain secrets. In these cases, you can disable the warning for this line by adding `#disable-next-line secure-secrets-in-params` before the line with the warning. For example:
44+
45+
```bicep
46+
#disable-next-line secure-secrets-in-params // Doesn't contain a secret
47+
param mypassword string
48+
```
49+
50+
It's good practice to add a comment explaining why the rule doesn't apply to this line.
51+
52+
## Next steps
53+
54+
For more information about the linter, see [Use Bicep linter](./linter.md).

articles/azure-resource-manager/bicep/linter.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ The default set of linter rules is minimal and taken from [arm-ttk test cases](.
3232
- [prefer-interpolation](./linter-rule-prefer-interpolation.md)
3333
- [prefer-unquoted-property-names](./linter-rule-prefer-unquoted-property-names.md)
3434
- [secure-parameter-default](./linter-rule-secure-parameter-default.md)
35+
- [secure-secrets-in-params](./linter-rule-secure-secrets-in-parameters.md)
3536
- [simplify-interpolation](./linter-rule-simplify-interpolation.md)
3637
- [use-protectedsettings-for-commandtoexecute-secrets](./linter-rule-use-protectedsettings-for-commandtoexecute-secrets.md)
3738
- [use-stable-resource-identifiers](./linter-rule-use-stable-resource-identifier.md)

articles/azure-resource-manager/bicep/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@
386386
href: linter-rule-prefer-unquoted-property-names.md
387387
- name: Secure parameter default
388388
href: linter-rule-secure-parameter-default.md
389+
- name: Secure secrets in parameters
390+
href: linter-rule-secure-secrets-in-parameters.md
389391
- name: Simplify interpolation
390392
href: linter-rule-simplify-interpolation.md
391393
- name: Use explicit values for module location parameters

0 commit comments

Comments
 (0)