File tree Expand file tree Collapse file tree 3 files changed +19
-5
lines changed
src/queries/security/cwe-250
test/query-tests/security/cwe-250 Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,9 @@ class SetExecutionPolicy extends CmdCall {
41
41
else result = this .getPositionalArgument ( 1 )
42
42
)
43
43
}
44
+
45
+ /** Holds if the argument `flag` is supplied with a `$true` value. */
46
+ predicate isForced ( ) { this .getNamedArgument ( "force" ) .getValue ( ) .asBoolean ( ) = true }
44
47
}
45
48
46
49
class Process extends Expr {
@@ -56,5 +59,7 @@ class BypassSetExecutionPolicy extends SetExecutionPolicy {
56
59
}
57
60
58
61
from BypassSetExecutionPolicy setExecutionPolicy
59
- where not setExecutionPolicy .getScope ( ) instanceof Process
62
+ where
63
+ not setExecutionPolicy .getScope ( ) instanceof Process and
64
+ setExecutionPolicy .isForced ( )
60
65
select setExecutionPolicy , "Insecure use of 'Set-ExecutionPolicy'."
Original file line number Diff line number Diff line change 1
- | test.ps1:1:1:1:26 | Call to set-executionpolicy | Insecure use of 'Set-ExecutionPolicy'. |
2
- | test.ps1:5:1:5:47 | Call to set-executionpolicy | Insecure use of 'Set-ExecutionPolicy'. |
1
+ | test.ps1:1:1:1:33 | Call to set-executionpolicy | Insecure use of 'Set-ExecutionPolicy'. |
2
+ | test.ps1:5:1:5:54 | Call to set-executionpolicy | Insecure use of 'Set-ExecutionPolicy'. |
Original file line number Diff line number Diff line change 1
- Set-ExecutionPolicy Bypass # BAD
1
+ Set-ExecutionPolicy Bypass - Force # BAD
2
+ Set-ExecutionPolicy RemoteSigned - Force # GOOD
3
+ Set-ExecutionPolicy Bypass - Scope Process - Force # GOOD
4
+ Set-ExecutionPolicy RemoteSigned - Scope Process - Force # GOOD
5
+ Set-ExecutionPolicy Bypass - Scope MachinePolicy - Force # BAD
6
+
7
+ Set-ExecutionPolicy Bypass - Force:$true # BAD [NOT DETECTED]
8
+ Set-ExecutionPolicy Bypass - Force:$false # GOOD
9
+
10
+ Set-ExecutionPolicy Bypass # GOOD
2
11
Set-ExecutionPolicy RemoteSigned # GOOD
3
12
Set-ExecutionPolicy Bypass - Scope Process # GOOD
4
13
Set-ExecutionPolicy RemoteSigned - Scope Process # GOOD
5
- Set-ExecutionPolicy Bypass - Scope MachinePolicy # BAD
14
+ Set-ExecutionPolicy Bypass - Scope MachinePolicy # GOOD
You can’t perform that action at this time.
0 commit comments