Skip to content

Commit 6c388d1

Browse files
committed
Add rule documentation for AvoidUsingCovertToSecureString
1 parent 9cea2a8 commit 6c388d1

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#AvoidUsingConvertToSecureStringWithPlainTextNoViolations
2+
**Severity Level: Error**
3+
4+
5+
##Description
6+
7+
Information in the script should be protected properly. Using ConvertTo-SecureString with plain text will expose secure information.
8+
9+
##How to Fix
10+
11+
To fix a violation of this rule, please use a standard encrypted variable to do the conversion.
12+
13+
##Example
14+
15+
Wrong:
16+
17+
```
18+
$notsecure = convertto-securestring "abc" -asplaintext -force
19+
20+
New-Object System.Management.Automation.PSCredential -ArgumentList "username", (ConvertTo-SecureString "notsecure" -AsPlainText -Force)
21+
22+
```
23+
24+
Correct:
25+
26+
```
27+
$secure = read-host -assecurestring
28+
$encrypted = convertfrom-securestring -securestring $secure
29+
convertto-securestring -string $encrypted
30+
```

0 commit comments

Comments
 (0)