Skip to content

Commit c20b688

Browse files
committed
Merge master into next.
2 parents 3cee874 + f4ec168 commit c20b688

File tree

394 files changed

+5793
-1700
lines changed

Some content is hidden

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

394 files changed

+5793
-1700
lines changed

change-notes/1.19/analysis-cpp.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,33 @@
99
| Cast between `HRESULT` and a Boolean type (`cpp/hresult-boolean-conversion`) | external/cwe/cwe-253 | Finds logic errors caused by mistakenly treating the Windows `HRESULT` type as a Boolean instead of testing it with the appropriate macros. Enabled by default. |
1010
| Setting a DACL to `NULL` in a `SECURITY_DESCRIPTOR` (`cpp/unsafe-dacl-security-descriptor`) | external/cwe/cwe-732 | This query finds code that creates world-writable objects on Windows by setting their DACL to `NULL`. Enabled by default. |
1111
| Cast from `char*` to `wchar_t*` | security, external/cwe/cwe-704 | Detects potentially dangerous casts from `char*` to `wchar_t*`. Enabled by default on LGTM. |
12-
| Dead code due to `goto` or `break` statement (`cpp/dead-code-goto`) | maintainability, external/cwe/cwe-561 | Detects dead code following a goto or break statement. Enabled by default on LGTM. |
12+
| Dead code due to `goto` or `break` statement (`cpp/dead-code-goto`) | maintainability, external/cwe/cwe-561 | Detects dead code following a `goto` or `break` statement. Enabled by default on LGTM. |
13+
| Inconsistent direction of for loop | correctness, external/cwe/cwe-835 | This query detects `for` loops where the increment and guard condition don't appear to correspond. Enabled by default on LGTM. |
14+
| Incorrect Not Operator Usage | security, external/cwe/cwe-480 | This query finds uses of the logical not (`!`) operator that look like they should be bit-wise not (`~`). Available but not displayed by default on LGTM. |
15+
| NULL application name with an unquoted path in call to CreateProcess | security, external/cwe/cwe-428 | This query finds unsafe uses of the `CreateProcess` function. Available but not displayed by default on LGTM. |
1316

1417
## Changes to existing queries
1518

1619
| **Query** | **Expected impact** | **Change** |
1720
|----------------------------|------------------------|------------------------------------------------------------------|
21+
| Array offset used before range check | More results and fewer false positive results | The query now recognizes array accesses in different positions within the expression. False positives where the range is checked before and after the array access have been fixed. |
1822
| Empty branch of conditional | Fewer false positive results | The query now recognizes commented blocks more reliably. |
1923
| Expression has no effect | Fewer false positive results | Expressions in template instantiations are now excluded from this query. |
24+
| Global could be static | Fewer false positive results | Variables with declarations in header files are now excluded from this query. |
2025
| Resource not released in destructor | Fewer false positive results | Placement new is now excluded from the query. Also fixed an issue where false positives could occur if the destructor body was not in the snapshot. |
2126
| Missing return statement (`cpp/missing-return`) | Visible by default | The precision of this query has been increased from 'medium' to 'high', which makes it visible by default in LGTM. It was 'medium' in release 1.17 and 1.18 because it had false positives due to an extractor bug that was fixed in 1.18. |
22-
| Missing return statement | Fewer false positive results | The query is now produces correct results when a function returns a template-dependent type. |
27+
| Missing return statement | Fewer false positive results | The query is now produces correct results when a function returns a template-dependent type, or makes a non-returning call to another function. |
28+
| Static array access may cause overflow | More correct results | Data flow to the size argument of a buffer operation is now checked in this query. |
2329
| Call to memory access function may overflow buffer | More correct results | Array indexing with a negative index is now detected by this query. |
30+
| Self comparison | Fewer false positive results | Code inside macro invocations is now excluded from the query. |
2431
| Suspicious call to memset | Fewer false positive results | Types involving decltype are now correctly compared. |
2532
| Suspicious add with sizeof | Fewer false positive results | Arithmetic with void pointers (where allowed) is now excluded from this query. |
2633
| Wrong type of arguments to formatting function | Fewer false positive results | False positive results involving typedefs have been removed. Expected argument types are determined more accurately, especially for wide string and pointer types. Custom (non-standard) formatting functions are also identified more accurately. |
34+
| AV Rule 164 | Fewer false positive results | This query now accounts for explicit casts. |
35+
| Negation of unsigned value | Fewer false positive results | This query now accounts for explicit casts. |
36+
| Variable scope too large | Fewer false positive results | Variables with declarations in header files, or that are used at file scope, are now excluded from this query. |
37+
| Comparison result is always the same | Fewer false positive results | Comparisons in template instantiations are now excluded from this query. |
38+
| Unsigned comparison to zero | Fewer false positive results | Comparisons in template instantiations are now excluded from this query. |
2739

