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

Commit 2938274

Browse files
committed
Taint-track package errors
1 parent fee596a commit 2938274

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import semmle.go.frameworks.stdlib.EncodingPem
2929
import semmle.go.frameworks.stdlib.EncodingXml
3030
import semmle.go.frameworks.stdlib.Html
3131
import semmle.go.frameworks.stdlib.HtmlTemplate
32+
import semmle.go.frameworks.stdlib.Errors
3233
import semmle.go.frameworks.stdlib.Path
3334
import semmle.go.frameworks.stdlib.PathFilepath
3435
import semmle.go.frameworks.stdlib.Reflect
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Provides classes modeling security-relevant aspects of the `errors` package.
3+
*/
4+
5+
import go
6+
7+
/** Provides models of commonly used functions in the `errors` package. */
8+
module Errors {
9+
private class FunctionModels extends TaintTracking::FunctionModel {
10+
FunctionInput inp;
11+
FunctionOutput outp;
12+
13+
FunctionModels() {
14+
// signature: func As(err error, target interface{}) bool
15+
hasQualifiedName("errors", "As") and
16+
(inp.isParameter(0) and outp.isParameter(1))
17+
or
18+
// signature: func New(text string) error
19+
hasQualifiedName("errors", "New") and
20+
(inp.isParameter(0) and outp.isResult())
21+
or
22+
// signature: func Unwrap(err error) error
23+
hasQualifiedName("errors", "Unwrap") and
24+
(inp.isParameter(0) and outp.isResult())
25+
}
26+
27+
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
28+
input = inp and output = outp
29+
}
30+
}
31+
}

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

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