Skip to content

Commit 2ec107b

Browse files
committed
Merge branch 'master' into CWE-643
2 parents 949914e + 3ae1aad commit 2ec107b

File tree

943 files changed

+49203
-23179
lines changed

Some content is hidden

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

943 files changed

+49203
-23179
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" ] }

.gitignore

Lines changed: 1 addition & 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

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: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@ The following changes in version 1.24 affect C/C++ analysis in all applications.
1919
| 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. |
2020
| 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. |
2121
| 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. |
2223
| Hard-coded Japanese era start date (`cpp/japanese-era/exact-era-date`) | | This query is no longer run on LGTM. |
2324
| 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. |
2425
| 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. |
2526
| 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. |
2627

2728
## Changes to libraries
2829

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.
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.
3334
* 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.
3435
* 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.
3536
* The new class `StackVariable` should be used in place of `LocalScopeVariable`
@@ -45,3 +46,5 @@ The following changes in version 1.24 affect C/C++ analysis in all applications.
4546
the following improvements:
4647
* The library now models data flow through `strdup` and similar functions.
4748
* 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: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,28 @@ The following changes in version 1.24 affect C# analysis in all applications.
1818
| **Query** | **Expected impact** | **Change** |
1919
|------------------------------|------------------------|-----------------------------------|
2020
| 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. |
2122
| 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`. |
2224

2325
## Removal of old queries
2426

2527
## Changes to code extraction
2628

2729
* Tuple expressions, for example `(int,bool)` in `default((int,bool))` are now extracted correctly.
28-
* Expression nullability flow state is extracted.
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.
2933

3034
## Changes to libraries
3135

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.
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.
3640
* The taint tracking library now tracks flow through (implicit or explicit) conversion operator calls.
3741
* [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.
3842
* 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`.
3944

4045
## Changes to autobuilder

change-notes/1.24/analysis-java.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ The following changes in version 1.24 affect Java analysis in all applications.
55
## General improvements
66

77
* Alert suppression can now be done with single-line block comments (`/* ... */`) as well as line comments (`// ...`).
8+
* A `Customizations.qll` file has been added to allow customizations of the standard library that apply to all queries.
89

910
## New queries
1011

1112
| **Query** | **Tags** | **Purpose** |
1213
|-----------------------------|-----------|--------------------------------------------------------------------|
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. |
14+
| 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. |
1415
| 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. |
16+
| 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. |
1517
| 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. |
16-
| Suspicious date format (`java/suspicious-date-format`) | correctness | Finds date format patterns that use placeholders that are likely to be incorrect. |
18+
| 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. |
1719

1820
## Changes to existing queries
1921

@@ -25,10 +27,10 @@ The following changes in version 1.24 affect Java analysis in all applications.
2527

2628
## Changes to libraries
2729

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.
30+
* The data-flow library has been improved, which affects and improves most security queries. The improvements are:
31+
- Track flow through methods that combine taint tracking with flow through fields.
32+
- Track flow through clone-like methods, that is, methods that read contents of a field from a
33+
parameter and stores the value in the field of a returned object.
3234
* Identification of test classes has been improved. Previously, one of the
3335
match conditions would classify any class with a name containing the string
3436
"Test" as a test class, but now this matching has been replaced with one that

change-notes/1.24/analysis-javascript.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,40 @@
22

33
## General improvements
44

5+
* TypeScript 3.8 is now supported.
6+
57
* Alert suppression can now be done with single-line block comments (`/* ... */`) as well as line comments (`// ...`).
68

79
* Imports with the `.js` extension can now be resolved to a TypeScript file,
810
when the import refers to a file generated by TypeScript.
911

1012
* Imports that rely on path-mappings from a `tsconfig.json` file can now be resolved.
1113

14+
* Export declarations of the form `export * as ns from "x"` are now analyzed more precisely.
15+
1216
* The analysis of sanitizer guards has improved, leading to fewer false-positive results from the security queries.
1317

