Skip to content

Commit c8b4a21

Browse files
authored
Merge pull request #14573 from hvitved/flow-summary-impl-param
Move `FlowSummaryImpl.qll` to `dataflow` pack
2 parents 8f0e0b6 + 098afb9 commit c8b4a21

File tree

110 files changed

+4438
-12777
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+4438
-12777
lines changed

config/identical-files.json

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,6 @@
5353
"ruby/ql/lib/codeql/ruby/dataflow/internal/tainttracking1/TaintTrackingImpl.qll",
5454
"swift/ql/lib/codeql/swift/dataflow/internal/tainttracking1/TaintTrackingImpl.qll"
5555
],
56-
"DataFlow Java/C#/Go/Ruby/Python/Swift Flow Summaries": [
57-
"java/ql/lib/semmle/code/java/dataflow/internal/FlowSummaryImpl.qll",
58-
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/FlowSummaryImpl.qll",
59-
"go/ql/lib/semmle/go/dataflow/internal/FlowSummaryImpl.qll",
60-
"ruby/ql/lib/codeql/ruby/dataflow/internal/FlowSummaryImpl.qll",
61-
"python/ql/lib/semmle/python/dataflow/new/internal/FlowSummaryImpl.qll",
62-
"swift/ql/lib/codeql/swift/dataflow/internal/FlowSummaryImpl.qll"
63-
],
6456
"SsaReadPosition Java/C#": [
6557
"java/ql/lib/semmle/code/java/dataflow/internal/rangeanalysis/SsaReadPositionCommon.qll",
6658
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/SsaReadPositionCommon.qll"
@@ -466,15 +458,6 @@
466458
"python/ql/lib/semmle/python/dataflow/new/internal/SummaryTypeTracker.qll",
467459
"ruby/ql/lib/codeql/ruby/typetracking/internal/SummaryTypeTracker.qll"
468460
],
469-
"AccessPathSyntax": [
470-
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/AccessPathSyntax.qll",
471-
"go/ql/lib/semmle/go/dataflow/internal/AccessPathSyntax.qll",
472-
"java/ql/lib/semmle/code/java/dataflow/internal/AccessPathSyntax.qll",
473-
"javascript/ql/lib/semmle/javascript/frameworks/data/internal/AccessPathSyntax.qll",
474-
"ruby/ql/lib/codeql/ruby/dataflow/internal/AccessPathSyntax.qll",
475-
"python/ql/lib/semmle/python/dataflow/new/internal/AccessPathSyntax.qll",
476-
"swift/ql/lib/codeql/swift/dataflow/internal/AccessPathSyntax.qll"
477-
],
478461
"IncompleteUrlSubstringSanitization": [
479462
"javascript/ql/src/Security/CWE-020/IncompleteUrlSubstringSanitization.qll",
480463
"ruby/ql/src/queries/security/cwe-020/IncompleteUrlSubstringSanitization.qll"
Lines changed: 7 additions & 183 deletions
Original file line numberDiff line numberDiff line change
@@ -1,199 +1,23 @@
11
/** Provides classes and predicates for defining flow summaries. */
22

33
import csharp
4-
private import dotnet
54
private import internal.FlowSummaryImpl as Impl
65
private import internal.DataFlowDispatch as DataFlowDispatch
7-
private import Impl::Public::SummaryComponent as SummaryComponentInternal
86

9-
class ParameterPosition = DataFlowDispatch::ParameterPosition;
7+
deprecated class ParameterPosition = DataFlowDispatch::ParameterPosition;
108

11-
class ArgumentPosition = DataFlowDispatch::ArgumentPosition;
9+
deprecated class ArgumentPosition = DataFlowDispatch::ArgumentPosition;
1210

13-
// import all instances below
14-
private module Summaries {
15-
private import semmle.code.csharp.frameworks.EntityFramework
16-
}
11+
deprecated class SummaryComponent = Impl::Private::SummaryComponent;
1712

18-
class SummaryComponent = Impl::Public::SummaryComponent;
13+
deprecated module SummaryComponent = Impl::Private::SummaryComponent;
1914

20-
/** Provides predicates for constructing summary components. */
21-
module SummaryComponent {
22-
predicate content = SummaryComponentInternal::content/1;
15+
deprecated class SummaryComponentStack = Impl::Private::SummaryComponentStack;
2316

24-
/** Gets a summary component for parameter `i`. */
25-
SummaryComponent parameter(int i) {
26-
exists(ArgumentPosition pos |
27-
result = SummaryComponentInternal::parameter(pos) and
28-
i = pos.getPosition()
29-
)
30-
}
17+
deprecated module SummaryComponentStack = Impl::Private::SummaryComponentStack;
3118

32-
/** Gets a summary component for argument `i`. */
33-
SummaryComponent argument(int i) {
34-
exists(ParameterPosition pos |
35-
result = SummaryComponentInternal::argument(pos) and
36-
i = pos.getPosition()
37-
)
38-
}
39-
40-
predicate return = SummaryComponentInternal::return/1;
41-
42-
/** Gets a summary component that represents a qualifier. */
43-
SummaryComponent qualifier() {
44-
exists(ParameterPosition pos |
45-
result = SummaryComponentInternal::argument(pos) and
46-
pos.isThisParameter()
47-
)
48-
}
49-
50-
/** Gets a summary component that represents an element in a collection. */
51-
SummaryComponent element() { result = content(any(DataFlow::ElementContent c)) }
52-
53-
/** Gets a summary component for property `p`. */
54-
SummaryComponent property(Property p) {
55-
result = content(any(DataFlow::PropertyContent c | c.getProperty() = p.getUnboundDeclaration()))
56-
}
57-
58-
/** Gets a summary component for field `f`. */
59-
SummaryComponent field(Field f) {
60-
result = content(any(DataFlow::FieldContent c | c.getField() = f.getUnboundDeclaration()))
61-
}
62-
63-
/** Gets a summary component that represents the return value of a call. */
64-
SummaryComponent return() { result = return(any(DataFlowDispatch::NormalReturnKind rk)) }
65-
66-
predicate syntheticGlobal = SummaryComponentInternal::syntheticGlobal/1;
67-
68-
class SyntheticGlobal = SummaryComponentInternal::SyntheticGlobal;
69-
}
70-
71-
class SummaryComponentStack = Impl::Public::SummaryComponentStack;
72-
73-
/** Provides predicates for constructing stacks of summary components. */
74-
module SummaryComponentStack {
75-
private import Impl::Public::SummaryComponentStack as SummaryComponentStackInternal
76-
77-
predicate singleton = SummaryComponentStackInternal::singleton/1;
78-
79-
predicate push = SummaryComponentStackInternal::push/2;
80-
81-
/** Gets a singleton stack for argument `i`. */
82-
SummaryComponentStack argument(int i) { result = singleton(SummaryComponent::argument(i)) }
83-
84-
predicate return = SummaryComponentStackInternal::return/1;
85-
86-
/** Gets a singleton stack representing a qualifier. */
87-
SummaryComponentStack qualifier() { result = singleton(SummaryComponent::qualifier()) }
88-
89-
/** Gets a stack representing an element of `container`. */
90-
SummaryComponentStack elementOf(SummaryComponentStack container) {
91-
result = push(SummaryComponent::element(), container)
92-
}
93-
94-
/** Gets a stack representing a property `p` of `object`. */
95-
SummaryComponentStack propertyOf(Property p, SummaryComponentStack object) {
96-
result = push(SummaryComponent::property(p), object)
97-
}
98-
99-
/** Gets a stack representing a field `f` of `object`. */
100-
SummaryComponentStack fieldOf(Field f, SummaryComponentStack object) {
101-
result = push(SummaryComponent::field(f), object)
102-
}
103-
104-
/** Gets a singleton stack representing the return value of a call. */
105-
SummaryComponentStack return() { result = singleton(SummaryComponent::return()) }
106-
107-
/** Gets a singleton stack representing a synthetic global with name `name`. */
108-
SummaryComponentStack syntheticGlobal(string synthetic) {
109-
result = singleton(SummaryComponent::syntheticGlobal(synthetic))
110-
}
111-
112-
/**
113-
* DEPRECATED: Use the member predicate `getMadRepresentation` instead.
114-
*
115-
* Gets a textual representation of this stack used for flow summaries.
116-
*/
117-
deprecated string getComponentStack(SummaryComponentStack s) { result = s.getMadRepresentation() }
118-
}
19+
deprecated class RequiredSummaryComponentStack = Impl::Private::RequiredSummaryComponentStack;
11920

12021
class SummarizedCallable = Impl::Public::SummarizedCallable;
12122

122-
private predicate recordConstructorFlow(Constructor c, int i, Property p) {
123-
c = any(RecordType r).getAMember() and
124-
exists(string name |
125-
c.getParameter(i).getName() = name and
126-
c.getDeclaringType().getAMember(name) = p
127-
)
128-
}
129-
130-
private class RecordConstructorFlow extends SummarizedCallable {
131-
RecordConstructorFlow() { recordConstructorFlow(this, _, _) }
132-
133-
override predicate propagatesFlow(
134-
SummaryComponentStack input, SummaryComponentStack output, boolean preservesValue
135-
) {
136-
exists(int i, Property p |
137-
recordConstructorFlow(this, i, p) and
138-
input = SummaryComponentStack::argument(i) and
139-
output = SummaryComponentStack::propertyOf(p, SummaryComponentStack::return()) and
140-
preservesValue = true
141-
)
142-
}
143-
}
144-
145-
class RequiredSummaryComponentStack = Impl::Public::RequiredSummaryComponentStack;
146-
147-
private class RecordConstructorFlowRequiredSummaryComponentStack extends RequiredSummaryComponentStack
148-
{
149-
override predicate required(SummaryComponent head, SummaryComponentStack tail) {
150-
exists(Property p |
151-
recordConstructorFlow(_, _, p) and
152-
head = SummaryComponent::property(p) and
153-
tail = SummaryComponentStack::return()
154-
)
155-
}
156-
}
157-
15823
class Provenance = Impl::Public::Provenance;
159-
160-
private import semmle.code.csharp.frameworks.system.linq.Expressions
161-
162-
private SummaryComponent delegateSelf() {
163-
exists(ArgumentPosition pos |
164-
result = SummaryComponentInternal::parameter(pos) and
165-
pos.isDelegateSelf()
166-
)
167-
}
168-
169-
private predicate mayInvokeCallback(Callable c, int n) {
170-
c.getParameter(n).getType() instanceof SystemLinqExpressions::DelegateExtType and
171-
not c.hasBody() and
172-
(if c instanceof Accessor then not c.fromSource() else any())
173-
}
174-
175-
private class SummarizedCallableWithCallback extends SummarizedCallable {
176-
private int pos;
177-
178-
SummarizedCallableWithCallback() { mayInvokeCallback(this, pos) }
179-
180-
override predicate propagatesFlow(
181-
SummaryComponentStack input, SummaryComponentStack output, boolean preservesValue
182-
) {
183-
input = SummaryComponentStack::argument(pos) and
184-
output = SummaryComponentStack::push(delegateSelf(), input) and
185-
preservesValue = true
186-
}
187-
188-
override predicate hasProvenance(Provenance provenance) { provenance = "hq-generated" }
189-
}
190-
191-
private class RequiredComponentStackForCallback extends RequiredSummaryComponentStack {
192-
override predicate required(SummaryComponent head, SummaryComponentStack tail) {
193-
exists(int pos |
194-
mayInvokeCallback(_, pos) and
195-
head = delegateSelf() and
196-
tail = SummaryComponentStack::argument(pos)
197-
)
198-
}
199-
}

0 commit comments

Comments
 (0)