Skip to content

Commit 4617940

Browse files
author
Robert Marsh
committed
Merge branch 'master' into connect-ir-dataflow-models
2 parents 1b9e375 + b2a87f6 commit 4617940

File tree

518 files changed

+9567
-2578
lines changed

Some content is hidden

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

518 files changed

+9567
-2578
lines changed

change-notes/1.24/analysis-cpp.md

Lines changed: 5 additions & 1 deletion
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`
@@ -40,4 +44,4 @@ The following changes in version 1.24 affect C/C++ analysis in all applications.
4044
* The taint tracking library (`semmle.code.cpp.dataflow.TaintTracking`) has had
4145
the following improvements:
4246
* The library now models data flow through `strdup` and similar functions.
43-
47+
* The library now models data flow through formatting functions such as `sprintf`.

change-notes/1.24/analysis-csharp.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ The following changes in version 1.24 affect C# analysis in all applications.
66

77
| **Query** | **Tags** | **Purpose** |
88
|-----------------------------|-----------|--------------------------------------------------------------------|
9+
| Assembly path injection (`cs/assembly-path-injection`) | security, external/cwe/cwe-114 | Finds user-controlled data used to load an assembly. |
910
| Insecure configuration for ASP.NET requestValidationMode (`cs/insecure-request-validation-mode`) | security, external/cwe/cwe-016 | Finds where this attribute has been set to a value less than 4.5, which turns off some validation features and makes the application less secure. |
10-
| Page request validation is disabled (`cs/web/request-validation-disabled`) | security, frameworks/asp.net, external/cwe/cwe-016 | Finds where ASP.NET page request validation has been disabled, which could makes the application less secure. |
11+
| Insecure SQL connection (`cs/insecure-sql-connection`) | security, external/cwe/cwe-327 | Finds unencrypted SQL connection strings. |
12+
| Page request validation is disabled (`cs/web/request-validation-disabled`) | security, frameworks/asp.net, external/cwe/cwe-016 | Finds where ASP.NET page request validation has been disabled, which could make the application less secure. |
13+
| Serialization check bypass (`cs/serialization-check-bypass`) | security, external/cwe/cwe-20 | Finds where data is not validated in a deserialization method. |
14+
| XML injection (`cs/xml-injection`) | security, external/cwe/cwe-091 | Finds user-controlled data that is used to write directly to an XML document. |
1115

1216
## Changes to existing queries
1317

@@ -25,9 +29,12 @@ The following changes in version 1.24 affect C# analysis in all applications.
2529

2630
## Changes to libraries
2731

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.
2836
* The taint tracking library now tracks flow through (implicit or explicit) conversion operator calls.
2937
* [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.
3038
* Expression nullability flow state is given by the predicates `Expr.hasNotNullFlowState()` and `Expr.hasMaybeNullFlowState()`.
3139

3240
## Changes to autobuilder
33-

change-notes/1.24/analysis-java.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,25 @@ The following changes in version 1.24 affect Java analysis in all applications.
1010

1111
| **Query** | **Tags** | **Purpose** |
1212
|-----------------------------|-----------|--------------------------------------------------------------------|
13+
| Disabled Spring CSRF protection (`java/spring-disabled-csrf-protection`) | security, external/cwe/cwe-352 | Finds disabled Cross-Site Request Forgery (CSRF) protection in Spring. |
1314
| Failure to use HTTPS or SFTP URL in Maven artifact upload/download (`java/maven/non-https-url`) | security, external/cwe/cwe-300, external/cwe/cwe-319, external/cwe/cwe-494, external/cwe/cwe-829 | Finds use of insecure protocols during Maven dependency resolution. Results are shown on LGTM by default. |
15+
| Left shift by more than the type width (`java/lshift-larger-than-type-width`) | correctness | Finds left shifts of ints by 32 bits or more and left shifts of longs by 64 bits or more. Results are shown on LGTM by default. |
1416
| Suspicious date format (`java/suspicious-date-format`) | correctness | Finds date format patterns that use placeholders that are likely to be incorrect. |
1517

1618
## Changes to existing queries
1719

1820
| **Query** | **Expected impact** | **Change** |
1921
|------------------------------|------------------------|-----------------------------------|
2022
| Dereferenced variable may be null (`java/dereferenced-value-may-be-null`) | Fewer false positives | Final fields with a non-null initializer are no longer reported. |
21-
| Expression always evaluates to the same value (`java/evaluation-to-constant`) | Fewer false positives | Expressions of the form `0 * x` are usually intended and no longer reported. |
23+
| Expression always evaluates to the same value (`java/evaluation-to-constant`) | Fewer false positives | Expressions of the form `0 * x` are usually intended and no longer reported. Also left shift of ints by 32 bits and longs by 64 bits are no longer reported as they are not constant, these results are instead reported by the new query `java/lshift-larger-than-type-width`. |
2224
| Useless null check (`java/useless-null-check`) | More true positives | Useless checks on final fields with a non-null initializer are now reported. |
2325

2426
## Changes to libraries
2527

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.
2632
* Identification of test classes has been improved. Previously, one of the
2733
match conditions would classify any class with a name containing the string
2834
"Test" as a test class, but now this matching has been replaced with one that

change-notes/1.24/analysis-javascript.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
| Unbound event handler receiver (`js/unbound-event-handler-receiver`) | Fewer false positive results | This query now recognizes additional ways event handler receivers can be bound. |
3939
| Expression has no effect (`js/useless-expression`) | Fewer false positive results | The query now recognizes block-level flow type annotations and ignores the first statement of a try block. |
4040
| Use of call stack introspection in strict mode (`js/strict-mode-call-stack-introspection`) | Fewer false positive results | The query no longer flags expression statements. |
41+
| Missing CSRF middleware (`js/missing-token-validation`) | Fewer false positive results | The query reports fewer duplicates and only flags handlers that explicitly access cookie data. |
4142

4243
## Changes to libraries
4344

config/identical-files.json

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@
8282
"cpp/ql/src/semmle/code/cpp/ir/implementation/IRType.qll",
8383
"csharp/ql/src/semmle/code/csharp/ir/implementation/IRType.qll"
8484
],
85+
"IR IRConfiguration": [
86+
"cpp/ql/src/semmle/code/cpp/ir/implementation/IRConfiguration.qll",
87+
"csharp/ql/src/semmle/code/csharp/ir/implementation/IRConfiguration.qll"
88+
],
89+
"IR UseSoundEscapeAnalysis": [
90+
"cpp/ql/src/semmle/code/cpp/ir/implementation/UseSoundEscapeAnalysis.qll",
91+
"csharp/ql/src/semmle/code/csharp/ir/implementation/UseSoundEscapeAnalysis.qll"
92+
],
8593
"IR Operand Tag": [
8694
"cpp/ql/src/semmle/code/cpp/ir/implementation/internal/OperandTag.qll",
8795
"csharp/ql/src/semmle/code/csharp/ir/implementation/internal/OperandTag.qll"
@@ -182,9 +190,14 @@
182190
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstructionImports.qll",
183191
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstructionImports.qll"
184192
],
185-
"C++ SSA AliasAnalysis": [
193+
"SSA AliasAnalysis": [
186194
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/AliasAnalysis.qll",
187-
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/AliasAnalysis.qll"
195+
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/AliasAnalysis.qll",
196+
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/internal/AliasAnalysis.qll"
197+
],
198+
"C++ SSA AliasAnalysisImports": [
199+
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/AliasAnalysisImports.qll",
200+
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/AliasAnalysisImports.qll"
188201
],
189202
"C++ IR ValueNumberingImports": [
190203
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/gvn/internal/ValueNumberingImports.qll",
@@ -195,6 +208,10 @@
195208
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SimpleSSA.qll",
196209
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/internal/SimpleSSA.qll"
197210
],
211+
"IR AliasConfiguration (unaliased_ssa)": [
212+
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/AliasConfiguration.qll",
213+
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/internal/AliasConfiguration.qll"
214+
],
198215
"IR SSA SSAConstruction": [
199216
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll",
200217
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll",

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
}

0 commit comments

Comments
 (0)