18+
* The call graph construction has been improved, leading to more results from the security queries:
19+
- Calls can now be resolved to indirectly-defined class members in more cases.
20+
- Calls through partial invocations such as `.bind` can now be resolved in more cases.
21+
1422
* Support for the following frameworks and libraries has been improved:
15-
- [react](https://www.npmjs.com/package/react)
16-
- [typeahead.js](https://www.npmjs.com/package/typeahead.js)
17-
- [Handlebars](https://www.npmjs.com/package/handlebars)
1823
- [Electron](https://electronjs.org/)
24+
- [Handlebars](https://www.npmjs.com/package/handlebars)
25+
- [Koa](https://www.npmjs.com/package/koa)
1926
- [Node.js](https://nodejs.org/)
2027
- [Socket.IO](https://socket.io/)
21-
- [ws](https://github.com/websockets/ws)
2228
- [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API)
23-
- [Koa](https://www.npmjs.com/package/koa)
29+
- [chrome-remote-interface](https://www.npmjs.com/package/chrome-remote-interface)
30+
- [for-in](https://www.npmjs.com/package/for-in)
31+
- [for-own](https://www.npmjs.com/package/for-own)
32+
- [http2](https://nodejs.org/api/http2.html)
33+
- [lazy-cache](https://www.npmjs.com/package/lazy-cache)
34+
- [react](https://www.npmjs.com/package/react)
35+
- [request](https://www.npmjs.com/package/request)
36+
- [send](https://www.npmjs.com/package/send)
37+
- [typeahead.js](https://www.npmjs.com/package/typeahead.js)
38+
- [ws](https://github.com/websockets/ws)
2439

2540
## New queries
2641

@@ -29,7 +44,11 @@
2944
| Cross-site scripting through exception (`js/xss-through-exception`) | security, external/cwe/cwe-079, external/cwe/cwe-116 | Highlights potential XSS vulnerabilities where an exception is written to the DOM. Results are not shown on LGTM by default. |
3045
| Regular expression always matches (`js/regex/always-matches`) | correctness, regular-expressions | Highlights regular expression checks that trivially succeed by matching an empty substring. Results are shown on LGTM by default. |
3146
| Missing await (`js/missing-await`) | correctness | Highlights expressions that operate directly on a promise object in a nonsensical way, instead of awaiting its result. Results are shown on LGTM by default. |
32-
| Prototype pollution in utility function (`js/prototype-pollution-utility`) | security, external/cwe/cwe-400, external/cwe/cwe-471 | Highlights recursive copying operations that are susceptible to prototype pollution. Results are shown on LGTM by default. |
47+
| Polynomial regular expression used on uncontrolled data (`js/polynomial-redos`) | security, external/cwe/cwe-730, external/cwe/cwe-400 | Highlights expensive regular expressions that may be used on malicious input. Results are shown on LGTM by default. |
48+
| Prototype pollution in utility function (`js/prototype-pollution-utility`) | security, external/cwe/cwe-400, external/cwe/cwe-471 | Highlights recursive assignment operations that are susceptible to prototype pollution. Results are shown on LGTM by default. |
49+
| Unsafe jQuery plugin (`js/unsafe-jquery-plugin`) | Highlights potential XSS vulnerabilities in unsafely designed jQuery plugins. Results are shown on LGTM by default. |
50+
| Unnecessary use of `cat` process (`js/unnecessary-use-of-cat`) | correctness, security, maintainability | Highlights command executions of `cat` where the fs API should be used instead. Results are shown on LGTM by default. |
51+
3352

3453
## Changes to existing queries
3554

@@ -42,6 +61,9 @@
4261
| 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. |
4362
| 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. |
4463
| 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. |
64+
| Uncontrolled data used in path expression (`js/path-injection`) | More results | This query now recognizes additional ways dangerous paths can be constructed and used. |
65+
| Uncontrolled command line (`js/command-line-injection`) | More results | This query now recognizes additional ways of constructing arguments to `cmd.exe` and `/bin/sh`. |
66+
| Syntax error (`js/syntax-error`) | Lower severity | This results of this query are now displayed with lower severity. |
4567

4668
## Changes to libraries
4769

change-notes/1.24/analysis-python.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Improvements to Python analysis
2+
3+
The following changes in version 1.24 affect Python analysis in all applications.
4+
5+
## General improvements
6+
7+
## New queries
8+
9+
| **Query** | **Tags** | **Purpose** |
10+
|-----------------------------|-----------|--------------------------------------------------------------------|
11+
12+
## Changes to existing queries
13+
14+
| **Query** | **Expected impact** | **Change** |
15+
|----------------------------|------------------------|------------------------------------------------------------------|
16+
17+
### Web framework support
18+
19+
The QL-library support for the web frameworks Bottle, CherryPy, Falcon, Pyramid, TurboGears, Tornado, and Twisted have
20+
been fixed so they provide a proper HttpRequestTaintSource, instead of a TaintSource. This will enable results for the following queries:
21+
22+
- py/path-injection
23+
- py/command-line-injection
24+
- py/reflective-xss
25+
- py/sql-injection
26+
- py/code-injection
27+
- py/unsafe-deserialization
28+
- py/url-redirection
29+
30+
The QL-library support for the web framework Twisted have been fixed so they provide a proper
31+
HttpResponseTaintSink, instead of a TaintSink. This will enable results for the following
32+
queries:
33+
34+
- py/reflective-xss
35+
- py/stack-trace-exposure
36+
37+
## Changes to libraries

config/identical-files.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,14 @@
222222
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/PrintSSA.qll",
223223
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/internal/PrintSSA.qll"
224224
],
225-
"IR ValueNumber": [
225+
"IR ValueNumberInternal": [
226+
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/gvn/internal/ValueNumberingInternal.qll",
227+
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/gvn/internal/ValueNumberingInternal.qll",
228+
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/gvn/internal/ValueNumberingInternal.qll",
229+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/gvn/internal/ValueNumberingInternal.qll",
230+
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/gvn/internal/ValueNumberingInternal.qll"
231+
],
232+
"C++ IR ValueNumber": [
226233
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/gvn/ValueNumbering.qll",
227234
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/gvn/ValueNumbering.qll",
228235
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/gvn/ValueNumbering.qll",

0 commit comments

Comments
 (0)