Skip to content

Commit 9d1c2c6

Browse files
authored
Merge branch 'main' into mbg/go/semver-type
2 parents 2662808 + 0ab67d1 commit 9d1c2c6

File tree

151 files changed

+4706
-3283
lines changed

Some content is hidden

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

151 files changed

+4706
-3283
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
/csharp/paket.main_extension.bzl linguist-generated=true
8484

8585
# ripunzip tool
86-
/misc/bazel/internal/ripunzip/ripunzip-* filter=lfs diff=lfs merge=lfs -text
86+
/misc/ripunzip/ripunzip-* filter=lfs diff=lfs merge=lfs -text
8787

8888
# swift prebuilt resources
8989
/swift/third_party/resource-dir/*.zip filter=lfs diff=lfs merge=lfs -text

MODULE.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,19 @@ lfs_files = use_repo_rule("//misc/bazel:lfs.bzl", "lfs_files")
118118

119119
lfs_files(
120120
name = "ripunzip-linux",
121-
srcs = ["//misc/bazel/internal/ripunzip:ripunzip-linux"],
121+
srcs = ["//misc/ripunzip:ripunzip-linux"],
122122
executable = True,
123123
)
124124

125125
lfs_files(
126126
name = "ripunzip-windows",
127-
srcs = ["//misc/bazel/internal/ripunzip:ripunzip-windows.exe"],
127+
srcs = ["//misc/ripunzip:ripunzip-windows.exe"],
128128
executable = True,
129129
)
130130

131131
lfs_files(
132132
name = "ripunzip-macos",
133-
srcs = ["//misc/bazel/internal/ripunzip:ripunzip-macos"],
133+
srcs = ["//misc/ripunzip:ripunzip-macos"],
134134
executable = True,
135135
)
136136

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* A partial model for the `Boost.Asio` network library has been added. This includes sources, sinks and summaries for certain functions in `Boost.Asio`, such as `read_until` and `write`.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: feature
3+
---
4+
* Data models can now be added with data extensions. In this way source, sink and summary models can be added in extension `.model.yml` files, rather than by writing classes in QL code. New models should be added in the `lib/ext` folder.

cpp/ql/lib/ext/Boost.Asio.model.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
extensions:
2+
# partial model of the Boost::Asio network library
3+
extensions:
4+
- addsTo:
5+
pack: codeql/cpp-all
6+
extensible: sourceModel
7+
data: # namespace, type, subtypes, name, signature, ext, output, kind, provenance
8+
- ["boost::asio", "", False, "read", "", "", "Argument[*1]", "remote", "manual"]
9+
- ["boost::asio", "", False, "read_at", "", "", "Argument[*2]", "remote", "manual"]
10+
- ["boost::asio", "", False, "read_until", "", "", "Argument[*1]", "remote", "manual"]
11+
- ["boost::asio", "", False, "async_read", "", "", "Argument[*1]", "remote", "manual"]
12+
- ["boost::asio", "", False, "async_read_at", "", "", "Argument[*2]", "remote", "manual"]
13+
- ["boost::asio", "", False, "async_read_until", "", "", "Argument[*1]", "remote", "manual"]
14+
- addsTo:
15+
pack: codeql/cpp-all
16+
extensible: sinkModel
17+
data: # namespace, type, subtypes, name, signature, ext, input, kind, provenance
18+
- ["boost::asio", "", False, "write", "", "", "Argument[*1]", "remote-sink", "manual"]
19+
- ["boost::asio", "", False, "write_at", "", "", "Argument[*2]", "remote-sink", "manual"]
20+
- ["boost::asio", "", False, "async_write", "", "", "Argument[*1]", "remote-sink", "manual"]
21+
- ["boost::asio", "", False, "async_write_at", "", "", "Argument[*2]", "remote-sink", "manual"]
22+
- addsTo:
23+
pack: codeql/cpp-all
24+
extensible: summaryModel
25+
data: # namespace, type, subtypes, name, signature, ext, input, output, kind, provenance
26+
- ["boost::asio", "", False, "buffer", "", "", "Argument[*0]", "ReturnValue", "taint", "manual"]

cpp/ql/lib/ext/empty.model.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
extensions:
2+
# Make sure that the extensible model predicates have at least one definition
3+
# to avoid errors about undefined extensionals.
4+
- addsTo:
5+
pack: codeql/cpp-all
6+
extensible: sourceModel
7+
data: []
8+
- addsTo:
9+
pack: codeql/cpp-all
10+
extensible: sinkModel
11+
data: []
12+
- addsTo:
13+
pack: codeql/cpp-all
14+
extensible: summaryModel
15+
data: []

cpp/ql/lib/qlpack.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ dependencies:
1414
codeql/tutorial: ${workspace}
1515
codeql/util: ${workspace}
1616
codeql/xml: ${workspace}
17+
dataExtensions:
18+
- ext/*.model.yml
1719
warnOnImplicitThis: true

cpp/ql/lib/semmle/code/cpp/Variable.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,10 @@ class LocalVariable extends LocalScopeVariable, @localvariable {
410410
or
411411
orphaned_variables(underlyingElement(this), unresolveElement(result))
412412
}
413+
414+
override predicate isStatic() {
415+
super.isStatic() or orphaned_variables(underlyingElement(this), _)
416+
}
413417
}
414418

415419
/**

cpp/ql/lib/semmle/code/cpp/dataflow/ExternalFlow.qll

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ private import internal.FlowSummaryImpl
7878
private import internal.FlowSummaryImpl::Public
7979
private import internal.FlowSummaryImpl::Private
8080
private import internal.FlowSummaryImpl::Private::External
81+
private import internal.ExternalFlowExtensions as Extensions
8182
private import codeql.mad.ModelValidation as SharedModelVal
8283
private import codeql.util.Unit
8384

@@ -138,6 +139,9 @@ predicate sourceModel(
138139
row.splitAt(";", 7) = kind
139140
) and
140141
provenance = "manual"
142+
or
143+
Extensions::sourceModel(namespace, type, subtypes, name, signature, ext, output, kind, provenance,
144+
_)
141145
}
142146

143147
/** Holds if a sink model exists for the given parameters. */
@@ -158,6 +162,8 @@ predicate sinkModel(
158162
row.splitAt(";", 7) = kind
159163
) and
160164
provenance = "manual"
165+
or
166+
Extensions::sinkModel(namespace, type, subtypes, name, signature, ext, input, kind, provenance, _)
161167
}
162168

