|
4 | 4 |
|
5 | 5 | import javascript
|
6 | 6 | private import dataflow.internal.StepSummary
|
| 7 | +private import semmle.javascript.dataflow.internal.FlowSteps |
7 | 8 |
|
8 | 9 | /**
|
9 | 10 | * A call to the `Promise` constructor, such as `new Promise((resolve, reject) => { ... })`.
|
@@ -397,6 +398,17 @@ module PromiseFlow {
|
397 | 398 | value = call.getCallback(0).getExceptionalReturn() and
|
398 | 399 | obj = call
|
399 | 400 | )
|
| 401 | + or |
| 402 | + exists(DataFlow::FunctionNode f | f.getFunction().isAsync() | |
| 403 | + // ordinary return |
| 404 | + prop = valueProp() and |
| 405 | + value = f.getAReturn() and |
| 406 | + obj = f.getReturnNode() |
| 407 | + or |
| 408 | + // exceptional return |
| 409 | + prop = errorProp() and |
| 410 | + localExceptionStepWithAsyncFlag(value, obj, true) |
| 411 | + ) |
400 | 412 | }
|
401 | 413 |
|
402 | 414 | /**
|
@@ -525,30 +537,6 @@ private class PromiseTaintStep extends TaintTracking::LegacyTaintStep {
|
525 | 537 | * Defines flow steps for return on async functions.
|
526 | 538 | */
|
527 | 539 | private module AsyncReturnSteps {
|
528 |
| - private predicate valueProp = Promises::valueProp/0; |
529 |
| - |
530 |
| - private predicate errorProp = Promises::errorProp/0; |
531 |
| - |
532 |
| - private import semmle.javascript.dataflow.internal.FlowSteps |
533 |
| - |
534 |
| - /** |
535 |
| - * A data-flow step for ordinary and exceptional returns from async functions. |
536 |
| - */ |
537 |
| - private class AsyncReturn extends LegacyPreCallGraphStep { |
538 |
| - override predicate storeStep(DataFlow::Node pred, DataFlow::SourceNode succ, string prop) { |
539 |
| - exists(DataFlow::FunctionNode f | f.getFunction().isAsync() | |
540 |
| - // ordinary return |
541 |
| - prop = valueProp() and |
542 |
| - pred = f.getAReturn() and |
543 |
| - succ = f.getReturnNode() |
544 |
| - or |
545 |
| - // exceptional return |
546 |
| - prop = errorProp() and |
547 |
| - localExceptionStepWithAsyncFlag(pred, succ, true) |
548 |
| - ) |
549 |
| - } |
550 |
| - } |
551 |
| - |
552 | 540 | /**
|
553 | 541 | * A data-flow step for ordinary return from an async function in a taint configuration.
|
554 | 542 | */
|
|
0 commit comments