2840
## Changes to QL libraries
2941

change-notes/1.19/analysis-csharp.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@
2929

3030
* `getArgument()` on `AccessorCall` has been improved so it now takes tuple assignments into account. For example, the argument for the implicit `value` parameter in the setter of property `P` is `0` in `(P, x) = (0, 1)`. Additionally, the argument for the `value` parameter in compound assignments is now only the expanded value, for example, in `P += 7` the argument is `P + 7` and not `7`.
3131
* The predicate `isInArgument()` has been added to the `AssignableAccess` class. This holds for expressions that are passed as arguments using `in`.
32+
33+
## Changes to the autobuilder
34+
35+
* When determining the target of `msbuild` or `dotnet build`, first look for `.proj` files, then `.sln` files, and finally `.csproj`/`.vcxproj` files. In all three cases, choose the project/solution file closest to the root.

change-notes/1.19/analysis-java.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
| **Query** | **Expected impact** | **Change** |
1717
|----------------------------|------------------------|------------------------------------------------------------------|
1818
| Array index out of bounds (`java/index-out-of-bounds`) | Fewer false positive results | False positives involving arrays with a length evenly divisible by 3 or some greater number and an index being increased with a similar stride length are no longer reported. |
19+
| Confusing overloading of methods (`java/confusing-method-signature`) | Fewer false positive results | A bugfix in the inheritance relation ensures that spurious results on certain generic classes no longer occur. |
1920
| Query built from user-controlled sources (`java/sql-injection`) | More results | Sql injection sinks from the Spring JDBC, MyBatis, and Hibernate frameworks are now reported. |
2021
| Query built without neutralizing special characters (`java/concatenated-sql-query`) | More results | Sql injection sinks from the Spring JDBC, MyBatis, and Hibernate frameworks are now reported. |
2122
| Unreachable catch clause (`java/unreachable-catch-clause`) | Fewer false positive results | This rule now accounts for calls to generic methods that throw generic exceptions. |

change-notes/1.19/analysis-javascript.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
* Modelling of taint flow through array operations has been improved. This may give additional results for the security queries.
66

7-
* The taint tracking library now recognizes additional sanitization patterns. This may give fewer false-positive results for the security queries.
8-
97
* Support for AMD modules has been improved. This may give additional results for the security queries as well as any queries that use type inference on code bases that use such modules.
108

