Commit Graph

19777 Commits

Author SHA1 Message Date
Rasmus Wriedt Larsen
70634fe30e Python: Remove usage of deprecated .getValue() 2020-03-06 16:20:31 +01:00
Felicity Chapman
90a9a6d2ac Update docs/language/learn-ql/python/introduce-libraries-python.rst 2020-03-06 15:13:10 +00:00
Jonas Jensen
cc38abd228 C++: Ignore constant static initializers 2020-03-06 15:05:28 +01:00
Jonas Jensen
02f0b89a0d C++: Test for constant static initializer 2020-03-06 15:05:28 +01:00
Rasmus Wriedt Larsen
2416cac8f4 Python: Modernise StringKind files 2020-03-06 14:45:03 +01:00
Alistair
40e8ccc020 Merge pull request #2879 from hubwriter/alistairs-docs-preparation-csharp
CodeQL migration: C# topics - change titles & add intros (2174)
2020-03-06 13:07:15 +00:00
mc
2c542df576 Merge pull request #2897 from mchammer01/js-migration-work
Code QL pre-migration tasks: update articles relating to CodeQL for JavaScript
2020-03-06 11:31:08 +00:00
mc
3558bb8bc0 Update docs/language/learn-ql/javascript/dataflow-cheat-sheet.rst
Co-Authored-By: Felicity Chapman <felicitymay@github.com>
2020-03-06 10:51:13 +00:00
mc
d777c08fc2 Update docs/language/learn-ql/javascript/type-tracking.rst
Co-Authored-By: Felicity Chapman <felicitymay@github.com>
2020-03-06 10:50:59 +00:00
semmle-qlci
3ae1aada37 Merge pull request #2995 from tausbn/python-fix-nested-sequence-assign-cp
Approved by RasmusWL
2020-03-06 09:43:24 +00:00
mchammer01
0a2ca55374 Merge branch 'js-migration-work' of github.com:mchammer01/ql into js-migration-work 2020-03-06 09:24:01 +00:00
mchammer01
fbe0735a5e pre-migration tasks: address review comments 2020-03-06 09:20:40 +00:00
semmle-qlci
7891f8621e Merge pull request #2982 from esbena/js/request-model-with-chaining
Approved by asgerf
2020-03-06 08:57:42 +00:00
semmle-qlci
ddc2f973d1 Merge pull request #3001 from asger-semmle/js/autoformat
Approved by erik-krogh
2020-03-06 08:53:56 +00:00
mc
e0ceeef4dc Update docs/language/learn-ql/javascript/type-tracking.rst
Co-Authored-By: Felicity Chapman <felicitymay@github.com>
2020-03-06 08:18:07 +00:00
mc
0773bfc2d7 Update docs/language/learn-ql/javascript/introduce-libraries-ts.rst
Co-Authored-By: Felicity Chapman <felicitymay@github.com>
2020-03-06 08:17:52 +00:00
Jonas Jensen
a13f355a85 C++: autoformat fixup 2020-03-06 08:29:46 +01:00
Ted Reed
8e1a7fef30 CPP: Add query for CWE-273 that detects out-of-order setuid 2020-03-05 14:21:32 -05:00
Asger Feldthaus
2c8eae22d1 JS: Autoformat 2020-03-05 16:58:49 +00:00
Taus Brock-Nannestad
2face94fa5 Python: Mitigate CP in nested_sequence_assign.
The problem here was that in the base case, there was no relationship between
`left_parent` and `right_parent`. These could be any two tuples or lists, even
if they were not part of an assignment statement.

To fix this, we add a bit of manual "magic", requiring that both of these
arguments must belong to the left and right-hand sides of the same assignment
statement.

