Skip to content

Commit 29c4e27

Browse files
authored
Merge pull request #1127 from felicity-semmle/1.20/python-change-notes
1.20: finalize python change notes
2 parents fb9c587 + 4ab8417 commit 29c4e27

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

change-notes/1.20/analysis-python.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
# Improvements to Python analysis
22

3+
## General improvements
34

4-
## General improvements
5+
### Extractor changes
56

6-
> Changes that affect alerts in many files or from many queries
7-
> For example, changes to file classification
7+
The extractor now parses all Python code from a single unified grammar. This means that almost all Python code will be successfully parsed, even if mutually incompatible Python code is present in the same project. This also means that Python code for any version can be correctly parsed on a worker running any other supported version of Python. For example, Python 3.7 code is parsed correctly, even if the installed version of Python is only 3.5. This will reduce the number of syntax errors found in many projects.
8+
9+
### Regular expression analysis improvements
10+
11+
The Python `re` (regular expressions) module library has a couple of constants called `MULTILINE` and `VERBOSE` which determine the parsing of regular expressions. Python 3.6 changed the implementation of these constants, which resulted in false positive results for some queries. The relevant QL libraries have been updated to support both implementations which will remove false positive results from projects that use Python 3.6 and later versions.
12+
13+
### API improvements
814

9-
The constants `MULTILINE` and `VERBOSE` in `re` module, are now understood for Python 3.6 and upward.
10-
Removes false positives seen when using Python 3.6, but not when using earlier versions.
1115
The API has been improved to declutter the global namespace and improve discoverability and readability.
1216
* New predicates `ModuleObject::named(name)` and `ModuleObject.attr(name)` have been added, allowing more readable access to common objects. For example, `(any ModuleObject m | m.getName() = "sys").getAttribute("exit")` can be replaced with `ModuleObject::named("sys").attr("exit")`
13-
* The API for accessing builtin functions has been improved. Predicates of the form `theXXXFunction()`, such as `theLenFunction()`, have been deprecated in favour of `Object::builtin(name)`.
17+
* The API for accessing builtin functions has been improved. Predicates of the form `theXXXFunction()`, such as `theLenFunction()`, have been deprecated in favor of `Object::builtin(name)`.
1418
* A configuration based API has been added for writing data flow and taint tracking queries. This is provided as a convenience for query authors who have written data flow or taint tracking queries for other languages, so they can use a similar format of query across multiple languages.
1519

16-
## New queries
20+
## New queries
1721

1822
| **Query** | **Tags** | **Purpose** |
1923
|-----------------------------|-----------|--------------------------------------------------------------------|
@@ -24,7 +28,7 @@ The API has been improved to declutter the global namespace and improve discover
2428
| Overly permissive file permissions (`py/overly-permissive-file`) | security, external/cwe/cwe-732 | Finds instances where a file is created with overly permissive permissions. Results are not shown on LGTM by default. |
2529
| Use of insecure SSL/TLS version (`py/insecure-protocol`) | security, external/cwe/cwe-327 | Finds instances where a known insecure protocol has been specified. Results are shown on LGTM by default. |
2630

27-
## Changes to existing queries
31+
## Changes to existing queries
2832

2933
| **Query** | **Expected impact** | **Change** |
3034
|----------------------------|------------------------|------------------------------------------------------------------|
@@ -35,11 +39,8 @@ The API has been improved to declutter the global namespace and improve discover
3539
| Unused import (`py/unused-import`) | Fewer false positive results | Results where the imported module is used in a `doctest` string are no longer reported. |
3640
| Unused import (`py/unused-import`) | Fewer false positive results | Results where the imported module is used in a type-hint comment are no longer reported. |
3741

38-
## Changes to code extraction
39-
40-
* The extractor now parses all Python code from a single unified grammar. This means that almost all Python code will be successfully parsed, even if mutually incompatible Python code is present in the same project. This also means that Python code for any version can be correctly parsed on a worker running any other supported version of Python. For example, Python 3.7 code is parsed correctly, even if the installed version of Python is only 3.5.
4142

42-
## Changes to QL libraries
43+
## Changes to QL libraries
4344

4445
* Added support for the `dill` pickle library.
4546
* Added support for the `bottle` web framework.

0 commit comments

Comments
 (0)