Skip to content

Commit 482fda7

Browse files
committed
formatting
1 parent 4e0ea04 commit 482fda7

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

powershell/ql/src/queries/security/cwe-319/UnsafeSMBSettings.qhelp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
<overview>
66
<p>The commands<code>Set-SmbClientConfiguration</code> and <code>Set-SmbServerConfiguration</code> are used to set configurations for SMB traffic.
77
Insecure configurations such as outdated versions, or turning off encryption, can make connections susceptible to attackers.
8+
</p>
89
</overview>
910

1011
<recommendation>
11-
<p>The minimum version of SMB is 3.0, but it is recommended to use the latest version. For SMB server service (inbound connections). For example: <code>Set-SmbServerConfiguration -Smb2DialectMin SMB300</code>
12-
For SMB client service (outbound connections). For example: <code>Set-SmbClientConfiguration -Smb2DialectMin SMB300</code>
13-
12+
<p>The minimum version of SMB is 3.0, but it is recommended to use the latest version. For example, use:
13+
<code>Set-SmbServerConfiguration -Smb2DialectMin SMB300</code> or <code>Set-SmbClientConfiguration -Smb2DialectMin SMB300</code>
14+
</p>
1415
<p>
15-
SMB encryption should be enabled
16-
For SMB server service (inbound connections). For example: <code> Set-SmbServerConfiguration -encryptdata $true -rejectunencryptedaccess $true </code>
17-
For SMB client service (outbound connections). For example: <code> Set-SmbClientConfiguration -RequireEncryption $true </code>
16+
SMB encryption should be enabled. For example, use:
17+
<code> Set-SmbServerConfiguration -encryptdata $true -rejectunencryptedaccess $true </code> or <code> Set-SmbClientConfiguration -RequireEncryption $true </code>
1818
</p>
1919

2020
<p>

powershell/ql/src/queries/security/cwe-319/UnsafeSMBSettings.ql

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,79 +10,79 @@
1010
* security
1111
* external/cwe/cwe-315
1212
*/
13-
import powershell
13+
14+
import powershell
1415

1516
abstract class SMBConfiguration extends CmdCall {
16-
abstract Expr getAMisconfiguredSetting();
17+
abstract Expr getAMisconfiguredSetting();
1718

1819
/** Gets the minimum version of the SMB protocol to be used */
1920
Expr getMisconfiguredSmb2DialectMin() {
20-
exists(Expr dialectMin |
21-
dialectMin = this.getNamedArgument("smb2dialectmin") and
22-
dialectMin.getValue().toString().toLowerCase() in ["none", "smb202", "smb210"] and
21+
exists(Expr dialectMin |
22+
dialectMin = this.getNamedArgument("smb2dialectmin") and
23+
dialectMin.getValue().toString().toLowerCase() in ["none", "smb202", "smb210"] and
2324
result = dialectMin
2425
)
2526
}
26-
}
27+
}
2728

2829
/** A call to `Set-SmbServerConfiguration`. */
2930
class SetSMBClientConfiguration extends SMBConfiguration {
3031
SetSMBClientConfiguration() { this.getAName() = "Set-SmbClientConfiguration" }
31-
32+
3233
/** holds if the argument `requireencryption` is supplied with a `$false` value. */
3334
Expr getMisconfiguredRequireEncryption() {
34-
exists(Expr requireEncryption |
35-
requireEncryption = this.getNamedArgument("requireencryption") and
36-
requireEncryption.getValue().asBoolean() = false and
35+
exists(Expr requireEncryption |
36+
requireEncryption = this.getNamedArgument("requireencryption") and
37+
requireEncryption.getValue().asBoolean() = false and
3738
result = requireEncryption
3839
)
3940
}
4041

4142
/** Holds if the argument `blockntlm` is supplied with a `$false` value. */
42-
Expr getMisconfiguredBlocksNTLM() {
43-
exists(Expr blocksNTLM |
44-
blocksNTLM = this.getNamedArgument("blockntlm") and
43+
Expr getMisconfiguredBlocksNTLM() {
44+
exists(Expr blocksNTLM |
45+
blocksNTLM = this.getNamedArgument("blockntlm") and
4546
blocksNTLM.getValue().asBoolean() = false and
4647
result = blocksNTLM
4748
)
4849
}
4950

50-
override Expr getAMisconfiguredSetting(){
51-
result = this.getMisconfiguredRequireEncryption() or
52-
result = this.getMisconfiguredBlocksNTLM() or
51+
override Expr getAMisconfiguredSetting() {
52+
result = this.getMisconfiguredRequireEncryption() or
53+
result = this.getMisconfiguredBlocksNTLM() or
5354
result = this.getMisconfiguredSmb2DialectMin()
5455
}
5556
}
5657

5758
/** A call to `Set-SmbServerConfiguration`. */
5859
class SetSMBServerConfiguration extends SMBConfiguration {
59-
SetSMBServerConfiguration() {
60-
this.getAName() = "Set-SmbServerConfiguration"
61-
}
60+
SetSMBServerConfiguration() { this.getAName() = "Set-SmbServerConfiguration" }
61+
6262
/** holds if the argument `encryptdata` is supplied with a `$false` value. */
6363
Expr getMisconfiguredEncryptData() {
6464
exists(Expr encryptData |
65-
encryptData = this.getNamedArgument("encryptdata") and
65+
encryptData = this.getNamedArgument("encryptdata") and
6666
encryptData.getValue().asBoolean() = false and
6767
result = encryptData
68-
)
68+
)
6969
}
70+
7071
/** holds if the argument `encryptdata` is supplied with a `$false` value. */
71-
Expr getMisconfiguredRejectUnencryptedAccess(){
72-
exists(Expr rejectUnencryptedAccess |
73-
rejectUnencryptedAccess = this.getNamedArgument("rejectunencryptedaccess") and
74-
rejectUnencryptedAccess.getValue().asBoolean() = false and
75-
result = rejectUnencryptedAccess
72+
Expr getMisconfiguredRejectUnencryptedAccess() {
73+
exists(Expr rejectUnencryptedAccess |
74+
rejectUnencryptedAccess = this.getNamedArgument("rejectunencryptedaccess") and
75+
rejectUnencryptedAccess.getValue().asBoolean() = false and
76+
result = rejectUnencryptedAccess
7677
)
7778
}
78-
79-
override Expr getAMisconfiguredSetting(){
80-
result = this.getMisconfiguredEncryptData() or
81-
result = this.getMisconfiguredRejectUnencryptedAccess() or
79+
80+
override Expr getAMisconfiguredSetting() {
81+
result = this.getMisconfiguredEncryptData() or
82+
result = this.getMisconfiguredRejectUnencryptedAccess() or
8283
result = this.getMisconfiguredSmb2DialectMin()
8384
}
84-
8585
}
8686

8787
from SMBConfiguration config
88-
select config.getAMisconfiguredSetting(), "Unsafe SMB setting"
88+
select config.getAMisconfiguredSetting(), "Unsafe SMB setting"

0 commit comments

Comments
 (0)