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

Commit dedeb7b

Browse files
committed
Add taint-tracking for container/ring package
1 parent 75e3ee6 commit dedeb7b

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import semmle.go.frameworks.stdlib.CompressLzw
1414
import semmle.go.frameworks.stdlib.CompressZlib
1515
import semmle.go.frameworks.stdlib.ContainerHeap
1616
import semmle.go.frameworks.stdlib.ContainerList
17+
import semmle.go.frameworks.stdlib.ContainerRing
1718
import semmle.go.frameworks.stdlib.Mime
1819
import semmle.go.frameworks.stdlib.MimeMultipart
1920
import semmle.go.frameworks.stdlib.MimeQuotedprintable
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Provides classes modeling security-relevant aspects of the `container/ring` package.
3+
*/
4+
5+
import go
6+
7+
/** Provides models of commonly used functions in the `container/ring` package. */
8+
module ContainerRing {
9+
private class MethodModels extends TaintTracking::FunctionModel, Method {
10+
FunctionInput inp;
11+
FunctionOutput outp;
12+
13+
MethodModels() {
14+
// signature: func (*Ring).Link(s *Ring) *Ring
15+
this.hasQualifiedName("container/ring", "Ring", "Link") and
16+
(inp.isParameter(0) and outp.isResult())
17+
or
18+
// signature: func (*Ring).Move(n int) *Ring
19+
this.hasQualifiedName("container/ring", "Ring", "Move") and
20+
(inp.isReceiver() and outp.isResult())
21+
or
22+
// signature: func (*Ring).Next() *Ring
23+
this.hasQualifiedName("container/ring", "Ring", "Next") and
24+
(inp.isReceiver() and outp.isResult())
25+
or
26+
// signature: func (*Ring).Prev() *Ring
27+
this.hasQualifiedName("container/ring", "Ring", "Prev") and
28+
(inp.isReceiver() and outp.isResult())
29+
or
30+
// signature: func (*Ring).Unlink(n int) *Ring
31+
this.hasQualifiedName("container/ring", "Ring", "Unlink") and
32+
(inp.isReceiver() and outp.isResult())
33+
}
34+
35+
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
36+
input = inp and output = outp
37+
}
38+
}
39+
}

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

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