Skip to content

Commit 56347c2

Browse files
committed
Merge branch 'main' into redsun82/update-rules-kotlin
2 parents b012cb5 + 7a33e2f commit 56347c2

File tree

673 files changed

+3534
-3655
lines changed

Some content is hidden

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

673 files changed

+3534
-3655
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,5 @@ updates:
4545
directory: "/"
4646
schedule:
4747
interval: weekly
48+
exclude-paths:
49+
- "misc/bazel/registry/**"

MODULE.bazel

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ local_path_override(
1515
# see https://registry.bazel.build/ for a list of available packages
1616

1717
bazel_dep(name = "platforms", version = "1.0.0")
18-
bazel_dep(name = "rules_cc", version = "0.2.16")
19-
bazel_dep(name = "rules_go", version = "0.59.0")
18+
bazel_dep(name = "rules_cc", version = "0.2.17")
19+
bazel_dep(name = "rules_go", version = "0.60.0")
2020
bazel_dep(name = "rules_java", version = "9.0.3")
21-
bazel_dep(name = "rules_pkg", version = "1.0.1")
21+
bazel_dep(name = "rules_pkg", version = "1.2.0")
2222
bazel_dep(name = "rules_nodejs", version = "6.7.3")
23-
bazel_dep(name = "rules_python", version = "0.40.0")
24-
bazel_dep(name = "rules_shell", version = "0.5.0")
23+
bazel_dep(name = "rules_python", version = "1.9.0")
24+
bazel_dep(name = "rules_shell", version = "0.6.1")
2525
bazel_dep(name = "bazel_skylib", version = "1.8.1")
26-
bazel_dep(name = "abseil-cpp", version = "20240116.1", repo_name = "absl")
26+
bazel_dep(name = "abseil-cpp", version = "20260107.1", repo_name = "absl")
2727
bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "json")
2828
bazel_dep(name = "fmt", version = "12.1.0-codeql.1")
2929
bazel_dep(name = "rules_kotlin", version = "2.3.10.codeql.1")
3030
bazel_dep(name = "gazelle", version = "0.47.0")
3131
bazel_dep(name = "rules_dotnet", version = "0.21.5-codeql.1")
32-
bazel_dep(name = "googletest", version = "1.14.0.bcr.1")
33-
bazel_dep(name = "rules_rust", version = "0.68.1.codeql.1")
34-
bazel_dep(name = "zstd", version = "1.5.5.bcr.1")
32+
bazel_dep(name = "googletest", version = "1.17.0.bcr.2")
33+
bazel_dep(name = "rules_rust", version = "0.69.0")
34+
bazel_dep(name = "zstd", version = "1.5.7.bcr.1")
3535

3636
bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)
3737

config/add-overlay-annotations.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ def annotate_as_appropriate(filename, lines):
199199
# as overlay[local?]. It is not clear that these heuristics are exactly what we want,
200200
# but they seem to work well enough for now (as determined by speed and accuracy numbers).
201201
if (filename.endswith("Test.qll") or
202+
re.search(r"go/ql/lib/semmle/go/security/[^/]+[.]qll$", filename.replace(os.sep, "/")) or
202203
((filename.endswith("Query.qll") or filename.endswith("Config.qll")) and
203204
any("implements DataFlow::ConfigSig" in line for line in lines))):
204205
return None

config/identical-files.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,6 @@
172172
"cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/reachability/PrintDominance.qll",
173173
"cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/reachability/PrintDominance.qll"
174174
],
175-
"C# ControlFlowReachability": [
176-
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/ControlFlowReachability.qll",
177-
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/ControlFlowReachability.qll"
178-
],
179175
"C++ ExternalAPIs": [
180176
"cpp/ql/src/Security/CWE/CWE-020/ExternalAPIs.qll",
181177
"cpp/ql/src/Security/CWE/CWE-020/ir/ExternalAPIs.qll"

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,12 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
524524
not exists(NewOrNewArrayExpr new | e = new.getAllocatorCall().getArgument(0))
525525
)
526526
}
527+
528+
/**
529+
* Holds if this function has an ambiguous return type, meaning that zero or multiple return
530+
* types for this function are present in the database (this can occur in `build-mode: none`).
531+
*/
532+
predicate hasAmbiguousReturnType() { count(this.getType()) != 1 }
527533
}
528534

529535
pragma[noinline]