119
* Support for popular libraries has been improved. Consequently, queries may produce more results on code bases that use the following features:
1210
- file system access, for example through [fs-extra](https://github.com/jprichardson/node-fs-extra) or [globby](https://www.npmjs.com/package/globby)
1311
- outbound network access, for example through the [fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
1412
- the [lodash](https://lodash.com), [underscore](https://underscorejs.org/), [async](https://www.npmjs.com/package/async) and [async-es](https://www.npmjs.com/package/async-es) libraries
1513

14+
* The taint tracking library now recognizes additional sanitization patterns. This may give fewer false-positive results for the security queries.
15+
1616
* Type inference for function calls has been improved. This may give additional results for queries that rely on type inference.
1717

1818
* Where applicable, path explanations have been added to the security queries.
@@ -35,29 +35,38 @@
3535

3636
| **Query** | **Expected impact** | **Change** |
3737
|--------------------------------|----------------------------|----------------------------------------------|
38+
| Ambiguous HTML id attribute | Lower severity | The severity of this rule has been revised to "warning". |
39+
| Clear-text logging of sensitive information | Fewer results | This rule now tracks flow more precisely. |
3840
| Client side cross-site scripting | More results | This rule now also flags HTML injection in the body of an email. |
41+
| Client-side URL redirect | Fewer false-positive results | This rule now recognizes safe redirects in more cases. |
42+
| Conflicting HTML element attributes | Lower severity | The severity of this rule has been revised to "warning". |
43+
| Duplicate 'if' condition | Lower severity | The severity of this rule has been revised to "warning". |
44+
| Duplicate switch case | Lower severity | The severity of this rule has been revised to "warning". |
3945
| Information exposure through a stack trace | More results | This rule now also flags cases where the entire exception object (including the stack trace) may be exposed. |
4046
| Missing CSRF middleware | Fewer false-positive results | This rule now recognizes additional CSRF protection middlewares. |
47+
| Missing 'this' qualifier | Fewer false-positive results | This rule now recognizes additional intentional calls to global functions. |
48+
| Missing variable declaration | Lower severity | The severity of this rule has been revised to "warning". |
4149
| Regular expression injection | Fewer false-positive results | This rule now identifies calls to `String.prototype.search` with more precision. |
4250
| Remote property injection | Fewer results | The precision of this rule has been revised to "medium". Results are no longer shown on LGTM by default. |
4351
| Self assignment | Fewer false-positive results | This rule now ignores self-assignments preceded by a JSDoc comment with a `@type` tag. |
52+
| Server-side URL redirect | Fewer false-positive results | This rule now recognizes safe redirects in more cases. |
4453
| Server-side URL redirect | More results | This rule now recognizes redirection calls in more cases. |
4554
| Unbound event handler receiver | Fewer false-positive results | This rule now recognizes additional ways class methods can be bound. |
4655
| Uncontrolled data used in remote request | More results | This rule now recognizes additional kinds of requests. |
56+
| Unknown directive | Fewer false positives results | This rule now recognizes YUI compressor directives. |
4757
| Unused import | Fewer false-positive results | This rule no longer flags imports used by the `transform-react-jsx` Babel plugin. |
4858
| Unused variable, import, function or class | Fewer false-positive results | This rule now flags fewer variables that may be used by `eval` calls. |
4959
| Unused variable, import, function or class | Fewer results | This rule now flags import statements with multiple unused imports once. |
5060
| Useless assignment to local variable | Fewer false-positive results | This rule now recognizes additional ways default values can be set. |
5161
| Whitespace contradicts operator precedence | Fewer false-positive results | This rule no longer flags operators with asymmetric whitespace. |
52-
| Client-side URL redirect | Fewer false-positive results | This rule now recognizes safe redirects in more cases. |
53-
| Server-side URL redirect | Fewer false-positive results | This rule now recognizes safe redirects in more cases. |
62+
| Wrong use of 'this' for static method | More results, fewer false-positive results | This rule now recognizes inherited methods. |
5463

5564
## Changes to QL libraries
5665

57-
* The flow configuration framework now supports distinguishing and tracking different kinds of taint, specified by an extensible class `FlowLabel` (which can also be referred to by its alias `TaintKind`).
58-
59-
* The `DataFlow::ThisNode` class now corresponds to the implicit receiver parameter of a function, as opposed to an indivdual `this` expression. This means `getALocalSource` now maps all `this` expressions within a given function to the same source. The data-flow node associated with a `ThisExpr` can no longer be cast to `DataFlow::SourceNode` or `DataFlow::ThisNode` - it is recomended to use `getALocalSource` before casting or instead of casting.
66+
* A `DataFlow::ParameterNode` instance now exists for all function parameters. Previously, unused parameters did not have a corresponding dataflow node.
6067

6168
* `ReactComponent::getAThisAccess` has been renamed to `getAThisNode`. The old name is still usable but is deprecated. It no longer gets individual `this` expressions, but the `ThisNode` mentioned above.
6269

63-
* A `DataFlow::ParameterNode` instance now exists for all function parameters. Previously, unused parameters did not have a corresponding dataflow node.
70+
* The `DataFlow::ThisNode` class now corresponds to the implicit receiver parameter of a function, as opposed to an indivdual `this` expression. This means `getALocalSource` now maps all `this` expressions within a given function to the same source. The data-flow node associated with a `ThisExpr` can no longer be cast to `DataFlow::SourceNode` or `DataFlow::ThisNode` - it is recomended to use `getALocalSource` before casting or instead of casting.
71+
72+
* The flow configuration framework now supports distinguishing and tracking different kinds of taint, specified by an extensible class `FlowLabel` (which can also be referred to by its alias `TaintKind`).

change-notes/1.19/extractor-javascript.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,16 @@
1616
1717
## General improvements
1818

19-
> Changes that affect alerts in many files or from many queries
20-
> For example, changes to file classification
19+
* On LGTM, files whose name ends in `.min.js` or `-min.js` are no longer extracted by default, since they most likely contain minified code and results in these files would be hidden by default anyway. To extract such files anyway, you can add the following filters to your `lgtm.yml` file (or add them to existing filters):
20+
21+
```yaml
22+
extraction:
23+
javascript:
24+
index:
25+
filters:
26+
- include: "**/*.min.js"
27+
- include: "**/*-min.js"
28+
```
2129
2230
## Changes to code extraction
2331

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,9 @@ functions, and the total number of source code resp. comment lines.</p>
1515
depends on third-party libraries: low self-containedness means that many dependencies
1616
are to library classes (as opposed to source classes within the same application).</p>
1717

18-
</overview>
19-
<section title="How to Address the Query Results">
20-
2118
<p>The results of this query are purely informative and more useful for getting an overall impression of the application than for
22-
identifying particular defects.</p>
23-
24-
25-
26-
27-
28-
</section>
29-
<references>
30-
19+
identifying particular problems with the code.</p>
3120

21+
</overview>
3222

33-
</references>
3423
</qhelp>

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

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* @kind problem
66
* @id cpp/offset-use-before-range-check
77
* @problem.severity warning
8+
* @precision medium
89
* @tags reliability
910
* security
1011
* external/cwe/cwe-120
@@ -13,10 +14,29 @@
1314

1415
import cpp
1516

16-
from Variable v, LogicalAndExpr andexpr, ArrayExpr access, LTExpr rangecheck
17-
where access.getArrayOffset() = v.getAnAccess()
18-
and andexpr.getLeftOperand().getAChild() = access
19-
and andexpr.getRightOperand() = rangecheck
20-
and rangecheck.getLeftOperand() = v.getAnAccess()
21-
and not access.isInMacroExpansion()
17+
predicate beforeArrayAccess(Variable v, ArrayExpr access, Expr before) {
18+
exists(LogicalAndExpr andexpr |
19+
access.getArrayOffset() = v.getAnAccess() and
20+
andexpr.getRightOperand().getAChild*() = access and
21+
andexpr.getLeftOperand() = before
22+
)
23+
}
24+
25+
predicate afterArrayAccess(Variable v, ArrayExpr access, Expr after) {
26+
exists(LogicalAndExpr andexpr |
27+
access.getArrayOffset() = v.getAnAccess() and
28+
andexpr.getLeftOperand().getAChild*() = access and
29+
andexpr.getRightOperand() = after
30+
)
31+
}
32+
33+
from Variable v, ArrayExpr access, LTExpr rangecheck
34+
where
35+
afterArrayAccess(v, access, rangecheck) and
36+
rangecheck.getLeftOperand() = v.getAnAccess() and
37+
not access.isInMacroExpansion() and
38+
not exists(LTExpr altcheck |
39+
beforeArrayAccess(v, access, altcheck) and
40+
altcheck.getLeftOperand() = v.getAnAccess()
41+
)
2242
select access, "This use of offset '" + v.getName() + "' should follow the $@.", rangecheck, "range check"

cpp/ql/src/Best Practices/Magic Constants/MagicNumbersUseConstant.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* @kind problem
55
* @id cpp/use-number-constant
66
* @problem.severity recommendation
7+
* @precision low
8+
* @tags maintainability
79
*/
810
import cpp
911
import MagicConstants

cpp/ql/src/Best Practices/Magic Constants/MagicStringsUseConstant.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* @kind problem
55
* @id cpp/use-string-constant
66
* @problem.severity recommendation
7+
* @precision low
8+
* @tags maintainability
79
*/
810
import cpp
911
import MagicConstants

cpp/ql/src/Best Practices/NVI.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
* to enforce invariants that should hold for the whole hierarchy.
55
* @kind problem
66
* @id cpp/nvi
7-
* @problem.severity warning
7+
* @problem.severity recommendation
8+
* @precision low
9+
* @tags maintainability
810
*/
911
import cpp
1012

0 commit comments

Comments
 (0)