Skip to content

Commit b3b132c

Browse files
committed
Merge remote-tracking branch 'upstream/master' into ExceptionalPromise
2 parents a25c5d7 + 742bd1c commit b3b132c

153 files changed

Lines changed: 24449 additions & 8381 deletions

File tree

Some content is hidden

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

change-notes/1.24/analysis-cpp.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,7 @@ The following changes in version 1.24 affect C/C++ analysis in all applications.
3535
about the _name or scope_ of variables should remain unchanged.
3636
* The `LocalScopeVariableReachability` library is deprecated in favor of
3737
`StackVariableReachability`. The functionality is the same.
38+
* The taint tracking library (`semmle.code.cpp.dataflow.TaintTracking`) has had
39+
the following improvements:
40+
* The library now models data flow through `strdup` and similar functions.
41+

change-notes/1.24/analysis-java.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The following changes in version 1.24 affect Java analysis in all applications.
1010

1111
| **Query** | **Tags** | **Purpose** |
1212
|-----------------------------|-----------|--------------------------------------------------------------------|
13+
| Failure to use HTTPS or SFTP URL in Maven artifact upload/download (`java/maven/non-https-url`) | security, external/cwe/cwe-300, external/cwe/cwe-319, external/cwe/cwe-494, external/cwe/cwe-829 | Finds use of insecure protocols during Maven dependency resolution. Results are shown on LGTM by default. |
1314

1415
## Changes to existing queries
1516

change-notes/1.24/analysis-javascript.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
|---------------------------------------------------------------------------------|-------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
2121
| Cross-site scripting through exception (`js/xss-through-exception`) | security, external/cwe/cwe-079, external/cwe/cwe-116 | Highlights potential XSS vulnerabilities where an exception is written to the DOM. Results are not shown on LGTM by default. |
2222
| Regular expression always matches (`js/regex/always-matches`) | correctness, regular-expressions | Highlights regular expression checks that trivially succeed by matching an empty substring. Results are shown on LGTM by default. |
23+
| Missing await (`js/missing-await`) | correctness | Highlights expressions that operate directly on a promise object in a nonsensical way, instead of awaiting its result. Results are shown on LGTM by default. |
24+
| Prototype pollution in utility function (`js/prototype-pollution-utility`) | security, external/cwe/cwe-400, external/cwe/cwe-471 | Highlights recursive copying operations that are susceptible to prototype pollution. Results are shown on LGTM by default. |
2325

2426
## Changes to existing queries
2527

@@ -29,7 +31,8 @@
2931
| Duplicate parameter names (`js/duplicate-parameter-name`) | Fewer results | This query now recognizes additional parameters that reasonably can have duplicated names. |
3032
| Incomplete string escaping or encoding (`js/incomplete-sanitization`) | Fewer false positive results | This query now recognizes additional cases where a single replacement is likely to be intentional. |
3133
| Unbound event handler receiver (`js/unbound-event-handler-receiver`) | Fewer false positive results | This query now recognizes additional ways event handler receivers can be bound. |
32-
| Expression has no effect (`js/useless-expression`) | Fewer false positive results | The query now recognizes block-level flow type annotations. |
34+
| Expression has no effect (`js/useless-expression`) | Fewer false positive results | The query now recognizes block-level flow type annotations and ignores the first statement of a try block. |
35+
| Use of call stack introspection in strict mode (`js/strict-mode-call-stack-introspection`) | Fewer false positive results | The query no longer flags expression statements. |
3336

3437
## Changes to libraries
3538

cpp/ql/src/Likely Bugs/InconsistentCheckReturnNull.ql

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@ predicate assertInvocation(File f, int line) {
2525
)
2626
}
2727