(Note that this is in principle _still_ a gross overapproximation, but since
assignment statements are usually quite restricted in size, I don't expect this
to be a major problem.)
2020-03-05 14:09:50 +01:00
Rasmus Wriedt Larsen
fb1e993c0f Merge pull request #2963 from BekaValentine/python-objectapi-to-valueapi-advancedformatting
Python: ObjectAPI to ValueAPI: AdvancedFormatting
2020-03-05 13:40:02 +01:00
Jonas Jensen
e29f517af2 C++: Move InstructionSanity out of Instruction.qll
Having that module in `Instruction.qll` slowed down the parsing of that
file both humans and the compiler.

This commit moves the `InstructionSanity` module to `IRSanity.qll`
without making any changes to its contents apart from adding some
imports.
2020-03-05 12:11:50 +01:00
mchammer01
162a683075 pre-migration task: update links 2020-03-05 10:33:39 +00:00
Felicity Chapman
62bcc1a512 Merge pull request #2986 from felicitymay/1.23/2210-replace-links-semmle.com
1.23: Update or remove unwanted links
2020-03-05 10:20:35 +00:00
semmle-qlci
0d76c71ed7 Merge pull request #2981 from asger-semmle/js/lower-syntax-error-severity
Approved by max-schaefer
2020-03-05 09:47:56 +00:00
semmle-qlci
98cee5cc1d Merge pull request #2967 from asger-semmle/js/flow-through-prop
Approved by esbena
2020-03-05 09:46:35 +00:00
semmle-qlci
85ee5fc988 Merge pull request #2955 from erik-krogh/BetterHeader
Approved by asgerf
2020-03-05 08:24:43 +00:00
Rebecca Valentine
d535246703 Python: Modernizes query 2020-03-04 17:28:44 -08:00
Rebecca Valentine
646bc29e76 Python: Modernizes query 2020-03-04 17:22:21 -08:00
Rebecca Valentine
b09ab67e75 Python: Modernizes query 2020-03-04 17:10:32 -08:00
semmle-qlci
98034aaa53 Merge pull request #2988 from asger-semmle/js/autoformat-again-again
Approved by esbena
2020-03-04 21:20:52 +00:00
semmle-qlci
c6e3d8df49 Merge pull request #2969 from esbena/js/process-as-event-emitter
Approved by erik-krogh
2020-03-04 20:24:12 +00:00
Asger Feldthaus
53569453ba JS: Autoformat again 2020-03-04 19:28:24 +00:00
Robert Marsh
d9d6960110 Merge pull request #2985 from MathiasVP/bounded-uncontrolled-alloc-size
C++: Add testcase for cpp/uncontrolled-allocation-size
2020-03-04 10:00:43 -08:00
Robert Marsh
80ec5c11b3 Merge pull request #2983 from jbj/definitionReachesRank-perf
C++: IR: faster definitionReachesRank
2020-03-04 09:57:06 -08:00
semmle-qlci
c5d39039bc Merge pull request #2962 from erik-krogh/YetAnotherSanitizer
Approved by asgerf
2020-03-04 15:27:09 +00:00
Asger Feldthaus
c2f7cdce25 JS: Change precision to very-high 2020-03-04 15:06:10 +00:00
Mathias Vorreiter Pedersen
3973a50c9b C++: Add testcase for cpp/uncontrolled-allocation-size 2020-03-04 15:51:14 +01:00
Felicity Chapman
4a415d8ad6 Update or remove unwanted links 2020-03-04 14:18:24 +00:00
Jonas Jensen
6b2fd17f03 C++: IR: faster definitionReachesRank
On Wireshark with 6GB RAM, I've observed `definitionReachesRank` to be
the slowest predicate in the IR. It seems that the implementation was
slow because the optimizer failed to eliminate the common
`reachesRank - 1` subexpression. This led to context being pushed into
the `not`, which got implemented as `MATERIALIZE`. That wouldn't
normally be a disaster, but this is one of the largest predicates in the
IR SSA construction, and iteration 2 was very slow.

