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

Commit 7e5077c

Browse files
committed
Add compress/flate taint tracking
1 parent 6e2af3e commit 7e5077c

File tree

3 files changed

+154
-0
lines changed

3 files changed

+154
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import semmle.go.frameworks.stdlib.ArchiveZip
88
import semmle.go.frameworks.stdlib.Bufio
99
import semmle.go.frameworks.stdlib.Bytes
1010
import semmle.go.frameworks.stdlib.CompressBzip2
11+
import semmle.go.frameworks.stdlib.CompressFlate
1112

1213
/** A `String()` method. */
1314
class StringMethod extends TaintTracking::FunctionModel, Method {
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* Provides classes modeling security-relevant aspects of the `compress/flate` package.
3+
*/
4+
5+
import go
6+
7+
/** Provides models of commonly used functions in the `compress/flate` package. */
8+
module CompressFlate {
9+
private class FunctionModels extends TaintTracking::FunctionModel {
10+
FunctionInput inp;
11+
FunctionOutput outp;
12+
13+
FunctionModels() {
14+
// signature: func NewReader(r io.Reader) io.ReadCloser
15+
hasQualifiedName("compress/flate", "NewReader") and
16+
(inp.isParameter(0) and outp.isResult())
17+
or
18+
// signature: func NewReaderDict(r io.Reader, dict []byte) io.ReadCloser
19+
hasQualifiedName("compress/flate", "NewReaderDict") and
20+
(inp.isParameter(0) and outp.isResult())
21+
or
22+
// signature: func NewWriter(w io.Writer, level int) (*Writer, error)
23+
hasQualifiedName("compress/flate", "NewWriter") and
24+
(inp.isResult(0) and outp.isParameter(0))
25+
or
26+
// signature: func NewWriterDict(w io.Writer, level int, dict []byte) (*Writer, error)
27+
hasQualifiedName("compress/flate", "NewWriterDict") and
28+
(inp.isResult(0) and outp.isParameter(0))
29+
}
30+
31+
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
32+
input = inp and output = outp
33+
}
34+
}
35+
36+
private class MethodModels extends TaintTracking::FunctionModel, Method {
37+
FunctionInput inp;
38+
FunctionOutput outp;
39+
40+
MethodModels() {
41+
// signature: func (*Writer).Reset(dst io.Writer)
42+
this.hasQualifiedName("compress/flate", "Writer", "Reset") and
43+
(inp.isReceiver() and outp.isParameter(0))
44+
or
45+
// signature: func (*Writer).Write(data []byte) (n int, err error)
46+
this.hasQualifiedName("compress/flate", "Writer", "Write") and
47+
(inp.isParameter(0) and outp.isReceiver())
48+
or
49+
// signature: func (Resetter).Reset(r io.Reader, dict []byte) error
50+
this.implements("compress/flate", "Resetter", "Reset") and
51+
(inp.isParameter(0) and outp.isReceiver())
52+
}
53+
54+
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
55+
input = inp and output = outp
56+
}
57+
}
58+
}

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

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