163169
/** Holds if a summary model exists for the given parameters. */
@@ -179,6 +185,9 @@ predicate summaryModel(
179185
row.splitAt(";", 8) = kind
180186
) and
181187
provenance = "manual"
188+
or
189+
Extensions::summaryModel(namespace, type, subtypes, name, signature, ext, input, output, kind,
190+
provenance, _)
182191
}
183192

184193
private predicate relevantNamespace(string namespace) {
@@ -203,8 +212,10 @@ private predicate canonicalNamespaceLink(string namespace, string subns) {
203212
}
204213

205214
/**
206-
* Holds if CSV framework coverage of `namespace` is `n` api endpoints of the
207-
* kind `(kind, part)`.
215+
* Holds if MaD framework coverage of `namespace` is `n` api endpoints of the
216+
* kind `(kind, part)`, and `namespaces` is the number of subnamespaces of
217+
* `namespace` which have MaD framework coverage (including `namespace`
218+
* itself).
208219
*/
209220
predicate modelCoverage(string namespace, int namespaces, string kind, string part, int n) {
210221
namespaces = strictcount(string subns | canonicalNamespaceLink(namespace, subns)) and
@@ -321,10 +332,10 @@ module CsvValidation {
321332
or
322333
summaryModel(namespace, type, _, name, signature, ext, _, _, _, _) and pred = "summary"
323334
|
324-
not namespace.regexpMatch("[a-zA-Z0-9_\\.]+") and
335+
not namespace.regexpMatch("[a-zA-Z0-9_\\.:]*") and
325336
result = "Dubious namespace \"" + namespace + "\" in " + pred + " model."
326337
or
327-
not type.regexpMatch("[a-zA-Z0-9_<>,\\+]+") and
338+
not type.regexpMatch("[a-zA-Z0-9_<>,\\+]*") and
328339
result = "Dubious type \"" + type + "\" in " + pred + " model."
329340
or
330341
not name.regexpMatch("[a-zA-Z0-9_<>,]*") and
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* This module provides extensible predicates for defining MaD models.
3+
*/
4+
5+
/**
6+
* Holds if an external source model exists for the given parameters.
7+
*/
8+
extensible predicate sourceModel(
9+
string namespace, string type, boolean subtypes, string name, string signature, string ext,
10+
string output, string kind, string provenance, QlBuiltins::ExtensionId madId
11+
);
12+
13+
/**
14+
* Holds if an external sink model exists for the given parameters.
15+
*/
16+
extensible predicate sinkModel(
17+
string namespace, string type, boolean subtypes, string name, string signature, string ext,
18+
string input, string kind, string provenance, QlBuiltins::ExtensionId madId
19+
);
20+
21+
/**
22+
* Holds if an external summary model exists for the given parameters.
23+
*/
24+
extensible predicate summaryModel(
25+
string namespace, string type, boolean subtypes, string name, string signature, string ext,
26+
string input, string output, string kind, string provenance, QlBuiltins::ExtensionId madId
27+
);

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,8 @@ predicate nodeIsHidden(Node n) {
13361336
n instanceof FinalGlobalValue
13371337
or
13381338
n instanceof InitialGlobalValue
1339+
or
1340+
n instanceof SsaPhiInputNode
13391341
}
13401342

13411343
predicate neverSkipInPathGraph(Node n) {
@@ -1634,6 +1636,8 @@ private Instruction getAnInstruction(Node n) {
16341636
or
16351637
result = n.(SsaPhiNode).getPhiNode().getBasicBlock().getFirstInstruction()
16361638
or
1639+
result = n.(SsaPhiInputNode).getBasicBlock().getFirstInstruction()
1640+
or
16371641
n.(IndirectInstruction).hasInstructionAndIndirectionIndex(result, _)
16381642
or
16391643
not n instanceof IndirectInstruction and
@@ -1763,7 +1767,7 @@ module IteratorFlow {
17631767
crementCall = def.getValue().asInstruction().(StoreInstruction).getSourceValue() and
17641768
sv = def.getSourceVariable() and
17651769
bb.getInstruction(i) = crementCall and
1766-
Ssa::ssaDefReachesRead(sv, result.asDef(), bb, i)
1770+
Ssa::ssaDefReachesReadExt(sv, result.asDef(), bb, i)
17671771
)
17681772
}
17691773

@@ -1797,7 +1801,7 @@ module IteratorFlow {
17971801
isIteratorWrite(writeToDeref, address) and
17981802
operandForFullyConvertedCall(address, starCall) and
17991803
bbStar.getInstruction(iStar) = starCall and
1800-
Ssa::ssaDefReachesRead(_, def.asDef(), bbStar, iStar) and
1804+
Ssa::ssaDefReachesReadExt(_, def.asDef(), bbStar, iStar) and
18011805
ultimate = getAnUltimateDefinition*(def) and
18021806
beginStore = ultimate.getValue().asInstruction() and
18031807
operandForFullyConvertedCall(beginStore.getSourceValueOperand(), beginCall)

0 commit comments

Comments
 (0)