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

Commit 52d4c71

Browse files
committed
Add taint-tracking for html package.
1 parent 8d7cbe3 commit 52d4c71

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import semmle.go.frameworks.stdlib.EncodingHex
2727
import semmle.go.frameworks.stdlib.EncodingJson
2828
import semmle.go.frameworks.stdlib.EncodingPem
2929
import semmle.go.frameworks.stdlib.EncodingXml
30+
import semmle.go.frameworks.stdlib.Html
3031
import semmle.go.frameworks.stdlib.Path
3132
import semmle.go.frameworks.stdlib.PathFilepath
3233
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 `html` package.
3+
*/
4+
5+
import go
6+
7+
/** Provides models of commonly used functions in the `html` package. */
8+
module Html {
9+
private class FunctionModels extends TaintTracking::FunctionModel {
10+
FunctionInput inp;
11+
FunctionOutput outp;
12+
13+
FunctionModels() {
14+
// signature: func EscapeString(s string) string
15+
hasQualifiedName("html", "EscapeString") and
16+
(inp.isParameter(0) and outp.isResult())
17+
or
18+
// signature: func UnescapeString(s string) string
19+
hasQualifiedName("html", "UnescapeString") and
20+
(inp.isParameter(0) and outp.isResult())
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/Html.go

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