|
| 1 | +/** |
| 2 | + * @name Unmodeled step |
| 3 | + * @description A potential step from an argument to a return that has no data/taint step. |
| 4 | + * @kind metric |
| 5 | + * @metricType project |
| 6 | + * @metricAggregate sum |
| 7 | + * @tags meta |
| 8 | + * @id js/meta/unmodeled-step |
| 9 | + */ |
| 10 | + |
| 11 | +import javascript |
| 12 | +import meta.MetaMetrics |
| 13 | +private import Expressions.ExprHasNoEffect |
| 14 | +import meta.internal.TaintMetrics |
| 15 | + |
| 16 | +predicate unmodeled(API::Node callee, API::CallNode call, DataFlow::Node pred, DataFlow::Node succ) { |
| 17 | + callee.getACall() = call and |
| 18 | + pred = call.getAnArgument() and |
| 19 | + succ = call and |
| 20 | + not inVoidContext(succ.asExpr()) and // void calls are irrelevant |
| 21 | + not call.getAnArgument() = relevantTaintSink() and // calls with sinks are considered modeled |
| 22 | + // we assume taint to the return value means the call is modeled |
| 23 | + not ( |
| 24 | + TaintTracking::sharedTaintStep(_, succ) |
| 25 | + or |
| 26 | + DataFlow::SharedFlowStep::step(_, succ) |
| 27 | + or |
| 28 | + DataFlow::SharedFlowStep::step(_, succ, _, _) |
| 29 | + or |
| 30 | + DataFlow::SharedFlowStep::loadStep(_, succ, _) |
| 31 | + or |
| 32 | + DataFlow::SharedFlowStep::storeStep(_, succ, _) |
| 33 | + or |
| 34 | + DataFlow::SharedFlowStep::loadStoreStep(_, succ, _, _) |
| 35 | + or |
| 36 | + DataFlow::SharedFlowStep::loadStoreStep(_, succ, _) |
| 37 | + ) and |
| 38 | + not pred.getFile() instanceof IgnoredFile and |
| 39 | + not succ.getFile() instanceof IgnoredFile |
| 40 | +} |
| 41 | + |
| 42 | +select projectRoot(), count(DataFlow::Node pred, DataFlow::Node succ | unmodeled(_, _, pred, succ)) |
0 commit comments