Skip to content

Commit eb356d8

Browse files
author
Esben Sparre Andreasen
authored
Merge branch 'master' into js/format-string-taint-step
2 parents f522376 + 6969466 commit eb356d8

File tree

99 files changed

+825
-720
lines changed

Some content is hidden

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

99 files changed

+825
-720
lines changed

change-notes/1.18/analysis-javascript.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212

1313
* Modelling of taint flow through the array operations `map` and `join` has been improved. This may give additional results for the security queries.
1414

15-
* The taint tracking library recognizes more ways in which taint propagates. In particular, some flow through string formatters is now recognized.
15+
* The taint tracking library recognizes more ways in which taint propagates. In particular, some flow through string formatters is now recognized. This may give additional results for the security queries.
16+
17+
* The taint tracking library now recognizes additional sanitization patterns. This may give fewer false-positive results for the security queries.
1618

1719
* Support for popular libraries has been improved. Consequently, queries may produce more results on code bases that use the following libraries:
1820
- [bluebird](http://bluebirdjs.com)

cpp/ql/src/AlertSuppression.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ class SuppressionComment extends CppStyleComment {
5656
*/
5757
class SuppressionScope extends @comment {
5858
SuppressionScope() {
59-
this instanceof SuppressionComment
59+
mkElement(this) instanceof SuppressionComment
6060
}
6161

6262
/** Gets a suppression comment with this scope. */
6363
SuppressionComment getSuppressionComment() {
64-
result = this
64+
result = mkElement(this)
6565
}
6666

6767
/**
@@ -72,7 +72,7 @@ class SuppressionScope extends @comment {
7272
* [LGTM locations](https://lgtm.com/help/ql/locations).
7373
*/
7474
predicate hasLocationInfo(string filepath, int startline, int startcolumn, int endline, int endcolumn) {
75-
this.(SuppressionComment).covers(filepath, startline, startcolumn, endline, endcolumn)
75+
mkElement(this).(SuppressionComment).covers(filepath, startline, startcolumn, endline, endcolumn)
7676
}
7777

7878
/** Gets a textual representation of this element. */

cpp/ql/src/Architecture/Refactoring Opportunities/ClassesWithManyFields.ql

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import cpp
1313

1414
string kindstr(Class c)
1515
{
16-
exists(int kind | usertypes(c, _, kind) |
16+
exists(int kind | usertypes(unresolveElement(c), _, kind) |
1717
(kind = 1 and result = "Struct") or
1818
(kind = 2 and result = "Class") or
1919
(kind = 6 and result = "Template class")
@@ -48,37 +48,38 @@ predicate masterVde(VariableDeclarationEntry master, VariableDeclarationEntry vd
4848

4949
class VariableDeclarationGroup extends @var_decl {
5050
VariableDeclarationGroup() {
51-
not previousVde(_, this)
51+
not previousVde(_, mkElement(this))
5252
}
5353
Class getClass() {
54-
vdeInfo(this, result, _, _)
54+
vdeInfo(mkElement(this), result, _, _)
5555
}
5656

5757
// pragma[noopt] since otherwise the two locationInfo relations get join-ordered
5858
// after each other
5959
pragma[noopt]
6060
predicate hasLocationInfo(string path, int startline, int startcol, int endline, int endcol) {
61-
exists(VariableDeclarationEntry last, Location lstart, Location lend |
62-
masterVde(this, last) and
61+
exists(Element thisElement, VariableDeclarationEntry last, Location lstart, Location lend |
62+
thisElement = mkElement(this) and
63+
masterVde(thisElement, last) and
6364
this instanceof VariableDeclarationGroup and
6465
not previousVde(last, _) and
65-
exists(VariableDeclarationEntry vde | vde=this and vde instanceof VariableDeclarationEntry and vde.getLocation() = lstart) and
66+
exists(VariableDeclarationEntry vde | vde=mkElement(this) and vde instanceof VariableDeclarationEntry and vde.getLocation() = lstart) and
6667
last.getLocation() = lend and
6768
lstart.hasLocationInfo(path, startline, startcol, _, _) and
6869
lend.hasLocationInfo(path, _, _, endline, endcol)
6970
)
7071
}
7172

7273
string toString() {
73-
if previousVde(this, _) then
74+
if previousVde(mkElement(this), _) then
7475
result = "group of "
7576
+ strictcount(string name
7677
| exists(VariableDeclarationEntry vde
77-
| masterVde(this, vde) and
78+
| masterVde(mkElement(this), vde) and
7879
name = vde.getName()))
7980
+ " fields here"
8081
else
81-
result = "declaration of " + this.(VariableDeclarationEntry).getVariable().getName()
82+
result = "declaration of " + mkElement(this).(VariableDeclarationEntry).getVariable().getName()
8283
}
8384
}
8485

cpp/ql/src/CPython/Extensions.qll

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ import CPython.ArgParse
33

44

55
/* Root class of all 'C' objects */
6-
abstract class CObject extends @element {
6+
abstract class CObject extends Element {
77

88
abstract string getTrapID();
9-
10-
/** Gets a textual representation of this element. */
11-
abstract string toString();
129
}
1310

1411

cpp/ql/src/Likely Bugs/Format/SnprintfOverflow.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ predicate flowsToDefImpl(
9898
or
9999
// `x++`
100100
exists (CrementOperation crem
101-
| def = crem and
101+
| mkElement(def) = crem and
102102
crem.getOperand() = v.getAnAccess() and
103103
flowsToExpr(source, crem.getOperand(), pathMightOverflow))
104104
or

cpp/ql/src/Metrics/Dependencies/ExternalDependencies.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class Library extends LibraryT {
6666
result = lib.getAFile()
6767
) or exists(@external_package ep |
6868
this = LibraryTExternalPackage(ep, _, _) and
69-
header_to_external_package(result, ep)
69+
header_to_external_package(unresolveElement(result), ep)
7070
)
7171
}
7272
}

cpp/ql/src/Metrics/Files/FCommentRatio.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
import cpp
1313

1414
from File f, int comments, int total
15-
where f.fromSource() and numlines(f, total, _, comments) and total > 0
15+
where f.fromSource() and numlines(unresolveElement(f), total, _, comments) and total > 0
1616
select f, 100.0 * (comments.(float) / total.(float)) as ratio
1717
order by ratio desc

cpp/ql/src/PointsTo/PreparedStagedPointsTo.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77

88
import semmle.code.cpp.pointsto.PointsTo
99

10-
select count(int set, Element location | setlocations(set, location)),
11-
count(int set, Element element | pointstosets(set, element))
10+
select count(int set, Element location | setlocations(set, unresolveElement(location))),
11+
count(int set, Element element | pointstosets(set, unresolveElement(element)))
1212

cpp/ql/src/Security/CWE/CWE-764/LockFlow.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ predicate tryLockCondition(VariableAccess access,
2727
(cond = call.getParent*() and
2828
cond.isCondition() and
2929
failNode = cond.getASuccessor() and
30-
failNode instanceof BasicBlockWithReturn))
30+
unresolveElement(failNode) instanceof BasicBlockWithReturn))
3131
}
3232

3333
/**

cpp/ql/src/Security/CWE/CWE-764/UnreleasedLock.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ predicate failedLock(MutexType t, BasicBlock lockblock, BasicBlock failblock) {
2929
exists (ControlFlowNode lock |
3030
lock = lockblock.getEnd() and
3131
lock = t.getLockAccess() and
32-
lock.getAFalseSuccessor() = failblock
32+
lock.getAFalseSuccessor() = mkElement(failblock)
3333
)
3434
}
3535

0 commit comments

Comments
 (0)