This commit is contained in:
Erik Krogh Kristensen 2020-01-28 15:09:31 +01:00
Родитель 5063e3820d
Коммит aea365c424
2 изменённых файлов: 36 добавлений и 24 удалений

Просмотреть файл

@ -150,7 +150,7 @@ private module PromiseFlow {
this = promise
}
override predicate store(DataFlow::Node pred, DataFlow::Node succ, string prop) {
override predicate storeStep(DataFlow::Node pred, DataFlow::Node succ, string prop) {
prop = resolveField() and
pred = promise.getResolveParameter().getACall().getArgument(0) and
succ = this
@ -163,7 +163,7 @@ private module PromiseFlow {
succ = this
}
override predicate copyProperty(DataFlow::Node pred, DataFlow::Node succ, string prop) {
override predicate loadStoreStep(DataFlow::Node pred, DataFlow::Node succ, string prop) {
// Copy the value of a resolved promise to the value of this promise.
prop = resolveField() and
pred = promise.getResolveParameter().getACall().getArgument(0) and
@ -180,13 +180,13 @@ private module PromiseFlow {
this = promise
}
override predicate store(DataFlow::Node pred, DataFlow::Node succ, string prop) {
override predicate storeStep(DataFlow::Node pred, DataFlow::Node succ, string prop) {
prop = resolveField() and
pred = promise.getValue() and
succ = this
}
override predicate copyProperty(DataFlow::Node pred, DataFlow::Node succ, string prop) {
override predicate loadStoreStep(DataFlow::Node pred, DataFlow::Node succ, string prop) {
// Copy the value of a resolved promise to the value of this promise.
prop = resolveField() and
pred = promise.getValue() and
@ -207,7 +207,7 @@ private module PromiseFlow {
operand.getEnclosingExpr() = await.getOperand()
}
override predicate load(DataFlow::Node pred, DataFlow::Node succ, string prop) {
override predicate loadStep(DataFlow::Node pred, DataFlow::Node succ, string prop) {
prop = resolveField() and
succ = this and
pred = operand
@ -226,7 +226,7 @@ private module PromiseFlow {
this.getMethodName() = "then"
}
override predicate load(DataFlow::Node pred, DataFlow::Node succ, string prop) {
override predicate loadStep(DataFlow::Node pred, DataFlow::Node succ, string prop) {
prop = resolveField() and
pred = getReceiver() and
succ = getCallback(0).getParameter(0)
@ -236,7 +236,7 @@ private module PromiseFlow {
succ = getCallback(1).getParameter(0)
}
override predicate copyProperty(DataFlow::Node pred, DataFlow::Node succ, string prop) {
override predicate loadStoreStep(DataFlow::Node pred, DataFlow::Node succ, string prop) {
not exists(this.getArgument(1)) and
prop = rejectField() and
pred = getReceiver() and
@ -248,7 +248,7 @@ private module PromiseFlow {
succ = this
}
override predicate store(DataFlow::Node pred, DataFlow::Node succ, string prop) {
override predicate storeStep(DataFlow::Node pred, DataFlow::Node succ, string prop) {
prop = resolveField() and
pred = getCallback([0..1]).getAReturn() and
succ = this
@ -267,13 +267,13 @@ private module PromiseFlow {
this.getMethodName() = "catch"
}
override predicate load(DataFlow::Node pred, DataFlow::Node succ, string prop) {
override predicate loadStep(DataFlow::Node pred, DataFlow::Node succ, string prop) {
prop = rejectField() and
pred = getReceiver() and
succ = getCallback(0).getParameter(0)
}
override predicate copyProperty(DataFlow::Node pred, DataFlow::Node succ, string prop) {
override predicate loadStoreStep(DataFlow::Node pred, DataFlow::Node succ, string prop) {
prop = resolveField() and
pred = getReceiver().getALocalSource() and
succ = this
@ -284,7 +284,7 @@ private module PromiseFlow {
succ = this
}
override predicate store(DataFlow::Node pred, DataFlow::Node succ, string prop) {
override predicate storeStep(DataFlow::Node pred, DataFlow::Node succ, string prop) {
prop = rejectField() and
pred = getCallback(0).getExceptionalReturn() and
succ = this
@ -303,7 +303,7 @@ private module PromiseFlow {
this.getMethodName() = "finally"
}
override predicate copyProperty(DataFlow::Node pred, DataFlow::Node succ, string prop) {
override predicate loadStoreStep(DataFlow::Node pred, DataFlow::Node succ, string prop) {
(prop = resolveField() or prop = rejectField()) and
pred = getReceiver() and
succ = this
@ -314,7 +314,7 @@ private module PromiseFlow {
succ = this
}
override predicate store(DataFlow::Node pred, DataFlow::Node succ, string prop) {
override predicate storeStep(DataFlow::Node pred, DataFlow::Node succ, string prop) {
prop = rejectField() and
pred = getCallback(0).getExceptionalReturn() and
succ = this

Просмотреть файл

@ -225,19 +225,25 @@ abstract class Configuration extends string {
}
/**
* EXPERIMENTAL. This API may change in the future.
*
* Holds if `pred` should be stored in the object `succ` under the property `prop`.
*/
predicate isAdditionalStoreStep(DataFlow::Node pred, DataFlow::Node succ, string prop) { none() }
/**
* EXPERIMENTAL. This API may change in the future.
*
* Holds if the property `prop` of the object `pred` should be loaded into `succ`.
*/
predicate isAdditionalLoadStep(DataFlow::Node pred, DataFlow::Node succ, string prop) { none() }
/**
* EXPERIMENTAL. This API may change in the future.
*
* Holds if the property `prop` should be copied from the object `pred` to the object `succ`.
*/
predicate isAdditionalCopyPropertyStep(DataFlow::Node pred, DataFlow::Node succ, string prop) {
predicate isAdditionalLoadStoreStep(DataFlow::Node pred, DataFlow::Node succ, string prop) {
none()
}
}
@ -487,22 +493,28 @@ abstract class AdditionalFlowStep extends DataFlow::Node {
}
/**
* EXPERIMENTAL. This API may change in the future.
*
* Holds if `pred` should be stored in the object `succ` under the property `prop`.
*/
cached
predicate store(DataFlow::Node pred, DataFlow::Node succ, string prop) { none() }
predicate storeStep(DataFlow::Node pred, DataFlow::Node succ, string prop) { none() }
/**
* EXPERIMENTAL. This API may change in the future.
*
* Holds if the property `prop` of the object `pred` should be loaded into `succ`.
*/
cached
predicate load(DataFlow::Node pred, DataFlow::Node succ, string prop) { none() }
predicate loadStep(DataFlow::Node pred, DataFlow::Node succ, string prop) { none() }
/**
* EXPERIMENTAL. This API may change in the future.
*
* Holds if the property `prop` should be copied from the object `pred` to the object `succ`.
*/
cached
predicate copyProperty(DataFlow::Node pred, DataFlow::Node succ, string prop) { none() }
predicate loadStoreStep(DataFlow::Node pred, DataFlow::Node succ, string prop) { none() }
}
/**
@ -607,7 +619,7 @@ private predicate exploratoryFlowStep(
basicLoadStep(pred, succ, _) or
isAdditionalStoreStep(pred, succ, _, cfg) or
isAdditionalLoadStep(pred, succ, _, cfg) or
isAdditionalCopyPropertyStep(pred, succ, _, cfg) or
isAdditionalLoadStoreStep(pred, succ, _, cfg) or
// the following two disjuncts taken together over-approximate flow through
// higher-order calls
callback(pred, succ) or
@ -830,7 +842,7 @@ private predicate reachesReturn(
private predicate isAdditionalLoadStep(
DataFlow::Node pred, DataFlow::Node succ, string prop, DataFlow::Configuration cfg
) {
any(AdditionalFlowStep s).load(pred, succ, prop)
any(AdditionalFlowStep s).loadStep(pred, succ, prop)
or
cfg.isAdditionalLoadStep(pred, succ, prop)
}
@ -841,7 +853,7 @@ private predicate isAdditionalLoadStep(
private predicate isAdditionalStoreStep(
DataFlow::Node pred, DataFlow::Node succ, string prop, DataFlow::Configuration cfg
) {
any(AdditionalFlowStep s).store(pred, succ, prop)
any(AdditionalFlowStep s).storeStep(pred, succ, prop)
or
cfg.isAdditionalStoreStep(pred, succ, prop)
}
@ -849,12 +861,12 @@ private predicate isAdditionalStoreStep(
/**
* Holds if the property `prop` should be copied from the object `pred` to the object `succ`.
*/
private predicate isAdditionalCopyPropertyStep(
private predicate isAdditionalLoadStoreStep(
DataFlow::Node pred, DataFlow::Node succ, string prop, DataFlow::Configuration cfg
) {
any(AdditionalFlowStep s).copyProperty(pred, succ, prop)
any(AdditionalFlowStep s).loadStoreStep(pred, succ, prop)
or
cfg.isAdditionalCopyPropertyStep(pred, succ, prop)
cfg.isAdditionalLoadStoreStep(pred, succ, prop)
}
/**
@ -895,7 +907,7 @@ private predicate reachableFromStoreBase(
(
flowStep(mid, cfg, nd, newSummary)
or
isAdditionalCopyPropertyStep(mid, nd, prop, cfg) and
isAdditionalLoadStoreStep(mid, nd, prop, cfg) and
newSummary = PathSummary::level()
) and
summary = oldSummary.appendValuePreserving(newSummary)