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

Commit 947bbab

Browse files
committed
Extend MarshalingFunction and UnmarshalingFunction with encoding/pem
1 parent d472d5a commit 947bbab

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

ql/src/semmle/go/frameworks/stdlib/EncodingPem.qll

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,39 @@ import go
66

77
/** Provides models of commonly used functions in the `encoding/pem` package. */
88
module EncodingPem {
9+
/** The `Encode` function in the `encoding/pem` package. */
10+
private class EncodeFunction extends MarshalingFunction::Range {
11+
EncodeFunction() { hasQualifiedName("encoding/pem", "Encode") }
12+
13+
override FunctionInput getAnInput() { result.isParameter(1) }
14+
15+
override FunctionOutput getOutput() { result.isParameter(0) }
16+
17+
override string getFormat() { result = "PEM" }
18+
}
19+
20+
/** The `EncodeToMemory` function in the `encoding/pem` package. */
21+
private class EncodeToMemoryFunction extends MarshalingFunction::Range {
22+
EncodeToMemoryFunction() { hasQualifiedName("encoding/pem", "EncodeToMemory") }
23+
24+
override FunctionInput getAnInput() { result.isParameter(0) }
25+
26+
override FunctionOutput getOutput() { result.isResult() }
27+
28+
override string getFormat() { result = "PEM" }
29+
}
30+
31+
/** The `Decode` function in the `encoding/pem` package. */
32+
private class UnmarshalFunction extends UnmarshalingFunction::Range {
33+
UnmarshalFunction() { hasQualifiedName("encoding/pem", "Decode") }
34+
35+
override FunctionInput getAnInput() { result.isParameter(0) }
36+
37+
override FunctionOutput getOutput() { result.isResult(0) }
38+
39+
override string getFormat() { result = "PEM" }
40+
}
41+
942
private class FunctionModels extends TaintTracking::FunctionModel {
1043
FunctionInput inp;
1144
FunctionOutput outp;

0 commit comments

Comments
 (0)