-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathYaml.qll
More file actions
50 lines (37 loc) · 1.57 KB
/
Yaml.qll
File metadata and controls
50 lines (37 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* Provides classes for working with the [gopkg.in/yaml](https://pkg.go.dev/gopkg.in/yaml.v3) package.
*/
overlay[local?]
module;
import go
/**
* Provides classes for working with the [gopkg.in/yaml](https://pkg.go.dev/gopkg.in/yaml.v3) package.
*/
module Yaml {
/** Gets a package path for the Yaml package. */
string packagePath() { result = package("gopkg.in/yaml", "") }
private class MarshalFunction extends MarshalingFunction::Range {
MarshalFunction() { this.hasQualifiedName(packagePath(), "Marshal") }
override DataFlow::FunctionInput getAnInput() { result.isParameter(0) }
override DataFlow::FunctionOutput getOutput() { result.isResult(0) }
override string getFormat() { result = "yaml" }
}
private class UnmarshalFunction extends UnmarshalingFunction::Range {
UnmarshalFunction() { this.hasQualifiedName(packagePath(), ["Unmarshal", "UnmarshalStrict"]) }
override DataFlow::FunctionInput getAnInput() { result.isParameter(0) }
override DataFlow::FunctionOutput getOutput() { result.isParameter(1) }
override string getFormat() { result = "yaml" }
}
// These models are not implemented using Models-as-Data because they represent reverse flow.
private class FunctionModels extends TaintTracking::FunctionModel {
FunctionInput inp;
FunctionOutput outp;
FunctionModels() {
this.hasQualifiedName(packagePath(), "NewEncoder") and
(inp.isResult() and outp.isParameter(0))
}
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
input = inp and output = outp
}
}
}