Skip to content

Commit 4fc27aa

Browse files
author
Max Schaefer
authored
Merge branch 'master' into pseudo-random-bytes
2 parents a01a9dc + 06dd5f3 commit 4fc27aa

File tree

22 files changed

+92
-16
lines changed

22 files changed

+92
-16
lines changed

change-notes/1.20/analysis-javascript.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
|--------------------------------------------|------------------------------|------------------------------------------------------------------------------|
2222
| Client-side cross-site scripting | More results | This rule now recognizes WinJS functions that are vulnerable to HTML injection. |
2323
| Insecure randomness | More results | This rule now flags insecure uses of `crypto.pseudoRandomBytes`. |
24-
| Unused variable, import, function or class | Fewer false-positive results | This rule now flags fewer variables that are implictly used by JSX elements. |
24+
| Unused parameter | Fewer false-positive results | This rule no longer flags parameters with leading underscore. |
25+
| Unused variable, import, function or class | Fewer false-positive results | This rule now flags fewer variables that are implictly used by JSX elements, and no longer flags variables with leading underscore. |
2526

2627
## Changes to QL libraries
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// semmle-extractor-options: --expect_errors
2+
3+
void functionBeforeError()
4+
{
5+
}
6+
7+
void functionWithError1()
8+
{
9+
aaaaaaaaaa(); // error
10+
}
11+
12+
void functionWithError2()
13+
{
14+
int i = aaaaaaaaaa(); // error
15+
}
16+
17+
void functionAfterError()
18+
{
19+
}

cpp/ql/test/library-tests/sideEffects/functions/sideEffects.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
| cpp.cpp:87:5:87:26 | functionAccessesStatic | int | false |
4444
| cpp.cpp:93:6:93:14 | increment | int & -> void | false |
4545
| cpp.cpp:97:6:97:16 | doIncrement | void | false |
46+
| error.cpp:3:6:3:24 | functionBeforeError | void | true |
47+
| error.cpp:7:6:7:23 | functionWithError1 | void | false |
48+
| error.cpp:12:6:12:23 | functionWithError2 | void | false |
49+
| error.cpp:17:6:17:23 | functionAfterError | void | true |
4650
| file://:0:0:0:0 | operator= | __va_list_tag & | false |
4751
| file://:0:0:0:0 | operator= | __va_list_tag & | false |
4852
| sideEffects.c:4:5:4:6 | f1 | int | true |

cpp/ql/test/query-tests/Likely Bugs/Likely Typos/ExprHasNoEffect/ExprHasNoEffect.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
| calls.cpp:8:5:8:5 | 1 | This expression has no effect. | calls.cpp:8:5:8:5 | 1 | |
22
| calls.cpp:12:5:12:16 | call to thingy | This expression has no effect (because $@ has no external side effects). | calls.cpp:7:15:7:20 | thingy | thingy |
3+
| expr.cpp:8:2:8:2 | 0 | This expression has no effect. | expr.cpp:8:2:8:2 | 0 | |
4+
| expr.cpp:9:7:9:7 | 0 | This expression has no effect. | expr.cpp:9:7:9:7 | 0 | |
5+
| expr.cpp:10:2:10:5 | ... , ... | This expression has no effect. | expr.cpp:10:2:10:5 | ... , ... | |
36
| preproc.c:89:2:89:4 | call to fn4 | This expression has no effect (because $@ has no external side effects). | preproc.c:33:5:33:7 | fn4 | fn4 |
47
| preproc.c:94:2:94:4 | call to fn9 | This expression has no effect (because $@ has no external side effects). | preproc.c:78:5:78:7 | fn9 | fn9 |
58
| template.cpp:19:3:19:3 | call to operator++ | This expression has no effect (because $@ has no external side effects). | template.cpp:9:10:9:19 | operator++ | operator++ |
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace Expr {
2+
3+
int i;
4+
5+
void comma_expr_test()
6+
{
7+
i++, i++; // GOOD
8+
0, i++; // BAD (first part)
9+
i++, 0; // BAD (second part)
10+
0, 0; // BAD (whole)
11+
}
12+
13+
}

