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

Commit f3a61ed

Browse files
committed
Add MarshalFunction and UnmarshalFunction classes to EncodingXml module.
1 parent b4ff653 commit f3a61ed

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

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

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

77
/** Provides models of commonly used functions in the `encoding/xml` package. */
88
module EncodingXml {
9+
/** The `Marshal` or `MarshalIndent` function in the `encoding/xml` package. */
10+
class MarshalFunction extends TaintTracking::FunctionModel, MarshalingFunction::Range {
11+
MarshalFunction() {
12+
this.hasQualifiedName("encoding/xml", "Marshal") or
13+
this.hasQualifiedName("encoding/xml", "MarshalIndent")
14+
}
15+
16+
override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) {
17+
inp = getAnInput() and outp = getOutput()
18+
}
19+
20+
override FunctionInput getAnInput() { result.isParameter(0) }
21+
22+
override FunctionOutput getOutput() { result.isResult(0) }
23+
24+
override string getFormat() { result = "XML" }
25+
}
26+
27+
private class UnmarshalFunction extends TaintTracking::FunctionModel, UnmarshalingFunction::Range {
28+
UnmarshalFunction() { this.hasQualifiedName("encoding/xml", "Unmarshal") }
29+
30+
override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) {
31+
inp = getAnInput() and outp = getOutput()
32+
}
33+
34+
override FunctionInput getAnInput() { result.isParameter(0) }
35+
36+
override FunctionOutput getOutput() { result.isParameter(1) }
37+
38+
override string getFormat() { result = "XML" }
39+
}
40+
941
private class FunctionModels extends TaintTracking::FunctionModel {
1042
FunctionInput inp;
1143
FunctionOutput outp;

0 commit comments

Comments
 (0)