Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 4ecf9b0

Browse files
committed
Add taint-tracking for container/heap package
1 parent 6770c74 commit 4ecf9b0

File tree

3 files changed

+116
-0
lines changed

3 files changed

+116
-0
lines changed

ql/src/semmle/go/frameworks/Stdlib.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import semmle.go.frameworks.stdlib.CompressFlate
1212
import semmle.go.frameworks.stdlib.CompressGzip
1313
import semmle.go.frameworks.stdlib.CompressLzw
1414
import semmle.go.frameworks.stdlib.CompressZlib
15+
import semmle.go.frameworks.stdlib.ContainerHeap
1516
import semmle.go.frameworks.stdlib.Mime
1617
import semmle.go.frameworks.stdlib.MimeMultipart
1718
import semmle.go.frameworks.stdlib.MimeQuotedprintable
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* Provides classes modeling security-relevant aspects of the `container/heap` package.
3+
*/
4+
5+
import go
6+
7+
/** Provides models of commonly used functions in the `container/heap` package. */
8+
module ContainerHeap {
9+
private class FunctionModels extends TaintTracking::FunctionModel {
10+
FunctionInput inp;
11+
FunctionOutput outp;
12+
13+
FunctionModels() {
14+
// signature: func Pop(h Interface) interface{}
15+
hasQualifiedName("container/heap", "Pop") and
16+
(inp.isParameter(0) and outp.isResult())
17+
or
18+
// signature: func Push(h Interface, x interface{})
19+
hasQualifiedName("container/heap", "Push") and
20+
(inp.isParameter(1) and outp.isParameter(0))
21+
or
22+
// signature: func Remove(h Interface, i int) interface{}
23+
hasQualifiedName("container/heap", "Remove") and
24+
(inp.isParameter(0) and outp.isResult())
25+
}
26+
27+
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
28+
input = inp and output = outp
29+
}
30+
}
31+
32+
private class MethodModels extends TaintTracking::FunctionModel, Method {
33+
FunctionInput inp;
34+
FunctionOutput outp;
35+
36+
MethodModels() {
37+
// signature: func (Interface).Pop() interface{}
38+
this.implements("container/heap", "Interface", "Pop") and
39+
(inp.isReceiver() and outp.isResult())
40+
or
41+
// signature: func (Interface).Push(x interface{})
42+
this.implements("container/heap", "Interface", "Push") and
43+
(inp.isParameter(0) and outp.isReceiver())
44+
}
45+
46+
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
47+
input = inp and output = outp
48+
}
49+
}
50+
}

ql/test/library-tests/semmle/go/frameworks/StdlibTaintFlow/ContainerHeap.go

Lines changed: 65 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)