28-
predicate nullCheckAssert(Expr e, Variable v, Declaration qualifier) {
29-
nullCheckInCondition(e, v, qualifier) and
28+
class InterestingExpr extends Expr {
29+
InterestingExpr() { nullCheckInCondition(this, _, _) }
30+
}
31+
32+
predicate nullCheckAssert(InterestingExpr e, Variable v, Declaration qualifier) {
3033
exists(File f, int i |
31-
e.getLocation().getStartLine() = i and e.getFile() = f and assertInvocation(f, i)
34+
e.getLocation().getStartLine() = i and
35+
e.getFile() = f and
36+
assertInvocation(f, i) and
37+
nullCheckInCondition(e, v, qualifier)
3238
)
3339
}
3440

cpp/ql/src/Likely Bugs/Likely Typos/AssignWhereCompareMeant.ql

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,31 @@ abstract class BooleanControllingAssignment extends AssignExpr {
3838
abstract predicate isWhitelisted();
3939
}
4040

41+
/**
42+
* Gets an operand of a logical operation expression (we need the restriction
43+
* to BinaryLogicalOperation expressions to get the correct transitive closure).
44+
*/
45+
Expr getComparisonOperand(BinaryLogicalOperation op) { result = op.getAnOperand() }
46+
4147
class BooleanControllingAssignmentInExpr extends BooleanControllingAssignment {
4248
BooleanControllingAssignmentInExpr() {
4349
this.getParent() instanceof UnaryLogicalOperation or
4450
this.getParent() instanceof BinaryLogicalOperation or
4551
exists(ConditionalExpr c | c.getCondition() = this)
4652
}
4753

48-
override predicate isWhitelisted() { this.getConversion().(ParenthesisExpr).isParenthesised() }
54+
override predicate isWhitelisted() {
55+
this.getConversion().(ParenthesisExpr).isParenthesised()
56+
or
57+
// whitelist this assignment if all comparison operations in the expression that this
58+
// assignment is part of, are not parenthesized. In that case it seems like programmer
59+
// is fine with unparenthesized comparison operands to binary logical operators, and
60+
// the parenthesis around this assignment was used to call it out as an assignment.
61+
this.isParenthesised() and
62+
forex(ComparisonOperation op | op = getComparisonOperand*(this.getParent+()) |
63+
not op.isParenthesised()
64+
)
65+
}
4966
}
5067

5168
class BooleanControllingAssignmentInStmt extends BooleanControllingAssignment {
@@ -65,7 +82,8 @@ class BooleanControllingAssignmentInStmt extends BooleanControllingAssignment {
6582
*/
6683
predicate candidateResult(BooleanControllingAssignment ae) {
6784
ae.getRValue().isConstant() and
68-
not ae.isWhitelisted()
85+
not ae.isWhitelisted() and
86+
not ae.getRValue() instanceof StringLiteral
6987
}
7088

7189
/**
@@ -81,5 +99,6 @@ predicate candidateVariable(Variable v) {
8199
from BooleanControllingAssignment ae, UndefReachability undef
82100
where
83101
candidateResult(ae) and
102+
not ae.isFromUninstantiatedTemplate(_) and
84103
not undef.reaches(_, ae.getLValue().(VariableAccess).getTarget(), ae.getLValue())
85104
select ae, "Use of '=' where '==' may have been intended."

cpp/ql/src/Security/CWE/CWE-190/ArithmeticUncontrolled.ql

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,19 @@ import semmle.code.cpp.security.Overflow
1616
import semmle.code.cpp.security.Security
1717
import semmle.code.cpp.security.TaintTracking
1818

19+
predicate isRandCall(FunctionCall fc) { fc.getTarget().getName() = "rand" }
20+
21+
predicate isRandCallOrParent(Expr e) {
22+
isRandCall(e) or
23+
isRandCallOrParent(e.getAChild())
24+
}
25+
1926
predicate isRandValue(Expr e) {
20-
e.(FunctionCall).getTarget().getName() = "rand"
27+
isRandCall(e)
2128
or
2229
exists(MacroInvocation mi |
2330
e = mi.getExpr() and
24-
e.getAChild*().(FunctionCall).getTarget().getName() = "rand"
31+
isRandCallOrParent(e)
2532
)
2633
}
2734

0 commit comments

Comments
 (0)