Before:

    (1505s) Starting to evaluate predicate SSAConstruction::DefUse::definitionReachesRank#ffff#cur_delta/4[1]@93f592 (iteration 1)
    (1535s) Tuple counts for SSAConstruction::DefUse::definitionReachesRank#ffff#cur_delta:
    130670697 ~0%     {4} r1 = SCAN project#SSAConstruction::DefUse::hasDefinitionAtRank#fffff AS I OUTPUT I.<0>, I.<1>, I.<2>, (I.<2> + 1)
    130670697 ~6%     {5} r2 = JOIN r1 WITH SSAConstruction::DefUse::exitRank#fff AS R ON FIRST 2 OUTPUT r1.<0>, r1.<1>, r1.<2>, r1.<3>, R.<2>
    130670697 ~6%     {5} r3 = SELECT r2 ON r2.<3> <= r2.<4>
    130670697 ~0%     {4} r4 = SCAN r3 OUTPUT r3.<0>, r3.<1>, r3.<2>, r3.<3>
                      return r4
    (1535s) 			 - SSAConstruction::DefUse::definitionReachesRank#ffff_delta has 130670697 rows (order for disjuncts: delta=<standard>).

    (1535s) Starting to evaluate predicate SSAConstruction::DefUse::definitionReachesRank#ffff#cur_delta/4[2]@866c14 (iteration 2)
    (1626s) Tuple counts for SSAConstruction::DefUse::definitionReachesRank#ffff#cur_delta:
    261341394 ~107%     {4} r1 = JOIN SSAConstruction::DefUse::definitionReachesRank#ffff#prev_delta AS L WITH SSAConstruction::DefUse::definitionReachesRank#ffff#join_rhs AS R ON FIRST 3 OUTPUT R.<0>, R.<1>, R.<2>, (1 + L.<3>)
    261341394 ~107%     {4} r2 = r1 AND NOT SSAConstruction::DefUse::definitionReachesRank#ffff#prev AS R(r1.<0>, r1.<1>, r1.<2>, r1.<3>)
    130670697 ~0%       {5} r3 = SCAN r2 OUTPUT r2.<0>, r2.<1>, (r2.<3> - 1), r2.<2>, r2.<3>
    106034590 ~1%       {4} r4 = JOIN r3 WITH project#SSAConstruction::DefUse::hasDefinitionAtRank#fffff AS R ON FIRST 3 OUTPUT r3.<0>, r3.<1>, r3.<3>, r3.<4>
    106034590           {4} r5 = MATERIALIZE r4 AS antijoin_rhs
    24636107  ~3%       {4} r6 = r2 AND NOT r5(r2.<0>, r2.<1>, r2.<2>, r2.<3>)
    24636107  ~0%       {5} r7 = JOIN r6 WITH SSAConstruction::DefUse::exitRank#fff AS R ON FIRST 2 OUTPUT r6.<0>, r6.<1>, r6.<2>, r6.<3>, R.<2>
    2749441   ~0%       {5} r8 = SELECT r7 ON r7.<3> <= r7.<4>
    2749441   ~4%       {4} r9 = SCAN r8 OUTPUT r8.<0>, r8.<1>, r8.<2>, r8.<3>
                        return r9
    (1626s) 			 - SSAConstruction::DefUse::definitionReachesRank#ffff_delta has 2749441 rows (order for disjuncts: delta=<standard>).

