File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
javascript/ql/lib/semmle/javascript/dataflow Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -1693,7 +1693,11 @@ module DataFlow {
1693
1693
exists ( Expr predExpr , Expr succExpr |
1694
1694
pred = valueNode ( predExpr ) and succ = valueNode ( succExpr )
1695
1695
|
1696
- predExpr = succExpr .( LogicalBinaryExpr ) .getAnOperand ( )
1696
+ predExpr = succExpr .( LogicalOrExpr ) .getAnOperand ( )
1697
+ or
1698
+ predExpr = succExpr .( NullishCoalescingExpr ) .getAnOperand ( )
1699
+ or
1700
+ predExpr = succExpr .( LogicalAndExpr ) .getRightOperand ( )
1697
1701
or
1698
1702
predExpr = succExpr .( ConditionalExpr ) .getABranch ( )
1699
1703
or
Original file line number Diff line number Diff line change @@ -238,6 +238,26 @@ private class AnalyzedBinaryExpr extends DataFlow::AnalyzedValueNode {
238
238
}
239
239
}
240
240
241
+ pragma [ nomagic]
242
+ private predicate falsyValue ( AbstractValue value ) { value .getBooleanValue ( ) = false }
243
+
244
+ /**
245
+ * Flow analysis for `&&` operators.
246
+ */
247
+ private class AnalyzedLogicalAndExpr extends DataFlow:: AnalyzedValueNode {
248
+ override LogicalAndExpr astNode ;
249
+
250
+ pragma [ nomagic]
251
+ private AnalyzedValueNode leftOperand ( ) { result = astNode .getLeftOperand ( ) .analyze ( ) }
252
+
253
+ override AbstractValue getALocalValue ( ) {
254
+ result = super .getALocalValue ( )
255
+ or
256
+ result = this .leftOperand ( ) .getALocalValue ( ) and
257
+ falsyValue ( result )
258
+ }
259
+ }
260
+
241
261
/**
242
262
* Gets the `n`th operand of the given `+` or `+=` expression.
243
263
*/
You can’t perform that action at this time.
0 commit comments