Skip to content

Commit 1fb5973

Browse files
author
Dave Bartolomeo
authored
Merge pull request github#18434 from github/dbartol/revert-go
Revert two Go PRs
2 parents f12ff2d + 1323b3f commit 1fb5973

File tree

31 files changed

+23
-440
lines changed

31 files changed

+23
-440
lines changed

go/ql/lib/change-notes/2024-12-06-improve-flow-out-of-variadic-parameter.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

go/ql/lib/change-notes/2024-12-12-variadic-parameter-sources.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ predicate containerReadStep(Node node1, Node node2, Content c) {
6666
(
6767
node2.(Read).readsElement(node1, _)
6868
or
69-
exists(ImplicitVarargsSlice ivs |
70-
node1.(PostUpdateNode).getPreUpdateNode() = ivs and
71-
node2.(PostUpdateNode).getPreUpdateNode() = ivs.getCallNode().getAnImplicitVarargsArgument()
72-
)
73-
or
7469
node2.(RangeElementNode).getBase() = node1
7570
or
7671
// To model data flow from array elements of the base of a `SliceNode` to

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -845,9 +845,6 @@ module Public {
845845
or
846846
preupd = getAWrittenNode()
847847
or
848-
preupd instanceof ImplicitVarargsSlice and
849-
mutableType(preupd.(ImplicitVarargsSlice).getType().(SliceType).getElementType())
850-
or
851848
preupd = any(ArgumentNode arg).getACorrespondingSyntacticArgument() and
852849
mutableType(preupd.getType())
853850
) and

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -458,13 +458,3 @@ class ContentApprox = Unit;
458458
/** Gets an approximated value for content `c`. */
459459
pragma[inline]
460460
ContentApprox getContentApprox(Content c) { any() }
461-
462-
/**
463-
* Holds if the the content `c` is a container.
464-
*/
465-
predicate containerContent(ContentSet c) {
466-
c instanceof ArrayContent or
467-
c instanceof CollectionContent or
468-
c instanceof MapKeyContent or
469-
c instanceof MapValueContent
470-
}

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

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,11 @@ predicate localExprTaint(Expr src, Expr sink) {
2727
* Holds if taint can flow in one local step from `src` to `sink`.
2828
*/
2929
predicate localTaintStep(DataFlow::Node src, DataFlow::Node sink) {
30-
DataFlow::localFlowStep(src, sink)
31-
or
32-
localAdditionalTaintStep(src, sink, _)
33-
or
30+
DataFlow::localFlowStep(src, sink) or
31+
localAdditionalTaintStep(src, sink, _) or
3432
// Simple flow through library code is included in the exposed local
3533
// step relation, even though flow is technically inter-procedural
3634
FlowSummaryImpl::Private::Steps::summaryThroughStepTaint(src, sink, _)
37-
or
38-
// Treat container flow as taint for the local taint flow relation
39-
exists(DataFlow::Content c | DataFlowPrivate::containerContent(c) |
40-
DataFlowPrivate::readStep(src, c, sink) or
41-
DataFlowPrivate::storeStep(src, c, sink) or
42-
FlowSummaryImpl::Private::Steps::summaryGetterStep(src, c, sink, _) or
43-
FlowSummaryImpl::Private::Steps::summarySetterStep(src, c, sink, _)
44-
)
4535
}
4636

4737
private Type getElementType(Type containerType) {
@@ -98,18 +88,12 @@ class AdditionalTaintStep extends Unit {
9888
*/
9989
predicate localAdditionalTaintStep(DataFlow::Node pred, DataFlow::Node succ, string model) {
10090
(
101-
referenceStep(pred, succ)
102-
or
103-
elementWriteStep(pred, succ)
104-
or
105-
fieldReadStep(pred, succ)
106-
or
107-
elementStep(pred, succ)
108-
or
109-
tupleStep(pred, succ)
110-
or
111-
stringConcatStep(pred, succ)
112-
or
91+
referenceStep(pred, succ) or
92+
elementWriteStep(pred, succ) or
93+
fieldReadStep(pred, succ) or
94+
elementStep(pred, succ) or
95+
tupleStep(pred, succ) or
96+
stringConcatStep(pred, succ) or
11397
sliceStep(pred, succ)
11498
) and
11599
model = ""
@@ -179,12 +163,6 @@ predicate elementStep(DataFlow::Node pred, DataFlow::Node succ) {
179163
// only step into the value, not the index
180164
succ.asInstruction() = IR::extractTupleElement(nextEntry, 1)
181165
)
182-
or
183-
exists(DataFlow::ImplicitVarargsSlice ivs |
184-
pred.(DataFlow::PostUpdateNode).getPreUpdateNode() = ivs and
185-
succ.(DataFlow::PostUpdateNode).getPreUpdateNode() =
186-
ivs.getCallNode().getAnImplicitVarargsArgument()
187-
)
188166
}
189167

190168
/** Holds if taint flows from `pred` to `succ` via an extract tuple operation. */

go/ql/test/library-tests/semmle/go/dataflow/ExternalValueFlow/completetest.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import semmle.go.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
99
import utils.test.InlineFlowTest
1010

1111
module Config implements DataFlow::ConfigSig {
12-
predicate isSource(DataFlow::Node source) { sourceNode(source, "qltest") }
12+
predicate isSource(DataFlow::Node src) { sourceNode(src, "qltest") }
1313

14-
predicate isSink(DataFlow::Node sink) { sinkNode(sink, "qltest") }
14+
predicate isSink(DataFlow::Node src) { sinkNode(src, "qltest") }
1515
}
1616

1717
import ValueFlowTest<Config>

go/ql/test/library-tests/semmle/go/dataflow/FlowSteps/LocalTaintStep.expected

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,24 @@
55
| main.go:38:19:38:19 | 3 | main.go:38:7:38:20 | slice literal |
66
| main.go:39:8:39:25 | []type{args} | main.go:39:8:39:25 | call to append |
77
| main.go:39:15:39:15 | s | main.go:39:8:39:25 | call to append |
8-
| main.go:39:18:39:18 | 4 | main.go:39:8:39:25 | []type{args} |
9-
| main.go:39:21:39:21 | 5 | main.go:39:8:39:25 | []type{args} |
10-
| main.go:39:24:39:24 | 6 | main.go:39:8:39:25 | []type{args} |
118
| main.go:40:15:40:15 | s | main.go:40:8:40:23 | call to append |
129
| main.go:40:18:40:19 | s1 | main.go:40:8:40:23 | call to append |
1310
| main.go:42:10:42:11 | s4 | main.go:38:2:38:2 | definition of s |
1411
| main.go:47:20:47:21 | next key-value pair in range | main.go:47:2:50:2 | range statement[0] |
1512
| main.go:47:20:47:21 | next key-value pair in range | main.go:47:2:50:2 | range statement[1] |
1613
| main.go:47:20:47:21 | xs | main.go:47:2:50:2 | range statement[1] |
17-
| main.go:56:8:56:11 | true | main.go:56:2:56:3 | ch |
18-
| main.go:57:4:57:5 | ch | main.go:57:2:57:5 | <-... |
1914
| strings.go:9:24:9:24 | s | strings.go:9:8:9:38 | call to Replace |
2015
| strings.go:9:32:9:34 | "_" | strings.go:9:8:9:38 | call to Replace |
2116
| strings.go:10:27:10:27 | s | strings.go:10:8:10:42 | call to ReplaceAll |
2217
| strings.go:10:35:10:41 | "&amp;" | strings.go:10:8:10:42 | call to ReplaceAll |
23-
| strings.go:11:9:11:26 | []type{args} | strings.go:11:9:11:26 | call to Sprint |
2418
| strings.go:11:9:11:26 | call to Sprint | strings.go:11:9:11:50 | ...+... |
2519
| strings.go:11:9:11:50 | ...+... | strings.go:11:9:11:69 | ...+... |
26-
| strings.go:11:20:11:21 | s2 | strings.go:11:9:11:26 | []type{args} |
2720
| strings.go:11:20:11:21 | s2 | strings.go:11:9:11:26 | call to Sprint |
28-
| strings.go:11:24:11:25 | s3 | strings.go:11:9:11:26 | []type{args} |
2921
| strings.go:11:24:11:25 | s3 | strings.go:11:9:11:26 | call to Sprint |
30-
| strings.go:11:30:11:50 | []type{args} | strings.go:11:30:11:50 | call to Sprintf |
3122
| strings.go:11:30:11:50 | call to Sprintf | strings.go:11:9:11:50 | ...+... |
3223
| strings.go:11:42:11:45 | "%q" | strings.go:11:30:11:50 | call to Sprintf |
33-
| strings.go:11:48:11:49 | s2 | strings.go:11:30:11:50 | []type{args} |
3424
| strings.go:11:48:11:49 | s2 | strings.go:11:30:11:50 | call to Sprintf |
35-
| strings.go:11:54:11:69 | []type{args} | strings.go:11:54:11:69 | call to Sprintln |
3625
| strings.go:11:54:11:69 | call to Sprintln | strings.go:11:9:11:69 | ...+... |
37-
| strings.go:11:67:11:68 | s3 | strings.go:11:54:11:69 | []type{args} |
3826
| strings.go:11:67:11:68 | s3 | strings.go:11:54:11:69 | call to Sprintln |
3927
| url.go:12:14:12:48 | call to PathUnescape | url.go:12:3:12:48 | ... = ...[0] |
4028
| url.go:12:14:12:48 | call to PathUnescape | url.go:12:3:12:48 | ... = ...[1] |
@@ -51,25 +39,17 @@
5139
| url.go:27:9:27:30 | call to ParseRequestURI | url.go:27:2:27:30 | ... = ...[1] |
5240
| url.go:27:29:27:29 | s | url.go:27:2:27:30 | ... = ...[0] |
5341
| url.go:28:14:28:14 | u | url.go:28:14:28:28 | call to EscapedPath |
54-
| url.go:28:14:28:28 | call to EscapedPath | url.go:28:2:28:29 | []type{args} |
5542
| url.go:29:14:29:14 | u | url.go:29:14:29:25 | call to Hostname |
56-
| url.go:29:14:29:25 | call to Hostname | url.go:29:2:29:26 | []type{args} |
5743
| url.go:30:11:30:11 | u | url.go:30:2:30:27 | ... := ...[0] |
5844
| url.go:30:11:30:27 | call to MarshalBinary | url.go:30:2:30:27 | ... := ...[0] |
5945
| url.go:30:11:30:27 | call to MarshalBinary | url.go:30:2:30:27 | ... := ...[1] |
60-
| url.go:31:2:31:16 | []type{args} | url.go:30:2:30:3 | definition of bs |
61-
| url.go:31:14:31:15 | bs | url.go:31:2:31:16 | []type{args} |
6246
| url.go:32:9:32:9 | u | url.go:32:2:32:23 | ... = ...[0] |
6347
| url.go:32:9:32:23 | call to Parse | url.go:32:2:32:23 | ... = ...[0] |
6448
| url.go:32:9:32:23 | call to Parse | url.go:32:2:32:23 | ... = ...[1] |
6549
| url.go:32:17:32:22 | "/foo" | url.go:32:2:32:23 | ... = ...[0] |
6650
| url.go:33:14:33:14 | u | url.go:33:14:33:21 | call to Port |
67-
| url.go:33:14:33:21 | call to Port | url.go:33:2:33:22 | []type{args} |
68-
| url.go:34:2:34:23 | []type{args} | url.go:34:14:34:22 | call to Query |
6951
| url.go:34:14:34:14 | u | url.go:34:14:34:22 | call to Query |
70-
| url.go:34:14:34:22 | call to Query | url.go:34:2:34:23 | []type{args} |
7152
| url.go:35:14:35:14 | u | url.go:35:14:35:27 | call to RequestURI |
72-
| url.go:35:14:35:27 | call to RequestURI | url.go:35:2:35:28 | []type{args} |
7353
| url.go:36:6:36:6 | u | url.go:36:6:36:26 | call to ResolveReference |
7454
| url.go:36:25:36:25 | u | url.go:36:6:36:26 | call to ResolveReference |
7555
| url.go:41:17:41:20 | "me" | url.go:41:8:41:21 | call to User |
@@ -78,35 +58,27 @@
7858
| url.go:43:11:43:12 | ui | url.go:43:2:43:23 | ... := ...[0] |
7959
| url.go:43:11:43:23 | call to Password | url.go:43:2:43:23 | ... := ...[0] |
8060
| url.go:43:11:43:23 | call to Password | url.go:43:2:43:23 | ... := ...[1] |
81-
| url.go:44:14:44:15 | pw | url.go:44:2:44:16 | []type{args} |
8261
| url.go:45:14:45:15 | ui | url.go:45:14:45:26 | call to Username |
83-
| url.go:45:14:45:26 | call to Username | url.go:45:2:45:27 | []type{args} |
8462
| url.go:50:10:50:26 | call to ParseQuery | url.go:50:2:50:26 | ... := ...[0] |
8563
| url.go:50:10:50:26 | call to ParseQuery | url.go:50:2:50:26 | ... := ...[1] |
8664
| url.go:50:25:50:25 | q | url.go:50:2:50:26 | ... := ...[0] |
8765
| url.go:51:14:51:14 | v | url.go:51:14:51:23 | call to Encode |
88-
| url.go:51:14:51:23 | call to Encode | url.go:51:2:51:24 | []type{args} |
8966
| url.go:52:14:52:14 | v | url.go:52:14:52:26 | call to Get |
90-
| url.go:52:14:52:26 | call to Get | url.go:52:2:52:27 | []type{args} |
9167
| url.go:57:16:57:39 | call to JoinPath | url.go:57:2:57:39 | ... := ...[0] |
9268
| url.go:57:16:57:39 | call to JoinPath | url.go:57:2:57:39 | ... := ...[1] |
9369
| url.go:57:29:57:29 | q | url.go:57:2:57:39 | ... := ...[0] |
9470
| url.go:57:32:57:38 | "clean" | url.go:57:2:57:39 | ... := ...[0] |
95-
| url.go:57:32:57:38 | "clean" | url.go:57:16:57:39 | []type{args} |
9671
| url.go:58:16:58:45 | call to JoinPath | url.go:58:2:58:45 | ... := ...[0] |
9772
| url.go:58:16:58:45 | call to JoinPath | url.go:58:2:58:45 | ... := ...[1] |
9873
| url.go:58:29:58:35 | "clean" | url.go:58:2:58:45 | ... := ...[0] |
9974
| url.go:58:38:58:44 | joined1 | url.go:58:2:58:45 | ... := ...[0] |
100-
| url.go:58:38:58:44 | joined1 | url.go:58:16:58:45 | []type{args} |
10175
| url.go:59:14:59:31 | call to Parse | url.go:59:2:59:31 | ... := ...[0] |
10276
| url.go:59:14:59:31 | call to Parse | url.go:59:2:59:31 | ... := ...[1] |
10377
| url.go:59:24:59:30 | joined2 | url.go:59:2:59:31 | ... := ...[0] |
10478
| url.go:60:15:60:19 | asUrl | url.go:60:15:60:37 | call to JoinPath |
105-
| url.go:60:30:60:36 | "clean" | url.go:60:15:60:37 | []type{args} |
10679
| url.go:60:30:60:36 | "clean" | url.go:60:15:60:37 | call to JoinPath |
10780
| url.go:65:17:65:48 | call to Parse | url.go:65:2:65:48 | ... := ...[0] |
10881
| url.go:65:17:65:48 | call to Parse | url.go:65:2:65:48 | ... := ...[1] |
10982
| url.go:65:27:65:47 | "http://harmless.org" | url.go:65:2:65:48 | ... := ...[0] |
11083
| url.go:66:9:66:16 | cleanUrl | url.go:66:9:66:28 | call to JoinPath |
111-
| url.go:66:27:66:27 | q | url.go:66:9:66:28 | []type{args} |
11284
| url.go:66:27:66:27 | q | url.go:66:9:66:28 | call to JoinPath |

go/ql/test/library-tests/semmle/go/dataflow/VarArgs/main.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ func source() string {
44
return "untrusted data"
55
}
66

7-
func sink(any) {
7+
func sink(string) {
88
}
99

1010
type A struct {
@@ -19,10 +19,6 @@ func functionWithVarArgsParameter(s ...string) string {
1919
return s[1]
2020
}
2121

22-
func functionWithVarArgsOutParameter(in string, out ...*string) {
23-
*out[0] = in
24-
}
25-
2622
func functionWithSliceOfStructsParameter(s []A) string {
2723
return s[1].f
2824
}
@@ -42,12 +38,6 @@ func main() {
4238
sink(functionWithVarArgsParameter(sSlice...)) // $ hasValueFlow="call to functionWithVarArgsParameter"
4339
sink(functionWithVarArgsParameter(s0, s1)) // $ hasValueFlow="call to functionWithVarArgsParameter"
4440

45-
var out1 *string
46-
var out2 *string
47-
functionWithVarArgsOutParameter(source(), out1, out2)
48-
sink(out1) // $ MISSING: hasValueFlow="out1"
49-
sink(out2) // $ MISSING: hasValueFlow="out2"
50-
5141
sliceOfStructs := []A{{f: source()}}
5242
sink(sliceOfStructs[0].f) // $ hasValueFlow="selection of f"
5343

go/ql/test/library-tests/semmle/go/dataflow/VarArgsWithExternalFlow/Flows.expected

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)