Skip to content

Commit 2139b97

Browse files
authored
Merge branch 'main' into post-release-prep/codeql-cli-2.25.0
2 parents e3dbf5b + 7d53898 commit 2139b97

File tree

71 files changed

+2056
-1856
lines changed

Some content is hidden

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

71 files changed

+2056
-1856
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ 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")
2121
bazel_dep(name = "rules_pkg", version = "1.0.1")
2222
bazel_dep(name = "rules_nodejs", version = "6.7.3")

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/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/Security/CWE/CWE-079/CgiXss.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* allows for a cross-site scripting vulnerability.
55
* @kind path-problem
66
* @problem.severity error
7-
* @security-severity 6.1
7+
* @security-severity 7.8
88
* @precision high
99
* @id cpp/cgi-xss
1010
* @tags security
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Fixed an issue with the "Multiplication result converted to larger type" (`cpp/integer-multiplication-cast-to-long`) query causing false positive results in `build-mode: none` databases.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: queryMetadata
3+
---
4+
* The `@security-severity` metadata of `cpp/cgi-xss` has been increased from 6.1 (medium) to 7.8 (high).
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// semmle-extractor-options: --expect_errors
2+
3+
void test_float_double1(float f, double d) {
4+
float r1 = f * f; // GOOD
5+
float r2 = f * d; // GOOD
6+
double r3 = f * f; // BAD
7+
double r4 = f * d; // GOOD
8+
9+
float f1 = fabsf(f * f); // GOOD
10+
float f2 = fabsf(f * d); // GOOD
11+
double f3 = fabs(f * f); // BAD [NOT DETECTED]
12+
double f4 = fabs(f * d); // GOOD
13+
}
14+
15+
double fabs(double f);
16+
float fabsf(float f);
17+
18+
void test_float_double2(float f, double d) {
19+
float r1 = f * f; // GOOD
20+
float r2 = f * d; // GOOD
21+
double r3 = f * f; // BAD
22+
double r4 = f * d; // GOOD
23+
24+
float f1 = fabsf(f * f); // GOOD
25+
float f2 = fabsf(f * d); // GOOD
26+
double f3 = fabs(f * f); // BAD [NOT DETECTED]
27+
double f4 = fabs(f * d); // GOOD
28+
}

cpp/ql/test/query-tests/Likely Bugs/Arithmetic/IntMultToLong/IntMultToLong.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
| Buildless.c:6:17:6:21 | ... * ... | Multiplication result may overflow 'float' before it is converted to 'double'. |
2+
| Buildless.c:21:17:21:21 | ... * ... | Multiplication result may overflow 'float' before it is converted to 'double'. |
13
| IntMultToLong.c:4:10:4:14 | ... * ... | Multiplication result may overflow 'int' before it is converted to 'long long'. |
24
| IntMultToLong.c:7:16:7:20 | ... * ... | Multiplication result may overflow 'int' before it is converted to 'long long'. |
35
| IntMultToLong.c:18:19:18:23 | ... * ... | Multiplication result may overflow 'float' before it is converted to 'double'. |

csharp/ql/lib/semmle/code/csharp/Callable.qll

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,22 @@ class ExtensionTypeExtensionMethod extends ExtensionMethodImpl {
336336
ExtensionTypeExtensionMethod() { this.isInExtension() }
337337
}
338338

339+
/**
340+
* A non-static member with an initializer, for example a field `int Field = 0`.
341+
*/
342+
private class InitializedInstanceMember extends Member {
343+
private AssignExpr ae;
344+
345+
InitializedInstanceMember() {
346+
not this.isStatic() and
347+
expr_parent_top_level(ae, _, this) and
348+
not ae = getExpressionBody(_)
349+
}
350+
351+
/** Gets the initializer expression. */
352+
AssignExpr getInitializer() { result = ae }
353+
}
354+
339355
/**
340356
* An object initializer method.
341357
*
@@ -347,6 +363,17 @@ class ExtensionTypeExtensionMethod extends ExtensionMethodImpl {
347363
*/
348364
class ObjectInitMethod extends Method {
349365
ObjectInitMethod() { this.getName() = "<object initializer>" }
366+
367+
/**
368+
* Holds if this object initializer method performs the initialization
369+
* of a member via assignment `init`.
370+
*/
371+
predicate initializes(AssignExpr init) {
372+
exists(InitializedInstanceMember m |
373+
this.getDeclaringType().getAMember() = m and
374+
init = m.getInitializer()
375+
)
376+
}
350377
}
351378

352379
/**

0 commit comments

Comments
 (0)