Skip to content

Commit 0af5300

Browse files
authored
Merge pull request github#11697 from owen-mc/go/make-dataflowtype-singleton
Make DataFlowType a singleton
2 parents 1b49bfe + d18179c commit 0af5300

File tree

50 files changed

+2436
-2437
lines changed

Some content is hidden

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

50 files changed

+2436
-2437
lines changed

go/ql/lib/semmle/go/dataflow/internal/DataFlowPrivate.qll

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,21 +199,17 @@ predicate expectsContent(Node n, ContentSet c) {
199199
}
200200

201201
/** Gets the type of `n` used for type pruning. */
202-
DataFlowType getNodeType(Node n) {
203-
result = n.getType()
204-
or
205-
result = FlowSummaryImpl::Private::summaryNodeType(n)
206-
}
202+
DataFlowType getNodeType(Node n) { result = TTodoDataFlowType() and exists(n) }
207203

208204
/** Gets a string representation of a type returned by `getNodeType()`. */
209-
string ppReprType(Type t) { result = t.toString() }
205+
string ppReprType(DataFlowType t) { none() }
210206

211207
/**
212208
* Holds if `t1` and `t2` are compatible, that is, whether data can flow from
213209
* a node of type `t1` to a node of type `t2`.
214210
*/
215211
pragma[inline]
216-
predicate compatibleTypes(Type t1, Type t2) {
212+
predicate compatibleTypes(DataFlowType t1, DataFlowType t2) {
217213
any() // stub implementation
218214
}
219215

@@ -227,7 +223,14 @@ class CastNode extends ExprNode {
227223

228224
class DataFlowExpr = Expr;
229225

230-
class DataFlowType = Type;
226+
private newtype TDataFlowType =
227+
TTodoDataFlowType() or
228+
TTodoDataFlowType2() // Add a dummy value to prevent bad functionality-induced joins arising from a type of size 1.
229+
230+
class DataFlowType extends TDataFlowType {
231+
/** Gets a textual representation of this element. */
232+
string toString() { result = "" }
233+
}
231234

232235
class DataFlowLocation = Location;
233236

go/ql/lib/semmle/go/dataflow/internal/DataFlowUtil.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ private newtype TContent =
149149
*/
150150
class Content extends TContent {
151151
/** Gets the type of the contained data for the purpose of type pruning. */
152-
DataFlowType getType() { result instanceof EmptyInterfaceType }
152+
DataFlowType getType() { any() }
153153

154154
/** Gets a textual representation of this element. */
155155
abstract string toString();
@@ -177,7 +177,7 @@ class FieldContent extends Content, TFieldContent {
177177
/** Gets the field associated with this `FieldContent`. */
178178
Field getField() { result = f }
179179

180-
override DataFlowType getType() { result = f.getType() }
180+
override DataFlowType getType() { any() }
181181

182182
override string toString() { result = f.toString() }
183183

@@ -205,7 +205,7 @@ class PointerContent extends Content, TPointerContent {
205205
/** Gets the pointer type that containers with this content must have. */
206206
PointerType getPointerType() { result = t }
207207

208-
override DataFlowType getType() { result = t.getBaseType() }
208+
override DataFlowType getType() { any() }
209209

210210
override string toString() { result = "pointer" }
211211
}
@@ -228,7 +228,7 @@ class SyntheticFieldContent extends Content, TSyntheticFieldContent {
228228
/** Gets the field associated with this `SyntheticFieldContent`. */
229229
SyntheticField getField() { result = s }
230230

231-
override DataFlowType getType() { result = s.getType() }
231+
override DataFlowType getType() { any() }
232232

233233
override string toString() { result = s.toString() }
234234
}

go/ql/lib/semmle/go/dataflow/internal/FlowSummaryImplSpecific.qll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ DataFlowCall summaryDataFlowCall(Node receiver) {
4040
DataFlowType getContentType(Content c) { result = c.getType() }
4141

4242
/** Gets the return type of kind `rk` for callable `c`. */
43-
DataFlowType getReturnType(SummarizedCallable c, ReturnKind rk) {
44-
result = c.getType().getResultType(rk.getIndex())
45-
}
43+
DataFlowType getReturnType(SummarizedCallable c, ReturnKind rk) { any() }
4644

4745
/**
4846
* Gets the type of the `i`th parameter in a synthesized call that targets a
Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
11
edges
2-
| LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:59:3:59:11 | untrusted |
3-
| LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:61:3:61:51 | ...+... |
4-
| LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:62:3:62:33 | slice literal |
5-
| LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:62:24:62:32 | untrusted : string |
6-
| LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:66:3:66:11 | untrusted |
7-
| LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:68:3:68:51 | ...+... |
8-
| LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:69:3:69:33 | slice literal |
9-
| LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:69:24:69:32 | untrusted : string |
10-
| LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:73:3:73:11 | untrusted |
11-
| LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:75:3:75:51 | ...+... |
12-
| LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:76:3:76:33 | slice literal |
13-
| LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:76:24:76:32 | untrusted : string |
14-
| LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:80:22:80:30 | untrusted |
15-
| LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:81:25:81:33 | untrusted |
16-
| LDAPInjection.go:62:3:62:33 | slice literal [array] : string | LDAPInjection.go:62:3:62:33 | slice literal |
17-
| LDAPInjection.go:62:24:62:32 | untrusted : string | LDAPInjection.go:62:3:62:33 | slice literal [array] : string |
18-
| LDAPInjection.go:69:3:69:33 | slice literal [array] : string | LDAPInjection.go:69:3:69:33 | slice literal |
19-
| LDAPInjection.go:69:24:69:32 | untrusted : string | LDAPInjection.go:69:3:69:33 | slice literal [array] : string |
20-
| LDAPInjection.go:76:3:76:33 | slice literal [array] : string | LDAPInjection.go:76:3:76:33 | slice literal |
21-
| LDAPInjection.go:76:24:76:32 | untrusted : string | LDAPInjection.go:76:3:76:33 | slice literal [array] : string |
2+
| LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:59:3:59:11 | untrusted |
3+
| LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:61:3:61:51 | ...+... |
4+
| LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:62:3:62:33 | slice literal |
5+
| LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:62:24:62:32 | untrusted |
6+
| LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:66:3:66:11 | untrusted |
7+
| LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:68:3:68:51 | ...+... |
8+
| LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:69:3:69:33 | slice literal |
9+
| LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:69:24:69:32 | untrusted |
10+
| LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:73:3:73:11 | untrusted |
11+
| LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:75:3:75:51 | ...+... |
12+
| LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:76:3:76:33 | slice literal |
13+
| LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:76:24:76:32 | untrusted |
14+
| LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:80:22:80:30 | untrusted |
15+
| LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:81:25:81:33 | untrusted |
16+
| LDAPInjection.go:62:3:62:33 | slice literal [array] | LDAPInjection.go:62:3:62:33 | slice literal |
17+
| LDAPInjection.go:62:24:62:32 | untrusted | LDAPInjection.go:62:3:62:33 | slice literal [array] |
18+
| LDAPInjection.go:69:3:69:33 | slice literal [array] | LDAPInjection.go:69:3:69:33 | slice literal |
19+
| LDAPInjection.go:69:24:69:32 | untrusted | LDAPInjection.go:69:3:69:33 | slice literal [array] |
20+
| LDAPInjection.go:76:3:76:33 | slice literal [array] | LDAPInjection.go:76:3:76:33 | slice literal |
21+
| LDAPInjection.go:76:24:76:32 | untrusted | LDAPInjection.go:76:3:76:33 | slice literal [array] |
2222
nodes
23-
| LDAPInjection.go:57:15:57:29 | call to UserAgent : string | semmle.label | call to UserAgent : string |
23+
| LDAPInjection.go:57:15:57:29 | call to UserAgent | semmle.label | call to UserAgent |
2424
| LDAPInjection.go:59:3:59:11 | untrusted | semmle.label | untrusted |
2525
| LDAPInjection.go:61:3:61:51 | ...+... | semmle.label | ...+... |
2626
| LDAPInjection.go:62:3:62:33 | slice literal | semmle.label | slice literal |
27-
| LDAPInjection.go:62:3:62:33 | slice literal [array] : string | semmle.label | slice literal [array] : string |
28-
| LDAPInjection.go:62:24:62:32 | untrusted : string | semmle.label | untrusted : string |
27+
| LDAPInjection.go:62:3:62:33 | slice literal [array] | semmle.label | slice literal [array] |
28+
| LDAPInjection.go:62:24:62:32 | untrusted | semmle.label | untrusted |
2929
| LDAPInjection.go:66:3:66:11 | untrusted | semmle.label | untrusted |
3030
| LDAPInjection.go:68:3:68:51 | ...+... | semmle.label | ...+... |
3131
| LDAPInjection.go:69:3:69:33 | slice literal | semmle.label | slice literal |
32-
| LDAPInjection.go:69:3:69:33 | slice literal [array] : string | semmle.label | slice literal [array] : string |
33-
| LDAPInjection.go:69:24:69:32 | untrusted : string | semmle.label | untrusted : string |
32+
| LDAPInjection.go:69:3:69:33 | slice literal [array] | semmle.label | slice literal [array] |
33+
| LDAPInjection.go:69:24:69:32 | untrusted | semmle.label | untrusted |
3434
| LDAPInjection.go:73:3:73:11 | untrusted | semmle.label | untrusted |
3535
| LDAPInjection.go:75:3:75:51 | ...+... | semmle.label | ...+... |
3636
| LDAPInjection.go:76:3:76:33 | slice literal | semmle.label | slice literal |
37-
| LDAPInjection.go:76:3:76:33 | slice literal [array] : string | semmle.label | slice literal [array] : string |
38-
| LDAPInjection.go:76:24:76:32 | untrusted : string | semmle.label | untrusted : string |
37+
| LDAPInjection.go:76:3:76:33 | slice literal [array] | semmle.label | slice literal [array] |
38+
| LDAPInjection.go:76:24:76:32 | untrusted | semmle.label | untrusted |
3939
| LDAPInjection.go:80:22:80:30 | untrusted | semmle.label | untrusted |
4040
| LDAPInjection.go:81:25:81:33 | untrusted | semmle.label | untrusted |
4141
subpaths
4242
#select
43-
| LDAPInjection.go:59:3:59:11 | untrusted | LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:59:3:59:11 | untrusted | LDAP query parameter depends on a $@. | LDAPInjection.go:57:15:57:29 | call to UserAgent | user-provided value |
44-
| LDAPInjection.go:61:3:61:51 | ...+... | LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:61:3:61:51 | ...+... | LDAP query parameter depends on a $@. | LDAPInjection.go:57:15:57:29 | call to UserAgent | user-provided value |
45-
| LDAPInjection.go:62:3:62:33 | slice literal | LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:62:3:62:33 | slice literal | LDAP query parameter depends on a $@. | LDAPInjection.go:57:15:57:29 | call to UserAgent | user-provided value |
46-
| LDAPInjection.go:66:3:66:11 | untrusted | LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:66:3:66:11 | untrusted | LDAP query parameter depends on a $@. | LDAPInjection.go:57:15:57:29 | call to UserAgent | user-provided value |
47-
| LDAPInjection.go:68:3:68:51 | ...+... | LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:68:3:68:51 | ...+... | LDAP query parameter depends on a $@. | LDAPInjection.go:57:15:57:29 | call to UserAgent | user-provided value |
48-
| LDAPInjection.go:69:3:69:33 | slice literal | LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:69:3:69:33 | slice literal | LDAP query parameter depends on a $@. | LDAPInjection.go:57:15:57:29 | call to UserAgent | user-provided value |
49-
| LDAPInjection.go:73:3:73:11 | untrusted | LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:73:3:73:11 | untrusted | LDAP query parameter depends on a $@. | LDAPInjection.go:57:15:57:29 | call to UserAgent | user-provided value |
50-
| LDAPInjection.go:75:3:75:51 | ...+... | LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:75:3:75:51 | ...+... | LDAP query parameter depends on a $@. | LDAPInjection.go:57:15:57:29 | call to UserAgent | user-provided value |
51-
| LDAPInjection.go:76:3:76:33 | slice literal | LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:76:3:76:33 | slice literal | LDAP query parameter depends on a $@. | LDAPInjection.go:57:15:57:29 | call to UserAgent | user-provided value |
52-
| LDAPInjection.go:80:22:80:30 | untrusted | LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:80:22:80:30 | untrusted | LDAP query parameter depends on a $@. | LDAPInjection.go:57:15:57:29 | call to UserAgent | user-provided value |
53-
| LDAPInjection.go:81:25:81:33 | untrusted | LDAPInjection.go:57:15:57:29 | call to UserAgent : string | LDAPInjection.go:81:25:81:33 | untrusted | LDAP query parameter depends on a $@. | LDAPInjection.go:57:15:57:29 | call to UserAgent | user-provided value |
43+
| LDAPInjection.go:59:3:59:11 | untrusted | LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:59:3:59:11 | untrusted | LDAP query parameter depends on a $@. | LDAPInjection.go:57:15:57:29 | call to UserAgent | user-provided value |
44+
| LDAPInjection.go:61:3:61:51 | ...+... | LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:61:3:61:51 | ...+... | LDAP query parameter depends on a $@. | LDAPInjection.go:57:15:57:29 | call to UserAgent | user-provided value |
45+
| LDAPInjection.go:62:3:62:33 | slice literal | LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:62:3:62:33 | slice literal | LDAP query parameter depends on a $@. | LDAPInjection.go:57:15:57:29 | call to UserAgent | user-provided value |
46+
| LDAPInjection.go:66:3:66:11 | untrusted | LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:66:3:66:11 | untrusted | LDAP query parameter depends on a $@. | LDAPInjection.go:57:15:57:29 | call to UserAgent | user-provided value |
47+
| LDAPInjection.go:68:3:68:51 | ...+... | LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:68:3:68:51 | ...+... | LDAP query parameter depends on a $@. | LDAPInjection.go:57:15:57:29 | call to UserAgent | user-provided value |
48+
| LDAPInjection.go:69:3:69:33 | slice literal | LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:69:3:69:33 | slice literal | LDAP query parameter depends on a $@. | LDAPInjection.go:57:15:57:29 | call to UserAgent | user-provided value |
49+
| LDAPInjection.go:73:3:73:11 | untrusted | LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:73:3:73:11 | untrusted | LDAP query parameter depends on a $@. | LDAPInjection.go:57:15:57:29 | call to UserAgent | user-provided value |
50+
| LDAPInjection.go:75:3:75:51 | ...+... | LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:75:3:75:51 | ...+... | LDAP query parameter depends on a $@. | LDAPInjection.go:57:15:57:29 | call to UserAgent | user-provided value |
51+
| LDAPInjection.go:76:3:76:33 | slice literal | LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:76:3:76:33 | slice literal | LDAP query parameter depends on a $@. | LDAPInjection.go:57:15:57:29 | call to UserAgent | user-provided value |
52+
| LDAPInjection.go:80:22:80:30 | untrusted | LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:80:22:80:30 | untrusted | LDAP query parameter depends on a $@. | LDAPInjection.go:57:15:57:29 | call to UserAgent | user-provided value |
53+
| LDAPInjection.go:81:25:81:33 | untrusted | LDAPInjection.go:57:15:57:29 | call to UserAgent | LDAPInjection.go:81:25:81:33 | untrusted | LDAP query parameter depends on a $@. | LDAPInjection.go:57:15:57:29 | call to UserAgent | user-provided value |

0 commit comments

Comments
 (0)