Skip to content

Commit 700604a

Browse files
committed
Convert old-style models for built-ins to MaD
These models are to cover the special cases where `append` can be used with a second argument which is a string followed by `...`, and `copy` can be used with a second argument which is a string. In this case the taint is carried by the whole string, rather than in array elements.
1 parent 3574b9f commit 700604a

File tree

2 files changed

+3
-24
lines changed

2 files changed

+3
-24
lines changed

go/ql/lib/ext/builtin.model.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ extensions:
33
pack: codeql/go-all
44
extensible: summaryModel
55
data:
6+
- ["", "", False, "append", "", "", "Argument[0]", "ReturnValue", "taint", "manual"] # special case for when arg[0] has core type []byte and second argument has core type bytestring and is followed by ...
67
- ["", "", False, "append", "", "", "Argument[0].ArrayElement", "ReturnValue.ArrayElement", "value", "manual"]
8+
- ["", "", False, "append", "", "", "Argument[1]", "ReturnValue", "taint", "manual"] # special case for when arg[0] has core type []byte and second argument has core type bytestring and is followed by ...
79
- ["", "", False, "append", "", "", "Argument[1].ArrayElement", "ReturnValue.ArrayElement", "value", "manual"]
10+
- ["", "", False, "copy", "", "", "Argument[1]", "Argument[0]", "taint", "manual"] # special case for when arg[0] has core type []byte and second argument has core type bytestring
811
- ["", "", False, "copy", "", "", "Argument[1].ArrayElement", "Argument[0].ArrayElement", "value", "manual"]
912
- ["", "", False, "max", "", "", "Argument[0..1000]", "ReturnValue", "value", "manual"]
1013
- ["", "", False, "min", "", "", "Argument[0..1000]", "ReturnValue", "value", "manual"]

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,30 +44,6 @@ import semmle.go.frameworks.stdlib.TextTabwriter
4444
import semmle.go.frameworks.stdlib.TextTemplate
4545
import semmle.go.frameworks.stdlib.Unsafe
4646

47-
/**
48-
* A model of the built-in `append` function, which propagates taint from its arguments to its
49-
* result.
50-
*/
51-
private class AppendFunction extends TaintTracking::FunctionModel {
52-
AppendFunction() { this = Builtin::append() }
53-
54-
override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) {
55-
inp.isParameter(_) and outp.isResult()
56-
}
57-
}
58-
59-
/**
60-
* A model of the built-in `copy` function, which propagates taint from its second argument
61-
* to its first.
62-
*/
63-
private class CopyFunction extends TaintTracking::FunctionModel {
64-
CopyFunction() { this = Builtin::copy() }
65-
66-
override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) {
67-
inp.isParameter(1) and outp.isParameter(0)
68-
}
69-
}
70-
7147
/** Provides a class for modeling functions which convert strings into integers. */
7248
module IntegerParser {
7349
/**

0 commit comments

Comments
 (0)