After:

    (12s) Tuple counts for SSAConstruction::DefUse::definitionReachesRank#ffff#cur_delta:
    130670697 ~0%     {4} r1 = SCAN project#SSAConstruction::DefUse::hasDefinitionAtRank#fffff AS I OUTPUT I.<0>, I.<1>, I.<2>, (I.<2> + 1)
                      return r1
    (12s) 			 - SSAConstruction::DefUse::definitionReachesRank#ffff_delta has 130670697 rows (order for disjuncts: delta=<standard>).
    (12s) Starting to evaluate predicate SSAConstruction::DefUse::definitionReachesRank#ffff#cur_delta/4[2]@fff64c (iteration 2)
    (34s) Tuple counts for SSAConstruction::DefUse::definitionReachesRank#ffff#cur_delta:
    108784031 ~0%     {4} r1 = SSAConstruction::DefUse::definitionReachesRank#ffff#prev_delta AS L AND NOT SSAConstruction::DefUse::exitRank#fff AS R(L.<0>, L.<1>, L.<3>)
    2749441   ~5%     {4} r2 = r1 AND NOT project#SSAConstruction::DefUse::hasDefinitionAtRank#fffff AS R(r1.<0>, r1.<1>, r1.<3>)
    2749441   ~4%     {4} r3 = SCAN r2 OUTPUT r2.<0>, r2.<1>, r2.<2>, (r2.<3> + 1)
    2749441   ~4%     {4} r4 = r3 AND NOT SSAConstruction::DefUse::definitionReachesRank#ffff#prev AS R(r3.<0>, r3.<1>, r3.<2>, r3.<3>)
                      return r4
    (34s) 			 - SSAConstruction::DefUse::definitionReachesRank#ffff_delta has 2749441 rows (order for disjuncts: delta=<standard>).

Note that the row counts are exactly the same before and after.
2020-03-04 15:00:47 +01:00
Mathias Vorreiter Pedersen
bbcf0b52df Merge pull request #2941 from jbj/Overflow-stmtDominates
C++: Avoid `iDominates*` in Overflow.qll
2020-03-04 12:40:52 +01:00
Esben Sparre Andreasen
db335ae89b JS: add default/chaining for request 2020-03-04 12:36:49 +01:00
Esben Sparre Andreasen
92b3e8c060 JS: add default/chaining tests for request 2020-03-04 12:25:23 +01:00
Mathias Vorreiter Pedersen
b20afa6370 Merge pull request #2979 from jbj/GVN-noinline
C++: pragma[noinline] on GVN charpred
2020-03-04 12:19:27 +01:00
Asger Feldthaus
6f2b05932e JS: Change note 2020-03-04 11:18:12 +00:00
Asger Feldthaus
af0df6c369 JS: Lower severity of js/syntax-error 2020-03-04 11:16:59 +00:00
semmle-qlci
c4b961c8af Merge pull request #2973 from tausbn/python-fix-or-disable-cps
Approved by BekaValentine
2020-03-04 10:36:47 +00:00
Jonas Jensen
60bcbf477a C++: pragma[noinline] on GVN charpred
The charpred of class `GVN` in `ASTValueNumbering.qll` got inlined into
the member predicate `getAnInstruction` and caused a tuple explosion on
Wireshark in the query `StrncpyFlippedArgs.ql`.

I interrupted the predicate after 10 minutes and got these intermediate
tuple counts:

    (5208s) Tuple counts for ASTValueNumbering::GVN::getAnInstruction_dispred#ff:
    8754900909 ~5%          {3} r1 = JOIN ValueNumberingInternal::tvalueNumber#ff_10#join_rhs AS L WITH ValueNumberingInternal::tvalueNumber#ff_10#join_rhs AS R ON FIRST 1 OUTPUT R.<1>, L.<1>, L.<0>
    4390274632 ~150085%     {2} r2 = JOIN r1 WITH project#SSAConstruction::Cached::getInstructionUnconvertedResultExpression AS R ON FIRST 1 OUTPUT r1.<2>, r1.<1>
                            return r2

After this change, the `getAnInstruction` predicate is itself inlined,
like it should be. The new non-inlined charpred takes 2.1s and has these
tuple counts:

    (2s) Tuple counts for ASTValueNumbering::GVN#f:
    9158442  ~117%     {1} r1 = JOIN project#SSAConstruction::Cached::getInstructionUnconvertedResultExpression AS L WITH ValueNumberingInternal::tvalueNumber#ff@staged_ext AS R ON FIRST 1 OUTPUT R.<1>
                       return r1
2020-03-04 10:34:05 +01:00
Esben Sparre Andreasen
ae43e90a67 JS: model process as an EventEmitter 2020-03-04 09:49:16 +01:00
Rebecca Valentine
2bcd8c8cb8 Python: Moves query over to modernized predicates 2020-03-03 17:05:47 -08:00