Skip to content

Commit 0be13e4

Browse files
committed
Merge remote-tracking branch 'upstream/master' into MissingEnumCaseInSwitch-perf
2 parents d686347 + ec90627 commit 0be13e4

File tree

2,174 files changed

+126609
-57310
lines changed

Some content is hidden

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

2,174 files changed

+126609
-57310
lines changed

.codeqlmanifest.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
"*/ql/test/qlpack.yml",
33
"*/upgrades/qlpack.yml",
44
"misc/legacy-support/*/qlpack.yml",
5-
"misc/suite-helpers/qlpack.yml",
6-
"codeql/.codeqlmanifest.json" ] }
5+
"misc/suite-helpers/qlpack.yml" ] }

.github/labeler.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"C++":
2+
- cpp/**/*
3+
- change-notes/**/*cpp*
4+
5+
"C#":
6+
- csharp/**/*
7+
- change-notes/**/*csharp*
8+
9+
Java:
10+
- java/**/*
11+
- change-notes/**/*java.*
12+
13+
JS:
14+
- javascript/**/*
15+
- change-notes/**/*javascript*
16+
17+
Python:
18+
- python/**/*
19+
- change-notes/**/*python*
20+
21+
documentation:
22+
- "**/*.qhelp"
23+
- "**/*.md"
24+
- docs/**/*

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# editor and OS artifacts
22
*~
33
.DS_STORE
4+
*.swp
45

56
# query compilation caches
67
.cache
@@ -15,3 +16,5 @@
1516

1617
# It's useful (though not required) to be able to unpack codeql in the ql checkout itself
1718
/codeql/
19+
.vscode/settings.json
20+
csharp/extractor/Semmle.Extraction.CSharp.Driver/Properties/launchSettings.json

CONTRIBUTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ Follow the steps below to help other users understand what your query does, and
4646
Query help files explain the purpose of your query to other users. Write your query help in a `.qhelp` file and save it in the same directory as your new query.
4747
For more information on writing query help, see the [Query help style guide](https://github.com/Semmle/ql/blob/master/docs/query-help-style-guide.md).
4848

49+
7. **Maintain backwards compatibility**
50+
51+
The standard CodeQL libraries must evolve in a backwards compatible manner. If any backwards incompatible changes need to be made, the existing API must first be marked as deprecated. This is done by adding a `deprecated` annotation along with a QLDoc reference to the replacement API. Only after at least one full release cycle has elapsed may the old API be removed.
52+
53+
In addition to contributions to our standard queries and libraries, we also welcome contributions of a more experimental nature, which do not need to fulfill all the requirements listed above. See the guidelines for [experimental queries and libraries](docs/experimental.md) for details.
54+
4955
## Using your personal data
5056

5157
If you contribute to this project, we will record your name and email

change-notes/1.24/analysis-cpp.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Improvements to C/C++ analysis
2+
3+
The following changes in version 1.24 affect C/C++ analysis in all applications.
4+
5+
## General improvements
6+
7+
## New queries
8+
9+
| **Query** | **Tags** | **Purpose** |
10+
|-----------------------------|-----------|--------------------------------------------------------------------|
11+
| Implicit function declarations (`cpp/Likely Bugs/Underspecified Functions/ImplicitFunctionDeclaration.ql`) | correctness, maintainability | This query finds calls to undeclared functions that are compiled by a C compiler. Results are shown on LGTM by default. |
12+
13+
## Changes to existing queries
14+
15+
| **Query** | **Expected impact** | **Change** |
16+
|----------------------------|------------------------|------------------------------------------------------------------|
17+
| Buffer not sufficient for string (`cpp/overflow-calculated`) | More true positive results | This query now identifies a wider variety of buffer allocations using the `semmle.code.cpp.models.interfaces.Allocation` library. |
18+
| No space for zero terminator (`cpp/no-space-for-terminator`) | More true positive results | This query now identifies a wider variety of buffer allocations using the `semmle.code.cpp.models.interfaces.Allocation` library. |
19+
| Memory is never freed (`cpp/memory-never-freed`) | More true positive results | This query now identifies a wider variety of buffer allocations using the `semmle.code.cpp.models.interfaces.Allocation` library. |
20+
| Memory may not be freed (`cpp/memory-may-not-be-freed`) | More true positive results | This query now identifies a wider variety of buffer allocations using the `semmle.code.cpp.models.interfaces.Allocation` library. |
21+
| Missing return statement (`cpp/missing-return`) | Fewer false positive results | Functions containing `asm` statements are no longer highlighted by this query. |
22+
| No space for zero terminator (`cpp/no-space-for-terminator`) | More correct results | String arguments to formatting functions are now (usually) expected to be null terminated strings. |
23+
| Hard-coded Japanese era start date (`cpp/japanese-era/exact-era-date`) | | This query is no longer run on LGTM. |
24+
| No space for zero terminator (`cpp/no-space-for-terminator`) | Fewer false positive results | This query has been modified to be more conservative when identifying which pointers point to null-terminated strings. This approach produces fewer, more accurate results. |
25+
| Overloaded assignment does not return 'this' (`cpp/assignment-does-not-return-this`) | Fewer false positive results | This query no longer reports incorrect results in template classes. |
26+
| Unsafe array for days of the year (`cpp/leap-year/unsafe-array-for-days-of-the-year`) | | This query is no longer run on LGTM. |
27+
28+
## Changes to libraries
29+
30+
* The data-flow library has been improved, which affects and improves some security queries. The improvements are:
31+
- Track flow through functions that combine taint tracking with flow through fields.
32+
- Track flow through clone-like functions, that is, functions that read contents of a field from a
33+
parameter and stores the value in the field of a returned object.
34+
* 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.
35+
* 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.
36+
* The new class `StackVariable` should be used in place of `LocalScopeVariable`
37+
in most cases. The difference is that `StackVariable` does not include
38+
variables declared with `static` or `thread_local`.
39+
* As a rule of thumb, custom queries about the _values_ of variables should
40+
be changed from `LocalScopeVariable` to `StackVariable`, while queries
41+
about the _name or scope_ of variables should remain unchanged.
42+
* The `LocalScopeVariableReachability` library is deprecated in favor of
43+
`StackVariableReachability`. The functionality is the same.
44+
* The models library models `strlen` in more detail, and includes common variations such as `wcslen`.
45+
* The taint tracking library (`semmle.code.cpp.dataflow.TaintTracking`) has had
46+
the following improvements:
47+
* The library now models data flow through `strdup` and similar functions.
48+
* The library now models data flow through formatting functions such as `sprintf`.
49+
* The security pack taint tracking library (`semmle.code.cpp.security.TaintTracking`) uses a new intermediate representation. This provides a more precise analysis of pointers to stack variables and flow through parameters, improving the results of many security queries.
50+
* The global value numbering library (`semmle.code.cpp.valuenumbering.GlobalValueNumbering`) uses a new intermediate representation to provide a more precise analysis of heap allocated memory and pointers to stack variables.

change-notes/1.24/analysis-csharp.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Improvements to C# analysis
2+
3+
The following changes in version 1.24 affect C# analysis in all applications.
4+
5+
## New queries
6+
7+
| **Query** | **Tags** | **Purpose** |
8+
|-----------------------------|-----------|--------------------------------------------------------------------|
9+
| Assembly path injection (`cs/assembly-path-injection`) | security, external/cwe/cwe-114 | Finds user-controlled data used to load an assembly. |
10+
| 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. |
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. |
15+
16+
## Changes to existing queries
17+
18+
| **Query** | **Expected impact** | **Change** |
19+
|------------------------------|------------------------|-----------------------------------|
20+
| Useless assignment to local variable (`cs/useless-assignment-to-local`) | Fewer false positive results | Results have been removed when the variable is named `_` in a `foreach` statement. |
21+
| Potentially dangerous use of non-short-circuit logic (`cs/non-short-circuit`) | Fewer false positive results | Results have been removed when the expression contains an `out` parameter. |
22+
| Dereferenced variable may be null (`cs/dereferenced-value-may-be-null`) | More results | Results are reported from parameters with a default value of `null`. |
23+
| Useless assignment to local variable (`cs/useless-assignment-to-local`) | Fewer false positive results | Results have been removed when the value assigned is an (implicitly or explicitly) cast default-like value. For example, `var s = (string)null` and `string s = default`. |
24+
25+
## Removal of old queries
26+
27+
## Changes to code extraction
28+
29+
* Tuple expressions, for example `(int,bool)` in `default((int,bool))` are now extracted correctly.
30+
* Expression nullability flow state is extracted.
31+
* Implicitly typed `stackalloc` expressions are now extracted correctly.
32+
* The difference between `stackalloc` array creations and normal array creations is extracted.
33+
34+
## Changes to libraries
35+
36+
* The data-flow library has been improved, which affects and improves most security queries. The improvements are:
37+
- Track flow through methods that combine taint tracking with flow through fields.
38+
- Track flow through clone-like methods, that is, methods that read contents of a field from a
39+
parameter and stores the value in the field of a returned object.
40+
* The taint tracking library now tracks flow through (implicit or explicit) conversion operator calls.
41+
* [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.
42+
* Expression nullability flow state is given by the predicates `Expr.hasNotNullFlowState()` and `Expr.hasMaybeNullFlowState()`.
43+
* `stackalloc` array creations are now represented by the QL class `Stackalloc`. Previously they were represented by the class `ArrayCreation`.
44+
45+
## Changes to autobuilder

change-notes/1.24/analysis-java.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Improvements to Java analysis
2+
3+
The following changes in version 1.24 affect Java analysis in all applications.
4+
5+
## General improvements
6+
7+
* Alert suppression can now be done with single-line block comments (`/* ... */`) as well as line comments (`// ...`).
8+
9+
## New queries
10+
11+
| **Query** | **Tags** | **Purpose** |
12+
|-----------------------------|-----------|--------------------------------------------------------------------|
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. Results are shown on LGTM by default. |
14+
| 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+
| LDAP query built from user-controlled sources (`java/ldap-injection`) | security, external/cwe/cwe-090 | Finds LDAP queries vulnerable to injection of unsanitized user-controlled input. Results are shown on LGTM by default. |
16+
| 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. |
17+
| Suspicious date format (`java/suspicious-date-format`) | correctness | Finds date format patterns that use placeholders that are likely to be incorrect. Results are shown on LGTM by default. |
18+
19+
## Changes to existing queries
20+
21+
| **Query** | **Expected impact** | **Change** |
22+
|------------------------------|------------------------|-----------------------------------|
23+
| 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. |
24+
| 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`. |
25+
| Useless null check (`java/useless-null-check`) | More true positives | Useless checks on final fields with a non-null initializer are now reported. |
26+
27+
## Changes to libraries
28+
29+
* The data-flow library has been improved, which affects and improves most security queries. The improvements are:
30+
- Track flow through methods that combine taint tracking with flow through fields.
31+
- Track flow through clone-like methods, that is, methods that read contents of a field from a
32+
parameter and stores the value in the field of a returned object.
33+
* Identification of test classes has been improved. Previously, one of the
34+
match conditions would classify any class with a name containing the string
35+
"Test" as a test class, but now this matching has been replaced with one that
36+
looks for the occurrence of actual unit-test annotations. This affects the
37+
general file classification mechanism and thus suppression of alerts, and
38+
also any security queries using taint tracking, as test classes act as
39+
default barriers stopping taint flow.
40+
* Parentheses are now no longer modelled directly in the AST, that is, the
41+
`ParExpr` class is empty. Instead, a parenthesized expression can be
42+
identified with the `Expr.isParenthesized()` member predicate.

0 commit comments

Comments
 (0)