Skip to content

Commit 677f0f0

Browse files
author
Robert Marsh
committed
Merge branch 'master' into rdmarsh/cpp/ir-flow-through-outparams
2 parents 71d87be + 2b10cd6 commit 677f0f0

543 files changed

Lines changed: 8301 additions & 2140 deletions

File tree

Some content is hidden

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

change-notes/1.24/analysis-cpp.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ The following changes in version 1.24 affect C/C++ analysis in all applications.
2626

2727
## Changes to libraries
2828

29+
* The data-flow library has been improved when flow through functions needs to be
30+
combined with both taint tracking and flow through fields allowing more flow
31+
to be tracked. This affects and improves some security queries, which may
32+
report additional results.
2933
* Created the `semmle.code.cpp.models.interfaces.Allocation` library to model allocation such as `new` expressions and calls to `malloc`. This in intended to replace the functionality in `semmle.code.cpp.commons.Alloc` with a more consistent and useful interface.
3034
* Created the `semmle.code.cpp.models.interfaces.Deallocation` library to model deallocation such as `delete` expressions and calls to `free`. This in intended to replace the functionality in `semmle.code.cpp.commons.Alloc` with a more consistent and useful interface.
3135
* The new class `StackVariable` should be used in place of `LocalScopeVariable`

change-notes/1.24/analysis-csharp.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ The following changes in version 1.24 affect C# analysis in all applications.
2929

3030
## Changes to libraries
3131

