Commit Graph

5735 Commits

Author SHA1 Message Date
Geoffrey White
59964bd9a4 Merge pull request #1575 from jbj/UncheckedLeapYear-bb
C++: Fix performance of unchecked leap year query
2019-07-11 13:57:07 +01:00
semmle-qlci
66464b5c48 Merge pull request #1574 from xiemaisi/js/more-examples
Approved by esben-semmle
2019-07-11 08:09:59 +01:00
Jonas Jensen
21c6340180 C++: Fix performance of unchecked leap year query
This query used `getASuccessor()` on the CFG, which worked in many cases
but became quadratic on certain projects including PostgreSQL and
MySQL. The problem was that there was just enough context for magic to
apply to the transitive closure, but the use of magic meant that the
fast transitive closure algorithm wasn't used. In projects where the
magic had little effect, that led to the
`#ControlFlowGraph::ControlFlowNode::getASuccessor_dispred#bfPlus`
predicate taking quadratic time and space.

This commit changes the query to use basic blocks to find successors,
which is much faster because (1) there are many more `ControlFlowNode`s
than `BasicBlocks`, and (2) the optimizer does not apply magic but uses
fast transitive closure instead.

Behavior changes slightly in the `isUsedInCorrectLeapYearCheck` case: we
now accept a `yfacheck` that comes _before_ `yfa` if they are in the
same basic block. I don't think that matters in practice.
2019-07-10 13:20:32 +02:00
semmle-qlci
d3a880ee4d Merge pull request #1565 from asger-semmle/uncalled-function-metric
Approved by xiemaisi
2019-07-10 09:59:51 +01:00
semmle-qlci
a1f9fe3738 Merge pull request #1573 from asger-semmle/restrict-receiver-type
Approved by xiemaisi
2019-07-10 09:58:48 +01:00
Max Schaefer
1dc685b94b JavaScript: Address review comments. 2019-07-10 08:45:17 +01:00
Max Schaefer
96a0766f3a JavaScript: Add syntax examples in AMD.qll, AST.qll and Stmt.qll. 2019-07-10 08:19:47 +01:00
Dave Bartolomeo
e087b6c82a Merge pull request #1571 from jbj/ir-operand-cached
C++ IR: Make TOperand cached
2019-07-09 16:14:58 -07:00
Dave Bartolomeo
ad5a16e1b1 Merge pull request #1568 from jbj/ir-valuenumbering-copy
C++ IR: Don't propagate GVN through non-exact Copy
2019-07-09 16:13:55 -07:00
Asger F
badca07606 JS: Add test 2019-07-09 21:37:02 +01:00
Asger F
78adcd4a85 JS: Fix join ordering 2019-07-09 21:36:55 +01:00
Asger F
6a986a9179 JS: Avoid tracking classes into receiver of other classes 2019-07-09 21:32:04 +01:00
Jonas Jensen
9ee8a89492 C++ IR: Make TOperand cached
Just like `TInstruction` is cached to prevent re-numbering its tuples in
every IR query, I think `TOperand` should be cached too. I tested it on
the small comdb2 snapshot, where it only saves one second of work when
running a second IR query, but the savings should grow when snapshots
are larger and when there are more IR queries in a suite. Tuple
numbering is mildly quadratic, so it should be good to avoid repeating
it.

Adding these annotations adds three cached stages to the existing four
cached stages of the IR. The new cached stages are small and do not
appear to repeat any work from the other stages, so I see no advantage
to merging them with the existing stages.
2019-07-09 16:07:55 +02:00
semmle-qlci
d497fd26c0 Merge pull request #1569 from Semmle/js/examples-Expr.qll
Approved by asger-semmle, esben-semmle
2019-07-09 14:07:31 +01:00
Max Schaefer
e9ba66f5eb JavaScript: Address review comments. 2019-07-09 12:01:30 +01:00
Anders Schack-Mulligen
eeb7bdba95 Merge pull request #1553 from rneatherway/java/add-null-guard
Java: Add `isNotEmpty` to NullGuards
2019-07-09 11:25:21 +02:00
Max Schaefer
9479ae3069 JavaScript: Add concrete syntax examples to all API classes in Expr.qll. 2019-07-09 10:01:53 +01:00
Jonas Jensen
da13dc6442 C++ IR: Don't propagate GVN through non-exact Copy
The `ValueNumbering` library is supposed to propagate value numberings
through a `CopyInstruction` only when it's _congruent_, meaning it must
have exact overlap with its source. A `CopyInstruction` can be a
`LoadInstruction`, a `StoreInstruction`, or a `CopyValueInstruction`.
The latter is also a `UnaryInstruction`, and the value numbering rule
for `UnaryInstruction` applied to it as well.

This meant that value numbering would propagate even through a
non-congruent `CopyValueInstruction`. That's semantically wrong but
probably only an issue in very rare circumstances, and it should get
corrected when we change the definition of `getUnary` to require
congruence.

What's worse is the performance implications. It meant that the value
numbering IPA witness could take two different paths through every
`CopyValueInstruction`. If multiple `CopyValueInstruction`s were
chained, this would lead to an exponential number of variable numbers
for the same `Instruction`, and we would run out of time and space
while performing value numbering.

