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

Commit df55bb4

Browse files
committed
Add taint-tracking for encoding/binary
1 parent 20b4826 commit df55bb4

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import semmle.go.frameworks.stdlib.EncodingAscii85
2020
import semmle.go.frameworks.stdlib.EncodingAsn1
2121
import semmle.go.frameworks.stdlib.EncodingBase32
2222
import semmle.go.frameworks.stdlib.EncodingBase64
23+
import semmle.go.frameworks.stdlib.EncodingBinary
2324
import semmle.go.frameworks.stdlib.Path
2425
import semmle.go.frameworks.stdlib.PathFilepath
2526
import semmle.go.frameworks.stdlib.Reflect
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Provides classes modeling security-relevant aspects of the `encoding/binary` package.
3+
*/
4+
5+
import go
6+
7+
/** Provides models of commonly used functions in the `encoding/binary` package. */
8+
module EncodingBinary {
9+
private class FunctionModels extends TaintTracking::FunctionModel {
10+
FunctionInput inp;
11+
FunctionOutput outp;
12+
13+
FunctionModels() {
14+
// signature: func Read(r io.Reader, order ByteOrder, data interface{}) error
15+
hasQualifiedName("encoding/binary", "Read") and
16+
(inp.isParameter(0) and outp.isParameter(2))
17+
or
18+
// signature: func Write(w io.Writer, order ByteOrder, data interface{}) error
19+
hasQualifiedName("encoding/binary", "Write") and
20+
(inp.isParameter(2) and outp.isParameter(0))
21+
}
22+
23+
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
24+
input = inp and output = outp
25+
}
26+
}
27+
}

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

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