Skip to content

Commit 8d774cd

Browse files
committed
Merge branch 'master' into python-unsafe-use-of-mktemp
2 parents 08fcb98 + 9d78779 commit 8d774cd

File tree

1,572 files changed

+108468
-94693
lines changed

Some content is hidden

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

1,572 files changed

+108468
-94693
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ This open source repository contains the standard QL libraries and queries that
44

55
## How do I learn QL and run queries?
66

7-
LGTM has [extensive documentation](https://lgtm.com/help/ql/introduction-to-ql) on getting started with writing QL.
8-
You can use the [interactive query console](https://lgtm.com/help/lgtm/using-query-console) or the [QL for Eclipse](https://lgtm.com/help/lgtm/running-queries-ide) plugin to try out your queries on any open-source project that's currently being analyzed.
7+
There is [extensive documentation](https://help.semmle.com/QL/learn-ql/) on getting started with writing QL.
8+
You can use the [interactive query console](https://lgtm.com/help/lgtm/using-query-console) on LGTM.com or the [QL for Eclipse](https://lgtm.com/help/lgtm/running-queries-ide) plugin to try out your queries on any open-source project that's currently being analyzed.
99

1010
## Contributing
1111

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
Frameworks and libraries
2+
########################
3+
4+
The QL libraries and queries in this version have been explicitly checked against the libraries and frameworks listed below.
5+
6+
.. pull-quote::
7+
8+
Tip
9+
10+
If you're interested in other libraries or frameworks, you can extend the analysis to cover them.
11+
For example, by extending the data flow libraries to include data sources and sinks for additional libraries or frameworks.
12+
13+
.. There is currently no built-in support for libraries or frameworks for C/C++.
14+
15+
C# built-in support
16+
================================
17+
18+
* ASP.Net MVC framework
19+
* ASP.NET Web API
20+
* ASP.NET Web Forms
21+
* ASP.NET Core
22+
* ASP.NET Core MVC
23+
* ASP.Net Core Razor
24+
* Razor templates
25+
26+
27+
COBOL built-in support
28+
===================================
29+
30+
* Embedded SQL
31+
* Embedded CICS
32+
33+
34+
Java built-in support
35+
==================================
36+
37+
.. csv-table::
38+
:file: java-frameworks.csv
39+
:header-rows: 1
40+
:class: fullWidthTable
41+
:widths: auto
42+
43+
44+
JavaScript and TypeScript built-in support
45+
=======================================================
46+
47+
.. csv-table::
48+
:file: javascript-typescript-frameworks.csv
49+
:header-rows: 1
50+
:class: fullWidthTable
51+
:widths: auto
52+
53+
54+
Python built-in support
55+
====================================
56+
57+
.. csv-table::
58+
:file: python-frameworks.csv
59+
:header-rows: 1
60+
:class: fullWidthTable
61+
:widths: auto
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Name, Category
2+
Hibernate, Database
3+
iBatis / MyBatis, Database
4+
Java Persistence API (JPA), Database
5+
JDBC, Database
6+
Kryo deserialization, Serialization
7+
SnakeYaml, Serialization
8+
Spring JDBC, Database
9+
Spring MVC, Web application framework
10+
XStream, Serialization
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Name, Category
2+
angularjs, HTML framework
3+
axios, Network communicator
4+
browser, Runtime environment
5+
electron, Runtime environment
6+
express, Server
7+
hapi, Server
8+
jquery, Utility library
9+
koa, Server
10+
lodash, Utility library
11+
mongodb, Database
12+
mssql, Database
13+
mysql, Database
14+
node, Runtime environment
15+
postgres, Database
16+
ramda, Utility library
17+
react, HTML framework
18+
request, Network communicator
19+
sequelize, Database
20+
sqlite3, Database
21+
superagent, Network communicator
22+
underscore, Utility library
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Languages and compilers
2+
#######################
3+
4+
QL and LGTM version |version| support analysis of the following languages compiled by the following compilers.
5+
6+
Note that where there are several versions or dialects of a language, the supported variants are listed.
7+
8+
.. csv-table::
9+
:file: versions-compilers.csv
10+
:header-rows: 1
11+
:widths: auto
12+
:stub-columns: 1
13+
14+
.. container:: footnote-group
15+
16+
.. [1] The best results are achieved with COBOL code that stays close to the ANSI 85 standard.
17+
.. [2] Java 11 refers to the language features used. Builds that execute on Java 6 or higher can be analyzed.
18+
.. [3] JSX and Flow code, YAML, JSON, and HTML files may also be analyzed with JavaScript files.
19+
.. [4] TypeScript analysis is performed by running the JavaScript extractor with TypeScript enabled. This is the default for LGTM.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Name, Category
2+
Django, Web application framework
3+
Flask, Microframework
4+
Pyramid, Web application framework
5+
Tornado, Web application framework and asynchronous networking library
6+
Twisted, Networking engine
7+
WebOb, WSGI request library
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Language,Variants,Compilers,Extensions
2+
C/C++,"C89, C99, C11, C++98, C++03, C++11, C++14, C++17","Clang extensions (up to Clang 6.0)
3+
4+
GNU extensions (up to GCC 7.3),
5+
6+
Microsoft extensions (up to VS 2017)","``.cpp``, ``.c++``, ``.cxx``, ``.hpp``, ``.hh``, ``.h++``, ``.hxx``, ``.c``, ``.cc``, ``.h``"
7+
C#,C# up to 7.2 together with .NET versions up to 4.7.1,"Microsoft Visual Studio up to 2017,
8+
9+
.NET Core up to 2.1","``.sln``, ``.csproj``, ``.cs``, ``.cshtml``, ``.xaml``"
10+
COBOL,ANSI 85 or newer [1]_.,Not applicable,"``.cbl``, ``.CBL``, ``.cpy``, ``.CPY``, ``.copy``, ``.COPY``"
11+
Java,"Java 11 [2]_. or lower","javac (OpenJDK and Oracle JDK)
12+
13+
Eclipse compiler for Java (ECJ) batch compiler",``.java``
14+
JavaScript,ECMAScript 2018 or lower,Not applicable,"``.js``, ``.jsx``, ``.mjs``, ``.es``, ``.es6``, ``.htm``, ``.html``, ``.xhm``, ``.xhtml``, ``.vue``, ``.json`` [3]_."
15+
Python,"2.7, 3.5, 3.6, 3.7",Not applicable,``.py``
16+
TypeScript [4]_.,"2.6, 2.7, 2.8, 2.9, 3.0, 3.1",Standard TypeScript compiler,"``.ts``, ``.tsx``"

change-notes/1.20/analysis-cpp.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,29 @@
1111
| Use of string copy function in a condition (`cpp/string-copy-return-value-as-boolean`) | correctness | This query identifies calls to string copy functions used in conditions, where it's likely that a different function was intended to be called. |
1212
| Lossy function result cast (`cpp/lossy-function-result-cast`) | correctness | Finds function calls whose result type is a floating point type, which are implicitly cast to an integral type. Newly available but not displayed by default on LGTM. |
1313
| Array argument size mismatch (`cpp/array-arg-size-mismatch`) | reliability | Finds function calls where the size of an array being passed is smaller than the array size of the declared parameter. Newly displayed on LGTM. |
14+
| Returning stack-allocated memory (`cpp/return-stack-allocated-memory`) | reliability, external/cwe/cwe-825 | Finds functions that may return a pointer or reference to stack-allocated memory. This query existed already but has been rewritten from scratch to make the error rate low enough for use on LGTM. Displayed by default. |
1415

1516
## Changes to existing queries
1617

1718
| **Query** | **Expected impact** | **Change** |
1819
|----------------------------|------------------------|------------------------------------------------------------------|
1920
| Array argument size mismatch (`cpp/array-arg-size-mismatch`) | Fewer false positives | An exception has been added to this query for variable sized arrays. |
21+
| Call to memory access function may overflow buffer (`cpp/overflow-buffer`) | More correct results | This query now recognizes calls to `RtlCopyMemoryNonTemporal` and `RtlSecureZeroMemory`. |
22+
| Returning stack-allocated memory (`cpp/return-stack-allocated-memory`) | More correct results | Many more stack allocated expressions are now recognized. |
2023
| Suspicious add with sizeof (`cpp/suspicious-add-sizeof`) | Fewer false positives | Pointer arithmetic on `char * const` expressions (and other variations of `char *`) are now correctly excluded from the results. |
2124
| Suspicious pointer scaling (`cpp/suspicious-pointer-scaling`) | Fewer false positives | False positives involving types that are not uniquely named in the snapshot have been fixed. |
2225
| Call to memory access function may overflow buffer (`cpp/overflow-buffer`) | More correct results | Calls to `fread` are now examined by this query. |
2326
| Lossy function result cast (`cpp/lossy-function-result-cast`) | Fewer false positive results | The whitelist of rounding functions built into this query has been expanded. |
2427
| Unused static variable (`cpp/unused-static-variable`) | Fewer false positive results | Variables with the attribute `unused` are now excluded from the query. |
2528
| Resource not released in destructor (`cpp/resource-not-released-in-destructor`) | Fewer false positive results | Fix false positives where a resource is released via a virtual method call, function pointer, or lambda. |
29+
| 'new[]' array freed with 'delete' (`cpp/new-array-delete-mismatch`) | More correct results | Data flow through global variables for this query has been improved. |
30+
| 'new' object freed with 'delete[]' (`cpp/new-delete-array-mismatch`) | More correct results | Data flow through global variables for this query has been improved. |
31+
| Mismatching new/free or malloc/delete (`cpp/new-free-mismatch`) | More correct results | Data flow through global variables for this query has been improved. |
32+
| Use of inherently dangerous function (`cpp/potential-buffer-overflow`) | Cleaned up | This query no longer catches uses of `gets`, and has been renamed 'Potential buffer overflow'. |
33+
| Use of potentially dangerous function (`cpp/potentially-dangerous-function`) | More correct results | This query now catches uses of `gets`. |
2634

2735
## Changes to QL libraries
2836

29-
There is a new `Namespace.isInline()` predicate, which holds if the namespace was declared as `inline namespace`.
37+
* There is a new `Namespace.isInline()` predicate, which holds if the namespace was declared as `inline namespace`.
38+
* The `Expr.isConstant()` predicate now also holds for _address constant expressions_, which are addresses that will be constant after the program has been linked. These address constants do not have a result for `Expr.getValue()`.
39+
* There are new `Function.isDeclaredConstexpr()` and `Function.isConstexpr()` predicates. They can be used to tell whether a function was declared as `constexpr`, and whether it actually is `constexpr`.

change-notes/1.20/analysis-csharp.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@
1111

1212
| *@name of query (Query ID)* | *Impact on results* | *How/why the query has changed* |
1313
|------------------------------|------------------------|-----------------------------------|
14-
| Off-by-one comparison against container length (cs/index-out-of-bounds) | Fewer false positives | Results have been removed when there are additional guards on the index. |
15-
| Dereferenced variable is always null (cs/dereferenced-value-is-always-null) | Improved results | The query has been rewritten from scratch, and the analysis is now based on static single assignment (SSA) forms. The query is now enabled by default in LGTM. |
16-
| Dereferenced variable may be null (cs/dereferenced-value-may-be-null) | Improved results | The query has been rewritten from scratch, and the analysis is now based on static single assignment (SSA) forms. The query is now enabled by default in LGTM. |
17-
| SQL query built from user-controlled sources (cs/sql-injection), Improper control of generation of code (cs/code-injection), Uncontrolled format string (cs/uncontrolled-format-string), Clear text storage of sensitive information (cs/cleartext-storage-of-sensitive-information), Exposure of private information (cs/exposure-of-sensitive-information) | More results | Data sources have been added from user controls in `System.Windows.Forms`. |
18-
| Use of default ToString() (cs/call-to-object-tostring) | Fewer false positives | Results have been removed for `char` arrays passed to `StringBuilder.Append()`, which were incorrectly marked as using `ToString`. |
14+
| Off-by-one comparison against container length (`cs/index-out-of-bounds`) | Fewer false positives | Results have been removed when there are additional guards on the index. |
15+
| Dereferenced variable is always null (`cs/dereferenced-value-is-always-null`) | Improved results | The query has been rewritten from scratch, and the analysis is now based on static single assignment (SSA) forms. The query is now enabled by default in LGTM. |
16+
| Dereferenced variable may be null (`cs/dereferenced-value-may-be-null`) | Improved results | The query has been rewritten from scratch, and the analysis is now based on static single assignment (SSA) forms. The query is now enabled by default in LGTM. |
17+
| SQL query built from user-controlled sources (`cs/sql-injection`), Improper control of generation of code (`cs/code-injection`), Uncontrolled format string (`cs/uncontrolled-format-string`), Clear text storage of sensitive information (`cs/cleartext-storage-of-sensitive-information`), Exposure of private information (`cs/exposure-of-sensitive-information`) | More results | Data sources have been added from user controls in `System.Windows.Forms`. |
18+
| Use of default ToString() (`cs/call-to-object-tostring`) | Fewer false positives | Results have been removed for `char` arrays passed to `StringBuilder.Append()`, which were incorrectly marked as using `ToString`. |
19+
| Use of default ToString() (`cs/call-to-object-tostring`) | Fewer results | Results have been removed when the object is an interface or an abstract class. |
20+
| Unused format argument (`cs/format-argument-unused`) | Fewer false positives | Results have been removed where the format string is empty. This is often used as a default value and is not an interesting result. |
21+
| Double-checked lock is not thread-safe (`cs/unsafe-double-checked-lock`) | Fewer false positives, more true positives | Results have been removed where the underlying field was not updated in the `lock` statement, or where the field is a `struct`. Results have been added where there are other statements inside the `lock` statement. |
22+
| Using a package with a known vulnerability (`cs/use-of-vulnerable-package`) | More results | This query detects packages vulnerable to CVE-2019-0657. |
1923

2024
## Changes to code extraction
2125

@@ -24,6 +28,7 @@
2428

2529
## Changes to QL libraries
2630

27-
* The class `AccessorCall` (and subclasses `PropertyCall`, `IndexerCall`, and `EventCall`) have been redefined, so the expressions they represent are not necessarily the accesses themselves, but rather the expressions that give rise to the accessor calls. For example, in the property assignment `x.Prop = 0`, the call to the setter for `Prop` is no longer represented by the access `x.Prop`, but instead the whole assignment. Consequently, it is no longer safe to cast directly between `AccessorCall`s and `Access`es, and the predicate `AccessorCall::getAccess()` should be used instead.
31+
* The class `TrivialProperty` now includes library properties determined to be trivial using CIL analysis. This may increase the number of results for all queries that use data flow.
32+
* Taint-tracking steps have been added for the `Json.NET` package. This will improve results for queries that use taint-tracking.
2833

2934
## Changes to the autobuilder

change-notes/1.20/analysis-java.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
| **Query** | **Expected impact** | **Change** |
1616
|----------------------------|------------------------|------------------------------------------------------------------|
17+
| Arbitrary file write during archive extraction ("Zip Slip") (`java/zipslip`) | Fewer false positive results | Results involving a sanitization step that converts a destination `Path` to a `File` are no longer reported. |
1718
| Double-checked locking is not thread-safe (`java/unsafe-double-checked-locking`) | Fewer false positive results and more true positive results | Results that use safe publication through a `final` field are no longer reported. Results that initialize immutable types like `String` incorrectly are now reported. |
1819
| Result of multiplication cast to wider type (`java/integer-multiplication-cast-to-long`) | Fewer results | Results involving conversions to `float` or `double` are no longer reported, as they were almost exclusively false positives. |
1920

@@ -24,5 +25,12 @@
2425
`semmle.code.java.dataflow.DataFlow`,
2526
`semmle.code.java.dataflow.TaintTracking`, and
2627
`semmle.code.java.dataflow.FlowSources` since 1.16.
28+
* Taint tracking now includes additional default data-flow steps through
29+
collections, maps, and iterators. This affects all security queries, which
30+
can report more results based on such paths.
31+
* The `FlowSources` and `TaintTracking` libraries are extended to cover additional remote user
32+
input and taint steps from the Apache Thrift, Apache Struts, Guice and Protobuf frameworks.
33+
This affects all security queries, which may yield additional results on projects
34+
that use these frameworks.
2735

2836

0 commit comments

Comments
 (0)