Skip to content

Commit 413c845

Browse files
author
Robert Marsh
committed
Merge branch 'main' into rdmarsh2/cpp/output-iterators-2
Accept test changes for unnamed elements
2 parents aad6d43 + 9964885 commit 413c845

File tree

1,207 files changed

+52632
-22073
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,207 files changed

+52632
-22073
lines changed

change-notes/1.26/analysis-cpp.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ The following changes in version 1.26 affect C/C++ analysis in all applications.
2626
* The models library now models many taint flows through `std::istream` and `std::ostream`.
2727
* The models library now models some taint flows through `std::shared_ptr`, `std::unique_ptr`, `std::make_shared` and `std::make_unique`.
2828
* The models library now models many taint flows through `std::pair`, `std::map`, `std::unordered_map`, `std::set` and `std::unordered_set`.
29+
* The models library now models `bcopy`.
2930
* The `SimpleRangeAnalysis` library now supports multiplications of the form
3031
`e1 * e2` and `x *= e2` when `e1` and `e2` are unsigned or constant.

change-notes/1.26/analysis-javascript.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22

33
## General improvements
44

5+
* Angular-specific taint sources and sinks are now recognized by the security queries.
6+
57
* Support for the following frameworks and libraries has been improved:
8+
- [@angular/*](https://www.npmjs.com/package/@angular/core)
69
- [AWS Serverless](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html)
710
- [Alibaba Serverless](https://www.alibabacloud.com/help/doc-detail/156876.htm)
11+
- [debounce](https://www.npmjs.com/package/debounce)
812
- [bluebird](https://www.npmjs.com/package/bluebird)
13+
- [call-limit](https://www.npmjs.com/package/call-limit)
914
- [express](https://www.npmjs.com/package/express)
1015
- [fast-json-stable-stringify](https://www.npmjs.com/package/fast-json-stable-stringify)
1116
- [fast-safe-stringify](https://www.npmjs.com/package/fast-safe-stringify)
@@ -15,11 +20,15 @@
1520
- [json-stable-stringify](https://www.npmjs.com/package/json-stable-stringify)
1621
- [json-stringify-safe](https://www.npmjs.com/package/json-stringify-safe)
1722
- [json3](https://www.npmjs.com/package/json3)
23+
- [jQuery throttle / debounce](https://github.com/cowboy/jquery-throttle-debounce)
1824
- [lodash](https://www.npmjs.com/package/lodash)
25+
- [lodash.debounce](https://www.npmjs.com/package/lodash.debounce)
26+
- [lodash.throttle](https://www.npmjs.com/package/lodash.throttle)
1927
- [needle](https://www.npmjs.com/package/needle)
2028
- [object-inspect](https://www.npmjs.com/package/object-inspect)
2129
- [pretty-format](https://www.npmjs.com/package/pretty-format)
2230
- [stringify-object](https://www.npmjs.com/package/stringify-object)
31+
- [throttle-debounce](https://www.npmjs.com/package/throttle-debounce)
2332
- [underscore](https://www.npmjs.com/package/underscore)
2433

2534
* Analyzing files with the ".cjs" extension is now supported.
@@ -43,6 +52,7 @@
4352
| Unsafe jQuery plugin (`js/unsafe-jquery-plugin`) | More results | This query now detects more unsafe uses of nested option properties. |
4453
| Client-side URL redirect (`js/client-side-unvalidated-url-redirection`) | More results | This query now recognizes some unsafe uses of `importScripts()` inside WebWorkers. |
4554
| Missing CSRF middleware (`js/missing-token-validation`) | More results | This query now recognizes writes to cookie and session variables as potentially vulnerable to CSRF attacks. |
55+
| Missing CSRF middleware (`js/missing-token-validation`) | Fewer results | This query now recognizes more ways of protecting against CSRF attacks. |
4656

4757

4858
## Changes to libraries

cpp/ql/src/Likely Bugs/Arithmetic/IntMultToLong.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ long j = i * i; //Wrong: due to overflow on the multiplication between ints,
44

55
long k = (long) i * i; //Correct: the multiplication is done on longs instead of ints,
66
//and will not overflow
7+
8+
long l = static_cast<long>(i) * i; //Correct: modern C++

cpp/ql/src/semmle/code/cpp/Include.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Include extends PreprocessorDirective, @ppd_include {
2121

2222
/**
2323
* Gets the token which occurs after `#include`, for example `"filename"`
24-
* or `&lt;filename>`.
24+
* or `<filename>`.
2525
*/
2626
string getIncludeText() { result = getHead() }
2727

cpp/ql/src/semmle/code/cpp/Parameter.qll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Parameter extends LocalScopeVariable, @parameter {
3636
* 1. The name given to the parameter at the function's definition or
3737
* (for catch block parameters) at the catch block.
3838
* 2. A name given to the parameter at a function declaration.
39-
* 3. The name "p#i" where i is the index of the parameter.
39+
* 3. The name "(unnamed parameter i)" where i is the index of the parameter.
4040
*/
4141
override string getName() {
4242
exists(VariableDeclarationEntry vde |
@@ -46,7 +46,7 @@ class Parameter extends LocalScopeVariable, @parameter {
4646
)
4747
or
4848
not exists(getANamedDeclarationEntry()) and
49-
result = "p#" + this.getIndex().toString()
49+
result = "(unnamed parameter " + this.getIndex().toString() + ")"
5050
}
5151

5252
override string getAPrimaryQlClass() { result = "Parameter" }
@@ -111,7 +111,8 @@ class Parameter extends LocalScopeVariable, @parameter {
111111
* Holds if this parameter has a name.
112112
*
113113
* In other words, this predicate holds precisely when the result of
114-
* `getName()` is not "p#i" (where `i` is the index of the parameter).
114+
* `getName()` is not "(unnamed parameter i)" (where `i` is the index
115+
* of the parameter).
115116
*/
116117
predicate isNamed() { exists(getANamedDeclarationEntry()) }
117118

cpp/ql/src/semmle/code/cpp/controlflow/Dereferenced.qll

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,25 @@
44

55
import cpp
66
import Nullness
7+
import semmle.code.cpp.models.interfaces.ArrayFunction
78

89
/**
910
* Holds if the call `fc` will dereference argument `i`.
1011
*/
1112
predicate callDereferences(FunctionCall fc, int i) {
12-
exists(string name |
13-
fc.getTarget().hasGlobalOrStdName(name) and
13+
exists(ArrayFunction af |
14+
fc.getTarget() = af and
1415
(
15-
name = "bcopy" and i in [0 .. 1]
16-
or
17-
name = "memcpy" and i in [0 .. 1]
18-
or
19-
name = "memmove" and i in [0 .. 1]
20-
or
21-
name = "strcpy" and i in [0 .. 1]
22-
or
23-
name = "strncpy" and i in [0 .. 1]
24-
or
25-
name = "strdup" and i = 0
26-
or
27-
name = "strndup" and i = 0
28-
or
29-
name = "strlen" and i = 0
30-
or
31-
name = "printf" and fc.getArgument(i).getType() instanceof PointerType
32-
or
33-
name = "fprintf" and fc.getArgument(i).getType() instanceof PointerType
34-
or
35-
name = "sprintf" and fc.getArgument(i).getType() instanceof PointerType
36-
or
37-
name = "snprintf" and fc.getArgument(i).getType() instanceof PointerType
38-
or
39-
name = "vprintf" and fc.getArgument(i).getType() instanceof PointerType
40-
or
41-
name = "vfprintf" and fc.getArgument(i).getType() instanceof PointerType
42-
or
43-
name = "vsprintf" and fc.getArgument(i).getType() instanceof PointerType
44-
or
45-
name = "vsnprintf" and fc.getArgument(i).getType() instanceof PointerType
16+
af.hasArrayInput(i) or
17+
af.hasArrayOutput(i)
4618
)
4719
)
20+
or
21+
exists(FormattingFunction ff |
22+
fc.getTarget() = ff and
23+
i >= ff.getFirstFormatArgumentIndex() and
24+
fc.getArgument(i).getType() instanceof PointerType
25+
)
4826
}
4927

5028
/**

0 commit comments

Comments
 (0)