Skip to content

Commit f6f22c0

Browse files
authored
Merge pull request github#12783 from smowton/smowton/feature/golang-hide-summary-nodes
Go: hide summary nodes from path explanations
2 parents 227aee8 + 939a025 commit f6f22c0

File tree

4 files changed

+53
-1
lines changed

4 files changed

+53
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ Node getArgument(CallNode c, int i) {
352352
}
353353

354354
/** Holds if `n` should be hidden from path explanations. */
355-
predicate nodeIsHidden(Node n) { none() }
355+
predicate nodeIsHidden(Node n) { n instanceof SummaryNode or n instanceof SummarizedParameterNode }
356356

357357
class LambdaCallKind = Unit;
358358

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
edges
2+
| test.go:14:8:14:15 | call to source | test.go:15:34:15:35 | fi |
3+
| test.go:15:2:15:44 | ... := ...[0] | test.go:16:7:16:12 | header |
4+
| test.go:15:34:15:35 | fi | test.go:15:2:15:44 | ... := ...[0] |
5+
nodes
6+
| test.go:14:8:14:15 | call to source | semmle.label | call to source |
7+
| test.go:15:2:15:44 | ... := ...[0] | semmle.label | ... := ...[0] |
8+
| test.go:15:34:15:35 | fi | semmle.label | fi |
9+
| test.go:16:7:16:12 | header | semmle.label | header |
10+
subpaths
11+
#select
12+
| test.go:14:8:14:15 | call to source | test.go:14:8:14:15 | call to source | test.go:16:7:16:12 | header | Path |
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package test
2+
3+
import (
4+
"archive/tar"
5+
"os"
6+
)
7+
8+
func source() interface{} { return nil }
9+
10+
func sink(x interface{}) {}
11+
12+
func test() {
13+
14+
fi := source().(os.FileInfo)
15+
header, _ := tar.FileInfoHeader(fi, "link")
16+
sink(header)
17+
18+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* @kind path-problem
3+
*/
4+
5+
import go
6+
import DataFlow::PathGraph
7+
8+
class Config extends TaintTracking::Configuration {
9+
Config() { this = "config" }
10+
11+
override predicate isSource(DataFlow::Node n) {
12+
n = any(DataFlow::CallNode call | call.getTarget().getName() = "source").getResult()
13+
}
14+
15+
override predicate isSink(DataFlow::Node n) {
16+
n = any(DataFlow::CallNode call | call.getTarget().getName() = "sink").getAnArgument()
17+
}
18+
}
19+
20+
from DataFlow::PathNode source, DataFlow::PathNode sink, Config c
21+
where c.hasFlowPath(source, sink)
22+
select source, source, sink, "Path"

0 commit comments

Comments
 (0)