|
1 | 1 | private import codeql.dataflow.DataFlow
|
| 2 | +private import codeql.typetracking.TypeTracking as Tt |
2 | 3 |
|
3 | 4 | module MakeImplCommon<InputSig Lang> {
|
4 | 5 | private import Lang
|
@@ -52,8 +53,82 @@ module MakeImplCommon<InputSig Lang> {
|
52 | 53 | class FeatureEqualSourceSinkCallContext extends FlowFeature, TFeatureEqualSourceSinkCallContext {
|
53 | 54 | override string toString() { result = "FeatureEqualSourceSinkCallContext" }
|
54 | 55 | }
|
| 56 | + |
| 57 | + signature predicate sourceNode(Node n); |
| 58 | + |
| 59 | + /** |
| 60 | + * EXPERIMENTAL: This API is subject to change without notice. |
| 61 | + * |
| 62 | + * Given a source definition, this constructs a simple forward flow |
| 63 | + * computation with an access path limit of 1. |
| 64 | + */ |
| 65 | + module SimpleGlobal<sourceNode/1 source> { |
| 66 | + import TypeTracking::TypeTrack<source/1> |
| 67 | + } |
55 | 68 | }
|
56 | 69 |
|
| 70 | + private module TypeTrackingInput implements Tt::TypeTrackingInput { |
| 71 | + final class Node = Lang::Node; |
| 72 | + |
| 73 | + class LocalSourceNode extends Node { |
| 74 | + LocalSourceNode() { |
| 75 | + storeStep(_, this, _) or |
| 76 | + loadStep(_, this, _) or |
| 77 | + jumpStepCached(_, this) or |
| 78 | + this instanceof ParamNode or |
| 79 | + this instanceof OutNodeExt |
| 80 | + } |
| 81 | + } |
| 82 | + |
| 83 | + final private class LangContentSet = Lang::ContentSet; |
| 84 | + |
| 85 | + class Content extends LangContentSet { |
| 86 | + string toString() { result = "Content" } |
| 87 | + } |
| 88 | + |
| 89 | + class ContentFilter extends Content { |
| 90 | + Content getAMatchingContent() { result = this } |
| 91 | + } |
| 92 | + |
| 93 | + predicate compatibleContents(Content storeContents, Content loadContents) { |
| 94 | + storeContents.getAStoreContent() = loadContents.getAReadContent() |
| 95 | + } |
| 96 | + |
| 97 | + predicate simpleLocalSmallStep = simpleLocalFlowStepExt/2; |
| 98 | + |
| 99 | + predicate levelStepNoCall(Node n1, LocalSourceNode n2) { none() } |
| 100 | + |
| 101 | + predicate levelStepCall(Node n1, LocalSourceNode n2) { |
| 102 | + argumentValueFlowsThrough(n1, TReadStepTypesNone(), n2) |
| 103 | + } |
| 104 | + |
| 105 | + predicate storeStep(Node n1, Node n2, Content f) { storeSet(n1, f, n2, _, _) } |
| 106 | + |
| 107 | + predicate loadStep(Node n1, LocalSourceNode n2, Content f) { |
| 108 | + readSet(n1, f, n2) |
| 109 | + or |
| 110 | + argumentValueFlowsThrough(n1, TReadStepTypesSome(_, f, _), n2) |
| 111 | + } |
| 112 | + |
| 113 | + predicate loadStoreStep(Node nodeFrom, Node nodeTo, Content f1, Content f2) { none() } |
| 114 | + |
| 115 | + predicate withContentStep(Node nodeFrom, LocalSourceNode nodeTo, ContentFilter f) { none() } |
| 116 | + |
| 117 | + predicate withoutContentStep(Node nodeFrom, LocalSourceNode nodeTo, ContentFilter f) { none() } |
| 118 | + |
| 119 | + predicate jumpStep(Node n1, LocalSourceNode n2) { jumpStepCached(n1, n2) } |
| 120 | + |
| 121 | + predicate callStep(Node n1, LocalSourceNode n2) { viableParamArg(_, n2, n1) } |
| 122 | + |
| 123 | + predicate returnStep(Node n1, LocalSourceNode n2) { |
| 124 | + viableReturnPosOut(_, getReturnPosition(n1), n2) |
| 125 | + } |
| 126 | + |
| 127 | + predicate hasFeatureBacktrackStoreTarget() { none() } |
| 128 | + } |
| 129 | + |
| 130 | + private module TypeTracking = Tt::TypeTracking<TypeTrackingInput>; |
| 131 | + |
57 | 132 | /**
|
58 | 133 | * The cost limits for the `AccessPathFront` to `AccessPathApprox` expansion.
|
59 | 134 | *
|
|
0 commit comments