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

Commit 4df363d

Browse files
committed
Add taint-tracking for text/scanner package.
1 parent 25e4245 commit 4df363d

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-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.Path
1616
import semmle.go.frameworks.stdlib.PathFilepath
17+
import semmle.go.frameworks.stdlib.TextScanner
1718

1819
/** A `String()` method. */
1920
class StringMethod extends TaintTracking::FunctionModel, Method {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Provides classes modeling security-relevant aspects of the `text/scanner` package.
3+
*/
4+
5+
import go
6+
7+
/** Provides models of commonly used functions in the `text/scanner` package. */
8+
module TextScanner {
9+
private class MethodModels extends TaintTracking::FunctionModel, Method {
10+
FunctionInput inp;
11+
FunctionOutput outp;
12+
13+
MethodModels() {
14+
// signature: func (*Scanner).Init(src io.Reader) *Scanner
15+
this.hasQualifiedName("text/scanner", "Scanner", "Init") and
16+
(
17+
inp.isParameter(0) and
18+
(outp.isReceiver() or outp.isResult())
19+
)
20+
or
21+
// signature: func (*Scanner).TokenText() string
22+
this.hasQualifiedName("text/scanner", "Scanner", "TokenText") and
23+
(inp.isReceiver() and outp.isResult())
24+
}
25+
26+
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
27+
input = inp and output = outp
28+
}
29+
}
30+
}

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

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