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

Commit e7fc3c5

Browse files
committed
Add taint-tracking for encoding/pem
1 parent 669ed91 commit e7fc3c5

3 files changed

Lines changed: 88 additions & 0 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import semmle.go.frameworks.stdlib.EncodingCsv
2525
import semmle.go.frameworks.stdlib.EncodingGob
2626
import semmle.go.frameworks.stdlib.EncodingHex
2727
import semmle.go.frameworks.stdlib.EncodingJson
28+
import semmle.go.frameworks.stdlib.EncodingPem
2829
import semmle.go.frameworks.stdlib.Path
2930
import semmle.go.frameworks.stdlib.PathFilepath
3031
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 `encoding/pem` package.
3+
*/
4+
5+
import go
6+
7+
/** Provides models of commonly used functions in the `encoding/pem` package. */
8+
module EncodingPem {
9+
private class FunctionModels extends TaintTracking::FunctionModel {
10+
FunctionInput inp;
11+
FunctionOutput outp;
12+
13+
FunctionModels() {
14+
// signature: func Decode(data []byte) (p *Block, rest []byte)
15+
hasQualifiedName("encoding/pem", "Decode") and
16+
(inp.isParameter(0) and outp.isResult(_))
17+
or
18+
// signature: func Encode(out io.Writer, b *Block) error
19+
hasQualifiedName("encoding/pem", "Encode") and
20+
(inp.isParameter(1) and outp.isParameter(0))
21+
or
22+
// signature: func EncodeToMemory(b *Block) []byte
23+
hasQualifiedName("encoding/pem", "EncodeToMemory") 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/EncodingPem.go

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