File tree Expand file tree Collapse file tree 1 file changed +44
-1
lines changed
powershell/ql/lib/semmle/code/powershell/controlflow/internal Expand file tree Collapse file tree 1 file changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,50 @@ private predicate mustHaveBooleanCompletion(Ast n) { inBooleanContext(n) }
83
83
* Holds if `n` is used in a Boolean context. That is, the value
84
84
* that `n` evaluates to determines a true/false branch successor.
85
85
*/
86
- private predicate inBooleanContext ( Ast n ) { none ( ) }
86
+ private predicate inBooleanContext ( Ast n ) {
87
+ n = any ( IfStmt ifStmt ) .getACondition ( )
88
+ or
89
+ n = any ( WhileStmt whileStmt ) .getCondition ( )
90
+ or
91
+ n = any ( DoWhileStmt doWhileStmt ) .getCondition ( )
92
+ or
93
+ n = any ( ForStmt forStmt ) .getCondition ( )
94
+ or
95
+ n = any ( DoUntilStmt doUntilStmt ) .getCondition ( )
96
+ or
97
+ exists ( ConditionalExpr cond |
98
+ n = cond .getCondition ( )
99
+ or
100
+ inBooleanContext ( cond ) and
101
+ n = cond .getABranch ( )
102
+ )
103
+ or
104
+ exists ( LogicalAndExpr parent |
105
+ n = parent .getLeft ( )
106
+ or
107
+ inBooleanContext ( parent ) and
108
+ n = parent .getRight ( )
109
+ )
110
+ or
111
+ exists ( LogicalOrExpr parent |
112
+ n = parent .getLeft ( )
113
+ or
114
+ inBooleanContext ( parent ) and
115
+ n = parent .getRight ( )
116
+ )
117
+ or
118
+ n = any ( NotExpr parent | inBooleanContext ( parent ) ) .getOperand ( )
119
+ or
120
+ exists ( Pipeline pipeline |
121
+ inBooleanContext ( pipeline ) and
122
+ n = pipeline .getComponent ( pipeline .getNumberOfComponents ( ) - 1 )
123
+ )
124
+ or
125
+ exists ( CmdExpr cmdExpr |
126
+ inBooleanContext ( cmdExpr ) and
127
+ n = cmdExpr .getExpr ( )
128
+ )
129
+ }
87
130
88
131
/**
89
132
* A completion that represents normal evaluation of a statement or an
You can’t perform that action at this time.
0 commit comments