Skip to content

Commit b2500a0

Browse files
authored
Merge branch 'master' into csharp/maybe-null-path-query
2 parents 1062773 + 83ccddf commit b2500a0

File tree

106 files changed

+818
-1772
lines changed

Some content is hidden

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

106 files changed

+818
-1772
lines changed

change-notes/1.20/analysis-csharp.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
## Changes to code extraction
1919

20+
* Fix extraction of `for` statements where the condition declares new variables using `is`.
2021
* Initializers of `stackalloc` arrays are now extracted.
2122

2223
## Changes to QL libraries

change-notes/1.20/analysis-javascript.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## General improvements
44

5-
* Support for popular libraries has been improved. Consequently, queries may produce more results on code bases that use the following features:
5+
* Support for popular libraries has been improved. Consequently, queries may produce better results on code bases that use the following features:
66
- client-side code, for example [React](https://reactjs.org/)
77
- cookies and webstorage, for example [js-cookie](https://github.com/js-cookie/js-cookie)
88
- server-side code, for example [hapi](https://hapijs.com/)
@@ -15,6 +15,7 @@
1515
| **Query** | **Tags** | **Purpose** |
1616
|-----------------------------------------------|------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
1717
| Double escaping or unescaping (`js/double-escaping`) | correctness, security, external/cwe/cwe-116 | Highlights potential double escaping or unescaping of special characters, indicating a possible violation of [CWE-116](https://cwe.mitre.org/data/definitions/116.html). Results are shown on LGTM by default. |
18+
| Incomplete regular expression for hostnames (`js/incomplete-hostname-regexp`) | correctness, security, external/cwe/cwe-020 | Highlights hostname sanitizers that are likely to be incomplete, indicating a violation of [CWE-020](https://cwe.mitre.org/data/definitions/20.html). Results are shown on LGTM by default.|
1819
| Incomplete URL substring sanitization | correctness, security, external/cwe/cwe-020 | Highlights URL sanitizers that are likely to be incomplete, indicating a violation of [CWE-020](https://cwe.mitre.org/data/definitions/20.html). Results shown on LGTM by default. |
1920
| Incorrect suffix check (`js/incorrect-suffix-check`) | correctness, security, external/cwe/cwe-020 | Highlights error-prone suffix checks based on `indexOf`, indicating a potential violation of [CWE-20](https://cwe.mitre.org/data/definitions/20.html). Results are shown on LGTM by default. |
2021
| Useless comparison test (`js/useless-comparison-test`) | correctness | Highlights code that is unreachable due to a numeric comparison that is always true or always false. Results are shown on LGTM by default. |
@@ -23,9 +24,11 @@
2324

2425
| **Query** | **Expected impact** | **Change** |
2526
|--------------------------------------------|------------------------------|------------------------------------------------------------------------------|
26-
| Client-side cross-site scripting | More results | This rule now recognizes WinJS functions that are vulnerable to HTML injection. |
27+
| Client-side cross-site scripting | More true-positive results, fewer false-positive results. | This rule now recognizes WinJS functions that are vulnerable to HTML injection, and no longer flags certain safe uses of jQuery. |
2728
| Insecure randomness | More results | This rule now flags insecure uses of `crypto.pseudoRandomBytes`. |
29+
| Uncontrolled data used in network request | More results | This rule now recognizes host values that are vulnerable to injection. |
2830
| Unused parameter | Fewer false-positive results | This rule no longer flags parameters with leading underscore. |
2931
| Unused variable, import, function or class | Fewer false-positive results | This rule now flags fewer variables that are implictly used by JSX elements, and no longer flags variables with leading underscore. |
32+
| Uncontrolled data used in path expression | Fewer false-positive results | This rule now recognizes the Express `root` option, which prevents path traversal. |
3033

3134
## Changes to QL libraries

cpp/ql/src/semmle/code/cpp/security/CommandExecution.qll

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,17 +159,6 @@ predicate shellCommandPreface(string cmd, string flag) {
159159
)
160160
}
161161

162-
/**
163-
* An array element. This supports multiple kinds of array syntax.
164-
*/
165-
private predicate arrayElement(Expr arrayLit, int idx, Expr element) {
166-
exists (ArrayLiteral lit | lit = arrayLit |
167-
lit.getElement(idx) = element)
168-
or exists (MessageExpr arrayWithObjects | arrayWithObjects = arrayLit |
169-
arrayWithObjects.getStaticTarget().getQualifiedName().matches("NSArray%::+arrayWithObjects:") and
170-
arrayWithObjects.getArgument(idx) = element)
171-
}
172-
173162
/**
174163
* A command that is used as a command, or component of a command,
175164
* that will be executed by a general-purpose command interpreter

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expression.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,19 @@ public static ExprKind UnaryOperatorKind(Context cx, ExprKind originalKind, Expr
117117
public void OperatorCall(ExpressionSyntax node)
118118
{
119119
var @operator = cx.GetSymbolInfo(node);
120-
var method = @operator.Symbol as IMethodSymbol;
121-
122-
if (GetCallType(cx, node) == CallType.Dynamic)
120+
if (@operator.Symbol is IMethodSymbol method)
123121
{
124-
UserOperator.OperatorSymbol(method.Name, out string operatorName);
125-
cx.Emit(Tuples.dynamic_member_name(this, operatorName));
126-
return;
127-
}
128122

129-
if (method != null)
123+
var callType = GetCallType(cx, node);
124+
if (callType == CallType.Dynamic)
125+
{
126+
UserOperator.OperatorSymbol(method.Name, out string operatorName);
127+
cx.Emit(Tuples.dynamic_member_name(this, operatorName));
128+
return;
129+
}
130+
130131
cx.Emit(Tuples.expr_call(this, Method.Create(cx, method)));
132+
}
131133
}
132134

133135
public enum CallType
@@ -148,12 +150,9 @@ public static CallType GetCallType(Context cx, ExpressionSyntax node)
148150
{
149151
var @operator = cx.GetSymbolInfo(node);
150152

151-
if (@operator.Symbol != null)
153+
if (@operator.Symbol is IMethodSymbol method)
152154
{
153-
var method = @operator.Symbol as IMethodSymbol;
154-
155-
var containingSymbol = method.ContainingSymbol as ITypeSymbol;
156-
if (containingSymbol != null && containingSymbol.TypeKind == Microsoft.CodeAnalysis.TypeKind.Dynamic)
155+
if (method.ContainingSymbol is ITypeSymbol containingSymbol && containingSymbol.TypeKind == Microsoft.CodeAnalysis.TypeKind.Dynamic)
157156
{
158157
return CallType.Dynamic;
159158
}

0 commit comments

Comments
 (0)