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

Commit 25e3f75

Browse files
committed
Add taint-tracking for mime/quotedprintable package.
1 parent 99b251d commit 25e3f75

File tree

3 files changed

+106
-0
lines changed

3 files changed

+106
-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.Mime
1616
import semmle.go.frameworks.stdlib.MimeMultipart
17+
import semmle.go.frameworks.stdlib.MimeQuotedprintable
1718
import semmle.go.frameworks.stdlib.Path
1819
import semmle.go.frameworks.stdlib.PathFilepath
1920

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* Provides classes modeling security-relevant aspects of the `mime/quotedprintable` package.
3+
*/
4+
5+
import go
6+
7+
/** Provides models of commonly used functions in the `mime/quotedprintable` package. */
8+
module MimeQuotedprintable {
9+
private class FunctionModels extends TaintTracking::FunctionModel {
10+
FunctionInput inp;
11+
FunctionOutput outp;
12+
13+
FunctionModels() {
14+
// signature: func NewReader(r io.Reader) *Reader
15+
hasQualifiedName("mime/quotedprintable", "NewReader") and
16+
(inp.isParameter(0) and outp.isResult())
17+
or
18+
// signature: func NewWriter(w io.Writer) *Writer
19+
hasQualifiedName("mime/quotedprintable", "NewWriter") and
20+
(inp.isResult() and outp.isParameter(0))
21+
}
22+
23+
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
24+
input = inp and output = outp
25+
}
26+
}
27+
28+
private class MethodModels extends TaintTracking::FunctionModel, Method {
29+
FunctionInput inp;
30+
FunctionOutput outp;
31+
32+
MethodModels() {
33+
// signature: func (*Reader).Read(p []byte) (n int, err error)
34+
this.hasQualifiedName("mime/quotedprintable", "Reader", "Read") and
35+
(inp.isReceiver() and outp.isParameter(0))
36+
or
37+
// signature: func (*Writer).Write(p []byte) (n int, err error)
38+
this.hasQualifiedName("mime/quotedprintable", "Writer", "Write") and
39+
(inp.isParameter(0) and outp.isReceiver())
40+
}
41+
42+
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
43+
input = inp and output = outp
44+
}
45+
}
46+
}

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

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