Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e77ea62

Browse files
author
Max Schaefer
committed
JavaScript: Tweak storeStep predicate.
1 parent 94bba88 commit e77ea62

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

javascript/ql/src/semmle/javascript/dataflow/Configuration.qll

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -600,20 +600,28 @@ private predicate flowThroughCall(DataFlow::Node input, DataFlow::Node invk,
600600
* Holds if `pred` may flow into property `prop` of `succ` under configuration `cfg`
601601
* along a path summarized by `summary`.
602602
*/
603-
private predicate storeStep(DataFlow::Node pred, DataFlow::SourceNode succ, string prop,
603+
pragma[nomagic]
604+
private predicate storeStep(DataFlow::Node pred, DataFlow::Node succ, string prop,
604605
DataFlow::Configuration cfg, PathSummary summary) {
605606
basicStoreStep(pred, succ, prop) and
606607
summary = PathSummary::level()
607608
or
608-
exists (Function f, DataFlow::Node mid, DataFlow::SourceNode base |
609+
exists (Function f, DataFlow::Node mid, DataFlow::Node base |
609610
// `f` stores its parameter `pred` in property `prop` of a value that it returns,
610611
// and `succ` is an invocation of `f`
611612
reachableFromInput(f, succ, pred, mid, cfg, summary) and
612-
base.hasPropertyWrite(prop, mid) and
613-
base.flowsToExpr(f.getAReturnedExpr())
613+
returnedPropWrite(f, base, prop, mid)
614614
)
615615
}
616616

617+
/**
618+
* Holds if `f` may return `base`, which has a write of property `prop` with right-hand side `rhs`.
619+
*/
620+
predicate returnedPropWrite(Function f, DataFlow::SourceNode base, string prop, DataFlow::Node rhs) {
621+
base.hasPropertyWrite(prop, rhs) and
622+
base.flowsToExpr(f.getAReturnedExpr())
623+
}
624+
617625
/**
618626
* Holds if `rhs` is the right-hand side of a write to property `prop`, and `nd` is reachable
619627
* from the base of that write under configuration `cfg` (possibly through callees) along a

0 commit comments

Comments
 (0)