|
| 1 | +private import semmle.javascript.Locations |
| 2 | +private import codeql.typetracking.internal.SummaryTypeTracker |
| 3 | +private import semmle.javascript.dataflow.internal.DataFlowPrivate as DataFlowPrivate |
| 4 | +private import semmle.javascript.dataflow.FlowSummary as FlowSummary |
| 5 | +private import FlowSummaryImpl as FlowSummaryImpl |
| 6 | +private import DataFlowArg |
| 7 | + |
| 8 | +private module SummaryFlowConfig implements Input { |
| 9 | + import JSDataFlow |
| 10 | + import FlowSummaryImpl::Public |
| 11 | + import FlowSummaryImpl::Private |
| 12 | + import FlowSummaryImpl::Private::SummaryComponent |
| 13 | + |
| 14 | + class Content = DataFlow::ContentSet; |
| 15 | + |
| 16 | + class ContentFilter extends Unit { |
| 17 | + ContentFilter() { none() } |
| 18 | + } |
| 19 | + |
| 20 | + ContentFilter getFilterFromWithoutContentStep(Content content) { none() } |
| 21 | + |
| 22 | + ContentFilter getFilterFromWithContentStep(Content content) { none() } |
| 23 | + |
| 24 | + predicate singleton = SummaryComponentStack::singleton/1; |
| 25 | + |
| 26 | + predicate push = SummaryComponentStack::push/2; |
| 27 | + |
| 28 | + SummaryComponent return() { |
| 29 | + result = SummaryComponent::return(DataFlowPrivate::MkNormalReturnKind()) |
| 30 | + } |
| 31 | + |
| 32 | + Node argumentOf(Node call, SummaryComponent arg, boolean isPostUpdate) { |
| 33 | + exists(ArgumentPosition apos, ParameterPosition ppos, Node argNode | |
| 34 | + arg = argument(ppos) and |
| 35 | + parameterMatch(ppos, apos) and |
| 36 | + isArgumentNode(argNode, any(DataFlowCall c | c.asOrdinaryCall() = call), apos) |
| 37 | + | |
| 38 | + isPostUpdate = true and result = argNode.getPostUpdateNode() |
| 39 | + or |
| 40 | + isPostUpdate = false and result = argNode |
| 41 | + ) |
| 42 | + } |
| 43 | + |
| 44 | + Node parameterOf(Node callable, SummaryComponent param) { |
| 45 | + exists(ArgumentPosition apos, ParameterPosition ppos, Function function | |
| 46 | + param = parameter(apos) and |
| 47 | + parameterMatch(ppos, apos) and |
| 48 | + callable = function.flow() and |
| 49 | + isParameterNode(result, any(DataFlowCallable c | c.asSourceCallable() = function), ppos) |
| 50 | + ) |
| 51 | + } |
| 52 | + |
| 53 | + Node returnOf(Node callable, SummaryComponent return) { |
| 54 | + return = return() and |
| 55 | + result = callable.(DataFlow::FunctionNode).getReturnNode() |
| 56 | + } |
| 57 | + |
| 58 | + class SummarizedCallable instanceof SummarizedCallableImpl { |
| 59 | + predicate propagatesFlow( |
| 60 | + SummaryComponentStack input, SummaryComponentStack output, boolean preservesValue |
| 61 | + ) { |
| 62 | + super.propagatesFlow(input, output, preservesValue, _) |
| 63 | + } |
| 64 | + |
| 65 | + string toString() { result = super.toString() } |
| 66 | + } |
| 67 | + |
| 68 | + Node callTo(SummarizedCallable callable) { |
| 69 | + result = callable.(FlowSummary::SummarizedCallable).getACallSimple() |
| 70 | + } |
| 71 | +} |
| 72 | + |
| 73 | +import SummaryFlow<SummaryFlowConfig> |
0 commit comments