Skip to content

Commit 04e17ec

Browse files
authored
Merge pull request github#18565 from owen-mc/go/mad/parameter
Go: Fix "Parameter" in models-as-data
2 parents 168fe4a + 577d9eb commit 04e17ec

File tree

12 files changed

+23
-1
lines changed

12 files changed

+23
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Models-as-data models using "Parameter", "Parameter[n]" or "Parameter[n1..n2]" as the output now work correctly.

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,9 @@ module SourceSinkInterpretationInput implements
252252

253253
/** Gets the callable that this node corresponds to, if any. */
254254
DataFlowCallable asCallable() {
255-
result.asSummarizedCallable().asFunction() = this.asElement().asEntity()
255+
this.asElement().asEntity() = result.asSummarizedCallable().asFunction() or
256+
this.asElement().asEntity() = result.asCallable().asFunction() or
257+
this.asElement().asAstNode() = result.asCallable().asFuncLit()
256258
}
257259

258260
/** Gets the target of this call, if any. */

go/ql/test/library-tests/semmle/go/dataflow/ExternalTaintFlow/completetest.ext.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ extensions:
3737
data:
3838
- ["github.com/nonexistent/test", "", False, "SourceVariable", "", "", "", "qltest", "manual"]
3939
- ["github.com/nonexistent/test", "A", False, "Src1", "", "", "ReturnValue", "qltest", "manual"]
40+
- ["semmle.go.Packages", "", True, "srcParam", "", "", "Parameter[0]", "qltest", "manual"]
4041
- addsTo:
4142
pack: codeql/go-all
4243
extensible: sinkModel

go/ql/test/library-tests/semmle/go/dataflow/ExternalTaintFlow/sinks.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ invalidModelRow
4444
| test.go:199:23:199:26 | arg2 | qltest |
4545
| test.go:199:29:199:32 | arg3 | qltest |
4646
| test.go:202:22:202:25 | temp | qltest |
47+
| test.go:206:10:206:12 | src | qltest |

go/ql/test/library-tests/semmle/go/dataflow/ExternalTaintFlow/srcs.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ invalidModelRow
2222
| test.go:187:24:187:31 | call to Src1 | qltest |
2323
| test.go:191:24:191:31 | call to Src1 | qltest |
2424
| test.go:201:10:201:28 | selection of SourceVariable | qltest |
25+
| test.go:205:15:205:17 | definition of src | qltest |

go/ql/test/library-tests/semmle/go/dataflow/ExternalTaintFlow/srcs.ext.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ extensions:
1010
- ["github.com/nonexistent/test", "A", False, "SrcArg", "", "", "Argument[0]", "qltest-arg", "manual"]
1111
- ["github.com/nonexistent/test", "A", False, "Src3", "", "", "ReturnValue[0]", "qltest", "manual"]
1212
- ["github.com/nonexistent/test", "A", True, "Src3", "", "", "ReturnValue[1]", "qltest-w-subtypes", "manual"]
13+
- ["semmle.go.Packages", "", True, "srcParam", "", "", "Parameter[0]", "qltest", "manual"]

go/ql/test/library-tests/semmle/go/dataflow/ExternalTaintFlow/test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ func simpleflow() {
202202
test.SinkVariable = temp // $ hasTaintFlow="temp"
203203
}
204204

205+
func srcParam(src string, b test.B) {
206+
b.Sink1(src) // $ hasTaintFlow="src"
207+
}
208+
205209
type mapstringstringtype map[string]string
206210
type arraytype []interface{}
207211
type channeltype chan interface{}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ extensions:
3737
data:
3838
- ["github.com/nonexistent/test", "", False, "SourceVariable", "", "", "", "qltest", "manual"]
3939
- ["github.com/nonexistent/test", "A", False, "Src1", "", "", "ReturnValue", "qltest", "manual"]
40+
- ["semmle.go.Packages", "", True, "srcParam", "", "", "Parameter[0]", "qltest", "manual"]
4041
- addsTo:
4142
pack: codeql/go-all
4243
extensible: sinkModel

go/ql/test/library-tests/semmle/go/dataflow/ExternalValueFlow/sinks.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,4 @@ invalidModelRow
5050
| test.go:206:10:206:26 | call to min | qltest |
5151
| test.go:207:10:207:26 | call to min | qltest |
5252
| test.go:210:22:210:25 | temp | qltest |
53+
| test.go:214:10:214:12 | src | qltest |

go/ql/test/library-tests/semmle/go/dataflow/ExternalValueFlow/srcs.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ invalidModelRow
2222
| test.go:187:24:187:31 | call to Src1 | qltest |
2323
| test.go:191:24:191:31 | call to Src1 | qltest |
2424
| test.go:209:10:209:28 | selection of SourceVariable | qltest |
25+
| test.go:213:15:213:17 | definition of src | qltest |

0 commit comments

Comments
 (0)