cpp/ql/lib/semmle/code/cpp/controlflow/IRGuards.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1663,7 +1663,7 @@ private module Cached {
16631663
private predicate compares_ge(
16641664
ValueNumber test, Operand left, Operand right, int k, boolean isGe, GuardValue value
16651665
) {
1666-
exists(int onemk | k = 1 - onemk | compares_lt(test, right, left, onemk, isGe, value))
1666+
compares_lt(test, right, left, 1 - k, isGe, value)
16671667
}
16681668

16691669
/** Rearrange various simple comparisons into `left < right + k` form. */

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,26 @@ module CsvValidation {
353353
)
354354
}
355355

356+
private string getIncorrectConstructorSummaryOutput() {
357+
exists(string namespace, string type, string name, string output |
358+
type = name or
359+
type = name + "<" + any(string s)
360+
|
361+
summaryModel(namespace, type, _, name, _, _, _, output, _, _, _) and
362+
output.matches("ReturnValue%") and
363+
result =
364+
"Constructor model for " + namespace + "." + type +
365+
" should use `Argument[this]` in the output, not `ReturnValue`."
366+
)
367+
}
368+
356369
/** Holds if some row in a CSV-based flow model appears to contain typos. */
357370
query predicate invalidModelRow(string msg) {
358371
msg =
359372
[
360373
getInvalidModelSignature(), getInvalidModelInput(), getInvalidModelOutput(),
361-
getInvalidModelSubtype(), getInvalidModelColumnCount(), KindVal::getInvalidModelKind()
374+
getInvalidModelSubtype(), getInvalidModelColumnCount(), KindVal::getInvalidModelKind(),
375+
getIncorrectConstructorSummaryOutput()
362376
]
363377
}
364378
}

cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll

Lines changed: 42 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -6,117 +6,67 @@ private import OverlayXml
66

77
/**
88
* Holds always for the overlay variant and never for the base variant.
9-
* This local predicate is used to define local predicates that behave
10-
* differently for the base and overlay variant.
119
*/
1210
overlay[local]
1311
predicate isOverlay() { databaseMetadata("isOverlay", "true") }
1412

