Skip to content

Commit 7aa421f

Browse files
committed
prune clearly infeasible store steps
1 parent 8cf71e5 commit 7aa421f

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,8 +753,7 @@ private predicate exploratoryFlowStep(
753753
DataFlow::Node pred, DataFlow::Node succ, DataFlow::Configuration cfg
754754
) {
755755
basicFlowStepNoBarrier(pred, succ, _, cfg) or
756-
basicStoreStep(pred, succ, _) or
757-
isAdditionalStoreStep(pred, succ, _, cfg) or
756+
exploratoryStoreStep(pred, succ, cfg) or
758757
exploratoryLoadStep(pred, succ, cfg) or
759758
isAdditionalLoadStoreStep(pred, succ, _, _, cfg) or
760759
// the following three disjuncts taken together over-approximate flow through
@@ -832,6 +831,23 @@ private string getAPropertyUsedInLoadStore(DataFlow::Configuration cfg) {
832831
)
833832
}
834833

834+
/**
835+
* Holds if there exists a store-step from `pred` to `succ` under configuration `cfg`,
836+
* and somewhere in the program there exists a load-step that could possibly read the stored value.
837+
*/
838+
predicate exploratoryStoreStep(
839+
DataFlow::Node pred, DataFlow::Node succ, DataFlow::Configuration cfg
840+
) {
841+
exists(string prop |
842+
basicLoadStep(_, _, prop) or
843+
isAdditionalLoadStep(_, _, prop, cfg) or
844+
prop = getAPropertyUsedInLoadStore(cfg)
845+
|
846+
isAdditionalStoreStep(pred, succ, prop, cfg) or
847+
basicStoreStep(pred, succ, prop)
848+
)
849+
}
850+
835851
/**
836852
* Holds if `nd` may be reachable from a source under `cfg`.
837853
*

0 commit comments

Comments
 (0)