Skip to content

Commit d049b11

Browse files
authored
Merge pull request github#12750 from smowton/smowton/admin/add-dataflow-viableParamArgSpecific-hook
Go: mass-convert taint-flow models to models-as-data format (with `viableParamArgSpecific` hook)
2 parents 566513e + d648b34 commit d049b11

File tree

240 files changed

+3681
-4173
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

240 files changed

+3681
-4173
lines changed

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowDispatch.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,13 @@ class ArgumentPosition extends int {
7979
/** Holds if arguments at position `apos` match parameters at position `ppos`. */
8080
pragma[inline]
8181
predicate parameterMatch(ParameterPosition ppos, ArgumentPosition apos) { ppos = apos }
82+
83+
/**
84+
* Holds if flow from `call`'s argument `arg` to parameter `p` is permissible.
85+
*
86+
* This is a temporary hook to support technical debt in the Go language; do not use.
87+
*/
88+
pragma[inline]
89+
predicate golangSpecificParamArgFilter(DataFlowCall call, ParameterNode p, ArgumentNode arg) {
90+
any()
91+
}

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImplCommon.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,8 @@ private module Cached {
425425
exists(ParameterPosition ppos |
426426
viableParam(call, ppos, p) and
427427
argumentPositionMatch(call, arg, ppos) and
428-
compatibleTypes(getNodeDataFlowType(arg), getNodeDataFlowType(p))
428+
compatibleTypes(getNodeDataFlowType(arg), getNodeDataFlowType(p)) and
429+
golangSpecificParamArgFilter(call, p, arg)
429430
)
430431
}
431432

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowDispatch.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,13 @@ Function viableImplInCallContext(CallInstruction call, CallInstruction ctx) {
271271
/** Holds if arguments at position `apos` match parameters at position `ppos`. */
272272
pragma[inline]
273273
predicate parameterMatch(ParameterPosition ppos, ArgumentPosition apos) { ppos = apos }
274+
275+
/**
276+
* Holds if flow from `call`'s argument `arg` to parameter `p` is permissible.
277+
*
278+
* This is a temporary hook to support technical debt in the Go language; do not use.
279+
*/
280+
pragma[inline]
281+
predicate golangSpecificParamArgFilter(DataFlowCall call, ParameterNode p, ArgumentNode arg) {
282+
any()
283+
}

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowImplCommon.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,8 @@ private module Cached {
425425
exists(ParameterPosition ppos |
426426
viableParam(call, ppos, p) and
427427
argumentPositionMatch(call, arg, ppos) and
428-
compatibleTypes(getNodeDataFlowType(arg), getNodeDataFlowType(p))
428+
compatibleTypes(getNodeDataFlowType(arg), getNodeDataFlowType(p)) and
429+
golangSpecificParamArgFilter(call, p, arg)
429430
)
430431
}
431432

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowDispatch.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,3 +555,13 @@ predicate parameterMatch(ParameterPosition ppos, ArgumentPosition apos) {
555555
apos.isImplicitCapturedArgumentPosition(v)
556556
)
557557
}
558+
559+
/**
560+
* Holds if flow from `call`'s argument `arg` to parameter `p` is permissible.
561+
*
562+
* This is a temporary hook to support technical debt in the Go language; do not use.
563+
*/
564+
pragma[inline]
565+
predicate golangSpecificParamArgFilter(DataFlowCall call, ParameterNode p, ArgumentNode arg) {
566+
any()
567+
}

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowImplCommon.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,8 @@ private module Cached {
425425
exists(ParameterPosition ppos |
426426
viableParam(call, ppos, p) and
427427
argumentPositionMatch(call, arg, ppos) and
428-
compatibleTypes(getNodeDataFlowType(arg), getNodeDataFlowType(p))
428+
compatibleTypes(getNodeDataFlowType(arg), getNodeDataFlowType(p)) and
429+
golangSpecificParamArgFilter(call, p, arg)
429430
)
430431
}
431432

go/ql/lib/ext/archive.tar.model.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
extensions:
2+
- addsTo:
3+
pack: codeql/go-all
4+
extensible: summaryModel
5+
data:
6+
- ["archive/tar", "", False, "FileInfoHeader", "", "", "Argument[0]", "ReturnValue[0]", "taint", "manual"]
7+
- ["archive/tar", "", False, "NewReader", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]
8+
- ["archive/tar", "Header", True, "FileInfo", "", "", "Argument[-1]", "ReturnValue", "taint", "manual"]
9+
- ["archive/tar", "Reader", True, "Next", "", "", "Argument[-1]", "ReturnValue[0]", "taint", "manual"]
10+
- ["archive/tar", "Writer", True, "WriteHeader", "", "", "Argument[0]", "Argument[-1]", "taint", "manual"]

go/ql/lib/ext/archive.zip.model.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
extensions:
2+
- addsTo:
3+
pack: codeql/go-all
4+
extensible: summaryModel
5+
data:
6+
- ["archive/zip", "", False, "FileInfoHeader", "", "", "Argument[0]", "ReturnValue[0]", "taint", "manual"]
7+
- ["archive/zip", "", False, "NewReader", "", "", "Argument[0]", "ReturnValue[0]", "taint", "manual"]
8+
- ["archive/zip", "", False, "OpenReader", "", "", "Argument[0]", "ReturnValue[0]", "taint", "manual"]
9+
- ["archive/zip", "File", True, "Open", "", "", "Argument[-1]", "ReturnValue[0]", "taint", "manual"]
10+
- ["archive/zip", "File", True, "OpenRaw", "", "", "Argument[-1]", "ReturnValue[0]", "taint", "manual"]
11+
- ["archive/zip", "Writer", True, "Copy", "", "", "Argument[0]", "Argument[-1]", "taint", "manual"]

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

Lines changed: 0 additions & 6 deletions
This file was deleted.

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
extensions:
2+
- addsTo:
3+
pack: codeql/go-all
4+
extensible: summaryModel
5+
data:
6+
- ["bufio", "", False, "NewReadWriter", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]
7+
- ["bufio", "", False, "NewReader", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]
8+
- ["bufio", "", False, "NewReaderSize", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]
9+
- ["bufio", "", False, "NewScanner", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]
10+
- ["bufio", "", False, "ScanBytes", "", "", "Argument[0]", "ReturnValue[1]", "taint", "manual"]
11+
- ["bufio", "", False, "ScanLines", "", "", "Argument[0]", "ReturnValue[1]", "taint", "manual"]
12+
- ["bufio", "", False, "ScanRunes", "", "", "Argument[0]", "ReturnValue[1]", "taint", "manual"]
13+
- ["bufio", "", False, "ScanWords", "", "", "Argument[0]", "ReturnValue[1]", "taint", "manual"]
14+
- ["bufio", "Reader", True, "Peek", "", "", "Argument[-1]", "ReturnValue[0]", "taint", "manual"]
15+
- ["bufio", "Reader", True, "ReadBytes", "", "", "Argument[-1]", "ReturnValue[0]", "taint", "manual"]
16+
- ["bufio", "Reader", True, "ReadLine", "", "", "Argument[-1]", "ReturnValue[0]", "taint", "manual"]
17+
- ["bufio", "Reader", True, "ReadSlice", "", "", "Argument[-1]", "ReturnValue[0]", "taint", "manual"]
18+
- ["bufio", "Reader", True, "ReadString", "", "", "Argument[-1]", "ReturnValue[0]", "taint", "manual"]
19+
- ["bufio", "Reader", True, "Reset", "", "", "Argument[0]", "Argument[-1]", "taint", "manual"]
20+
- ["bufio", "Scanner", True, "Bytes", "", "", "Argument[-1]", "ReturnValue", "taint", "manual"]
21+
- ["bufio", "Scanner", True, "Text", "", "", "Argument[-1]", "ReturnValue", "taint", "manual"]
22+
- ["bufio", "Writer", True, "Reset", "", "", "Argument[-1]", "Argument[0]", "taint", "manual"]

0 commit comments

Comments
 (0)