15-
overlay[local]
16-
private string getLocationFilePath(@location_default loc) {
17-
exists(@file file | locations_default(loc, file, _, _, _, _) | files(file, result))
18-
}
19-
20-
/**
21-
* Gets the file path for an element with a single location.
22-
*/
23-
overlay[local]
24-
private string getSingleLocationFilePath(@element e) {
25-
exists(@location_default loc |
26-
var_decls(e, _, _, _, loc)
27-
or
28-
fun_decls(e, _, _, _, loc)
29-
or
30-
type_decls(e, _, loc)
31-
or
32-
namespace_decls(e, _, loc, _)
33-
or
34-
macroinvocations(e, _, loc, _)
35-
or
36-
preprocdirects(e, _, loc)
37-
or
38-
diagnostics(e, _, _, _, _, loc)
39-
or
40-
usings(e, _, loc, _)
41-
or
42-
static_asserts(e, _, _, loc, _)
43-
or
44-
derivations(e, _, _, _, loc)
45-
or
46-
frienddecls(e, _, _, loc)
47-
or
48-
comments(e, _, loc)
49-
or
50-
exprs(e, _, loc)
51-
or
52-
stmts(e, _, loc)
53-
or
54-
initialisers(e, _, _, loc)
55-
or
56-
attributes(e, _, _, _, loc)
57-
or
58-
attribute_args(e, _, _, _, loc)
59-
or
60-
namequalifiers(e, _, _, loc)
61-
or
62-
enumconstants(e, _, _, _, _, loc)
63-
or
64-
type_mentions(e, _, loc, _)
65-
or
66-
lambda_capture(e, _, _, _, _, _, loc)
67-
or
68-
concept_templates(e, _, loc)
69-
|
70-
result = getLocationFilePath(loc)
71-
)
72-
}
73-
7413
/**
75-
* Gets the file path for an element with potentially multiple locations.
14+
* Holds if the TRAP file or tag `t` is reachable from source file `sourceFile`
15+
* in the base (isOverlayVariant=false) or overlay (isOverlayVariant=true) variant.
7616
*/
7717
overlay[local]
78-
private string getMultiLocationFilePath(@element e) {
79-
exists(@location_default loc |
80-
var_decls(_, e, _, _, loc)
81-
or
82-
fun_decls(_, e, _, _, loc)
83-
or
84-
type_decls(_, e, loc)
85-
or
86-
namespace_decls(_, e, loc, _)
87-
|
88-
result = getLocationFilePath(loc)
18+
private predicate locallyReachableTrapOrTag(
19+
boolean isOverlayVariant, string sourceFile, @trap_or_tag t
20+
) {
21+
exists(@source_file sf, @trap trap |
22+
(if isOverlay() then isOverlayVariant = true else isOverlayVariant = false) and
23+
source_file_uses_trap(sf, trap) and
24+
source_file_name(sf, sourceFile) and
25+
(t = trap or trap_uses_tag(trap, t))
8926
)
9027
}
9128

9229
/**
93-
* A local helper predicate that holds in the base variant and never in the
94-
* overlay variant.
95-
*/
96-
overlay[local]
97-
private predicate isBase() { not isOverlay() }
98-
99-
/**
100-
* Holds if `path` was extracted in the overlay database.
30+
* Holds if element `e` is in TRAP file or tag `t`
31+
* in the base (isOverlayVariant=false) or overlay (isOverlayVariant=true) variant.
10132
*/
10233
overlay[local]
103-
private predicate overlayHasFile(string path) {
104-
isOverlay() and
105-
files(_, path) and
106-
path != ""
34+
private predicate locallyInTrapOrTag(boolean isOverlayVariant, @element e, @trap_or_tag t) {
35+
(if isOverlay() then isOverlayVariant = true else isOverlayVariant = false) and
36+
in_trap_or_tag(e, t)
10737
}
10838

10939
/**
11040
* Discards an element from the base variant if:
111-
* - It has a single location in a file extracted in the overlay, or
112-
* - All of its locations are in files extracted in the overlay.
41+
* - We have knowledge about what TRAP file or tag it is in (in the base).
42+
* - It is not in any overlay TRAP file or tag that is reachable from an overlay source file.
43+
* - For every base TRAP file or tag that contains it and is reachable from a base source file,
44+
* either the source file has changed, or the overlay has redefined the TRAP file or tag,
45+
* or the overlay runner has re-extracted the same source file.
11346
*/
11447
overlay[discard_entity]
11548
private predicate discardElement(@element e) {
116-
isBase() and
117-
(
118-
overlayHasFile(getSingleLocationFilePath(e))
119-
or
120-
forex(string path | path = getMultiLocationFilePath(e) | overlayHasFile(path))
49+
// If we don't have any knowledge about what TRAP file something
50+
// is in, then we don't want to discard it, so we only consider
51+
// entities that are known to be in a base TRAP file or tag.
52+
locallyInTrapOrTag(false, e, _) and
53+
// Anything that is reachable from an overlay source file should
54+
// not be discarded.
55+
not exists(@trap_or_tag t | locallyInTrapOrTag(true, e, t) |
56+
locallyReachableTrapOrTag(true, _, t)
57+
) and
58+
// Finally, we have to make sure the base variant does not retain it.
59+
// If it is reachable from a base source file, then that is
60+
// sufficient unless either the base source file has changed (in
61+
// particular, been deleted), or the overlay has redefined the TRAP
62+
// file or tag it is in, or the overlay runner has re-extracted the same
63+
// source file (e.g. because a header it includes has changed).
64+
forall(@trap_or_tag t, string sourceFile |
65+
locallyInTrapOrTag(false, e, t) and
66+
locallyReachableTrapOrTag(false, sourceFile, t)
67+
|
68+
overlayChangedFiles(sourceFile) or
69+
locallyReachableTrapOrTag(true, _, t) or
70+
locallyReachableTrapOrTag(true, sourceFile, _)
12171
)
12272
}

cpp/ql/src/Likely Bugs/Arithmetic/IntMultToLong.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ where
218218
// only report if we cannot prove that the result of the
219219
// multiplication will be less (resp. greater) than the
220220
// maximum (resp. minimum) number we can compute.
221-
overflows(me, t1)
221+
overflows(me, t1) and
222+
// exclude cases where the expression type may not have been extracted accurately
223+
not me.getParent().(Call).getTarget().hasAmbiguousReturnType()
222224
select me,
223225
"Multiplication result may overflow '" + me.getType().toString() + "' before it is converted to '"
224226
+ me.getFullyConverted().getType().toString() + "'."

cpp/ql/src/Likely Bugs/Format/WrongTypeFormatArguments.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,11 @@ where
168168
formatOtherArgType(ffc, n, expected, arg, actual) and
169169
not actual.getUnspecifiedType().(IntegralType).getSize() = sizeof_IntType()
170170
) and
171+
// Exclude some cases where we're less confident the result is correct / clear / valuable
171172
not arg.isAffectedByMacro() and
172173
not arg.isFromUninstantiatedTemplate(_) and
173174
not actual.stripType() instanceof ErroneousType and
175+
not arg.getType().stripType().(RoutineType).getReturnType() instanceof ErroneousType and
174176
not arg.(Call).mayBeFromImplicitlyDeclaredFunction() and
175177
// Make sure that the format function definition is consistent
176178
count(ffc.getTarget().getFormatParameterIndex()) = 1

0 commit comments

Comments
 (0)