32+
* The data-flow library has been improved when flow through methods needs to be
33+
combined with both taint tracking and flow through fields allowing more flow
34+
to be tracked. This affects and improves most security queries, which may
35+
report additional results.
3236
* The taint tracking library now tracks flow through (implicit or explicit) conversion operator calls.
3337
* [Code contracts](https://docs.microsoft.com/en-us/dotnet/framework/debug-trace-profile/code-contracts) are now recognized, and are treated like any other assertion methods.
3438
* Expression nullability flow state is given by the predicates `Expr.hasNotNullFlowState()` and `Expr.hasMaybeNullFlowState()`.

change-notes/1.24/analysis-java.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,17 @@ The following changes in version 1.24 affect Java analysis in all applications.
2525

2626
## Changes to libraries
2727

28+
* The data-flow library has been improved when flow through methods needs to be
29+
combined with both taint tracking and flow through fields allowing more flow
30+
to be tracked. This affects and improves most security queries, which may
31+
report additional results.
2832
* Identification of test classes has been improved. Previously, one of the
2933
match conditions would classify any class with a name containing the string
3034
"Test" as a test class, but now this matching has been replaced with one that
3135
looks for the occurrence of actual unit-test annotations. This affects the
3236
general file classification mechanism and thus suppression of alerts, and
3337
also any security queries using taint tracking, as test classes act as
3438
default barriers stopping taint flow.
39+
* Parentheses are now no longer modelled directly in the AST, that is, the
40+
`ParExpr` class is empty. Instead, a parenthesized expression can be
41+
identified with the `Expr.isParenthesized()` member predicate.

change-notes/1.24/analysis-javascript.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
* Imports with the `.js` extension can now be resolved to a TypeScript file,
88
when the import refers to a file generated by TypeScript.
99

10-
- The analysis of sanitizer guards has improved, leading to fewer false-positive results from the security queries.
10+
* Imports that rely on path-mappings from a `tsconfig.json` file can now be resolved.
11+
12+
* The analysis of sanitizer guards has improved, leading to fewer false-positive results from the security queries.
1113

1214
* Support for the following frameworks and libraries has been improved:
1315
- [react](https://www.npmjs.com/package/react)
@@ -18,6 +20,7 @@
1820
- [Socket.IO](https://socket.io/)
1921
- [ws](https://github.com/websockets/ws)
2022
- [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API)
23+
- [Koa](https://www.npmjs.com/package/koa)
2124

2225
## New queries
2326

cpp/ql/src/Architecture/FeatureEnvy.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ predicate functionUsesFunction(Function source, Function f, File target) {
2525
}
2626

2727
predicate dependencyCount(Function source, File target, int res) {
28-
res = strictcount(Declaration d |
28+
res =
29+
strictcount(Declaration d |
2930
functionUsesVariable(source, d, target) or
3031
functionUsesFunction(source, d, target)
3132
)

cpp/ql/src/Architecture/General Top-Level Information/GeneralStatistics.ql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@ where
3838
n = count(Function f | f.fromSource()).toString()
3939
or
4040
l = "Number of Lines Of Code" and
41-
n = sum(File f, int toSum |
41+
n =
42+
sum(File f, int toSum |
4243
f.fromSource() and toSum = f.getMetrics().getNumberOfLinesOfCode()
4344
|
4445
toSum
4546
).toString()
4647
or
4748
l = "Self-Containedness" and
48-
n = (
49+
n =
50+
(
4951
100 * sum(Class c | c.fromSource() | c.getMetrics().getEfferentSourceCoupling()) /
5052
sum(Class c | c.fromSource() | c.getMetrics().getEfferentCoupling())
5153
).toString() + "%"

cpp/ql/src/Architecture/Refactoring Opportunities/ClassesWithManyFields.ql

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,8 @@ class VariableDeclarationLine extends TVariableDeclarationInfo {
8080
* (that is, the first is 0, the second is 1 and so on).
8181
*/
8282
private int getRank() {
83-
line = rank[result](VariableDeclarationLine vdl, int l |
84-
vdl = TVariableDeclarationLine(c, f, l)
85-
|
86-
l
87-
)
83+
line =
84+
rank[result](VariableDeclarationLine vdl, int l | vdl = TVariableDeclarationLine(c, f, l) | l)
8885
}
8986

9087
/**
@@ -133,7 +130,8 @@ class VariableDeclarationGroup extends VariableDeclarationLine {
133130
* Gets the number of uniquely named `VariableDeclarationEntry`s in this group.
134131
*/
135132
int getCount() {
136-
result = count(VariableDeclarationLine l |
133+
result =
134+
count(VariableDeclarationLine l |
137135
l = getProximateNext*()
138136
|
139137
l.getAVDE().getVariable().getName()
@@ -166,7 +164,8 @@ class ExtClass extends Class {
166164

167165
from ExtClass c, int n, VariableDeclarationGroup vdg, string suffix
168166
where
169-
n = strictcount(string fieldName |
167+
n =
168+
strictcount(string fieldName |
170169
exists(Field f |
171170
f.getDeclaringType() = c and
172171
fieldName = f.getName() and

cpp/ql/src/Best Practices/Likely Errors/EmptyBlock.ql

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,24 @@ class BlockOrNonChild extends Element {
5050

5151
private int getNonContiguousStartRankIn(AffectedFile file) {
5252
// When using `rank` with `order by`, the ranks may not be contiguous.
53-
this = rank[result](BlockOrNonChild boc, int startLine, int startCol |
53+
this =
54+
rank[result](BlockOrNonChild boc, int startLine, int startCol |
5455
boc.getLocation().hasLocationInfo(file.getAbsolutePath(), startLine, startCol, _, _)
5556
|
5657
boc order by startLine, startCol
5758
)
5859
}
5960

6061
int getStartRankIn(AffectedFile file) {
61-
this.getNonContiguousStartRankIn(file) = rank[result](int rnk |
62+
this.getNonContiguousStartRankIn(file) =
63+
rank[result](int rnk |
6264
exists(BlockOrNonChild boc | boc.getNonContiguousStartRankIn(file) = rnk)
6365
)
6466
}
6567

6668
int getNonContiguousEndRankIn(AffectedFile file) {
67-
this = rank[result](BlockOrNonChild boc, int endLine, int endCol |
69+
this =
70+
rank[result](BlockOrNonChild boc, int endLine, int endCol |
6871
boc.getLocation().hasLocationInfo(file.getAbsolutePath(), _, _, endLine, endCol)
6972
|
7073
boc order by endLine, endCol
@@ -79,9 +82,8 @@ predicate emptyBlockContainsNonchild(Block b) {
7982
emptyBlock(_, b) and
8083
exists(BlockOrNonChild c, AffectedFile file |
8184
c.(BlockOrNonChild).getStartRankIn(file) = 1 + b.(BlockOrNonChild).getStartRankIn(file) and
82-
c.(BlockOrNonChild).getNonContiguousEndRankIn(file) < b
83-
.(BlockOrNonChild)
84-
.getNonContiguousEndRankIn(file)
85+
c.(BlockOrNonChild).getNonContiguousEndRankIn(file) <
86+
b.(BlockOrNonChild).getNonContiguousEndRankIn(file)
8587
)
8688
}
8789

cpp/ql/src/Best Practices/Magic Constants/MagicConstants.qll

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ predicate nonTrivialValue(string value, Literal literal) {
307307
}
308308

309309
predicate valueOccurrenceCount(string value, int n) {
310-
n = strictcount(Location loc |
310+
n =
311+
strictcount(Location loc |
311312
exists(Literal lit | lit.getLocation() = loc | nonTrivialValue(value, lit)) and
312313
// Exclude generated files (they do not have the same maintainability
313314
// concerns as ordinary source files)
@@ -338,7 +339,8 @@ predicate check(Literal lit, string value, int n, File f) {
338339
}
339340

340341
predicate checkWithFileCount(string value, int overallCount, int fileCount, File f) {
341-
fileCount = strictcount(Location loc |
342+
fileCount =
343+
strictcount(Location loc |
342344
exists(Literal lit | lit.getLocation() = loc | check(lit, value, overallCount, f))
343345
)
344346
}
@@ -364,7 +366,8 @@ predicate firstOccurrence(Literal lit, string value, int n) {
364366
predicate magicConstant(Literal e, string msg) {
365367
exists(string value, int n |
366368
firstOccurrence(e, value, n) and
367-
msg = "Magic constant: literal '" + value + "' is repeated " + n.toString() +
369+
msg =
370+
"Magic constant: literal '" + value + "' is repeated " + n.toString() +
368371
" times and should be encapsulated in a constant."
369372
)
370373
}

cpp/ql/src/Best Practices/RuleOfTwo.ql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ import cpp
2828
// design question and carries has no safety risk.
2929
predicate generatedCopyAssignment(CopyConstructor cc, string msg) {
3030
cc.getDeclaringType().hasImplicitCopyAssignmentOperator() and
31-
msg = "No matching copy assignment operator in class " + cc.getDeclaringType().getName() +
31+
msg =
32+
"No matching copy assignment operator in class " + cc.getDeclaringType().getName() +
3233
". It is good practice to match a copy constructor with a " + "copy assignment operator."
3334
}
3435

3536
predicate generatedCopyConstructor(CopyAssignmentOperator ca, string msg) {
3637
ca.getDeclaringType().hasImplicitCopyConstructor() and
37-
msg = "No matching copy constructor in class " + ca.getDeclaringType().getName() +
38+
msg =
39+
"No matching copy constructor in class " + ca.getDeclaringType().getName() +
3840
". It is good practice to match a copy assignment operator with a " + "copy constructor."
3941
}
4042

0 commit comments

Comments
 (0)