Skip to content

Commit f6c59ab

Browse files
committed
Merge branch 'master' of github.com:github/codeql into UnmatchableDollar
to make CodeScan happy
2 parents 6e9c48b + 941177e commit f6c59ab

File tree

1,314 files changed

+43568
-20419
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,314 files changed

+43568
-20419
lines changed

.devcontainer/devcontainer.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extensions": [
3+
"github.vscode-codeql",
4+
"slevesque.vscode-zipexplorer"
5+
],
6+
"settings": {
7+
"codeQL.experimentalBqrsParsing": true
8+
}
9+
}

.github/codeql/codeql-config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: "CodeQL config"
2+
3+
queries:
4+
- uses: security-and-quality

.github/workflows/codeql-analysis.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: "Code scanning - action"
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '0 9 * * 1'
8+
9+
jobs:
10+
CodeQL-Build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v2
17+
with:
18+
# We must fetch at least the immediate parents so that if this is
19+
# a pull request then we can checkout the head.
20+
fetch-depth: 2
21+
22+
# If this run was triggered by a pull request event, then checkout
23+
# the head of the pull request instead of the merge commit.
24+
- run: git checkout HEAD^2
25+
if: ${{ github.event_name == 'pull_request' }}
26+
27+
# Initializes the CodeQL tools for scanning.
28+
- name: Initialize CodeQL
29+
uses: github/codeql-action/init@v1
30+
# Override language selection by uncommenting this and choosing your languages
31+
with:
32+
languages: csharp
33+
config-file: ./.github/codeql/codeql-config.yml
34+
35+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
36+
# If this step fails, then you should remove it and run the build manually (see below)
37+
- name: Autobuild
38+
uses: github/codeql-action/autobuild@v1
39+
40+
# ℹ️ Command-line programs to run using the OS shell.
41+
# 📚 https://git.io/JvXDl
42+
43+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
44+
# and modify them (or add more) to build your code if your project
45+
# uses a compiled language
46+
47+
#- run: |
48+
# make bootstrap
49+
# make release
50+
51+
- name: Perform CodeQL Analysis
52+
uses: github/codeql-action/analyze@v1

CONTRIBUTING.md

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

