Skip to content

Commit 99e6708

Browse files
Merge branch 'master' into users/raulga/c6276
2 parents 253b8d1 + 13ef492 commit 99e6708

File tree

77 files changed

+2408
-272
lines changed

Some content is hidden

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

77 files changed

+2408
-272
lines changed

.gitignore

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
# qltest projects and artifacts
99
*/ql/test/**/*.testproj
1010
*/ql/test/**/*.actual
11-
/.vs/slnx.sqlite
12-
/.vs/ql/v15/Browse.VC.opendb
13-
/.vs/ql/v15/Browse.VC.db
14-
/.vs/ProjectSettings.json
1511

16-
/.vs/ql/v15/.suo
12+
# Visual studio temporaries, except a file used by QL4VS
13+
.vs/*
14+
!.vs/VSWorkspaceSettings.json

change-notes/1.19/analysis-javascript.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
* Modelling of taint flow through array operations has been improved. This may give additional results for the security queries.
66

7+
* The taint tracking library now recognizes additional sanitization patterns. This may give fewer false-positive results for the security queries.
8+
79
* Support for popular libraries has been improved. Consequently, queries may produce more results on code bases that use the following features:
810
- file system access, for example through [fs-extra](https://github.com/jprichardson/node-fs-extra) or [globby](https://www.npmjs.com/package/globby)
911

@@ -14,6 +16,7 @@
1416
|-----------------------------------------------|------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
1517
| Enabling Node.js integration for Electron web content renderers (`js/enabling-electron-renderer-node-integration`) | security, frameworks/electron, external/cwe/cwe-094 | Highlights Electron web content renderer preferences with Node.js integration enabled, indicating a violation of [CWE-94](https://cwe.mitre.org/data/definitions/94.html). Results are not shown on LGTM by default. |
1618
| Stored cross-site scripting (`js/stored-xss`) | security, external/cwe/cwe-079, external/cwe/cwe-116 | Highlights uncontrolled stored values flowing into HTML content, indicating a violation of [CWE-079](https://cwe.mitre.org/data/definitions/79.html). Results shown on LGTM by default. |
19+
| Replacement of a substring with itself (`js/identity-replacement`) | correctness, security, external/cwe/cwe-116 | Highlights string replacements that replace a string with itself, which usually indicates a mistake. Results shown on LGTM by default. |
1720

1821
## Changes to existing queries
1922

cpp/ql/src/Documentation/CommentedOutCode.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class CommentBlock extends Comment {
119119
*/
120120
predicate hasLocationInfo(string filepath, int startline, int startcolumn, int endline, int endcolumn) {
121121
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, _, _) and
122-
this.lastComment().getLocation().hasLocationInfo(filepath, _, _, endline, endcolumn)
122+
this.lastComment().getLocation().hasLocationInfo(_, _, _, endline, endcolumn)
123123
}
124124
}
125125

cpp/ql/src/META-INF/MANIFEST.MF

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: Semmle C/C++ Default Queries
44
Bundle-SymbolicName: com.semmle.plugin.semmlecode.cpp.queries;singleton:=true
5-
Bundle-Version: 1.18.0.qualifier
5+
Bundle-Version: 1.18.1.qualifier
66
Bundle-Vendor: Semmle Ltd.
77
Bundle-ActivationPolicy: lazy
8-
Require-Bundle: com.semmle.plugin.qdt.ui;bundle-version="[1.18.0.qualifier,1.18.0.qualifier]"
8+
Require-Bundle: com.semmle.plugin.qdt.ui;bundle-version="[1.18.1.qualifier,1.18.1.qualifier]"

cpp/ql/src/Security/CWE/CWE-468/SuspiciousAddWithSizeof.ql

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,19 @@
1313
import cpp
1414
import IncorrectPointerScalingCommon
1515

16-
private predicate isCharPtrExpr(Expr e) {
16+
private predicate isCharSzPtrExpr(Expr e) {
1717
exists (PointerType pt
1818
| pt = e.getFullyConverted().getUnderlyingType()
19-
| pt.getBaseType().getUnspecifiedType() instanceof CharType)
19+
| pt.getBaseType().getUnspecifiedType() instanceof CharType
20+
or pt.getBaseType().getUnspecifiedType() instanceof VoidType)
2021
}
2122

