Skip to content

Commit 1c66564

Browse files
committed
address review comments
1 parent 8f41ff3 commit 1c66564

File tree

6 files changed

+46
-41
lines changed

6 files changed

+46
-41
lines changed

go/ql/lib/semmle/go/StringOps.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ module StringOps {
331331
formatDirective = this.getComponent(n) and
332332
formatDirective.charAt(0) = "%" and
333333
formatDirective.charAt(1) != "%" and
334-
result = this.getImplicitVarargsArgument((n / 2))
334+
result = this.getImplicitVarargsArgument(n / 2)
335335
}
336336
}
337337
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ predicate containerStoreStep(Node node1, Node node2, Content c) {
2323
(
2424
exists(Write w | w.writesElement(node2, _, node1))
2525
or
26-
node1 = node2.(ImplicitVarargsSlice).getCallNode().getImplicitVarargsArgument(_)
26+
node1 = node2.(ImplicitVarargsSlice).getCallNode().getAnImplicitVarargsArgument()
2727
)
2828
)
2929
or

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,12 @@ module Public {
598598
)
599599
}
600600

601+
/**
602+
* Gets an argument without an ellipsis after it which is passed to
603+
* the varargs parameter of the target of this call (if there is one).
604+
*/
605+
Node getAnImplicitVarargsArgument() { result = this.getImplicitVarargsArgument(_) }
606+
601607
/** Gets a function passed as the `i`th argument of this call. */
602608
FunctionNode getCallback(int i) { result.getASuccessor*() = this.getArgument(i) }
603609

@@ -772,7 +778,7 @@ module Public {
772778
(
773779
preupd instanceof ArgumentNode and not preupd instanceof ImplicitVarargsSlice
774780
or
775-
preupd = any(CallNode c).getImplicitVarargsArgument(_)
781+
preupd = any(CallNode c).getAnImplicitVarargsArgument()
776782
) and
777783
mutableType(preupd.getType())
778784
) and

go/ql/lib/semmle/go/frameworks/Revel.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ module Revel {
124124
or
125125
methodName = "RenderText" and
126126
contentType = "text/plain" and
127-
this = methodCall.getSyntacticArgument(_)
127+
this = methodCall.getASyntacticArgument()
128128
)
129129
}
130130

go/ql/lib/semmle/go/frameworks/stdlib/NetHttp.qll

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -134,44 +134,43 @@ module NetHttp {
134134
result = call.getReceiver()
135135
}
136136

137-
private class ResponseBody extends Http::ResponseBody::Range, DataFlow::Node {
137+
private class ResponseBody extends Http::ResponseBody::Range {
138138
DataFlow::Node responseWriter;
139139

140140
ResponseBody() {
141-
this = any(DataFlow::CallNode call).getASyntacticArgument() and
142-
(
143-
exists(DataFlow::CallNode call |
144-
// A direct call to ResponseWriter.Write, conveying taint from the argument to the receiver
145-
call.getTarget().(Method).implements("net/http", "ResponseWriter", "Write") and
146-
this = call.getArgument(0) and
147-
responseWriter = call.(DataFlow::MethodCallNode).getReceiver()
148-
)
149-
or
150-
exists(TaintTracking::FunctionModel model |
151-
// A modeled function conveying taint from some input to the response writer,
152-
// e.g. `io.Copy(responseWriter, someTaintedReader)`
153-
model.taintStep(this, responseWriter) and
154-
responseWriter.getType().implements("net/http", "ResponseWriter")
155-
)
156-
or
157-
exists(
158-
SummarizedCallable callable, DataFlow::CallNode call, SummaryComponentStack input,
159-
SummaryComponentStack output
160-
|
161-
callable = call.getACalleeIncludingExternals() and
162-
callable.propagatesFlow(input, output, _)
163-
|
164-
// A modeled function conveying taint from some input to the response writer,
165-
// e.g. `io.Copy(responseWriter, someTaintedReader)`
166-
// NB. SummarizedCallables do not implement a direct call-site-crossing flow step; instead
167-
// they are implemented by a function body with internal dataflow nodes, so we mimic the
168-
// one-step style for the particular case of taint propagation direct from an argument or receiver
169-
// to another argument, receiver or return value, matching the behavior for a `TaintTracking::FunctionModel`.
170-
this = getSummaryInputOrOutputNode(call, input) and
171-
responseWriter.(DataFlow::PostUpdateNode).getPreUpdateNode() =
172-
getSummaryInputOrOutputNode(call, output) and
173-
responseWriter.getType().implements("net/http", "ResponseWriter")
174-
)
141+
exists(DataFlow::CallNode call |
142+
// A direct call to ResponseWriter.Write, conveying taint from the argument to the receiver
143+
call.getTarget().(Method).implements("net/http", "ResponseWriter", "Write") and
144+
this = call.getArgument(0) and
145+
responseWriter = call.(DataFlow::MethodCallNode).getReceiver()
146+
)
147+
or
148+
exists(TaintTracking::FunctionModel model |
149+
// A modeled function conveying taint from some input to the response writer,
150+
// e.g. `io.Copy(responseWriter, someTaintedReader)`
151+
this = model.getACall().getASyntacticArgument() and
152+
model.taintStep(this, responseWriter) and
153+
responseWriter.getType().implements("net/http", "ResponseWriter")
154+
)
155+
or
156+
exists(
157+
SummarizedCallable callable, DataFlow::CallNode call, SummaryComponentStack input,
158+
SummaryComponentStack output
159+
|
160+
this = call.getASyntacticArgument() and
161+
callable = call.getACalleeIncludingExternals() and
162+
callable.propagatesFlow(input, output, _)
163+
|
164+
// A modeled function conveying taint from some input to the response writer,
165+
// e.g. `io.Copy(responseWriter, someTaintedReader)`
166+
// NB. SummarizedCallables do not implement a direct call-site-crossing flow step; instead
167+
// they are implemented by a function body with internal dataflow nodes, so we mimic the
168+
// one-step style for the particular case of taint propagation direct from an argument or receiver
169+
// to another argument, receiver or return value, matching the behavior for a `TaintTracking::FunctionModel`.
170+
this = getSummaryInputOrOutputNode(call, input) and
171+
responseWriter.(DataFlow::PostUpdateNode).getPreUpdateNode() =
172+
getSummaryInputOrOutputNode(call, output) and
173+
responseWriter.getType().implements("net/http", "ResponseWriter")
175174
)
176175
}
177176

go/ql/src/experimental/frameworks/Fiber.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ private module Fiber {
270270
or
271271
// signature: func (*Ctx) Send(bodies ...interface{})
272272
methodName = "Send" and
273-
bodyNode = bodySetterCall.getSyntacticArgument(_)
273+
bodyNode = bodySetterCall.getASyntacticArgument()
274274
or
275275
// signature: func (*Ctx) SendBytes(body []byte)
276276
methodName = "SendBytes" and
@@ -286,7 +286,7 @@ private module Fiber {
286286
or
287287
// signature: func (*Ctx) Write(bodies ...interface{})
288288
methodName = "Write" and
289-
bodyNode = bodySetterCall.getSyntacticArgument(_)
289+
bodyNode = bodySetterCall.getASyntacticArgument()
290290
)
291291
)
292292
)

0 commit comments

Comments
 (0)