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

Commit ed2e5b0

Browse files
committed
Extend MarshalingFunction and UnmarshalingFunction with encoding/asn1
1 parent afede9b commit ed2e5b0

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

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

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

77
/** Provides models of commonly used functions in the `encoding/asn1` package. */
88
module EncodingAsn1 {
9+
/** The `Marshal` or `MarshalWithParams` function in the `encoding/asn1` package. */
10+
private class MarshalFunction extends MarshalingFunction::Range {
11+
MarshalFunction() {
12+
hasQualifiedName("encoding/asn1", "Marshal") or
13+
hasQualifiedName("encoding/asn1", "MarshalWithParams")
14+
}
15+
16+
override FunctionInput getAnInput() { result.isParameter(0) }
17+
18+
override FunctionOutput getOutput() { result.isResult(0) }
19+
20+
override string getFormat() { result = "ASN1" }
21+
}
22+
23+
/** The `Unmarshal` or `UnmarshalWithParams` function in the `encoding/asn1` package. */
24+
private class UnmarshalFunction extends UnmarshalingFunction::Range {
25+
UnmarshalFunction() {
26+
hasQualifiedName("encoding/asn1", "Unmarshal") or
27+
hasQualifiedName("encoding/asn1", "UnmarshalWithParams")
28+
}
29+
30+
override FunctionInput getAnInput() { result.isParameter(0) }
31+
32+
override FunctionOutput getOutput() { result.isParameter(1) }
33+
34+
override string getFormat() { result = "ASN1" }
35+
}
36+
937
private class FunctionModels extends TaintTracking::FunctionModel {
1038
FunctionInput inp;
1139
FunctionOutput outp;

0 commit comments

Comments
 (0)