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

Commit 75e3ee6

Browse files
committed
Add taint-tracking for container/list package
1 parent 4ecf9b0 commit 75e3ee6

File tree

3 files changed

+339
-0
lines changed

3 files changed

+339
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import semmle.go.frameworks.stdlib.CompressGzip
1313
import semmle.go.frameworks.stdlib.CompressLzw
1414
import semmle.go.frameworks.stdlib.CompressZlib
1515
import semmle.go.frameworks.stdlib.ContainerHeap
16+
import semmle.go.frameworks.stdlib.ContainerList
1617
import semmle.go.frameworks.stdlib.Mime
1718
import semmle.go.frameworks.stdlib.MimeMultipart
1819
import semmle.go.frameworks.stdlib.MimeQuotedprintable
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/**
2+
* Provides classes modeling security-relevant aspects of the `container/list` package.
3+
*/
4+
5+
import go
6+
7+
/** Provides models of commonly used functions in the `container/list` package. */
8+
module ContainerList {
9+
private class MethodModels extends TaintTracking::FunctionModel, Method {
10+
FunctionInput inp;
11+
FunctionOutput outp;
12+
13+
MethodModels() {
14+
// signature: func (*Element).Next() *Element
15+
this.hasQualifiedName("container/list", "Element", "Next") and
16+
(inp.isReceiver() and outp.isResult())
17+
or
18+
// signature: func (*Element).Prev() *Element
19+
this.hasQualifiedName("container/list", "Element", "Prev") and
20+
(inp.isReceiver() and outp.isResult())
21+
or
22+
// signature: func (*List).Back() *Element
23+
this.hasQualifiedName("container/list", "List", "Back") and
24+
(inp.isReceiver() and outp.isResult())
25+
or
26+
// signature: func (*List).Front() *Element
27+
this.hasQualifiedName("container/list", "List", "Front") and
28+
(inp.isReceiver() and outp.isResult())
29+
or
30+
// signature: func (*List).Init() *List
31+
this.hasQualifiedName("container/list", "List", "Init") and
32+
(inp.isReceiver() and outp.isResult())
33+
or
34+
// signature: func (*List).InsertAfter(v interface{}, mark *Element) *Element
35+
this.hasQualifiedName("container/list", "List", "InsertAfter") and
36+
(
37+
inp.isParameter(0) and
38+
(outp.isReceiver() or outp.isResult())
39+
)
40+
or
41+
// signature: func (*List).InsertBefore(v interface{}, mark *Element) *Element
42+
this.hasQualifiedName("container/list", "List", "InsertBefore") and
43+
(
44+
inp.isParameter(0) and
45+
(outp.isReceiver() or outp.isResult())
46+
)
47+
or
48+
// signature: func (*List).MoveAfter(e *Element, mark *Element)
49+
this.hasQualifiedName("container/list", "List", "MoveAfter") and
50+
(inp.isParameter(0) and outp.isReceiver())
51+
or
52+
// signature: func (*List).MoveBefore(e *Element, mark *Element)
53+
this.hasQualifiedName("container/list", "List", "MoveBefore") and
54+
(inp.isParameter(0) and outp.isReceiver())
55+
or
56+
// signature: func (*List).MoveToBack(e *Element)
57+
this.hasQualifiedName("container/list", "List", "MoveToBack") and
58+
(inp.isParameter(0) and outp.isReceiver())
59+
or
60+
// signature: func (*List).MoveToFront(e *Element)
61+
this.hasQualifiedName("container/list", "List", "MoveToFront") and
62+
(inp.isParameter(0) and outp.isReceiver())
63+
or
64+
// signature: func (*List).PushBack(v interface{}) *Element
65+
this.hasQualifiedName("container/list", "List", "PushBack") and
66+
(
67+
inp.isParameter(0) and
68+
(outp.isReceiver() or outp.isResult())
69+
)
70+
or
71+
// signature: func (*List).PushBackList(other *List)
72+
this.hasQualifiedName("container/list", "List", "PushBackList") and
73+
(inp.isParameter(0) and outp.isReceiver())
74+
or
75+
// signature: func (*List).PushFront(v interface{}) *Element
76+
this.hasQualifiedName("container/list", "List", "PushFront") and
77+
(
78+
inp.isParameter(0) and
79+
(outp.isReceiver() or outp.isResult())
80+
)
81+
or
82+
// signature: func (*List).PushFrontList(other *List)
83+
this.hasQualifiedName("container/list", "List", "PushFrontList") and
84+
(inp.isParameter(0) and outp.isReceiver())
85+
or
86+
// signature: func (*List).Remove(e *Element) interface{}
87+
this.hasQualifiedName("container/list", "List", "Remove") and
88+
(inp.isParameter(0) and outp.isResult())
89+
}
90+
91+
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
92+
input = inp and output = outp
93+
}
94+
}
95+
}

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

Lines changed: 243 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)