Skip to content

Commit a0dc840

Browse files
authored
Merge pull request #1518 from Semmle/rc/1.21
Merge rc/1.21 into master
2 parents af68fd4 + 74ad6e8 commit a0dc840

File tree

11 files changed

+40
-11
lines changed

11 files changed

+40
-11
lines changed

change-notes/1.21/analysis-csharp.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@
44

55
C# analysis now supports the extraction and analysis of many C# 8 features. For details see [Changes to code extraction](#changes-to-code-extraction) and [Changes to QL libraries](#changes-to-ql-libraries) below.
66

7+
## New queries
8+
9+
| **Query** | **Tags** | **Purpose** |
10+
|-----------------------------------------------|------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
11+
| Thread-unsafe capturing of an ICryptoTransform object (`cs/thread-unsafe-icryptotransform-captured-in-lambda`) | concurrency, security, external/cwe/cwe-362 | Highlights instances of classes where a field of type `System.Security.Cryptography.ICryptoTransform` is captured by a lambda, and appears to be used in a thread initialization method. Results are not shown on [LGTM](https://lgtm.com/rules/1508141845995/) by default. |
12+
713
## Changes to existing queries
814

915
| **Query** | **Expected impact** | **Change** |
1016
|------------------------------|------------------------|-----------------------------------|
11-
| Class defines a field that uses an ICryptoTransform class in a way that would be unsafe for concurrent threads (`cs/thread-unsafe-icryptotransform-field-in-class`) | Fewer false positive results | The criteria for a result has changed to include nested properties, nested fields, and collections. The format of the alert message has changed to highlight the static field. |
1217
| Constant condition (`cs/constant-condition`) | Fewer false positive results | The query now ignores code where the `null` value is in a conditional expression on the left hand side of a null-coalescing expression. For example, in `(a ? b : null) ?? c`, `null` is not considered to be a constant condition. |
18+
| Thread-unsafe use of a static ICryptoTransform field (`cs/thread-unsafe-icryptotransform-field-in-class`) | Fewer false positive results | The criteria for a result has changed to include nested properties, nested fields, and collections. The format of the alert message has changed to highlight the static field. The query name has been updated. |
1319
| Useless upcast (`cs/useless-upcast`) | Fewer false positive results | The query now ignores code where the upcast is used to disambiguate the target of a constructor call. |
1420

1521
## Changes to code extraction

change-notes/1.21/analysis-python.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ We welcome feedback on the new implementation, particularly any surprising chang
3636
| **Query** | **Tags** | **Purpose** |
3737
|-----------|----------|-------------|
3838
| Accepting unknown SSH host keys when using Paramiko (`py/paramiko-missing-host-key-validation`) | security, external/cwe/cwe-295 | Finds instances where Paramiko is configured to accept unknown host keys. Results are shown [on LGTM](https://lgtm.com/rules/1508297729270/) by default. |
39+
| Pythagorean calculation with sub-optimal numerics (`py/pythagorean`) | accuracy | Finds instances of hypotenuse calculation using `math.sqrt` instead of `math.hypot`. Results are not shown on LGTM by default. |
3940
| Use of 'return' or 'yield' outside a function (`py/return-or-yield-outside-function`) | reliability, correctness | Finds instances where `return`, `yield`, and `yield from` are used outside a function. Results are not shown on LGTM by default. |
4041

4142
## Changes to code extraction

csharp/ql/src/Likely Bugs/ThreadUnsafeICryptoTransform.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @name Class defines a field that uses an ICryptoTransform class in a way that would be unsafe for concurrent threads
2+
* @name Thread-unsafe use of a static ICryptoTransform field
33
* @description The class has a field that directly or indirectly make use of a static System.Security.Cryptography.ICryptoTransform object.
44
* Using this an instance of this class in concurrent threads is dangerous as it may not only result in an error,
55
* but under some circumstances may also result in incorrect results.

csharp/ql/src/Likely Bugs/ThreadUnsafeICryptoTransformLambda.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @name Potential usage of an object implementing ICryptoTransform class in a way that would be unsafe for concurrent threads.
2+
* @name Thread-unsafe capturing of an ICryptoTransform object
33
* @description An instance of a class that either implements or has a field of type System.Security.Cryptography.ICryptoTransform is being captured by a lambda,
44
* and used in what seems to be a thread initialization method.
55
* Using an instance of this class in concurrent threads is dangerous as it may not only result in an error,

python/ql/src/semmle/python/objects/Modules.qll

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,8 @@ class PackageObjectInternal extends ModuleObjectInternal, TPackageObject {
182182
or
183183
exists(Module init |
184184
init = this.getSourceModule() and
185-
(
186-
/* There is no variable shadowing the name of the child module */
187-
not exists(EssaVariable var | var.getAUse() = init.getANormalExit() and var.getSourceVariable().getName() = name)
188-
or
189-
/* The variable shadowing the name of the child module is undefined at exit */
190-
ModuleAttributes::pointsToAtExit(init, name, ObjectInternal::undefined(), _)
191-
) and
185+
/* The variable shadowing the name of the child module is undefined at exit */
186+
ModuleAttributes::pointsToAtExit(init, name, ObjectInternal::undefined(), _) and
192187
not name = "__init__" and
193188
value = this.submodule(name) and
194189
origin = CfgOrigin::fromObject(value)
@@ -254,6 +249,7 @@ class PythonModuleObjectInternal extends ModuleObjectInternal, TPythonModule {
254249
}
255250

256251
pragma [noinline] override predicate attribute(string name, ObjectInternal value, CfgOrigin origin) {
252+
value != ObjectInternal::undefined() and
257253
ModuleAttributes::pointsToAtExit(this.getSourceModule(), name, value, origin)
258254
}
259255

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
| nested/__init__.py:1:6:1:12 | ControlFlowNode for ImportExpr | import | nested/nested.py:0:0:0:0 | Module nested.nested |
2+
| nested/nested.py:1:1:1:13 | ControlFlowNode for FunctionExpr | import | nested/nested.py:1:1:1:13 | Function nested |
3+
| test.py:1:6:1:11 | ControlFlowNode for ImportExpr | import | file://:0:0:0:0 | Package nested |
4+
| test.py:2:1:2:6 | ControlFlowNode for nested | import | nested/nested.py:1:1:1:13 | Function nested |
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
import python
3+
4+
from ControlFlowNode f, Context ctx, Value v, ControlFlowNode origin
5+
where
6+
f.pointsTo(ctx, v, origin)
7+
select f, ctx, v
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .nested import *
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def nested():
2+
pass
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from nested import *
2+
nested

0 commit comments

Comments
 (0)