33
We welcome contributions to our CodeQL libraries and queries. Got an idea for a new check, or how to improve an existing query? Then please go ahead and open a pull request! Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license) to the public under the [project's open source license](LICENSE).
44

5-
There is lots of useful documentation to help you write queries, ranging from information about query file structure to tutorials for specific target languages. For more information on the documentation available, see [Writing CodeQL queries](https://help.semmle.com/QL/learn-ql/writing-queries/writing-queries.html) on [help.semmle.com](https://help.semmle.com).
5+
There is lots of useful documentation to help you write queries, ranging from information about query file structure to tutorials for specific target languages. For more information on the documentation available, see [CodeQL queries](https://help.semmle.com/QL/learn-ql/writing-queries/writing-queries.html) on [help.semmle.com](https://help.semmle.com).
66

77

88
## Submitting a new experimental query
@@ -32,7 +32,7 @@ If you have an idea for a query that you would like to share with other CodeQL u
3232

3333
For details, see the [guide on query metadata](docs/query-metadata-style-guide.md).
3434

35-
Make sure the `select` statement is compatible with the query `@kind`. See [Introduction to query files](https://help.semmle.com/QL/learn-ql/writing-queries/introduction-to-queries.html#select-clause) on help.semmle.com.
35+
Make sure the `select` statement is compatible with the query `@kind`. See [About CodeQL queries](https://help.semmle.com/QL/learn-ql/writing-queries/introduction-to-queries.html#select-clause) on help.semmle.com.
3636

3737
3. **Formatting**
3838

@@ -53,14 +53,6 @@ After the experimental query is merged, we welcome pull requests to improve it.
5353

5454
## Using your personal data
5555

56-
If you contribute to this project, we will record your name and email
57-
address (as provided by you with your contributions) as part of the code
58-
repositories, which are public. We might also use this information
59-
to contact you in relation to your contributions, as well as in the
60-
normal course of software development. We also store records of your
61-
CLA agreements. Under GDPR legislation, we do this
62-
on the basis of our legitimate interest in creating the CodeQL product.
63-
64-
Please do get in touch ([email protected]) if you have any questions about
65-
this or our data protection policies.
56+
If you contribute to this project, we will record your name and email address (as provided by you with your contributions) as part of the code repositories, which are public. We might also use this information to contact you in relation to your contributions, as well as in the normal course of software development. We also store records of CLA agreements signed in the past, but no longer require contributors to sign a CLA. Under GDPR legislation, we do this on the basis of our legitimate interest in creating the CodeQL product.
6657

58+
Please do get in touch ([email protected]) if you have any questions about this or our data protection policies.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# CodeQL
22

3-
This open source repository contains the standard CodeQL libraries and queries that power [LGTM](https://lgtm.com) and the other CodeQL products that [GitHub](https://github.com) makes available to its customers worldwide.
3+
This open source repository contains the standard CodeQL libraries and queries that power [LGTM](https://lgtm.com) and the other CodeQL products that [GitHub](https://github.com) makes available to its customers worldwide. For the queries, libraries, and extractor that power Go analysis, visit the [CodeQL for Go repository](https://github.com/github/codeql-go).
44

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

change-notes/1.25/analysis-cpp.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ The following changes in version 1.25 affect C/C++ analysis in all applications.
1616

1717
## Changes to libraries
1818

19+
* The library `VCS.qll` and all queries that imported it have been removed.
1920
* The data-flow library has been improved, which affects most security queries by potentially
2021
adding more results. Flow through functions now takes nested field reads/writes into account.
2122
For example, the library is able to track flow from `taint()` to `sink()` via the method
@@ -39,3 +40,5 @@ The following changes in version 1.25 affect C/C++ analysis in all applications.
3940
}
4041
};
4142
```
43+
* The security pack taint tracking library (`semmle.code.cpp.security.TaintTracking`) now considers that equality checks may block the flow of taint. This results in fewer false positive results from queries that use this library.
44+
* The length of a tainted string (such as the return value of a call to `strlen` or `strftime` with tainted parameters) is no longer itself considered tainted by the `models` library. This leads to fewer false positive results in queries that use any of our taint libraries.

change-notes/1.25/analysis-csharp.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ The following changes in version 1.25 affect C# analysis in all applications.
1818

1919
## Changes to code extraction
2020

21+
* Index initializers, of the form `{ [1] = "one" }`, are extracted correctly. Previously, the kind of the
22+
expression was incorrect, and the index was not extracted.
23+
2124
## Changes to libraries
2225

2326
* The class `UnboundGeneric` has been refined to only be those declarations that actually
24-
have type parameters. This means that non-generic nested types inside construced types,
27+
have type parameters. This means that non-generic nested types inside constructed types,
2528
such as `A<int>.B`, no longer are considered unbound generics. (Such nested types do,
2629
however, still have relevant `.getSourceDeclaration()`s, for example `A<>.B`.)
2730
* The data-flow library has been improved, which affects most security queries by potentially

change-notes/1.25/analysis-javascript.md

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,97 @@
33
## General improvements
44

55
* Support for the following frameworks and libraries has been improved:
6+
- [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
7+
- [bluebird](http://bluebirdjs.com/)
8+
- [express](https://www.npmjs.com/package/express)
9+
- [fastify](https://www.npmjs.com/package/fastify)
610
- [fstream](https://www.npmjs.com/package/fstream)
711
- [jGrowl](https://github.com/stanlemon/jGrowl)
812
- [jQuery](https://jquery.com/)
913
- [marsdb](https://www.npmjs.com/package/marsdb)
14+
- [micro](https://www.npmjs.com/package/micro/)
1015
- [minimongo](https://www.npmjs.com/package/minimongo/)
16+
- [mssql](https://www.npmjs.com/package/mssql)
17+
- [mysql](https://www.npmjs.com/package/mysql)
18+
- [pg](https://www.npmjs.com/package/pg)
19+
- [sequelize](https://www.npmjs.com/package/sequelize)
20+
- [spanner](https://www.npmjs.com/package/spanner)
21+
- [sqlite](https://www.npmjs.com/package/sqlite)
22+
- [ssh2-streams](https://www.npmjs.com/package/ssh2-streams)
23+
- [ssh2](https://www.npmjs.com/package/ssh2)
24+
- [yargs](https://www.npmjs.com/package/yargs)
25+
- [webpack-dev-server](https://www.npmjs.com/package/webpack-dev-server)
26+
27+
* TypeScript 3.9 is now supported.
28+
29+
* The analysis of sanitizers has improved, leading to more accurate
30+
results from the security queries.
1131

1232
## New queries
1333

1434
| **Query** | **Tags** | **Purpose** |
1535
|---------------------------------------------------------------------------------|-------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
16-
| Cross-site scripting through DOM (`js/xss-through-dom`) | security, external/cwe/cwe-079, external/cwe/cwe-116 | Highlights potential XSS vulnerabilities where existing text from the DOM is used as HTML. Results are not shown on LGTM by default. |
36+
| DOM text reinterpreted as HTML (`js/xss-through-dom`) | security, external/cwe/cwe-079, external/cwe/cwe-116 | Highlights potential XSS vulnerabilities where existing text from the DOM is used as HTML. Results are shown on LGTM by default. |
1737
| Incomplete HTML attribute sanitization (`js/incomplete-html-attribute-sanitization`) | security, external/cwe/cwe-20, external/cwe/cwe-079, external/cwe/cwe-116 | Highlights potential XSS vulnerabilities due to incomplete sanitization of HTML meta-characters. Results are shown on LGTM by default. |
1838
| Unsafe expansion of self-closing HTML tag (`js/unsafe-html-expansion`) | security, external/cwe/cwe-079, external/cwe/cwe-116 | Highlights potential XSS vulnerabilities caused by unsafe expansion of self-closing HTML tags. |
39+
| Unsafe shell command constructed from library input (`js/shell-command-constructed-from-input`) | correctness, security, external/cwe/cwe-078, external/cwe/cwe-088 | Highlights potential command injections due to a shell command being constructed from library inputs. Results are shown on LGTM by default. |
40+
| Download of sensitive file through insecure connection (`js/insecure-download`) | security, external/cwe/cwe-829 | Highlights downloads of sensitive files through an unencrypted protocol. Results are shown on LGTM by default. |
41+
| Exposure of private files (`js/exposure-of-private-files`) | security, external/cwe/cwe-200 | Highlights servers that serve private files. Results are shown on LGTM by default. |
42+
| Creating biased random numbers from a cryptographically secure source (`js/biased-cryptographic-random`) | security, external/cwe/cwe-327 | Highlights mathematical operations on cryptographically secure numbers that can create biased results. Results are shown on LGTM by default. |
43+
| Storage of sensitive information in build artifact (`js/build-artifact-leak`) | security, external/cwe/cwe-312 | Highlights storage of sensitive information in build artifacts. Results are shown on LGTM by default. |
44+
| Improper code sanitization (`js/bad-code-sanitization`) | security, external/cwe/cwe-094, external/cwe/cwe-079, external/cwe/cwe-116 | Highlights string concatenation where code is constructed without proper sanitization. Results are shown on LGTM by default. |
45+
| Disabling certificate validation (`js/disabling-certificate-validation`) | security, external/cwe-295 | Highlights locations where SSL certificate validation is disabled. Results are shown on LGTM by default. |
46+
| Incomplete multi-character sanitization (`js/incomplete-multi-character-sanitization`) | correctness, security, external/cwe/cwe-20, external/cwe/cwe-116 | Highlights sanitizers that fail to remove dangerous substrings completely. Results are shown on LGTM by default. |
1947

2048
## Changes to existing queries
2149

2250
| **Query** | **Expected impact** | **Change** |
2351
|--------------------------------|------------------------------|---------------------------------------------------------------------------|
52+
| Client-side cross-site scripting (`js/xss`) | Fewer results | This query now recognizes additional safe patterns of constructing HTML. |
53+
| Client-side URL redirect (`js/client-side-unvalidated-url-redirection`) | Fewer results | This query now recognizes additional safe patterns of doing URL redirects. |
54+
| Code injection (`js/code-injection`) | More results | More potential vulnerabilities involving NoSQL code operators are now recognized. |
55+
| Exception text reinterpreted as HTML (`js/exception-xss`) | Rephrased and changed visibility | Rephrased name and alert message. Severity lowered from error to warning. Results are now shown on LGTM by default. |
56+
| Expression has no effect (`js/useless-expression`) | Fewer results | This query no longer flags an expression when that expression is the only content of the containing file. |
57+
| Hard-coded credentials (`js/hardcoded-credentials`) | More results | This query now recognizes hard-coded credentials sent via HTTP authorization headers. |
58+
| Incomplete URL scheme check (`js/incomplete-url-scheme-check`) | More results | This query now recognizes additional url scheme checks. |
2459
| Misspelled variable name (`js/misspelled-variable-name`) | Message changed | The message for this query now correctly identifies the misspelled variable in additional cases. |
25-
| Uncontrolled data used in path expression (`js/path-injection`) | More results | This query now recognizes additional file system calls. |
60+
| Non-linear pattern (`js/non-linear-pattern`) | Fewer duplicates and message changed | This query now generates fewer duplicate alerts and has a clearer explanation in case of type annotations used in a pattern. |
61+
| Prototype pollution in utility function (`js/prototype-pollution-utility`) | More results | This query now recognizes additional utility functions as vulnerable to prototype polution. |
2662
| Uncontrolled command line (`js/command-line-injection`) | More results | This query now recognizes additional command execution calls. |
27-
| Expression has no effect (`js/useless-expression`) | Less results | This query no longer flags an expression when that expression is the only content of the containing file. |
28-
| Unknown directive (`js/unknown-directive`) | Less results | This query no longer flags directives generated by the Babel compiler. |
29-
| Code injection (`js/code-injection`) | More results | More potential vulnerabilities involving NoSQL code operators are now recognized. |
63+
| Uncontrolled data used in path expression (`js/path-injection`) | More results | This query now recognizes additional file system calls. |
64+
| Unknown directive (`js/unknown-directive`) | Fewer results | This query no longer flags directives generated by the Babel compiler. |
65+
| Unused property (`js/unused-property`) | Fewer results | This query no longer flags properties of objects that are operands of `yield` expressions. |
3066
| Zip Slip (`js/zipslip`) | More results | This query now recognizes additional vulnerabilities. |
3167

68+
The following low-precision queries are no longer run by default on LGTM (their results already were not displayed):
69+
70+
- `js/angular/dead-event-listener`
71+
- `js/angular/unused-dependency`
72+
- `js/bitwise-sign-check`
73+
- `js/comparison-of-identical-expressions`
74+
- `js/conflicting-html-attribute`
75+
- `js/ignored-setter-parameter`
76+
- `js/jsdoc/malformed-param-tag`
77+
- `js/jsdoc/missing-parameter`
78+
- `js/jsdoc/unknown-parameter`
79+
- `js/json-in-javascript-file`
80+
- `js/misspelled-identifier`
81+
- `js/nested-loops-with-same-variable`
82+
- `js/node/cyclic-import`
83+
- `js/node/unused-npm-dependency`
84+
- `js/omitted-array-element`
85+
- `js/return-outside-function`
86+
- `js/single-run-loop`
87+
- `js/too-many-parameters`
88+
- `js/unused-property`
89+
- `js/useless-assignment-to-global`
90+
3291
## Changes to libraries
3392

3493
* A library `semmle.javascript.explore.CallGraph` has been added to help write queries for exploring the call graph.
3594
* Added data flow for `Map` and `Set`, and added matching type-tracking steps that can accessed using the `CollectionsTypeTracking` module.
95+
* The data-flow node representing a parameter or destructuring pattern is now always the `ValueNode` corresponding to that AST node. This has a few consequences:
96+
- `Parameter.flow()` now gets the correct data flow node for a parameter. Previously this had a result, but the node was disconnected from the data flow graph.
97+
- `ParameterNode.asExpr()` and `.getAstNode()` now gets the parameter's AST node, whereas previously it had no result.
98+
- `Expr.flow()` now has a more meaningful result for destructuring patterns. Previously this node was disconnected from the data flow graph. Now it represents the values being destructured by the pattern.
99+
* The global data-flow and taint-tracking libraries now model indirect parameter accesses through the `arguments` object in some cases, which may lead to additional results from some of the security queries, particularly "Prototype pollution in utility function".

change-notes/1.25/analysis-python.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Improvements to Python analysis
2+
3+
The following changes in version 1.25 affect Python analysis in all applications.
4+
5+
## General improvements
6+
7+
8+
## New queries
9+
10+
| **Query** | **Tags** | **Purpose** |
11+
|-----------------------------|-----------|--------------------------------------------------------------------|
12+
13+
14+
## Changes to existing queries
15+
16+
| **Query** | **Expected impact** | **Change** |
17+
|----------------------------|------------------------|------------------------------------------------------------------|
18+
19+
20+
## Changes to libraries
21+
22+
* Importing `semmle.python.web.HttpRequest` will no longer import `UntrustedStringKind` transitively. `UntrustedStringKind` is the most commonly used non-abstract subclass of `ExternalStringKind`. If not imported (by one mean or another), taint-tracking queries that concern `ExternalStringKind` will not produce any results. Please ensure such queries contain an explicit import (`import semmle.python.security.strings.Untrusted`).

0 commit comments

Comments
 (0)