This fixes the performance of `ValueNumbering.qll` on
https://github.com/asterisk/asterisk, although this project might also
require a separate change for fixing an infinite loop in the IR constant
analysis.
2019-07-09 10:58:03 +02:00
Jonas Jensen
46d779248d Merge pull request #1559 from zlaski-semmle/zlaski/futile-params-fix
Reduce precision from `very-high` to `low` due to inability to handle…
2019-07-09 06:51:56 +02:00
Dave Bartolomeo
7bbfffec4d Merge pull request #1552 from jbj/ir-builtin_addressof
C++ IR: Support __builtin_addressof
2019-07-08 17:08:38 -07:00
Dave Bartolomeo
52e0f3fb62 Merge pull request #1551 from jbj/ir-DeleteExpr-placeholder
C++: Placeholder translation of delete expressions
2019-07-08 17:07:16 -07:00
Ziemowit Laski
ed5e2f3211 It turns out that the bminor/bash alert spewage was caused by
a bug in the extractor, which is verified fixed in the next release.
Reverting query to its original form.
2019-07-08 12:11:15 -07:00
Robert Marsh
11581e4720 Merge pull request #1562 from geoffw0/models
CPP: Extend StrcpyFunction and update UsingStrcpyAsBoolean.ql
2019-07-08 09:56:16 -07:00
Asger F
7fd4d192b2 JS: Add metric for uncalled functions 2019-07-08 17:38:17 +01:00
semmle-qlci
c5d0abaf8a Merge pull request #1560 from asger-semmle/static-calls
Approved by xiemaisi
2019-07-08 16:42:32 +01:00
Anders Schack-Mulligen
d8395b7268 Merge pull request #1539 from taus-semmle/python-controlflownode-getchild-performance-hotfix
Python: Fix bad join ordering in `ControlFlowNode::getAChild()`.
2019-07-08 17:41:46 +02:00
Asger F
6019e48917 JS: Add annotated call graph test case 2019-07-08 13:55:29 +01:00
Asger F
b63f14fe94 JS: Move CallGraphs test into subfolder 2019-07-08 12:57:34 +01:00
Geoffrey White
29e3e2a5bd CPP: Fix typo. 2019-07-08 09:45:40 +01:00
semmle-qlci
a6b7f2d1f6 Merge pull request #1561 from xiemaisi/js/await-sourcenode
Approved by asger-semmle
2019-07-08 09:44:05 +01:00
Max Schaefer
fec87ac716 JavaScript: Address review comment. 2019-07-08 08:29:12 +01:00
Ziemowit Laski
07ee9be9b6 Set query precision to high 2019-07-06 14:33:00 -07:00
Asger F
37ccfd0036 JS: Resolve static calls using type tracking 2019-07-06 22:32:00 +01:00
Ziemowit Laski
be0db66a55 Squelch bminor/bash alerts and set query precision to high. 2019-07-06 14:27:02 -07:00
Ziemowit Laski
9e600e3768 Reduce precision from very-high to low due to inability to handle K&R definitions correctly. 2019-07-05 18:10:03 -07:00
Robert Marsh
10172af401 Merge pull request #1557 from jbj/hiding-range-based-for
C++: Fix DeclarationHidesVariable FP for nested range-based for loops
2019-07-05 14:56:02 -07:00
Jonas Jensen
8d3cb78a9d C++: Fix DeclarationHidesVariable FP
We don't want alerts about the compiler-generated variables that appear
in the desugaring of range-based `for`.
2019-07-05 20:39:43 +02:00
Jonas Jensen
443a8fbc07 C++: Test for DeclarationHidesVariable FP 2019-07-05 20:34:30 +02:00
Taus Brock-Nannestad
4ddebb9349 Better names for helper predicates. 2019-07-05 16:38:39 +02:00
Taus Brock-Nannestad
703139142a More performance fixes. 2019-07-05 14:44:56 +02:00
Robin Neatherway
204a28df94 Java: Add isNotEmpty to NullGuards 2019-07-05 12:41:46 +01:00
Jonas Jensen
4b4e7caf9f C++ IR: Support __builtin_addressof 2019-07-05 11:05:00 +02:00
Jonas Jensen
6fe9945c04 C++: Placeholder translation of delete expressions
Before this change, `delete` and `delete[]` expressions had no control
flow after them, which caused the reachability analysis to remove all
code after a delete expression. This commit adds placeholder support for
delete expression by translating them to `NoOp` instructions so their
presence doesn't cause large chunks of the program to be removed.
2019-07-05 10:54:35 +02:00
semmle-qlci
50e8034b0b Merge pull request #1544 from esben-semmle/js/additional-configuration-splitting
Approved by xiemaisi
2019-07-05 09:10:22 +01:00
Ellen Arteca
39c37f519d JavaScript: Use type tracking to identify more portal entry/exit nodes. 2019-07-05 09:03:37 +01:00
Arthur Baars
9bf0a3f2cd Merge pull request #1547 from Semmle/rc/1.21
Merge rc/1.21 into master
2019-07-05 07:20:28 +02:00
Esben Sparre Andreasen
fca815f96d JS: make use of the recent Configuration split 2019-07-04 22:42:55 +02:00
Esben Sparre Andreasen
6d5b84fa88 JS: split XmlBomb.qll 2019-07-04 22:42:55 +02:00
Esben Sparre Andreasen
5163ccfd39 JS: split InsufficientPasswordHash.qll 2019-07-04 22:42:55 +02:00
Esben Sparre Andreasen
8664908f78 JS: split PrototypePollution.qll 2019-07-04 22:42:55 +02:00