java/ql/src/Likely Bugs/Termination/ConstantLoopCondition.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,5 @@ where
8181
not exists(MethodAccess ma | ma.getParent*() = cond) and
8282
not exists(FieldRead fa | fa.getParent*() = cond) and
8383
not exists(ArrayAccess aa | aa.getParent*() = cond)
84-
select loop, "Loop might not terminate, as this $@ is constant within the loop.", cond,
85-
"loop condition"
84+
select cond, "$@ might not terminate, as this loop condition is constant within the loop.", loop,
85+
"Loop"
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
| A.java:6:5:6:16 | stmt | Loop might not terminate, as this $@ is constant within the loop. | A.java:6:11:6:15 | !... | loop condition |
2-
| A.java:12:5:12:19 | stmt | Loop might not terminate, as this $@ is constant within the loop. | A.java:13:11:13:15 | ... > ... | loop condition |
3-
| A.java:27:5:27:38 | stmt | Loop might not terminate, as this $@ is constant within the loop. | A.java:27:20:27:32 | ... < ... | loop condition |
1+
| A.java:6:11:6:15 | !... | $@ might not terminate, as this loop condition is constant within the loop. | A.java:6:5:6:16 | stmt | Loop |
2+
| A.java:13:11:13:15 | ... > ... | $@ might not terminate, as this loop condition is constant within the loop. | A.java:12:5:12:19 | stmt | Loop |
3+
| A.java:27:20:27:32 | ... < ... | $@ might not terminate, as this loop condition is constant within the loop. | A.java:27:5:27:38 | stmt | Loop |

javascript/ql/src/AngularJS/DuplicateDependency.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
import javascript
13+
import semmle.javascript.RestrictedLocations
1314

1415
predicate isRepeatedDependency(AngularJS::InjectableFunction f, string name, ASTNode location) {
1516
exists(int i, int j | i < j and
@@ -20,4 +21,4 @@ predicate isRepeatedDependency(AngularJS::InjectableFunction f, string name, AST
2021
from AngularJS::InjectableFunction f, ASTNode node, string name
2122
where isRepeatedDependency(f, name, node) and
2223
not count(f.asFunction().getParameterByName(name)) > 1 // avoid duplicating reports from js/duplicate-parameter-name
23-
select f, "This function has a duplicate dependency '$@'.", node, name
24+
select (FirstLineOf)f.asFunction(), "This function has a duplicate dependency '$@'.", node, name

javascript/ql/src/AngularJS/RepeatedInjection.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
*/
1111

1212
import javascript
13+
import semmle.javascript.RestrictedLocations
1314

1415
from AngularJS::InjectableFunction f, ASTNode explicitInjection
1516
where count(f.getAnExplicitDependencyInjection()) > 1 and
1617
explicitInjection = f.getAnExplicitDependencyInjection()
17-
select f.asFunction(), "This function has $@ defined in multiple places.", explicitInjection, "dependency injections"
18+
select (FirstLineOf)f.asFunction(), "This function has $@ defined in multiple places.", explicitInjection, "dependency injections"

javascript/ql/src/AngularJS/UnusedAngularDependency.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import javascript
1313
import Declarations.UnusedParameter
14+
import semmle.javascript.RestrictedLocations
1415

1516
predicate isUnusedParameter(Function f, string msg, Parameter parameter) {
1617
exists(Variable pv |
@@ -36,4 +37,4 @@ predicate isMissingParameter(AngularJS::InjectableFunction f, string msg, ASTNod
3637

3738
from AngularJS::InjectableFunction f, string message, ASTNode location
3839
where isUnusedParameter(f.asFunction(), message, location) or isMissingParameter(f, message, location)
39-
select location, message
40+
select (FirstLineOf)location, message

0 commit comments

Comments
 (0)