2223
from Expr sizeofExpr, Expr e
2324
where
2425
// If we see an addWithSizeof then we expect the type of
25-
// the pointer expression to be char*. Otherwise it is probably
26-
// a mistake.
27-
addWithSizeof(e, sizeofExpr, _) and not isCharPtrExpr(e)
26+
// the pointer expression to be char* or void*. Otherwise it
27+
// is probably a mistake.
28+
addWithSizeof(e, sizeofExpr, _) and not isCharSzPtrExpr(e)
2829
select
2930
sizeofExpr,
3031
"Suspicious sizeof offset in a pointer arithmetic expression. " +

cpp/ql/src/definitions.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ private predicate constructorCallStartLoc(ConstructorCall cc, File f, int line,
102102

103103
/**
104104
* Holds if `f`, `line`, `column` indicate the start character
105-
* of `tm`, which mentions `t`.
105+
* of `tm`, which mentions `t`. Type mentions for instantiations
106+
* are filtered out.
106107
*/
107108
private predicate typeMentionStartLoc(TypeMention tm, Type t, File f, int line, int column) {
108109
exists(Location l |
@@ -111,7 +112,8 @@ private predicate typeMentionStartLoc(TypeMention tm, Type t, File f, int line,
111112
l.getStartLine() = line and
112113
l.getStartColumn() = column
113114
) and
114-
t = tm.getMentionedType()
115+
t = tm.getMentionedType() and
116+
not t instanceof ClassTemplateInstantiation
115117
}
116118

117119
/**

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

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,38 @@ import semmle.code.cpp.Location
22
private import semmle.code.cpp.Enclosing
33
private import semmle.code.cpp.internal.ResolveClass
44

5-
/**
6-
* Get the `@element` that represents this `@element`.
7-
* Normally this will simply be `e`, but sometimes it is not.
8-
* For example, for an incomplete struct `e` the result may be a
9-
* complete struct with the same name.
10-
*/
11-
private cached @element resolveElement(@element e) {
12-
if isClass(e)
13-
then result = resolveClass(e)
14-
else result = e
15-
}
16-
175
/**
186
* Get the `Element` that represents this `@element`.
197
* Normally this will simply be a cast of `e`, but sometimes it is not.
208
* For example, for an incomplete struct `e` the result may be a
219
* complete struct with the same name.
2210
*/
11+
pragma[inline]
2312
Element mkElement(@element e) {
24-
result = resolveElement(e)
13+
unresolveElement(result) = e
2514
}
2615

2716
/**
28-
* Get an `@element` that resolves to the `Element`. This should
17+
* INTERNAL: Do not use.
18+
*
19+
* Gets an `@element` that resolves to the `Element`. This should
2920
* normally only be called from member predicates, where `e` is not
3021
* `this` and you need the result for an argument to a database
3122
* extensional.
3223
* See `underlyingElement` for when `e` is `this`.
3324
*/
25+
pragma[inline]
3426
@element unresolveElement(Element e) {
35-
resolveElement(result) = e
27+
not result instanceof @usertype and
28+
result = e
29+
or
30+
e = resolveClass(result)
3631
}
3732

3833
/**
39-
* Get the `@element` that this `Element` extends. This should normally
34+
* INTERNAL: Do not use.
35+
*
36+
* Gets the `@element` that this `Element` extends. This should normally
4037
* only be called from member predicates, where `e` is `this` and you
4138
* need the result for an argument to a database extensional.
4239
* See `unresolveElement` for when `e` is not `this`.
@@ -53,10 +50,6 @@ Element mkElement(@element e) {
5350
* `getLocation`, or `hasLocationInfo`.
5451
*/
5552
class ElementBase extends @element {
56-
ElementBase() {
57-
this = resolveElement(_)
58-
}
59-
6053
/** Gets a textual representation of this element. */
6154
string toString() { none() }
6255
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,13 @@ class AttributeArgument extends Element, @attribute_arg {
294294
}
295295

296296
override string toString() {
297-
if exists (@attribute_arg_empty self | mkElement(self) = this)
297+
if exists (@attribute_arg_empty self | self = underlyingElement(this))
298298
then result = "empty argument"
299299
else exists (string prefix, string tail
300300
| (if exists(getName())
301301
then prefix = getName() + "="
302302
else prefix = "") and
303-
(if exists (@attribute_arg_type self | mkElement(self) = this)
303+
(if exists (@attribute_arg_type self | self = underlyingElement(this))
304304
then tail = getValueType().getName()
305305
else tail = getValueText()) and
306306
result = prefix + tail)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ private import semmle.code.cpp.internal.ResolveClass
77
* A C/C++ type.
88
*/
99
class Type extends Locatable, @type {
10+
Type() { isType(underlyingElement(this)) }
11+
1012
/**
1113
* Gets the name of this type.
1214
*/

0 commit comments

Comments
 (0)