Skip to content

Commit bd97fe6

Browse files
committed
Merge branch 'master' into remove-field-conflation-from-ir-fieldflow
2 parents b205d36 + 674c184 commit bd97fe6

File tree

346 files changed

+4875
-1599
lines changed

Some content is hidden

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

346 files changed

+4875
-1599
lines changed

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+

change-notes/1.25/analysis-javascript.md

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
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/)
68
- [express](https://www.npmjs.com/package/express)
9+
- [fastify](https://www.npmjs.com/package/fastify)
710
- [fstream](https://www.npmjs.com/package/fstream)
811
- [jGrowl](https://github.com/stanlemon/jGrowl)
912
- [jQuery](https://jquery.com/)
@@ -15,8 +18,10 @@
1518
- [sequelize](https://www.npmjs.com/package/sequelize)
1619
- [spanner](https://www.npmjs.com/package/spanner)
1720
- [sqlite](https://www.npmjs.com/package/sqlite)
18-
- [ssh2](https://www.npmjs.com/package/ssh2)
1921
- [ssh2-streams](https://www.npmjs.com/package/ssh2-streams)
22+
- [ssh2](https://www.npmjs.com/package/ssh2)
23+
24+
* TypeScript 3.9 is now supported.
2025

2126
## New queries
2227

@@ -25,48 +30,56 @@
2530
| 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. |
2631
| 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. |
2732
| 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. |
33+
| 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. |
2834

2935
## Changes to existing queries
3036

3137
| **Query** | **Expected impact** | **Change** |
3238
|--------------------------------|------------------------------|---------------------------------------------------------------------------|
33-
| Misspelled variable name (`js/misspelled-variable-name`) | Message changed | The message for this query now correctly identifies the misspelled variable in additional cases. |
34-
| Uncontrolled data used in path expression (`js/path-injection`) | More results | This query now recognizes additional file system calls. |
35-
| Uncontrolled command line (`js/command-line-injection`) | More results | This query now recognizes additional command execution calls. |
36-
| Client-side URL redirect (`js/client-side-unvalidated-url-redirection`) | Less results | This query now recognizes additional safe patterns of doing URL redirects. |
37-
| Client-side cross-site scripting (`js/xss`) | Less results | This query now recognizes additional safe strings based on URLs. |
39+
| Client-side cross-site scripting (`js/xss`) | Fewer results | This query no longer flags optionally sanitized values. |
40+
| Client-side URL redirect (`js/client-side-unvalidated-url-redirection`) | Fewer results | This query now recognizes additional safe patterns of doing URL redirects. |
41+
| Client-side cross-site scripting (`js/xss`) | Fewer results | This query now recognizes additional safe patterns of constructing HTML. |
42+
| Code injection (`js/code-injection`) | More results | More potential vulnerabilities involving NoSQL code operators are now recognized. |
43+
| 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. |
3844
| Incomplete URL scheme check (`js/incomplete-url-scheme-check`) | More results | This query now recognizes additional url scheme checks. |
45+
| Misspelled variable name (`js/misspelled-variable-name`) | Message changed | The message for this query now correctly identifies the misspelled variable in additional cases. |
3946
| Prototype pollution in utility function (`js/prototype-pollution-utility`) | More results | This query now recognizes additional utility functions as vulnerable to prototype polution. |
40-
| 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. |
41-
| Unknown directive (`js/unknown-directive`) | Less results | This query no longer flags directives generated by the Babel compiler. |
42-
| Code injection (`js/code-injection`) | More results | More potential vulnerabilities involving NoSQL code operators are now recognized. |
47+
| Prototype pollution in utility function (`js/prototype-pollution-utility`) | More results | This query now recognizes more coding patterns that are vulnerable to prototype pollution. |
48+
| Uncontrolled command line (`js/command-line-injection`) | More results | This query now recognizes additional command execution calls. |
49+
| Uncontrolled data used in path expression (`js/path-injection`) | More results | This query now recognizes additional file system calls. |
50+
| Unknown directive (`js/unknown-directive`) | Fewer results | This query no longer flags directives generated by the Babel compiler. |
51+
| Unused property (`js/unused-property`) | Fewer results | This query no longer flags properties of objects that are operands of `yield` expressions. |
4352
| Zip Slip (`js/zipslip`) | More results | This query now recognizes additional vulnerabilities. |
44-
| Unused property (`js/unused-property`) | Less results | This query no longer flags properties of objects that are operands of `yield` expressions. |
4553

4654
The following low-precision queries are no longer run by default on LGTM (their results already were not displayed):
4755

4856
- `js/angular/dead-event-listener`
4957
- `js/angular/unused-dependency`
50-
- `js/conflicting-html-attribute`
51-
- `js/useless-assignment-to-global`
52-
- `js/too-many-parameters`
53-
- `js/unused-property`
5458
- `js/bitwise-sign-check`
5559
- `js/comparison-of-identical-expressions`
56-
- `js/misspelled-identifier`
60+
- `js/conflicting-html-attribute`
61+
- `js/ignored-setter-parameter`
5762
- `js/jsdoc/malformed-param-tag`
58-
- `js/jsdoc/unknown-parameter`
5963
- `js/jsdoc/missing-parameter`
60-
- `js/omitted-array-element`
61-
- `js/ignored-setter-parameter`
64+
- `js/jsdoc/unknown-parameter`
6265
- `js/json-in-javascript-file`
66+
- `js/misspelled-identifier`
67+
- `js/nested-loops-with-same-variable`
6368
- `js/node/cyclic-import`
6469
- `js/node/unused-npm-dependency`
65-
- `js/single-run-loop`
66-
- `js/nested-loops-with-same-variable`
70+
- `js/omitted-array-element`
6771
- `js/return-outside-function`
72+
- `js/single-run-loop`
73+
- `js/too-many-parameters`
74+
- `js/unused-property`
75+
- `js/useless-assignment-to-global`
6876

6977
## Changes to libraries
7078

7179
* A library `semmle.javascript.explore.CallGraph` has been added to help write queries for exploring the call graph.
7280
* Added data flow for `Map` and `Set`, and added matching type-tracking steps that can accessed using the `CollectionsTypeTracking` module.
81+
* 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:
82+
- `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.
83+
- `ParameterNode.asExpr()` and `.getAstNode()` now gets the parameter's AST node, whereas previously it had no result.
84+
- `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.
85+
* 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".

cpp/ql/src/Likely Bugs/Underspecified Functions/TooFewArguments.qll

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,50 @@
66

77
import cpp
88

9-
// True if function was ()-declared, but not (void)-declared or K&R-defined
9+
/**
10+
* Holds if `fde` has a parameter declaration that's clear on the minimum
11+
* number of parameters. This is essentially true for everything except
12+
* `()`-declarations.
13+
*/
14+
private predicate hasDefiniteNumberOfParameters(FunctionDeclarationEntry fde) {
15+
fde.hasVoidParamList()
16+
or
17+
fde.getNumberOfParameters() > 0
18+
or
19+
fde.isDefinition()
20+
}
21+
22+
/* Holds if function was ()-declared, but not (void)-declared or K&R-defined. */
1023
private predicate hasZeroParamDecl(Function f) {
1124
exists(FunctionDeclarationEntry fde | fde = f.getADeclarationEntry() |
12-
not fde.hasVoidParamList() and fde.getNumberOfParameters() = 0 and not fde.isDefinition()
25+
not hasDefiniteNumberOfParameters(fde)
1326
)
1427
}
1528

16-
// True if this file (or header) was compiled as a C file
29+
/* Holds if this file (or header) was compiled as a C file. */
1730
private predicate isCompiledAsC(File f) {
1831
f.compiledAsC()
1932
or
2033
exists(File src | isCompiledAsC(src) | src.getAnIncludedFile() = f)
2134
}
2235

36+
/** Holds if `fc` is a call to `f` with too few arguments. */
2337
predicate tooFewArguments(FunctionCall fc, Function f) {
2438
f = fc.getTarget() and
2539
not f.isVarargs() and
2640
not f instanceof BuiltInFunction and
41+
// This query should only have results on C (not C++) functions that have a
42+
// `()` parameter list somewhere. If it has results on other functions, then
43+
// it's probably because the extractor only saw a partial compilation.
2744
hasZeroParamDecl(f) and
2845
isCompiledAsC(f.getFile()) and
29-
// There is an explicit declaration of the function whose parameter count is larger
30-
// than the number of call arguments
31-
exists(FunctionDeclarationEntry fde | fde = f.getADeclarationEntry() |
46+
// Produce an alert when all declarations that are authoritative on the
47+
// parameter count specify a parameter count larger than the number of call
48+
// arguments.
49+
forex(FunctionDeclarationEntry fde |
50+
fde = f.getADeclarationEntry() and
51+
hasDefiniteNumberOfParameters(fde)
52+
|
3253
fde.getNumberOfParameters() > fc.getNumberOfArguments()
3354
)
3455
}

cpp/ql/src/Metrics/History/HChurn.ql

Lines changed: 0 additions & 27 deletions
This file was deleted.

cpp/ql/src/Metrics/History/HLinesAdded.ql

Lines changed: 0 additions & 27 deletions
This file was deleted.

cpp/ql/src/Metrics/History/HLinesDeleted.ql

Lines changed: 0 additions & 27 deletions
This file was deleted.

cpp/ql/src/Metrics/History/HNumberOfAuthors.ql

Lines changed: 0 additions & 18 deletions
This file was deleted.

cpp/ql/src/Metrics/History/HNumberOfChanges.ql

Lines changed: 0 additions & 19 deletions
This file was deleted.

cpp/ql/src/Metrics/History/HNumberOfCoCommits.ql

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)