Compare commits

...

958 Commits

Author SHA1 Message Date
Chuan-kai Lin
1a575ef297 Merge pull request #14167 from asgerf/ts/tolerate-out-of-order-requests
JS: tolerate out of order requests in TypeScript extractor
2023-09-08 12:33:44 -07:00
Robert Marsh
e1ffc8d886 Merge pull request #14171 from MathiasVP/fix-dataflow-out-of-post-update-nodes
C++: Fix dataflow out of post update nodes
2023-09-08 14:56:41 -04:00
Mathias Vorreiter Pedersen
9f89c63771 C++: Accept test changes. 2023-09-08 17:07:26 +01:00
Mathias Vorreiter Pedersen
0be61be07a C++: Handle flow out of post-update nodes when there's another use of the variable in the call that we need to skip. 2023-09-08 17:07:26 +01:00
Mathias Vorreiter Pedersen
d5442ec9c5 C++: Add regression test. 2023-09-08 13:10:04 +01:00
Tom Hvitved
354a55c735 Merge pull request #14169 from hvitved/backport-fix
Revert "C#: Bump all dependencies"
2023-09-08 13:37:12 +02:00
Tom Hvitved
e6a6a7931b Revert "C#: Bump all dependencies" 2023-09-08 11:19:00 +02:00
Asger F
ea384b340a JS: Change note 2023-09-08 10:31:04 +02:00
Asger F
e08a873829 JS: Tolerate TypeScript files being requested out of order 2023-09-08 10:31:04 +02:00
Chuan-kai Lin
163252d5f6 Merge pull request #14147 from github/release-prep/2.14.4
Release preparation for version 2.14.4
2023-09-05 13:50:45 -07:00
github-actions[bot]
abf2b12b1c Release preparation for version 2.14.4 2023-09-05 16:56:14 +00:00
Ian Lynagh
a2659eecfb Merge pull request #14018 from igfoo/igfoo/extractor_information_kotlin1
Kotlin: Write usesK2 ("uses Kotlin 2") information to the database
2023-09-04 13:38:23 +01:00
Michael B. Gale
77369a09a4 Merge pull request #13872 from Kwstubbs/Kevin_error_sanitizer
Go: Add sanitizer to remove paths passing through http.Error
2023-09-04 13:25:55 +01:00
Ian Lynagh
03ad04bc8e Merge pull request #14118 from igfoo/igfoo/kotlin_master
Kotlin: Make it possible to build with master
2023-09-04 12:12:25 +01:00
AlexDenisov
e2602fbbc4 Merge pull request #14119 from github/alexdenisov/sequence-expr
Swift: fix SequenceExpr extraction
2023-09-04 12:29:07 +02:00
Paolo Tranquilli
7d89028688 Merge pull request #14106 from github/alexdenisov/rename-xcode-autobuilder
Swift: rename autobuilder. NFC
2023-09-04 12:28:47 +02:00
Ian Lynagh
bbf441f87a Kotlin: Add an integration test for Kotlin 2 2023-09-04 11:28:31 +01:00
Alex Denisov
888dd786b4 Swift: fix SequenceExpr extraction
Before we extracted all the subexpressions from the `SequenceExpr` while we should've only extracted the expressions at odd indices:
```
...
/// SequenceExpr - A list of binary operations which has not yet been
/// folded into a tree.  The operands all have even indices, while the
/// subexpressions with odd indices are all (potentially overloaded)
/// references to binary operators.
class SequenceExpr final : public Expr,
...
```

The AST for a `SequenceExpr` looks like this:

```
sequence_expr:
  unresolved_dot_expr:
    ...
  assign_expr:
    member_ref_expr:
      ...
    dot_syntax_call_expr:
      ...
  unresolved_member_chain_expr:
    ...
```

however, what's is not visible with the "final" AST is that `unresolved_dot_expr` is the unresolved version of `assign_expr.member_ref_expr` and the `unresolved_member_chain_expr` is the unresolved version of `assign_expr.dot_syntax_call_expr`.
This becomes visible when I enable typechecker debugging:

```c++
auto &typeCheckerOptions = invocation.getTypeCheckerOptions();
typeCheckerOptions.DebugConstraintSolver = true;
```

Which prints the following snippets:

```
---Initial constraints for the given expression---
(assign_expr type='()' location=foo.swift:25:54 range=[foo.swift:25:13 - line:25:57]
  (unresolved_dot_expr type='$T2' location=foo.swift:25:29 range=[foo.swift:25:13 - line:25:29] field 'preferredDatePickerStyle' function_ref=unapplied
    (unresolved_dot_expr type='$T1' location=foo.swift:25:18 range=[foo.swift:25:13 - line:25:18] field 'datePicker' function_ref=unapplied
      (declref_expr type='DatePickerCell' location=foo.swift:25:13 range=[foo.swift:25:13 - line:25:13] decl=foo.(file).DatePickerRowProtocol extension.configurePickerStyle(_:_:).cell@foo.swift:15:33 function_ref=unapplied)))
  (unresolved_member_chain_expr implicit type='$T5' location=foo.swift:25:57 range=[foo.swift:25:56 - line:25:57]
    (unresolved_member_expr type='$T4' location=foo.swift:25:57 range=[foo.swift:25:56 - line:25:57] name='wheels' function_ref=unapplied)))

// ...

---Type-checked expression---
(assign_expr type='()' location=foo.swift:25:54 range=[foo.swift:25:13 - line:25:57]
  (member_ref_expr type='@lvalue UIDatePickerStyle' location=foo.swift:25:29 range=[foo.swift:25:13 - line:25:29] decl=UIKit.(file).UIDatePicker.preferredDatePickerStyle
    (force_value_expr implicit type='UIDatePicker' location=foo.swift:25:18 range=[foo.swift:25:13 - line:25:18] implicit_iuo_unwrap
      (load_expr implicit type='UIDatePicker?' location=foo.swift:25:18 range=[foo.swift:25:13 - line:25:18]
        (member_ref_expr type='@lvalue UIDatePicker?' location=foo.swift:25:18 range=[foo.swift:25:13 - line:25:18] decl=foo.(file).DatePickerCell.datePicker@foo.swift:10:29
          (declref_expr type='DatePickerCell' location=foo.swift:25:13 range=[foo.swift:25:13 - line:25:13] decl=foo.(file).DatePickerRowProtocol extension.configurePickerStyle(_:_:).cell@foo.swift:15:33 function_ref=unapplied)))))
  (dot_syntax_call_expr type='UIDatePickerStyle' location=foo.swift:25:57 range=[foo.swift:25:56 - line:25:57]
    (declref_expr type='(UIDatePickerStyle.Type) -> UIDatePickerStyle' location=foo.swift:25:57 range=[foo.swift:25:57 - line:25:57] decl=UIKit.(file).UIDatePickerStyle.wheels function_ref=unapplied)
    (argument_list implicit
      (argument
        (type_expr implicit type='UIDatePickerStyle.Type' location=foo.swift:25:56 range=[foo.swift:25:56 - line:25:56] typerepr='UIDatePickerStyle')))))
```

The proposed solution is to only extract subexpressions at indices from `SequenceExpr` thus ignoring all the unresolved leftovers.

Note: I'm not entirely sure about the case when there is only child (`elements.size() == 1`) so I'm always extracting it.

This patch fixes the last source of unresolved expressions.
2023-09-04 11:42:12 +02:00
Rasmus Wriedt Larsen
a58c9e91ea Merge pull request #14130 from RasmusWL/fixup-accept-ci-changes
Misc: Fixup for `accept-expected-changes-from-ci.py`
2023-09-04 09:47:31 +02:00
Rasmus Wriedt Larsen
301133ad94 Misc: Fixup for accept-expected-changes-from-ci.py
Allow empty lines while looking for diff (between `---expected` and `FAILED`). This can happen when there is `Locations outside the test directory` since an empty line is printed after that warning message (this output can be interleaved with the diff due to parallel execution).
2023-09-04 09:32:06 +02:00
Erik Krogh Kristensen
284ca5e4ee Merge pull request #14129 from github/dependabot/cargo/ql/regex-1.9.5
Bump regex from 1.9.3 to 1.9.5 in /ql
2023-09-04 08:11:51 +02:00
dependabot[bot]
4919cc4c4e Bump regex from 1.9.3 to 1.9.5 in /ql
Bumps [regex](https://github.com/rust-lang/regex) from 1.9.3 to 1.9.5.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.9.3...1.9.5)

---
updated-dependencies:
- dependency-name: regex
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-04 03:47:05 +00:00
Ian Lynagh
181594badb Kotlin: Add packageFqName and IrSymbolInternals compatibility
In master, we need to switch to these, but for building for older
versions we need to add our own support.

Currently the v_1_9_255 files are nto used, but we will need them (in a
differently-named directory) for a future release.
2023-09-01 11:20:58 +01:00
Ian Lynagh
72e08a9277 Kotlin: Tweak the build system
You can now make a versions/* directory that the build system doesn't
know about. This can be used to add support for not-yet-supported
versions.
2023-09-01 11:08:54 +01:00
Mathias Vorreiter Pedersen
67a0112fcb Merge pull request #14115 from MathiasVP/fix-incorrect-load-of-constant
C++: Don't generate `Load`s for constant expressions
2023-09-01 08:50:44 +01:00
Mathias Vorreiter Pedersen
72d9812fea C++: Accept more test changes. 2023-08-31 21:56:35 +01:00
Mathias Vorreiter Pedersen
dfefd62089 C++: Accept test changes. 2023-08-31 20:38:46 +01:00
Mathias Vorreiter Pedersen
aed14f2924 C++: Don't insert loads for constants. 2023-08-31 20:38:40 +01:00
Mathias Vorreiter Pedersen
b575747357 C++: Add testcase with invalid IR. 2023-08-31 20:35:33 +01:00
yoff
da64ea40b9 Merge pull request #13782 from jorgectf/jorgectf/shlex-quote
Python: Add `shlex.quote` as `py/shell-command-constructed-from-input` sanitizer
2023-08-31 21:08:58 +02:00
Ian Lynagh
eb59bc04cd Kotlin: Add missing imports 2023-08-31 19:28:05 +01:00
Ian Lynagh
3009f40814 Kotlin: Opt in to org.jetbrains.kotlin.ir.symbols.IrSymbolInternals
Needed for upstream master.
2023-08-31 19:28:05 +01:00
Ian Lynagh
1ec29bffbb Kotlin: Don't use deprecated createBlockBody
The function that takes a list of statements is hidden in upstream
master.
2023-08-31 19:28:05 +01:00
Ian Lynagh
d511d46cde Kotlin: Use packageFqName rather than fqName
Upstream master says:
   error: using 'fqName: FqName' is an error. Please use `packageFqName` instead
2023-08-31 19:28:05 +01:00
Mathias Vorreiter Pedersen
10548b57d7 Merge pull request #14103 from MathiasVP/non-certain-def-is-a-use
C++: Non-certain definitions should always be uses
2023-08-31 16:15:30 +01:00
Erik Krogh Kristensen
cd590d356d Merge pull request #14053 from erik-krogh/ts52
JS: Add support for TypeScript 5.2
2023-08-31 14:39:50 +02:00
Tom Hvitved
23857267db Merge pull request #14110 from hvitved/ruby/remove-emptiness-successor
Ruby: Get rid of unused `EmptinessSuccessor`
2023-08-31 13:41:25 +02:00
Tom Hvitved
50db6916c8 Ruby: Get rid of unused EmptinessSuccessor 2023-08-31 13:17:05 +02:00
Tom Hvitved
73370e7282 Merge pull request #14100 from hvitved/dataflow/consistency-pack
Data flow: Add consistency checks to shared ql pack
2023-08-31 11:47:40 +02:00
Tom Hvitved
756886808d Merge pull request #14098 from hvitved/csharp/cil-best-impl
C#: Speedup `bestImplementation`
2023-08-31 10:57:28 +02:00
Mathias Vorreiter Pedersen
f5509da4bb Merge pull request #14038 from alexet/delete-ir
CPP: Add delete/delete[] calls to the IR.
2023-08-31 09:22:34 +01:00
Asger F
2d5c40db31 Merge pull request #14048 from asgerf/shared/variable-capture-write-source-node
Variable capture: allow arbitrary data-flow nodes to be the source of a write
2023-08-31 10:20:48 +02:00
Tom Hvitved
c68d0bc936 Merge pull request #14099 from hvitved/csharp/transitive-capture-call-unique
C#: Do not embed target callable in `TransitiveCapturedCall`
2023-08-31 10:12:26 +02:00
Alex Denisov
c1da2dfa73 Swift: fix autobuild.sh 2023-08-31 09:40:13 +02:00
Michael Nebel
ded49015e0 Merge pull request #13970 from michaelnebel/csharp/usereferenceassemlblies
C#: Compile against the reference assemblies in the standalone extractor (if possible)
2023-08-31 09:00:30 +02:00
Erik Krogh Kristensen
cd289f8207 Merge pull request #14105 from github/dependabot/cargo/ql/chrono-0.4.28
Bump chrono from 0.4.27 to 0.4.28 in /ql
2023-08-31 08:16:42 +02:00
Alex Denisov
803adae9c6 Swift: rename autobuilder. NFC 2023-08-31 08:12:52 +02:00
dependabot[bot]
4770eb0328 Bump chrono from 0.4.27 to 0.4.28 in /ql
Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.27 to 0.4.28.
- [Release notes](https://github.com/chronotope/chrono/releases)
- [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chronotope/chrono/compare/v0.4.27...v0.4.28)

---
updated-dependencies:
- dependency-name: chrono
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-31 03:44:01 +00:00
Mathias Vorreiter Pedersen
1159508e4f Merge pull request #14008 from MathiasVP/reuse-even-more-nodes
C++: Reuse even more `DataFlow::Node`s
2023-08-30 19:38:52 +01:00
Alex Eyers-Taylor
59a77666a6 CPP: Remove uneeded indirection around delete calls in the IR. 2023-08-30 16:31:51 +01:00
Michael Nebel
3afa4aa91e C#: Add change note. 2023-08-30 16:51:16 +02:00
Mathias Vorreiter Pedersen
261ba8e02d C++: Add QLDoc to 'isDereference'. 2023-08-30 14:34:30 +01:00
Tom Hvitved
253f932d2a Python: Use data flow consistency checks from shared pack 2023-08-30 15:29:41 +02:00
Tom Hvitved
9af706c2a5 Swift: Use data flow consistency checks from shared pack 2023-08-30 15:29:41 +02:00
Tom Hvitved
db304d118b C++: Use data flow consistency checks from shared pack 2023-08-30 15:29:41 +02:00
Tom Hvitved
fefe64bf0c Java: Use data flow consistency checks from shared pack 2023-08-30 15:29:41 +02:00
Tom Hvitved
5c8367a695 C#: Use data flow consistency checks from shared pack 2023-08-30 15:29:41 +02:00
Tom Hvitved
c4b626a416 Ruby: Use data flow consistency checks from shared pack 2023-08-30 15:29:41 +02:00
Tom Hvitved
de7c9bdd9b Data flow: Add consistency checks to shared ql pack 2023-08-30 15:29:41 +02:00
Michael Nebel
291d7b3e05 C#: Use reference assemblies instead of implementation assemblies. 2023-08-30 14:19:11 +02:00
Michael Nebel
a966c0e1eb C#: Do not include the mscorlib assembly and remove the option. 2023-08-30 14:19:11 +02:00
Tom Hvitved
ce229fe21f Merge pull request #14096 from hvitved/ruby/expected-test-fix
Ruby: Update expected test output
2023-08-30 13:50:49 +02:00
Tom Hvitved
29982fe30e C#: Do not embed target callable in TransitiveCapturedCall 2023-08-30 13:48:44 +02:00
Tom Hvitved
66f5e4a05b C#: Speedup bestImplementation
Avoids an expensive anti-join:

```
[2023-08-29 15:25:48] Evaluated non-recursive predicate _FileSystem#df18ed9a::Make#File#1a556f64::Input#::Container::toString#0#dispred#bf_Method#621e9e2e::__#antijoin_rhs@96d08bc8 in 272332ms (size: 1841891).
Evaluated relational algebra for predicate _FileSystem#df18ed9a::Make#File#1a556f64::Input#::Container::toString#0#dispred#bf_Method#621e9e2e::__#antijoin_rhs@96d08bc8 with tuple counts:
         4632443     ~2%    {3} r1 = JOIN _cil_instruction_3#antijoin_rhs_cil_method_implementation#shared WITH cil_method_implementation ON FIRST 1 OUTPUT Rhs.1, Lhs.0, Lhs.1

        71945701     ~3%    {3} r2 = JOIN r1 WITH cil_method_implementation_10#join_rhs ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2
        71945701  ~1329%    {3} r3 = JOIN r2 WITH Method#621e9e2e::MethodImplementation::getNumberOfInstructions#0#dispred#ff ON FIRST 1 OUTPUT Lhs.1, Lhs.2, Rhs.1
         5016836     ~4%    {4} r4 = JOIN r3 WITH Method#621e9e2e::MethodImplementation::getNumberOfInstructions#0#dispred#ff ON FIRST 1 OUTPUT Lhs.0, Lhs.1, Lhs.2, Rhs.1
                            {4} r5 = SELECT r4 ON In.3 < In.2
           65637     ~3%    {2} r6 = SCAN r5 OUTPUT In.0, In.1

        71945701     ~0%    {3} r7 = JOIN r1 WITH cil_method_implementation_10#join_rhs ON FIRST 1 OUTPUT Lhs.2, Lhs.1, Rhs.1
        71945701     ~1%    {4} r8 = JOIN r7 WITH assemblies ON FIRST 1 OUTPUT Lhs.2, Lhs.1, Lhs.0, Rhs.1
        71945701     ~0%    {5} r9 = JOIN r8 WITH cil_method_implementation ON FIRST 1 OUTPUT Rhs.2, Lhs.1, Lhs.2, Lhs.0, Lhs.3
        71945701     ~0%    {5} r10 = JOIN r9 WITH assemblies ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2, Lhs.3, Lhs.4
        71945701     ~0%    {5} r11 = JOIN r10 WITH FileSystem#df18ed9a::Make#File#1a556f64::Input#::Container::toString#0#dispred#bf ON FIRST 1 OUTPUT Lhs.4, Lhs.1, Lhs.2, Lhs.3, Rhs.1
        71945701     ~2%    {5} r12 = JOIN r11 WITH FileSystem#df18ed9a::Make#File#1a556f64::Input#::Container::toString#0#dispred#bf ON FIRST 1 OUTPUT Lhs.1, Lhs.2, Lhs.3, Lhs.4, Rhs.1
                            {5} r13 = SELECT r12 ON In.4 > In.3
        33509342     ~0%    {3} r14 = SCAN r13 OUTPUT In.0, In.1, In.2
        33509342     ~0%    {4} r15 = JOIN r14 WITH Method#621e9e2e::MethodImplementation::getNumberOfInstructions#0#dispred#ff ON FIRST 1 OUTPUT Lhs.2, Rhs.1, Lhs.0, Lhs.1
        33051362  ~1670%    {2} r16 = JOIN r15 WITH Method#621e9e2e::MethodImplementation::getNumberOfInstructions#0#dispred#ff ON FIRST 2 OUTPUT Lhs.2, Lhs.3

        33116999  ~1646%    {2} r17 = r6 UNION r16
                            return r17
```
2023-08-30 13:46:11 +02:00
Tom Hvitved
7e77c77d92 Ruby: Update expected test output 2023-08-30 13:33:48 +02:00
erik-krogh
984795ee46 fix off-by-one 2023-08-30 13:29:23 +02:00
Anders Starcke Henriksen
44a83a71a8 Merge pull request #13879 from github/starcke/automodel-pack
Create separate automodel pack
2023-08-30 13:24:25 +02:00
Rasmus Wriedt Larsen
62c2316124 Merge pull request #14084 from RasmusWL/flask-jsonify
Python: Remove XSS FP from use of `flask.jsonify`
2023-08-30 13:07:54 +02:00
Mathias Vorreiter Pedersen
4ca259b200 C++: Non-exact definitions should always be a use. 2023-08-30 11:50:57 +01:00
Mathias Vorreiter Pedersen
6a21fa04cd Merge pull request #14034 from geoffw0/hostname
Swift: New query: Incomplete regular expression for hostnames
2023-08-30 11:33:36 +01:00
Mathias Vorreiter Pedersen
b092da485d C++: Accept more test changes. 2023-08-30 11:26:40 +01:00
Tom Hvitved
c32c4bb6d2 Merge pull request #14086 from hvitved/csharp/perf-fixes
C#: Various performance fixes
2023-08-30 12:13:52 +02:00
Geoffrey White
39b45fa24f Merge pull request #13943 from geoffw0/weakhashexample
Swift: Update the weak sensitive data hashing examples and qhelp
2023-08-30 10:36:23 +01:00
Michael Nebel
f88428f3fd Merge pull request #14085 from michaelnebel/csharp/use-stubs-5
C#: Use stubs in unit tests.
2023-08-30 11:07:53 +02:00
Anders Starcke Henriksen
361ae1747e Merge branch 'main' into starcke/automodel-pack 2023-08-30 09:25:28 +02:00
erik-krogh
2643ab3dbf using is not a keyword 2023-08-30 08:44:59 +02:00
Michael Nebel
a966944fd8 Merge pull request #14083 from michaelnebel/csharp/autobuilderimports
C#: Re-factor using statements order in autobuilder.
2023-08-30 08:16:03 +02:00
erik-krogh
5e11fe74f7 Merge branch 'main' into ts52 2023-08-30 07:57:55 +02:00
Erik Krogh Kristensen
9bf5999ca0 Merge pull request #14093 from github/dependabot/cargo/ql/chrono-0.4.27
Bump chrono from 0.4.26 to 0.4.27 in /ql
2023-08-30 07:42:44 +02:00
dependabot[bot]
e3ff7644f7 Bump chrono from 0.4.26 to 0.4.27 in /ql
Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.26 to 0.4.27.
- [Release notes](https://github.com/chronotope/chrono/releases)
- [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chronotope/chrono/compare/v0.4.26...v0.4.27)

---
updated-dependencies:
- dependency-name: chrono
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-30 03:14:05 +00:00
Geoffrey White
125629a7e2 Swift: Delete 'usually'. 2023-08-29 23:25:22 +01:00
Geoffrey White
210a5bfff2 Update swift/ql/src/queries/Security/CWE-328/WeakSensitiveDataHashing.qhelp
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
2023-08-29 23:24:12 +01:00
Geoffrey White
7006cfd8f8 Swif: Fix paragraph breaks. 2023-08-29 23:00:17 +01:00
Kevin Stubbings
84d52b94a3 Forgot delete 2023-08-29 08:38:18 -07:00
Kevin Stubbings
ffa3bdc8bb Change note changes 2023-08-29 08:37:15 -07:00
Michael Nebel
e226c564b6 C#: Base WriteOnlyContainer test on stubs. 2023-08-29 16:24:01 +02:00
Michael Nebel
35a1dd8ba9 C#: Base Useless Code tests on stubs. 2023-08-29 16:20:59 +02:00
Mathias Vorreiter Pedersen
e4a11b86d9 Merge branch 'main' into reuse-even-more-nodes 2023-08-29 15:08:30 +01:00
Michael Nebel
e9b3f1282a C#: Base UseBraces tests on stubs. 2023-08-29 16:05:15 +02:00
Tom Hvitved
8624ff12be Merge pull request #14082 from hvitved/csharp/bump-dependencies
C#: Bump all dependencies
2023-08-29 15:52:40 +02:00
Michael Nebel
fc850b18fe C#: Base ReadOnlyContainer tests on stubs. 2023-08-29 15:36:03 +02:00
Michael Nebel
7d7a893b55 C#: Base Performance tests on stubs. 2023-08-29 15:34:33 +02:00
Jean Helie
41726f52a2 Merge pull request #13954 from github/kaeluka/add-provenance-to-metadata
Java: Automodel: Add Candidates for Regression Testing
2023-08-29 14:33:02 +01:00
Michael Nebel
6760dd9121 C#: Base Nullness tests on stubs. 2023-08-29 15:30:24 +02:00
Michael Nebel
b3be4797e2 C#: Base the Metrics tests on stubs. 2023-08-29 15:23:42 +02:00
Michael Nebel
c906009e5b C#: Base the MagicConstants tests on stubs. 2023-08-29 15:19:19 +02:00
Michael Nebel
4c16f1be8b C#: Base the Likely Bugs tests on stubs. 2023-08-29 15:16:48 +02:00
Mathias Vorreiter Pedersen
99cc4171f8 C++: Fix FPs by making 'isArgumentOfCallable' more robust. 2023-08-29 14:12:09 +01:00
yoff
ae4c76c788 Merge pull request #13975 from yoff/python/parsemodechars-not-chars 2023-08-29 14:05:57 +02:00
Alex Eyers-Taylor
9df5e30034 CPP: Add changenote for adding delete to the IR. 2023-08-29 12:13:40 +01:00
Alex Eyers-Taylor
24b679d5a0 CPP: Fix IR formatting. 2023-08-29 11:17:44 +01:00
Alex Eyers-Taylor
8b1b1618c4 CPP: Add tests for false positive in memory vulnerability queries. 2023-08-29 11:17:44 +01:00
Alex Eyers-Taylor
3b344c3578 CPP: Handle cases where the deallocator function is determined dynamically. 2023-08-29 11:17:44 +01:00
Alex Eyers-Taylor
689fda43ed CPP: Add delete/delete[] calls to the IR. 2023-08-29 11:17:43 +01:00
Michael Nebel
08c24930ac C#: Base the Language Abuse tests on stubs. 2023-08-29 11:39:47 +02:00
Tom Hvitved
7611bfb149 C#: Apply closed-world assumption for type-parameter qualifiers in dynamic calls 2023-08-29 11:27:45 +02:00
Tom Hvitved
1da885fae2 C#: Fix bad join in SSA library
```
[2023-08-29 10:10:29] Evaluated non-recursive predicate SsaImpl#75014cd4::Cached::lastRefBeforeRedefExt#4#ffff@4207c208 in 27604ms (size: 7511062).
Evaluated relational algebra for predicate SsaImpl#75014cd4::Cached::lastRefBeforeRedefExt#4#ffff@4207c208 with tuple counts:
           9905038   ~9%    {5} r1 = SCAN Ssa#da392372::Make#SsaImpl#75014cd4::SsaInput#::lastRefRedefExt#5#fffff OUTPUT In.2, In.3, In.1, In.0, In.4
                            {5} r2 = r1 AND NOT _SsaImpl#75014cd4::SsaInput::variableRead#4#ffff_3012#join_rhs_const_false#antijoin_rhs(Lhs.0, Lhs.1, Lhs.2)
           4605608   ~0%    {4} r3 = SCAN r2 OUTPUT In.3, In.0, In.1, In.4

        4510888816   ~0%    {5} r4 = JOIN _SsaImpl#75014cd4::SsaInput::variableRead#4#ffff_3012#join_rhs_const_false#antijoin_rhs WITH project#Ssa#da392372::Make#SsaImpl#75014cd4::SsaInput#::lastRefRedefExt#5#fffff_1203#join_rhs ON FIRST 2 OUTPUT Rhs.2, Lhs.2, Lhs.0, Lhs.1, Rhs.3
           5294405  ~82%    {4} r5 = JOIN r4 WITH SsaImpl#75014cd4::adjacentDefReachesReadExt#6#ffffff_014523#join_rhs ON FIRST 4 OUTPUT Lhs.0, Rhs.4, Rhs.5, Lhs.4

           9900013  ~28%    {4} r6 = r3 UNION r5
                            return r6
```
2023-08-29 11:26:30 +02:00
Tom Hvitved
e219281016 C#: Speed up ForwarderAssertMethod
Avoids the following bad predicate

```
[2023-08-29 10:03:13] (252s) Tuple counts for _Callable#f85cebf6::Callable::getBody#0#dispred#ff_Variable#afb43847::Variable::getAnAccess#0#dispre__#join_rhs/5@43feb6tl after 4m0s:
                      4416261    ~203%     {4} r1 = JOIN _Callable#f85cebf6::Callable::getAParameter#0#dispred#ff_10#join_rhs_Variable#afb43847::Variable::ge__#shared WITH Callable#f85cebf6::Callable::getBody#0#dispred#ff ON FIRST 1 OUTPUT Lhs.1 'arg1', Lhs.2 'arg2', Lhs.0 'arg3', Rhs.1 'arg4'
                      1189565718 ~152%     {5} r2 = JOIN r1 WITH Variable#afb43847::Variable::getAnAccess#0#dispred#ff ON FIRST 1 OUTPUT Rhs.1 'arg0', Lhs.0 'arg1', Lhs.1 'arg2', Lhs.2 'arg3', Lhs.3 'arg4'
                                           return r2
```
2023-08-29 11:25:20 +02:00
Michael Nebel
946854bd17 C#: Base the EmptyBlock test on stubs. 2023-08-29 11:24:10 +02:00
Tom Hvitved
1ac9d2ee5b CFG: Compute splitsToString using concat, and exclude partial split sets 2023-08-29 11:23:56 +02:00
Michael Nebel
7068da25f0 C#: Base the Documentation tests on stubs. 2023-08-29 11:22:51 +02:00
Michael Nebel
dd274422d1 Merge pull request #14079 from bgrainger/fix-unsynchronized-static-access-docs
Delete thin space from documentation
2023-08-29 11:17:52 +02:00
Michael Nebel
f2bf540209 C#: Base the Dead Code tests on stubs. 2023-08-29 11:15:43 +02:00
Rasmus Wriedt Larsen
49d510018d Python: Add change-note 2023-08-29 11:11:32 +02:00
Rasmus Wriedt Larsen
0b2458d065 Python: Improve modeling of Flask jsonify
I also tested whether `Flask.jsonify` or `Flask().jsonify` worked, but
they do not.
2023-08-29 11:11:32 +02:00
Rasmus Wriedt Larsen
26319bfc04 Python: Fix Flask jsonify XSS regression
The reason the result was found before, is that `jsonify(data)` was
modeled as TWO separate subclasses of `Http::Server::HttpResponse`, one
because of the implicit construction in return
(FlaskRouteHandlerReturn), and one from the `jsonify` call
(FlaskJsonifyCall). Due to the QL evaluation, we got a combination from
the two, meaning mime-type from FlaskRouteHandlerReturn and body from
FlaskJsonifyCall...
2023-08-29 11:11:32 +02:00
Jean Helie
de76c0749a Java: Automodel Framework Mode: Add Candidates for Regression Testing 2023-08-29 09:53:55 +01:00
Mathias Vorreiter Pedersen
d14ad92dbd Merge pull request #14006 from MathiasVP/promote-invalid-pointer-deref-out-of-experimental
C++: Promote `cpp/invalid-pointer-deref` out of experimental
2023-08-29 09:38:56 +01:00
Rasmus Wriedt Larsen
b36fd9fdab Python: Add jsonify XSS regression example 2023-08-29 10:38:49 +02:00
Mathias Vorreiter Pedersen
f3a77c6006 Merge pull request #14060 from MathiasVP/fix-compare-where-assign-meant-fp
C++: Fix FP in `cpp/compare-where-assign-meant`
2023-08-29 09:38:39 +01:00
Mathias Vorreiter Pedersen
dbdb433957 Merge pull request #14058 from alexet/delete-or-delete-array
CPP: Add parent class for delete and delete[]
2023-08-29 09:38:07 +01:00
Michael Nebel
d3ba7e6b3c C#: Re-factor using statements order in autobuilder. 2023-08-29 10:10:30 +02:00
Michael Nebel
5f4861f72e Merge pull request #14069 from michaelnebel/csharp/nugetexe
C#: Download `nuget.exe` in the dependency manager (if not present).
2023-08-29 10:04:50 +02:00
Michael Nebel
5de8d9181d C#: Address review comments. 2023-08-29 09:33:11 +02:00
Jeroen Ketema
0d1fd88729 Merge pull request #14050 from jketema/inline-6
Consolidate all `InlineFlowTest` libraries in the dataflow qlpack
2023-08-29 09:30:35 +02:00
Tom Hvitved
bce47fe344 C#: Bump all dependencies 2023-08-29 09:24:39 +02:00
Kevin Stubbings
29e14f7d8d Feedback, Format, Add Change Notes 2023-08-28 14:15:21 -07:00
Bradley Grainger
d10597f69d Delete thin space from documentation.
Update the MSDN link to avoid an unnecessary redirection and use the correct anchor.
2023-08-28 11:02:38 -07:00
Dave Bartolomeo
3343b78015 Merge pull request #14074 from github/post-release-prep/codeql-cli-2.14.3
Post-release preparation for codeql-cli-2.14.3
2023-08-28 13:34:10 -04:00
github-actions[bot]
3eba77421a Post-release preparation for codeql-cli-2.14.3 2023-08-28 15:53:49 +00:00
Mathias Vorreiter Pedersen
f65fe34513 C++: Add false positive caused by flowing back into a function after doing reverse reads. 2023-08-28 14:45:16 +01:00
Asger F
d4cfa8c2b8 Java: autoformatting changes 2023-08-28 15:35:06 +02:00
Asger F
d2fe4d235a Java: Inline VariableWrite.getSource() 2023-08-28 15:34:48 +02:00
Michael Nebel
e19c7758ed C#: Cleanup NugetPackages.cs. 2023-08-28 15:19:16 +02:00
Michael Nebel
6e4865ddd9 C#: Download nuget.exe to the source directory in case it is not installed. 2023-08-28 15:14:13 +02:00
Michael Nebel
b6c2ea520b C#: Some re-factoring of NugetPackages and logic for file downloading. 2023-08-28 15:14:13 +02:00
yoff
2e981e330b Merge pull request #14059 from RasmusWL/fix-loginjection-tests
Python: Fix stdlib sinks in LogInjection query
2023-08-28 14:44:51 +02:00
yoff
6e05246daa Merge pull request #13935 from yoff/python/mad-on-externals
Python: MaD on externals
2023-08-28 14:04:54 +02:00
Rasmus Wriedt Larsen
c807ab4216 Python: Apply suggestions from code review
Co-authored-by: yoff <lerchedahl@gmail.com>
2023-08-28 14:04:22 +02:00
yoff
826b8e6aa5 Merge pull request #14067 from RasmusWL/modern-dataflowquerytests
Python: Adopt tests to new `DataflowQueryTest`
2023-08-28 13:54:34 +02:00
erik-krogh
78487d437f add test for await using in TypeScript 2023-08-28 13:30:35 +02:00
erik-krogh
1e3387f2c5 Merge branch 'main' into ts52 2023-08-28 13:22:56 +02:00
Michael Nebel
e7dbe9f289 Merge pull request #14028 from michaelnebel/csharp/dependencygetfiles
C#: Improve GetFiles in the Dependency Manager.
2023-08-28 12:53:28 +02:00
Rasmus Wriedt Larsen
38b78128c0 Merge pull request #13990 from RasmusWL/experimental-cleanup
Python: Port old experimental points-to based queries
2023-08-28 12:11:17 +02:00
Rasmus Wriedt Larsen
889cb7a95b Python: Adopt tests to new DataflowQueryTest
Co-authored-by: Rasmus Lerchedahl Petersen <yoff@github.com>
2023-08-28 11:44:01 +02:00
Rasmus Wriedt Larsen
9c44235782 Python: Modernize DataflowQueryTest.qll
Co-authored-by: Rasmus Lerchedahl Petersen <yoff@github.com>
2023-08-28 11:40:41 +02:00
Rasmus Wriedt Larsen
7cba6cd1d8 Python: Update .expected files
Due to change in path-graph, and including LHS of assignments
2023-08-28 11:33:44 +02:00
Rasmus Wriedt Larsen
0f242475f2 Merge branch 'main' into experimental-cleanup 2023-08-28 11:01:22 +02:00
Rasmus Wriedt Larsen
0dca8a5d86 Python: Remove old points-to modeling file
Since all of this was ported already
2023-08-28 10:40:45 +02:00
Rasmus Wriedt Larsen
39e2b133e9 Python: Fix naming 2023-08-28 10:40:33 +02:00
erik-krogh
be2712698b add support for await using in the JS parser 2023-08-28 09:34:13 +02:00
erik-krogh
1cbee6a8a4 delete leftover todo comment that was implemented 2023-08-28 08:40:35 +02:00
Mathias Vorreiter Pedersen
bb1712b489 Merge branch 'main' into reuse-even-more-nodes 2023-08-26 18:08:58 +01:00
Alex Ford
9957e2683b Merge pull request #13313 from maikypedia/maikypedia/ldap-improper-auth
Ruby: Add Improper LDAP Authentication query (CWE-287)
2023-08-25 20:52:34 +01:00
Alexander Eyers-Taylor
ea2140dc7d Apply suggestions from code review
Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
2023-08-25 17:15:08 +01:00
Alex Eyers-Taylor
8badf10a53 CPP: Add change notes for changes to DeleteExpr/DeleteArrayExpr 2023-08-25 17:13:34 +01:00
Alex Ford
ae635c609f Ruby: autoformat 2023-08-25 17:11:07 +01:00
Mathias Vorreiter Pedersen
9542646a5d C++: Add change note. 2023-08-25 16:45:53 +01:00
Mathias Vorreiter Pedersen
104416cc59 C++: Accept test changes. 2023-08-25 16:40:06 +01:00
Mathias Vorreiter Pedersen
cb2f7b0f95 C++: Exclude results in macro expansions from 'cpp/compare-where-assign-meant'. 2023-08-25 16:39:47 +01:00
Mathias Vorreiter Pedersen
759f939edd C++: Add false positive. 2023-08-25 16:38:48 +01:00
Rasmus Wriedt Larsen
bf9a0dab2a Python: Fix stdlib sinks in LogInjection query 2023-08-25 17:04:48 +02:00
Rasmus Wriedt Larsen
7852429df2 Python: Accept LogInjection .expected changes
I don't know how this had gone unnoticed for so long, but I realized when I tried to run this query locally
2023-08-25 17:04:40 +02:00
Alex Eyers-Taylor
d699201ad0 CPP: Add a test demonstating when a deallocator call exists. 2023-08-25 15:45:50 +01:00
Alex Eyers-Taylor
027ed5e909 CPP: Docs improvements to DeleteOrDeleteArrayExpr 2023-08-25 15:45:50 +01:00
Alex Eyers-Taylor
417b9c9a32 CPP: Use DeleteOrDeleteArrayExpr in another place. 2023-08-25 15:45:50 +01:00
Alex Eyers-Taylor
a3711e1df0 CPP: Replace getAllocatorCall with getDeallocator call. 2023-08-25 15:45:50 +01:00
Shati Patel
c5612ae522 Merge pull request #14051 from github/shati-patel/mrva-results-view
Docs: Update screenshots of variant analysis results view
2023-08-25 15:42:49 +01:00
Mathias Vorreiter Pedersen
68bccfdb93 Merge pull request #14013 from alexet/only-taint-argv-indirections
CPP:Only taint argv indirections
2023-08-25 15:19:51 +01:00
Mathias Vorreiter Pedersen
b948ed9045 C++: Accept test changes and add a few non-field flow tests to make up for the fact that we're no longer using field flow in the query. 2023-08-25 15:18:15 +01:00
Mathias Vorreiter Pedersen
89b91ec5c8 C++: Disable field flow from the 'cpp/invalid-pointer-deref' query. 2023-08-25 15:01:37 +01:00
Mathias Vorreiter Pedersen
c3cf48b38a C++: Add a 'fieldFlowBranchLimit' override to the product flow library. 2023-08-25 14:58:56 +01:00
Michael Nebel
02b8adf717 C#: Address review comments and some light re-factoring. 2023-08-25 15:33:54 +02:00
Maiky
ffd618d6cc Revert "Add "" and nil as sources"
This reverts commit 664c1eba72.
2023-08-25 15:23:55 +02:00
Alex Eyers-Taylor
04f8ed6af0 CPP: Simplify code using DeleteOrDeleteArrayExpr 2023-08-25 13:57:16 +01:00
Alex Eyers-Taylor
c43ba456e5 CPP: Remove old DeleteOrDeleteArrayExpr from a query. 2023-08-25 13:57:16 +01:00
Alex Eyers-Taylor
4ca98bd6fd CPP: Add parent class for delete and delete[] 2023-08-25 13:57:16 +01:00
AlexDenisov
0fe7740dda Merge pull request #14052 from github/sashabu/swift-logging-compiler
Swift: Route compiler diagnostics through our log.
2023-08-25 14:47:24 +02:00
Alex Eyers-Taylor
1afcf8c8a8 Add changenotes. 2023-08-25 13:05:10 +01:00
Alex Eyers-Taylor
9f8fbf8a1a CPP: Update tests for argv change 2023-08-25 13:05:10 +01:00
Alex Eyers-Taylor
45ddb4832c CPP: Make wordexp take an indirect argument. 2023-08-25 13:05:10 +01:00
Alex Eyers-Taylor
a2f2b6c33f CPP:Only consider **argv as tainted. 2023-08-25 13:05:10 +01:00
Michael Nebel
61a523510e C#: Only use small files during file content reference analysis. 2023-08-25 14:04:52 +02:00
Michael Nebel
a81d982c90 C#: Fetch file info fewer times and make dependencies more clear. 2023-08-25 14:04:52 +02:00
Tony Torralba
6573b1f772 Merge pull request #14056 from atorralba/atorralba/java/jenkins-stapler-regenerate
Java: Re-generate Jenkins and Stapler models
2023-08-25 13:15:21 +02:00
Tom Hvitved
42fd9f0c54 Merge pull request #14047 from hvitved/dataflow/join-fix
Data flow: Fix a bad join order
2023-08-25 12:18:24 +02:00
Ian Lynagh
a7de0f96e2 Merge pull request #14049 from igfoo/igfoo/kot1.9.10
Kotlin: We now support 1.9.10
2023-08-25 11:11:14 +01:00
Rasmus Lerchedahl Petersen
ad49eada48 Python: Do not alter codeql-workspaces.yml
And remove the qlpack referred to therein.
Instead we rename and duplicate the extesion file
that this qlpack pointed to.
These two extension files are kept in sync by `identical-files.json`.
2023-08-25 11:46:41 +02:00
Rasmus Lerchedahl Petersen
68cd422788 Python: Fix test expectations 2023-08-25 11:27:53 +02:00
Tony Torralba
5367fb99d9 Manually update a couple of models affected by the nested name change 2023-08-25 11:25:40 +02:00
Mathias Vorreiter Pedersen
9c5d7350dc C++: Add a small amount of pruning to 'SizeBarrierConfig'. 2023-08-25 10:25:28 +01:00
Mathias Vorreiter Pedersen
ded06a77d0 C++: More pruning. 2023-08-25 10:22:55 +01:00
Mathias Vorreiter Pedersen
2fd627b460 Merge pull request #13827 from geoffw0/closuremodels
Swift: Model withUnsafeBytes and similar closure methods
2023-08-25 10:01:52 +01:00
Tony Torralba
50a9c31b4a Merge pull request #14055 from github/workflow/coverage/update
Update CSV framework coverage reports
2023-08-25 10:04:51 +02:00
Tony Torralba
2ed01d06b4 Java: Re-generate Jenkins and Stapler models
Re-generated the Jenkins and Stapler models to pick up the changes from github/codeql#14032
2023-08-25 10:01:28 +02:00
github-actions[bot]
c9d64b6b4f Add changed framework coverage reports 2023-08-25 00:14:40 +00:00
Jeroen Ketema
b550c067a1 Java: Remove redundant inline expectation test imports 2023-08-25 00:18:55 +02:00
Jeroen Ketema
9d573e5544 Consolidate all InlineFlowTest libraries in the dataflow qlpack 2023-08-24 21:38:46 +02:00
Rasmus Lerchedahl Petersen
137f9e7234 Python: Adress review comments
- make qldoc accurate
- fix ql4ql alert
2023-08-24 21:28:07 +02:00
Rasmus Lerchedahl Petersen
d3c24ba110 PythonÆ fix test expectations 2023-08-24 21:21:49 +02:00
Rasmus Lerchedahl Petersen
e9e6bce80a shared: handle empty groups in delta 2023-08-24 21:21:49 +02:00
Rasmus Lerchedahl Petersen
88fc96e8d7 Python: Add test with prefix 2023-08-24 21:21:49 +02:00
Rasmus Lerchedahl Petersen
7ad1a21c2d Python: make mode characters not be characters
They are simply considered part of the group start.
2023-08-24 21:21:49 +02:00
yoff
a834703195 Merge pull request #13779 from geoffw0/pythonparsemode
Python: Understand multiple parse mode flags specified in a regular expression string
2023-08-24 21:20:45 +02:00
Tom Hvitved
763216b932 Merge pull request #14045 from hvitved/csharp/standalone-resolve-target-framework
C#: Favor DLLs with most recent .NET Core target framework when resolving dependencies in standalone
2023-08-24 20:56:26 +02:00
erik-krogh
56f1ff8af1 bump from release candidate to final release 2023-08-24 20:32:27 +02:00
erik-krogh
0273b20c75 add downgrade and upgrade script 🤞 2023-08-24 20:30:26 +02:00
erik-krogh
ce97d38a18 add to the stat file 2023-08-24 20:30:26 +02:00
erik-krogh
cb66d62959 add test for the new type-stuff in TS 5.2 we get for free 2023-08-24 20:30:26 +02:00
erik-krogh
dc454d3a72 add support for the new using keyword in TypeScript 2023-08-24 20:30:26 +02:00
erik-krogh
a7d92b3473 add JS support the using keyword 2023-08-24 20:30:26 +02:00
erik-krogh
dfc83d844a very initial support for TypeScript 5.2 2023-08-24 20:30:25 +02:00
Geoffrey White
415d9e0674 Swift: Address review comments. 2023-08-24 18:41:48 +01:00
Alexandre Boulgakov
7e05551f16 Swift: Check whether a SourceLoc is valid before using it. 2023-08-24 18:14:34 +01:00
Ian Lynagh
5dff1852e1 Kotlin: We now support 1.9.10 2023-08-24 17:36:45 +01:00
Geoffrey White
242a49e6f1 Apply suggestions from code review
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
2023-08-24 17:19:01 +01:00
shati-patel
c44b8249a5 Docs: Update screenshots of variant analysis results view 2023-08-24 17:15:04 +01:00
Mathias Vorreiter Pedersen
bdad9e197b C++: Fix more joins.
Before:
```
[2023-08-24 15:47:20] Evaluated non-recursive predicate _IRBlock#896e97af::IRBlock::dominates#1#dispred#ff_Ssa#da392372::Make#SsaInternals#7b362d2f::SsaInpu__#antijoin_rhs@94b1847k in 9831ms (size: 70660).
Evaluated relational algebra for predicate _IRBlock#896e97af::IRBlock::dominates#1#dispred#ff_Ssa#da392372::Make#SsaInternals#7b362d2f::SsaInpu__#antijoin_rhs@94b1847k with tuple counts:
    1121232  ~0%    {4} r1 = JOIN _DataFlowUtil#47741e1f::Cached::simpleLocalFlowStep#2#ff_10#join_rhs_DataFlowUtil#47741e1f::TSsaPhiN__#shared WITH Ssa#da392372::Make#SsaInternals#7b362d2f::SsaInput#::DefinitionExt::definesAt#4#dispred#fffff ON FIRST 1 OUTPUT Rhs.2, Lhs.0, Lhs.1, Lhs.2
  265759166  ~2%    {4} r2 = JOIN r1 WITH IRBlock#896e97af::IRBlock::dominates#1#dispred#ff ON FIRST 1 OUTPUT Lhs.3, Rhs.1, Lhs.1, Lhs.2
      70684  ~5%    {3} r3 = JOIN r2 WITH project#DataFlowUtil#47741e1f::Node::hasIndexInBlock#fff ON FIRST 2 OUTPUT Lhs.2, Lhs.3, Lhs.0
                    return r3

[2023-08-24 15:47:29] Evaluated non-recursive predicate DataFlowUtil#47741e1f::SsaPhiNode::getAnInput#1#dispred#fff@b6f296tl in 8943ms (size: 1121232).
Evaluated relational algebra for predicate DataFlowUtil#47741e1f::SsaPhiNode::getAnInput#1#dispred#fff@b6f296tl with tuple counts:
    1050572   ~2%    {3} r1 = _DataFlowUtil#47741e1f::Cached::simpleLocalFlowStep#2#ff_10#join_rhs_DataFlowUtil#47741e1f::TSsaPhiN__#shared AND NOT _IRBlock#896e97af::IRBlock::dominates#1#dispred#ff_Ssa#da392372::Make#SsaInternals#7b362d2f::SsaInpu__#antijoin_rhs(Lhs.0, Lhs.1, Lhs.2)
    1050572   ~3%    {3} r2 = SCAN r1 OUTPUT In.1, false, In.2

    1121232   ~0%    {3} r3 = JOIN _DataFlowUtil#47741e1f::Cached::simpleLocalFlowStep#2#ff_10#join_rhs_DataFlowUtil#47741e1f::TSsaPhiN__#shared WITH Ssa#da392372::Make#SsaInternals#7b362d2f::SsaInput#::DefinitionExt::definesAt#4#dispred#fffff ON FIRST 1 OUTPUT Rhs.2, Lhs.1, Lhs.2
  265759166   ~1%    {3} r4 = JOIN r3 WITH IRBlock#896e97af::IRBlock::dominates#1#dispred#ff ON FIRST 1 OUTPUT Lhs.2, Rhs.1, Lhs.1
      70684   ~0%    {2} r5 = JOIN r4 WITH project#DataFlowUtil#47741e1f::Node::hasIndexInBlock#fff ON FIRST 2 OUTPUT Lhs.2, Lhs.0
      70684   ~0%    {3} r6 = SCAN r5 OUTPUT In.0, true, In.1

    1121256   ~2%    {3} r7 = r2 UNION r6
                      return r7
```

After:
```
Evaluated non-recursive predicate DataFlowUtil#47741e1f::SsaPhiNode::getAnInput#1#dispred#fff@59ab2a2e in 456ms (size: 1117096).
Evaluated relational algebra for predicate DataFlowUtil#47741e1f::SsaPhiNode::getAnInput#1#dispred#fff@59ab2a2e with tuple counts:
    384518   ~0%    {2} r1 = JOIN DataFlowUtil#47741e1f::TSsaPhiNode#ff WITH Ssa#da392372::Make#SsaInternals#7b362d2f::SsaInput#::DefinitionExt::definesAt#4#dispred#fffff ON FIRST 1 OUTPUT Lhs.1, Rhs.2
  1121232   ~0%    {3} r2 = JOIN r1 WITH DataFlowUtil#47741e1f::Cached::simpleLocalFlowStep#2#ff_10#join_rhs ON FIRST 1 OUTPUT Rhs.1, Lhs.0, Lhs.1

  1117447   ~0%    {4} r3 = JOIN r2 WITH project#DataFlowUtil#47741e1f::Node::hasIndexInBlock#fff ON FIRST 1 OUTPUT Lhs.2, Rhs.1, Lhs.1, Lhs.0
    70684   ~0%    {2} r4 = JOIN r3 WITH IRBlock#896e97af::IRBlock::dominates#1#dispred#ff ON FIRST 2 OUTPUT Lhs.2, Lhs.3
    70684   ~0%    {3} r5 = SCAN r4 OUTPUT In.0, true, In.1

  1117447   ~0%    {4} r6 = JOIN r2 WITH project#DataFlowUtil#47741e1f::Node::hasIndexInBlock#fff ON FIRST 1 OUTPUT Lhs.2, Rhs.1, Lhs.1, Lhs.0
                    {4} r7 = r6 AND NOT IRBlock#896e97af::IRBlock::dominates#1#dispred#ff(Lhs.0, Lhs.1)
  1046763   ~0%    {2} r8 = SCAN r7 OUTPUT In.2, In.3
  1046763   ~3%    {3} r9 = SCAN r8 OUTPUT In.0, false, In.1

  1117447   ~2%    {3} r10 = r5 UNION r9
                    return r10
```
2023-08-24 15:57:39 +01:00
Jeroen Ketema
da403c1a79 Merge pull request #14039 from jketema/non-constant-assign
C++: Omit assign case from `cpp/non-constant-format`
2023-08-24 16:54:19 +02:00
Jeroen Ketema
45c56fbce7 Update cpp/ql/src/change-notes/2023-08-24-remove-non-constant-assign-sources.md
Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
2023-08-24 16:17:59 +02:00
Jeroen Ketema
607f729339 C++: Add change note 2023-08-24 16:11:39 +02:00
Asger F
6c664e93ef Merge pull request #14035 from asgerf/shared/variable-capture-nested
Variable capture: synchronize with aliases in nested scopes
2023-08-24 15:39:34 +02:00
Paolo Tranquilli
e3d6b3e537 Swift: route compiler diagnostics through our log
(cherry picked from commit b8c55612e5)
2023-08-24 14:20:15 +01:00
Asger F
f17518ace2 Java: update to reflect changes in VariableCapture.qll 2023-08-24 14:06:44 +02:00
Asger F
cd7c851d64 VariableCapture: add VariableWriteSourceNode 2023-08-24 14:06:44 +02:00
Asger F
1286235773 Address review comments 2023-08-24 13:58:33 +02:00
Anders Schack-Mulligen
7af1e96943 Merge pull request #14032 from aschackmull/java/mad-nestednames
Java: Use nested names in MaD signatures.
2023-08-24 13:53:55 +02:00
Tony Torralba
6b58d11eeb Merge pull request #13900 from atorralba/atorralba/java/jaxws-getaremotemethod-improv
Java: Improve `JaxWsEndpoint::getARemoteMethod`
2023-08-24 13:37:15 +02:00
Mathias Vorreiter Pedersen
d42e892097 Fix more joins.
Before:
```
Tuple counts for valueFlowStepSsa#4#ffff/4@2cddce6j after 11.4s:
  11571217  ~3%     {3} r1 = SCAN semSsaUpdateStep#3#fff OUTPUT In.0 'v', In.1 'e', f2i(In.2)
  11992425  ~0%     {4} r2 = JOIN r1 WITH SemanticSSA#aa9d1d08::SemSsaReadPosition::hasReadOfVar#1#dispred#ff_10#join_rhs ON FIRST 1 OUTPUT Lhs.0 'v', Rhs.1 'pos', Lhs.1 'e', Lhs.2 'delta'

  869481225 ~2%     {4} r3 = JOIN SemanticGuard#7b46a302::semGuardDirectlyControlsSsaRead#3#fff_102#join_rhs WITH SemanticSSA#aa9d1d08::SemSsaReadPosition::hasReadOfVar#1#dispred#ff ON FIRST 1 OUTPUT Rhs.1 'v', Lhs.2, Lhs.1, Lhs.0 'pos'
  5749      ~0%     {4} r4 = JOIN r3 WITH semEqFlowCond#5#fffbff#cpe#12356_03412#join_rhs ON FIRST 3 OUTPUT Lhs.3 'pos', Lhs.0 'v', Rhs.3 'e', Rhs.4
  5749      ~1%     {4} r5 = SCAN r4 OUTPUT In.0 'pos', In.1 'v', In.2 'e', f2i(In.3)
  5749      ~0%     {4} r6 = SCAN r5 OUTPUT In.1 'v', In.0 'pos', In.2 'e', In.3 'delta'

  11998174  ~0%     {4} r7 = r2 UNION r6
                    return r7
```

After:
```
Tuple counts for valueFlowStepSsaEqFlowCond#4#ffff/4@f196e4ok after 37ms:
  59567  ~0%     {5} r1 = JOIN const_true WITH semEqFlowCond#5#ffffff_301245#join_rhs ON FIRST 1 OUTPUT Rhs.1 'v', Rhs.2 'e', Rhs.4, Rhs.5, Rhs.3
  59567  ~0%     {5} r2 = SCAN r1 OUTPUT In.0 'v', In.1 'e', In.2, In.3, f2i(In.4)
  59567  ~4%     {5} r3 = SCAN r2 OUTPUT In.3, In.2, In.0 'v', In.1 'e', In.4 'delta'
  176881 ~0%     {4} r4 = JOIN r3 WITH SemanticGuard#7b46a302::semGuardDirectlyControlsSsaRead#3#fff_021#join_rhs ON FIRST 2 OUTPUT Rhs.2 'pos', Lhs.2 'v', Lhs.3 'e', Lhs.4 'delta'
                  return r4

Tuple counts for valueFlowStepSsa#4#ffff/4@e22d39v5 after 1s:
  5749     ~0%     {4} r1 = JOIN SemanticSSA#aa9d1d08::SemSsaReadPosition::hasReadOfVar#1#dispred#ff WITH valueFlowStepSsaEqFlowCond#4#ffff ON FIRST 2 OUTPUT Lhs.1 'v', Lhs.0 'pos', Rhs.2 'e', Rhs.3 'delta'

  11571217 ~0%     {3} r2 = SCAN semSsaUpdateStep#3#fff OUTPUT In.0 'v', In.1 'e', f2i(In.2)
  11992425 ~0%     {4} r3 = JOIN r2 WITH SemanticSSA#aa9d1d08::SemSsaReadPosition::hasReadOfVar#1#dispred#ff_10#join_rhs ON FIRST 1 OUTPUT Lhs.0 'v', Rhs.1 'pos', Lhs.1 'e', Lhs.2 'delta'

  11998174 ~0%     {4} r4 = r1 UNION r3
                    return r4
```
2023-08-24 12:20:41 +01:00
Erik Krogh Kristensen
59de92ce64 Merge pull request #14027 from erik-krogh/py-reg-app
ReDoS: limit concretize to strings of at most length 100
2023-08-24 12:57:42 +02:00
Tom Hvitved
f2eed4d8c4 Data flow: Fix a bad join order
Before
```
Evaluated relational algebra for predicate DataFlowImpl#248dabc3::MakeImpl#DataFlowImplSpecific#21008cd7::RubyDataFlow#::Impl#DataFlow#167ac380::DataFlowMake#DataFlowImplSpecific#21008cd7::RubyDataFlow#::Global#XSS#e59174e9::OrmTracking::Config#::C#::MkStage#Stage2#::Stage#Stage3Param#::flowThroughIntoCall#6#ffffff@0ea4e2mt with tuple counts:
           1065437   ~0%    {4} r1 = SCAN project#DataFlowImpl#248dabc3::MakeImpl#DataFlowImplSpecific#21008cd7::RubyDataFlow#::Impl#DataFlow#167ac380::DataFlowMake#DataFlowImplSpecific#21008cd7::RubyDataFlow#::Global#XSS#e59174e9::OrmTracking::Config#::C#::MkStage#Stage2#::Stage#Stage3Param#::fwdFlow#9#fffffffff#2 OUTPUT In.0, In.3, In.1, In.2
        1158508760   ~0%    {6} r2 = JOIN r1 WITH project#DataFlowImpl#248dabc3::MakeImpl#DataFlowImplSpecific#21008cd7::RubyDataFlow#::Impl#DataFlow#167ac380::DataFlowMake#DataFlowImplSpecific#21008cd7::RubyDataFlow#::Global#XSS#e59174e9::OrmTracking::Config#::C#::MkStage#Stage2#::Stage#Stage3Param#::flowIntoCallApa#6#ffffff_14023#join_rhs ON FIRST 2 OUTPUT Lhs.0, Lhs.2, Lhs.3, Rhs.2, Rhs.3, Rhs.4

                            {6} r3 = SELECT r2 ON In.5 != false
        1158470345   ~4%    {6} r4 = SCAN r3 OUTPUT In.4, In.1, In.2, In.0, In.3, In.5

                            {6} r5 = SELECT r2 ON In.5 = false
             38415   ~0%    {5} r6 = SCAN r5 OUTPUT In.2, In.0, In.1, In.3, In.4
                 4   ~0%    {5} r7 = JOIN r6 WITH DataFlowImplCommon#f7de413b::MakeImplCommon#DataFlowImplSpecific#21008cd7::RubyDataFlow#::Cached::TApproxFrontNil#f ON FIRST 1 OUTPUT Lhs.4, Lhs.2, Lhs.0, Lhs.1, Lhs.3
                 4   ~0%    {6} r8 = SCAN r7 OUTPUT In.0, In.1, In.2, In.3, In.4, false

        1158470349   ~4%    {6} r9 = r4 UNION r8
             44065   ~3%    {6} r10 = JOIN r9 WITH project#DataFlowImpl#248dabc3::MakeImpl#DataFlowImplSpecific#21008cd7::RubyDataFlow#::Impl#DataFlow#167ac380::DataFlowMake#DataFlowImplSpecific#21008cd7::RubyDataFlow#::Global#XSS#e59174e9::OrmTracking::Config#::C#::MkStage#Stage2#::Stage#Stage3Param#::returnFlowsThrough#8#ffffffff ON FIRST 3 OUTPUT Lhs.4, Lhs.3, Lhs.0, Lhs.5, Lhs.2, Rhs.3
                            return r10
```

After
```
Evaluated relational algebra for predicate DataFlowImpl#248dabc3::MakeImpl#DataFlowImplSpecific#21008cd7::RubyDataFlow#::Impl#DataFlow#167ac380::DataFlowMake#DataFlowImplSpecific#21008cd7::RubyDataFlow#::Global#XSS#e59174e9::OrmTracking::Config#::C#::MkStage#Stage2#::Stage#Stage3Param#::flowThroughIntoCall#6#ffffff@979c54q9 with tuple counts:
         11095   ~0%    {4} r1 = SCAN project#DataFlowImpl#248dabc3::MakeImpl#DataFlowImplSpecific#21008cd7::RubyDataFlow#::Impl#DataFlow#167ac380::DataFlowMake#DataFlowImplSpecific#21008cd7::RubyDataFlow#::Global#XSS#e59174e9::OrmTracking::Config#::C#::MkStage#Stage2#::Stage#Stage3Param#::returnFlowsThrough#8#ffffffff OUTPUT In.0, In.3, In.1, In.2
        470154   ~1%    {8} r2 = JOIN r1 WITH project#DataFlowImpl#248dabc3::MakeImpl#DataFlowImplSpecific#21008cd7::RubyDataFlow#::Impl#DataFlow#167ac380::DataFlowMake#DataFlowImplSpecific#21008cd7::RubyDataFlow#::Global#XSS#e59174e9::OrmTracking::Config#::C#::MkStage#Stage2#::Stage#Stage3Param#::flowIntoCallApa#6#ffffff_20134#join_rhs ON FIRST 1 OUTPUT Lhs.1, Lhs.0, Lhs.2, Lhs.3, Rhs.1, Rhs.2, Rhs.3, Rhs.4

                        {8} r3 = SELECT r2 ON In.6 != false
        470152   ~0%    {8} r4 = SCAN r3 OUTPUT In.5, In.2, In.3, In.7, In.0, In.1, In.4, In.6

                        {8} r5 = SELECT r2 ON In.6 = false
             2   ~0%    {7} r6 = SCAN r5 OUTPUT In.3, In.0, In.1, In.2, In.4, In.5, In.7
             0   ~0%    {7} r7 = JOIN r6 WITH DataFlowImplCommon#f7de413b::MakeImplCommon#DataFlowImplSpecific#21008cd7::RubyDataFlow#::Cached::TApproxFrontNil#f ON FIRST 1 OUTPUT Lhs.5, Lhs.3, Lhs.0, Lhs.6, Lhs.1, Lhs.2, Lhs.4
             0   ~0%    {8} r8 = SCAN r7 OUTPUT In.0, In.1, In.2, In.3, In.4, In.5, In.6, false

        470152   ~0%    {8} r9 = r4 UNION r8
         44065   ~3%    {6} r10 = JOIN r9 WITH project#DataFlowImpl#248dabc3::MakeImpl#DataFlowImplSpecific#21008cd7::RubyDataFlow#::Impl#DataFlow#167ac380::DataFlowMake#DataFlowImplSpecific#21008cd7::RubyDataFlow#::Global#XSS#e59174e9::OrmTracking::Config#::C#::MkStage#Stage2#::Stage#Stage3Param#::fwdFlow#9#fffffffff#2 ON FIRST 4 OUTPUT Lhs.6, Lhs.0, Lhs.5, Lhs.7, Lhs.2, Lhs.4
                        return r10
```
2023-08-24 12:08:34 +02:00
Geoffrey White
f07f97a94e Python: Accept test changes. I think these reflect the 'parse mode chars should not be considered chars' issue. 2023-08-24 10:52:52 +01:00
Tom Hvitved
7723dbc6d7 Merge pull request #14026 from hvitved/dataflow/stage3-call-ctx
Data flow: Use call contexts in stage 3
2023-08-24 11:52:08 +02:00
Tony Torralba
8c32919381 Merge pull request #13903 from atorralba/atorralba/jaxrs-mad-models
Java: New models for JAX-RS
2023-08-24 11:43:13 +02:00
Tom Hvitved
554a2c26c3 C#: Favor DLLs with most recent .NET Core target framework when resolving dependencies in standalone 2023-08-24 11:42:06 +02:00
Tony Torralba
3f9701cea7 Two fixes:
* Consider that the @WebService annotation (et al) can be in a supertype or interface

* getARemoteMethod should only return public methods, since protected, package-private, and private methods are not exposed
2023-08-24 11:35:52 +02:00
Mathias Vorreiter Pedersen
4e6707fee5 Fix joins.
Before:
```
Pipeline standard for boundedSsa#8#ffffffff@d4d576wg was evaluated in 651 iterations totaling 39789ms (delta sizes total: 235714).
        3482    ~0%    {8} r1 = JOIN unequalIntegralSsa#5#fffff#prev_delta WITH boundedSsa#8#ffffffff#prev ON FIRST 4 OUTPUT Lhs.0, Lhs.1, Lhs.2, Lhs.3, Lhs.4, Rhs.4, Rhs.5, Rhs.6

        1747    ~0%    {8} r2 = SELECT r1 ON In.5 = false
        1747    ~3%    {8} r3 = SCAN r2 OUTPUT In.0, In.1, In.2, (In.3 + i2f(1)), false, In.6, In.7, In.4

        1735    ~4%    {8} r4 = SELECT r1 ON In.5 = true
        1735    ~6%    {8} r5 = SCAN r4 OUTPUT In.0, In.1, In.2, (In.3 - i2f(1)), true, In.6, In.7, In.4

        1843   ~97%    {8} r6 = JOIN unequalIntegralSsa#5#fffff#prev WITH boundedSsa#8#ffffffff#prev_delta ON FIRST 4 OUTPUT Lhs.0, Lhs.1, Lhs.2, Lhs.3, Lhs.4, Rhs.4, Rhs.5, Rhs.6

        907   ~99%    {8} r7 = SELECT r6 ON In.5 = false
        907  ~108%    {8} r8 = SCAN r7 OUTPUT In.0, In.1, In.2, (In.3 + i2f(1)), false, In.6, In.7, In.4

        2642   ~41%    {8} r9 = r5 UNION r8
        4389   ~22%    {8} r10 = r3 UNION r9

        936   ~99%    {8} r11 = SELECT r6 ON In.5 = true
        936  ~100%    {8} r12 = SCAN r11 OUTPUT In.0, In.1, In.2, (In.3 - i2f(1)), true, In.6, In.7, In.4

      512745    ~2%    {6} r13 = SCAN bounded#7#fffffff#prev_delta OUTPUT In.0, In.3, In.1, In.2, In.4, In.5
      229218    ~0%    {9} r14 = JOIN r13 WITH boundFlowStepSsa#6#ffffff_240135#join_rhs ON FIRST 2 OUTPUT Rhs.5, Rhs.2, Rhs.3, Lhs.2, Rhs.4, Lhs.3, Lhs.1, Lhs.4, Lhs.5
      229218    ~0%    {8} r15 = SCAN r14 OUTPUT In.0, In.1, In.2, In.3, (In.4 + In.5), In.6, In.7, In.8
                      {8} r16 = r15 AND NOT num#TSemNoReason#f(Lhs.0)
        5397    ~0%    {8} r17 = SCAN r16 OUTPUT In.1, In.2, In.3, In.4, In.5, In.6, In.7, In.0

      557965    ~0%    {5} r18 = SCAN unequalIntegralSsa#5#fffff#prev_delta OUTPUT In.0, In.2, In.3, In.1, In.4
          0    ~0%    {8} r19 = JOIN r18 WITH boundedPhi#7#fffffff#prev ON FIRST 3 OUTPUT Lhs.0, Lhs.3, Lhs.1, Lhs.2, Lhs.4, Rhs.3, Rhs.4, Rhs.5

          0    ~0%    {8} r20 = SELECT r19 ON In.5 = false
          0    ~0%    {8} r21 = SCAN r20 OUTPUT In.0, In.1, In.2, (In.3 + i2f(1)), false, In.6, In.7, In.4

        5397    ~0%    {8} r22 = r17 UNION r21
        6333   ~12%    {8} r23 = r12 UNION r22
      10722   ~16%    {8} r24 = r10 UNION r23

          0    ~0%    {8} r25 = SELECT r19 ON In.5 = true
          0    ~0%    {8} r26 = SCAN r25 OUTPUT In.0, In.1, In.2, (In.3 - i2f(1)), true, In.6, In.7, In.4

  362119282    ~1%    {5} r27 = SCAN unequalIntegralSsa#5#fffff#prev OUTPUT In.0, In.2, In.3, In.1, In.4
          41    ~8%    {8} r28 = JOIN r27 WITH boundedPhi#7#fffffff#prev_delta ON FIRST 3 OUTPUT Lhs.0, Lhs.3, Lhs.1, Lhs.2, Lhs.4, Rhs.3, Rhs.4, Rhs.5

          27    ~0%    {8} r29 = SELECT r28 ON In.5 = false
          27    ~4%    {8} r30 = SCAN r29 OUTPUT In.0, In.1, In.2, (In.3 + i2f(1)), false, In.6, In.7, In.4

          14   ~42%    {8} r31 = SELECT r28 ON In.5 = true
          14   ~42%    {8} r32 = SCAN r31 OUTPUT In.0, In.1, In.2, (In.3 - i2f(1)), true, In.6, In.7, In.4

          41   ~12%    {8} r33 = r30 UNION r32
          41   ~12%    {8} r34 = r26 UNION r33

      512745    ~0%    {7} r35 = SCAN bounded#7#fffffff#prev_delta OUTPUT In.0, In.3, In.1, In.2, In.4, In.5, In.6
      229272    ~0%    {10} r36 = JOIN r35 WITH boundFlowStepSsa#6#ffffff_240135#join_rhs ON FIRST 2 OUTPUT Rhs.5, Lhs.2, Lhs.1, Lhs.4, Lhs.5, Lhs.6, Rhs.2, Rhs.3, Rhs.4, Lhs.3
      229272    ~0%    {9} r37 = SCAN r36 OUTPUT In.0, In.1, In.2, In.3, In.4, In.5, In.6, In.7, (In.8 + In.9)
      223867    ~0%    {8} r38 = JOIN r37 WITH num#TSemNoReason#f ON FIRST 1 OUTPUT Lhs.6, Lhs.7, Lhs.1, Lhs.8, Lhs.2, Lhs.3, Lhs.4, Lhs.5

        3482    ~1%    {8} r39 = JOIN unequalIntegralSsa#5#fffff#prev_delta WITH boundedSsa#8#ffffffff#prev ON FIRST 4 OUTPUT Lhs.0, Lhs.1, Lhs.2, Lhs.3, Rhs.4, Rhs.5, Rhs.6, Rhs.7

        1747    ~0%    {8} r40 = SELECT r39 ON In.4 = false
        1747    ~0%    {8} r41 = SCAN r40 OUTPUT In.7, In.0, In.1, In.2, (In.3 + i2f(1)), false, In.5, In.6

        1735    ~0%    {8} r42 = SELECT r39 ON In.4 = true
        1735    ~0%    {8} r43 = SCAN r42 OUTPUT In.7, In.0, In.1, In.2, (In.3 - i2f(1)), true, In.5, In.6

        3482    ~0%    {8} r44 = r41 UNION r43

      557965    ~0%    {4} r45 = SCAN unequalIntegralSsa#5#fffff#prev_delta OUTPUT In.0, In.2, In.3, In.1
          0    ~0%    {8} r46 = JOIN r45 WITH boundedPhi#7#fffffff#prev ON FIRST 3 OUTPUT Lhs.0, Lhs.3, Lhs.1, Lhs.2, Rhs.3, Rhs.4, Rhs.5, Rhs.6

          0    ~0%    {8} r47 = SELECT r46 ON In.4 = false
          0    ~0%    {8} r48 = SCAN r47 OUTPUT In.7, In.0, In.1, In.2, (In.3 + i2f(1)), false, In.5, In.6

          0    ~0%    {8} r49 = SELECT r46 ON In.4 = true
          0    ~0%    {8} r50 = SCAN r49 OUTPUT In.7, In.0, In.1, In.2, (In.3 - i2f(1)), true, In.5, In.6

          0    ~0%    {8} r51 = r48 UNION r50
        3482    ~0%    {8} r52 = r44 UNION r51
                      {8} r53 = r52 AND NOT num#TSemNoReason#f(Lhs.0)
          20    ~0%    {8} r54 = SCAN r53 OUTPUT In.1, In.2, In.3, In.4, In.5, In.6, In.7, In.0

        1843    ~0%    {8} r55 = JOIN unequalIntegralSsa#5#fffff#prev WITH boundedSsa#8#ffffffff#prev_delta ON FIRST 4 OUTPUT Lhs.0, Lhs.1, Lhs.2, Lhs.3, Rhs.4, Rhs.5, Rhs.6, Rhs.7

        907    ~0%    {8} r56 = SELECT r55 ON In.4 = false
        907    ~1%    {8} r57 = SCAN r56 OUTPUT In.7, In.0, In.1, In.2, (In.3 + i2f(1)), false, In.5, In.6

        936    ~0%    {8} r58 = SELECT r55 ON In.4 = true
        936    ~1%    {8} r59 = SCAN r58 OUTPUT In.7, In.0, In.1, In.2, (In.3 - i2f(1)), true, In.5, In.6

        1843    ~3%    {8} r60 = r57 UNION r59

  362119282    ~0%    {4} r61 = SCAN unequalIntegralSsa#5#fffff#prev OUTPUT In.0, In.2, In.3, In.1
          41    ~0%    {8} r62 = JOIN r61 WITH boundedPhi#7#fffffff#prev_delta ON FIRST 3 OUTPUT Lhs.0, Lhs.3, Lhs.1, Lhs.2, Rhs.3, Rhs.4, Rhs.5, Rhs.6

          27    ~0%    {8} r63 = SELECT r62 ON In.4 = false
          27    ~0%    {8} r64 = SCAN r63 OUTPUT In.7, In.0, In.1, In.2, (In.3 + i2f(1)), false, In.5, In.6

          14    ~0%    {8} r65 = SELECT r62 ON In.4 = true
          14    ~0%    {8} r66 = SCAN r65 OUTPUT In.7, In.0, In.1, In.2, (In.3 - i2f(1)), true, In.5, In.6

          41    ~0%    {8} r67 = r64 UNION r66
        1884    ~3%    {8} r68 = r60 UNION r67
                      {8} r69 = r68 AND NOT num#TSemNoReason#f(Lhs.0)
        1853    ~0%    {8} r70 = SCAN r69 OUTPUT In.1, In.2, In.3, In.4, In.5, In.6, In.7, In.0

        1873    ~0%    {8} r71 = r54 UNION r70
      225740    ~0%    {8} r72 = r38 UNION r71
      225781    ~0%    {8} r73 = r34 UNION r72
      236503    ~2%    {8} r74 = r24 UNION r73
      235722    ~1%    {8} r75 = r74 AND NOT boundedSsa#8#ffffffff#prev(Lhs.0, Lhs.1, Lhs.2, Lhs.3, Lhs.4, Lhs.5, Lhs.6, Lhs.7)
                      return r75
```

After:
```
Pipeline standard for boundedSsa#8#ffffffff@2122e6w8 was evaluated in 651 iterations totaling 343ms (delta sizes total: 235815).
      0    ~0%    {8} r1 = JOIN unequalIntegralSsa#5#fffff#prev_delta WITH boundedPhi#7#fffffff#prev ON FIRST 3 OUTPUT Lhs.0, Lhs.1, Lhs.2, Lhs.3, Lhs.4, Rhs.3, Rhs.4, Rhs.5

      0    ~0%    {8} r2 = SELECT r1 ON In.5 = false
      0    ~0%    {8} r3 = SCAN r2 OUTPUT In.0, In.1, (In.2 + i2f(1)), In.3, false, In.6, In.7, In.4

      0    ~0%    {8} r4 = SELECT r1 ON In.5 = true
      0    ~0%    {8} r5 = SCAN r4 OUTPUT In.0, In.1, (In.2 - i2f(1)), In.3, true, In.6, In.7, In.4

    41    ~8%    {8} r6 = JOIN unequalIntegralSsa#5#fffff#prev WITH boundedPhi#7#fffffff#prev_delta ON FIRST 3 OUTPUT Lhs.0, Lhs.1, Lhs.2, Lhs.3, Lhs.4, Rhs.3, Rhs.4, Rhs.5

    27    ~0%    {8} r7 = SELECT r6 ON In.5 = false
    27    ~0%    {8} r8 = SCAN r7 OUTPUT In.0, In.1, (In.2 + i2f(1)), In.3, false, In.6, In.7, In.4

    27    ~0%    {8} r9 = r5 UNION r8
    27    ~0%    {8} r10 = r3 UNION r9

    14   ~42%    {8} r11 = SELECT r6 ON In.5 = true
    14   ~42%    {8} r12 = SCAN r11 OUTPUT In.0, In.1, (In.2 - i2f(1)), In.3, true, In.6, In.7, In.4

  3482    ~0%    {8} r13 = JOIN unequalIntegralSsa#5#fffff#prev_delta WITH boundedSsa#8#ffffffff#prev ON FIRST 4 OUTPUT Lhs.0, Lhs.1, Lhs.2, Lhs.3, Lhs.4, Rhs.4, Rhs.5, Rhs.6

  1747    ~0%    {8} r14 = SELECT r13 ON In.5 = false
  1747    ~3%    {8} r15 = SCAN r14 OUTPUT In.0, In.1, (In.2 + i2f(1)), In.3, false, In.6, In.7, In.4

  1735    ~3%    {8} r16 = SELECT r13 ON In.5 = true
  1735    ~3%    {8} r17 = SCAN r16 OUTPUT In.0, In.1, (In.2 - i2f(1)), In.3, true, In.6, In.7, In.4

  3482    ~0%    {8} r18 = r15 UNION r17
  3496    ~0%    {8} r19 = r12 UNION r18
  3523    ~0%    {8} r20 = r10 UNION r19

  1843  ~103%    {8} r21 = JOIN unequalIntegralSsa#5#fffff#prev WITH boundedSsa#8#ffffffff#prev_delta ON FIRST 4 OUTPUT Lhs.0, Lhs.1, Lhs.2, Lhs.3, Lhs.4, Rhs.4, Rhs.5, Rhs.6

    907  ~105%    {8} r22 = SELECT r21 ON In.5 = false
    907  ~108%    {8} r23 = SCAN r22 OUTPUT In.0, In.1, (In.2 + i2f(1)), In.3, false, In.6, In.7, In.4

    936  ~101%    {8} r24 = SELECT r21 ON In.5 = true
    936  ~109%    {8} r25 = SCAN r24 OUTPUT In.0, In.1, (In.2 - i2f(1)), In.3, true, In.6, In.7, In.4

512745    ~4%    {6} r26 = SCAN bounded#7#fffffff#prev_delta OUTPUT In.0, In.3, In.1, In.2, In.4, In.5
229313    ~0%    {9} r27 = JOIN r26 WITH boundFlowStepSsa#6#ffffff_240135#join_rhs ON FIRST 2 OUTPUT Rhs.5, Rhs.2, Lhs.2, Rhs.4, Lhs.3, Rhs.3, Lhs.1, Lhs.4, Lhs.5
229313    ~0%    {8} r28 = SCAN r27 OUTPUT In.0, In.1, In.2, (In.3 + In.4), In.5, In.6, In.7, In.8
                  {8} r29 = r28 AND NOT num#TSemNoReason#f(Lhs.0)
  5492    ~2%    {8} r30 = SCAN r29 OUTPUT In.1, In.2, In.3, In.4, In.5, In.6, In.7, In.0

  6428   ~15%    {8} r31 = r25 UNION r30
  7335   ~27%    {8} r32 = r23 UNION r31

512745    ~0%    {7} r33 = SCAN bounded#7#fffffff#prev_delta OUTPUT In.0, In.3, In.1, In.2, In.4, In.5, In.6
229367    ~0%    {10} r34 = JOIN r33 WITH boundFlowStepSsa#6#ffffff_240135#join_rhs ON FIRST 2 OUTPUT Rhs.5, Lhs.2, Lhs.1, Lhs.4, Lhs.5, Lhs.6, Rhs.2, Rhs.3, Rhs.4, Lhs.3
229367    ~0%    {9} r35 = SCAN r34 OUTPUT In.0, In.1, In.2, In.3, In.4, In.5, In.6, In.7, (In.8 + In.9)
223867    ~0%    {8} r36 = JOIN r35 WITH num#TSemNoReason#f ON FIRST 1 OUTPUT Lhs.6, Lhs.1, Lhs.8, Lhs.7, Lhs.2, Lhs.3, Lhs.4, Lhs.5

      0    ~0%    {8} r37 = JOIN unequalIntegralSsa#5#fffff#prev_delta WITH boundedPhi#7#fffffff#prev ON FIRST 3 OUTPUT Lhs.0, Lhs.1, Lhs.2, Lhs.3, Rhs.3, Rhs.4, Rhs.5, Rhs.6

      0    ~0%    {8} r38 = SELECT r37 ON In.4 = false
      0    ~0%    {8} r39 = SCAN r38 OUTPUT In.7, In.0, In.1, (In.2 + i2f(1)), In.3, false, In.5, In.6

      0    ~0%    {8} r40 = SELECT r37 ON In.4 = true
      0    ~0%    {8} r41 = SCAN r40 OUTPUT In.7, In.0, In.1, (In.2 - i2f(1)), In.3, true, In.5, In.6

      0    ~0%    {8} r42 = r39 UNION r41

  3482    ~0%    {8} r43 = JOIN unequalIntegralSsa#5#fffff#prev_delta WITH boundedSsa#8#ffffffff#prev ON FIRST 4 OUTPUT Lhs.0, Lhs.1, Lhs.2, Lhs.3, Rhs.4, Rhs.5, Rhs.6, Rhs.7

  1747    ~0%    {8} r44 = SELECT r43 ON In.4 = false
  1747    ~0%    {8} r45 = SCAN r44 OUTPUT In.7, In.0, In.1, (In.2 + i2f(1)), In.3, false, In.5, In.6

  1735    ~1%    {8} r46 = SELECT r43 ON In.4 = true
  1735    ~2%    {8} r47 = SCAN r46 OUTPUT In.7, In.0, In.1, (In.2 - i2f(1)), In.3, true, In.5, In.6

  3482    ~2%    {8} r48 = r45 UNION r47
  3482    ~2%    {8} r49 = r42 UNION r48
                  {8} r50 = r49 AND NOT num#TSemNoReason#f(Lhs.0)
    20    ~0%    {8} r51 = SCAN r50 OUTPUT In.1, In.2, In.3, In.4, In.5, In.6, In.7, In.0

    41    ~2%    {8} r52 = JOIN unequalIntegralSsa#5#fffff#prev WITH boundedPhi#7#fffffff#prev_delta ON FIRST 3 OUTPUT Lhs.0, Lhs.1, Lhs.2, Lhs.3, Rhs.3, Rhs.4, Rhs.5, Rhs.6

    27    ~0%    {8} r53 = SELECT r52 ON In.4 = false
    27    ~0%    {8} r54 = SCAN r53 OUTPUT In.7, In.0, In.1, (In.2 + i2f(1)), In.3, false, In.5, In.6

    14    ~0%    {8} r55 = SELECT r52 ON In.4 = true
    14    ~0%    {8} r56 = SCAN r55 OUTPUT In.7, In.0, In.1, (In.2 - i2f(1)), In.3, true, In.5, In.6

    41    ~0%    {8} r57 = r54 UNION r56

  1843    ~1%    {8} r58 = JOIN unequalIntegralSsa#5#fffff#prev WITH boundedSsa#8#ffffffff#prev_delta ON FIRST 4 OUTPUT Lhs.0, Lhs.1, Lhs.2, Lhs.3, Rhs.4, Rhs.5, Rhs.6, Rhs.7

    907    ~0%    {8} r59 = SELECT r58 ON In.4 = false
    907    ~1%    {8} r60 = SCAN r59 OUTPUT In.7, In.0, In.1, (In.2 + i2f(1)), In.3, false, In.5, In.6

    936    ~0%    {8} r61 = SELECT r58 ON In.4 = true
    936    ~0%    {8} r62 = SCAN r61 OUTPUT In.7, In.0, In.1, (In.2 - i2f(1)), In.3, true, In.5, In.6

  1843    ~0%    {8} r63 = r60 UNION r62
  1884    ~0%    {8} r64 = r57 UNION r63
                  {8} r65 = r64 AND NOT num#TSemNoReason#f(Lhs.0)
  1853    ~1%    {8} r66 = SCAN r65 OUTPUT In.1, In.2, In.3, In.4, In.5, In.6, In.7, In.0

  1873    ~1%    {8} r67 = r51 UNION r66
225740    ~0%    {8} r68 = r36 UNION r67
233075    ~0%    {8} r69 = r32 UNION r68
236598    ~0%    {8} r70 = r20 UNION r69
235817    ~0%    {8} r71 = r70 AND NOT boundedSsa#8#ffffffff#prev(Lhs.0, Lhs.1, Lhs.2, Lhs.3, Lhs.4, Lhs.5, Lhs.6, Lhs.7)
                  return r71
```
2023-08-24 10:29:04 +01:00
Asger F
b424f3fe83 Update a comment to be more accurate 2023-08-24 11:12:39 +02:00
Jeroen Ketema
9f7413eded C++: Omit assign case from cpp/non-constant-format 2023-08-24 11:02:40 +02:00
Anders Schack-Mulligen
ebe3f61ef6 Java: Fix models in qltest. 2023-08-24 09:44:43 +02:00
Jeroen Ketema
f996fa2f8b Merge pull request #14043 from jketema/ir-regres
C++: Add IR test case that shows regression after frontend update
2023-08-24 09:23:58 +02:00
AlexDenisov
d89a86fea4 Merge pull request #13979 from github/alexdenisov/autobuilder-spm
Swift: teach autobuilder about SPM, CocoaPods, and Carthage
2023-08-24 08:50:04 +02:00
Jeroen Ketema
c882945e30 C++: Add IR test case that shows regression after frontend update 2023-08-24 08:36:22 +02:00
erik-krogh
db2b8d4bcc remove some test code I accidentially commited 2023-08-24 07:56:05 +02:00
Mathias Vorreiter Pedersen
123e58767b C++: Share RangeAnalysisUtil with 'cpp/overrun-write'. 2023-08-23 22:42:00 +01:00
Harry Maclean
96e9dfc7b2 Merge pull request #13969 from hmac/shared-extractor-globs
Shared extractor: support file path globs
2023-08-23 16:41:39 +01:00
Harry Maclean
b76842ad3d Shared: Fix clippy lint 2023-08-23 16:24:57 +01:00
Harry Maclean
3680613f2d Shared: Restrict extractor file globs to filenames 2023-08-23 16:09:56 +01:00
Mathias Vorreiter Pedersen
6cf99688e1 Merge pull request #13985 from alexet/ir-tainted-sql
CPP: Convert SQL tainted away from away from DefaultTaintTracking.
2023-08-23 15:40:55 +01:00
Rasmus Wriedt Larsen
89b790d048 Merge pull request #14037 from RasmusWL/fix-tests
Python: Fix tests
2023-08-23 16:37:40 +02:00
Rasmus Wriedt Larsen
f33359bd5c Python: Fix tests 2023-08-23 15:37:55 +02:00
Asger F
2b540e251a Merge pull request #14007 from asgerf/js/import-path-string
JS: Follow immediate predecessors in path resolution
2023-08-23 15:28:22 +02:00
Harry Maclean
54c2221f35 Merge pull request #14033 from hmac/excon-bugfix
Ruby: Fix bug in excon model
2023-08-23 14:24:53 +01:00
Harry Maclean
cc7ef5dac1 Shared: Fix clippy lint in shared extractor 2023-08-23 14:11:22 +01:00
Harry Maclean
ed40d72e4f Shared: Bump extractor version 2023-08-23 14:11:22 +01:00
Harry Maclean
24ac6c0596 QL: Update for shared extractor changes 2023-08-23 14:11:21 +01:00
Harry Maclean
7e2abf20c6 Shared: Support glob patterns in shared extractor
Replace the `file_extensions` field with `file_globs`, which supports
UNIX style glob patterns powered by the `globset` crate.

This allows files with no extension (e.g. Dockerfiles) to be extracted,
by specifying a glob such as `*Dockerfile`.

One surprising aspect of this change is that the globs match against the
whole path, rather than just the file name.

This is a breaking change.
2023-08-23 14:11:21 +01:00
Asger F
d146514275 Merge pull request #13928 from asgerf/js/ignore-huge-files
JS: Ignore files larger than 10 MB during extraction
2023-08-23 15:09:58 +02:00
Asger F
d2fca1b804 Merge pull request #13926 from asgerf/js/fix-cyclic-alias-extraction
JS: fix crash in case of cyclic alias
2023-08-23 15:09:39 +02:00
Geoffrey White
46fc1fdaa1 Swift: Suggestions from review. 2023-08-23 14:04:56 +01:00
Geoffrey White
15c49eeee9 Update swift/ql/lib/codeql/swift/regex/Regex.qll
Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
2023-08-23 13:58:05 +01:00
Asger F
ee1b3fd7e9 Java: update test after VariableCapture.qll change 2023-08-23 14:57:26 +02:00
Asger F
8aec87ea57 Update VariableCapture.qll 2023-08-23 14:57:26 +02:00
Alex Eyers-Taylor
949b0a2613 CPP:Move import to start of file 2023-08-23 13:39:29 +01:00
Alex Eyers-Taylor
7d99d61662 CPP: Convert SQL tainted to IR dataflow. 2023-08-23 13:39:29 +01:00
Michael Nebel
08d44c1bdc Merge pull request #14019 from michaelnebel/csharp/excludedlls
C#: Exclude dll files when getting files in the dependency manager.
2023-08-23 14:15:32 +02:00
Asger F
b8fc84e8e4 JS: Change note 2023-08-23 14:11:07 +02:00
Asger F
c6a757e085 JS: More robust handling of cyclic aliases 2023-08-23 14:11:07 +02:00
Asger F
794a459c1b JS: Add reproduction test 2023-08-23 14:11:07 +02:00
Asger F
b93e404441 JS: Change log 2023-08-23 14:05:21 +02:00
Geoffrey White
02fbb47b64 Swift: Change note. 2023-08-23 13:04:49 +01:00
Geoffrey White
03ca29ab96 Swift: Adapt the IncompleteHostnameRegex qhelp for Swift. 2023-08-23 13:04:49 +01:00
Geoffrey White
1805b070dc Swift: Adapt the IncompleteHostnameRegex test for Swift. 2023-08-23 13:04:48 +01:00
Harry Maclean
d18ca3f5d7 Ruby: Fix bug in excon model
If a codebase included a definition for `Excon.new`, we matched
connection nodes to unrelated request nodes.
2023-08-23 12:55:36 +01:00
Tony Torralba
0f3918af16 Merge pull request #13773 from atorralba/atorralba/java/mdht-xxe-sink
Java: Add XXE sinks for MDHT
2023-08-23 13:49:49 +02:00
Asger F
ae2a1c7399 JS: Change note 2023-08-23 13:39:56 +02:00
Anders Schack-Mulligen
736c4beb9e Java: Add change note. 2023-08-23 13:26:41 +02:00
Anders Schack-Mulligen
6c02e30f56 Java: Update models. 2023-08-23 13:24:55 +02:00
Anders Schack-Mulligen
4b0a1cf74b Java: Remove old interpretation. 2023-08-23 13:19:16 +02:00
Anders Schack-Mulligen
410c09270f Java: Use nested names in MaD signatures. 2023-08-23 13:17:52 +02:00
Geoffrey White
efcadbda69 Swift: Get the IncompleteHostnameRegex query working for Swift. 2023-08-23 10:32:10 +01:00
Harry Maclean
a5c8917ff0 Merge pull request #14031 from hmac/hmac-fix-test
Ruby: Update test fixture
2023-08-23 10:15:23 +01:00
Harry Maclean
842da58269 Ruby: Update test fixture 2023-08-23 09:59:04 +01:00
Harry Maclean
fb4b774c0d Merge pull request #13967 from hmac/remove-splat-all
Ruby: Remove isSplatAll
2023-08-23 09:40:06 +01:00
Michael Nebel
1f1d48f768 Merge pull request #14020 from tamasvajk/fix/dependency-fetching-1
C#: Fix lazy evaluation of not yet downloaded packages
2023-08-23 10:39:29 +02:00
Michael Nebel
95193633fe Update csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs
Co-authored-by: Tom Hvitved <hvitved@github.com>
2023-08-23 10:35:20 +02:00
erik-krogh
25e4f2c3a2 limit concretize to strings of at most length 100 2023-08-23 10:26:29 +02:00
Tom Hvitved
3810b796a0 Data flow: Use call contexts in stage 3 2023-08-23 10:05:57 +02:00
Geoffrey White
6deaf4e5f8 Swift: Rework ParsedStringRegex and introduce the needed RegexPatternSource class. 2023-08-23 09:01:15 +01:00
Asger F
d8462ad1b3 JS: Add a file size limit to extractor 2023-08-23 09:54:55 +02:00
Asger F
bc47646a79 JS: Move getMegabyteCountFromPrefixedEnv into a shared place 2023-08-23 09:54:55 +02:00
Asger F
dec6039469 JS: Follow immediate predecessors in path resolution 2023-08-23 09:53:51 +02:00
Geoffrey White
6fb1058e73 Swift: Copy IncompleteHostnameRegex query from JS. 2023-08-23 08:46:13 +01:00
Michael Nebel
672d1637ab C#: Exclude dll files when getting files in the dependency manager. 2023-08-23 09:28:49 +02:00
Maiky
664c1eba72 Add "" and nil as sources 2023-08-22 18:10:33 +02:00
Ian Lynagh
deaf912cb8 Kotlin: Add an integration test for extractor information 2023-08-22 16:39:18 +01:00
Jeroen Ketema
cf53956d39 Merge pull request #14021 from jketema/non-const-format-test
C++: Add `cpp/non-constant-format` test
2023-08-22 17:38:45 +02:00
Jeroen Ketema
6566b91355 C++: Add indication that the test result is good 2023-08-22 16:38:46 +02:00
Robert Marsh
5734e475d4 Merge pull request #14014 from rdmarsh2/rdmarsh2/swift/keypath-force-steps
Swift: flow through keypath optional components
2023-08-22 10:35:36 -04:00
Jeroen Ketema
1e8daff02a C++: Add cpp/non-constant-format test 2023-08-22 16:23:47 +02:00
Robert Marsh
e94781fa8f Swift: fix comment 2023-08-22 13:27:17 +00:00
Michael Nebel
c1f167ceee C#: Move package filtering logic from FileContent to DependencyManager. 2023-08-22 14:51:33 +02:00
Tamas Vajk
87d0d723ed C#: Fix lazy evaluation of not yet downloaded packages 2023-08-22 14:50:03 +02:00
Mathias Vorreiter Pedersen
530c950b41 C++: Fix formatting. 2023-08-22 13:40:00 +01:00
Mathias Vorreiter Pedersen
66f11d427b C++: Simplify description. 2023-08-22 13:39:38 +01:00
Mathias Vorreiter Pedersen
bbce7ee96d C++: Cache 'getAnInput' since it's now used in several queries. 2023-08-22 13:37:24 +01:00
Tamás Vajk
afe1e9c453 Merge pull request #13957 from tamasvajk/razor-standalone-2
C#: Generate source files from cshtml files in standalone
2023-08-22 14:22:11 +02:00
Michael Nebel
fe36230061 Merge pull request #14015 from michaelnebel/csharp/vscodesettings
C#: Update of VS Code settings.
2023-08-22 14:16:31 +02:00
Mathias Vorreiter Pedersen
1c3a0d1632 Update cpp/ql/src/Security/CWE/CWE-193/InvalidPointerDeref.qhelp
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
2023-08-22 13:03:07 +01:00
Mathias Vorreiter Pedersen
e88277bd3b Update cpp/ql/src/Security/CWE/CWE-193/InvalidPointerDeref.qhelp
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
2023-08-22 13:02:37 +01:00
Mathias Vorreiter Pedersen
abe28cb106 Update cpp/ql/src/Security/CWE/CWE-193/InvalidPointerDeref.ql
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
2023-08-22 13:02:29 +01:00
Ian Lynagh
c67cc23e07 Kotlin: Write usesK2 information to the database 2023-08-22 12:37:01 +01:00
Tom Hvitved
31738a37ae Merge pull request #14016 from hvitved/csharp/codeql-threads
C#: Respect `$CODEQL_THREADS` environment variable
2023-08-22 13:04:48 +02:00
Maiky
f301e46175 Remove isEmptyPassword predicate 2023-08-22 12:23:32 +02:00
yoff
00c0ebe9e4 Merge pull request #13738 from RasmusWL/path-steps
Python: Include all assignments in data flow paths
2023-08-22 11:58:11 +02:00
Michael Nebel
2b718fbc62 Merge pull request #13995 from michaelnebel/csharp/refactorimports
C#: Re-factor imports.
2023-08-22 11:52:02 +02:00
Tom Hvitved
6bb37ca465 C#: Respect $CODEQL_THREADS environment variable 2023-08-22 11:46:03 +02:00
Michael Nebel
b4c903fd15 C#: tasks.json no longer needed if C# Dev kit is installed. 2023-08-22 11:45:53 +02:00
Michael Nebel
8441b54bd8 C#: Set the extractor solution file as the default solution for the C# Dev Kit and add config for the Format usings plugin. 2023-08-22 11:35:47 +02:00
Michael Nebel
e9b1c933ed C#: Recommend the C# Dev Kit and C# Format usings plugins. 2023-08-22 11:34:50 +02:00
Tom Hvitved
5192d7c137 Merge pull request #13997 from hvitved/ruby/type-tracking-splats
Ruby: Include more (hash) splat flow in type tracking
2023-08-22 11:33:39 +02:00
Tom Hvitved
3f54ecbcc2 Update ruby/ql/lib/codeql/ruby/typetracking/TypeTrackerSpecific.qll
Co-authored-by: Harry Maclean <hmac@github.com>
2023-08-22 11:18:12 +02:00
Alex Denisov
5cce37baa9 Swift: update test expectations 2023-08-22 11:11:28 +02:00
Alex Denisov
48607e3ad7 Swift: address code review comments 2023-08-22 10:01:16 +02:00
AlexDenisov
b98a966729 Apply suggestions from code review
Co-authored-by: Paolo Tranquilli <redsun82@github.com>
2023-08-22 09:57:25 +02:00
Anders Starcke Henriksen
3b8b33a94d Released pack. 2023-08-22 09:45:52 +02:00
Anders Starcke Henriksen
3aeacf6df3 Update publish script to have right path. 2023-08-22 09:37:31 +02:00
Anders Schack-Mulligen
bdc5f9cdea Merge pull request #14012 from knewbury01/knewbury01/add-sanitizer-command-query
Java: add sanitizer to command injection query
2023-08-22 08:40:49 +02:00
Michael Nebel
ce6fd8ac5f Merge pull request #13432 from michaelnebel/updateissupported
Java/C#: Update telemetry queries to report callables with sink/source neutrals as being supported.
2023-08-22 08:39:38 +02:00
Sid Shankar
a9ea61f0b2 Merge pull request #14001 from github/sidshank/clarify-js-and-ts-requirements
Clarify system requirements for TypeScript extraction
2023-08-21 20:59:11 -04:00
Robert Marsh
a335ece5e5 Swift: change note for keypath optional flows 2023-08-21 20:11:37 +00:00
Robert Marsh
1634fa2e25 Swift: support for optional chaining in keypaths 2023-08-21 20:09:28 +00:00
Robert Marsh
81bf415b50 Swift: modify test so implicit read isn't needed at sink 2023-08-21 20:08:30 +00:00
Robert Marsh
246d5c530e Swift: flow through keypath force components 2023-08-21 19:07:40 +00:00
Geoffrey White
f7776f812c Swift: 'good enough' fix for UnsafeJsEval flow. 2023-08-21 18:30:30 +01:00
Henry Mercer
5a76b9f59e Merge pull request #14010 from github/henrymercer/cs/add-alias
C#: Add "c#" alias to language pack
2023-08-21 18:26:54 +01:00
Geoffrey White
317757b7ae Swift: Create proper models for JavaScriptCore. 2023-08-21 18:24:26 +01:00
Kristen Newbury
5e01e1d464 Java: add sanitizer to command injection query 2023-08-21 12:33:05 -04:00
Mathias Vorreiter Pedersen
e1ed49f3ac Merge pull request #14011 from github/revert-13991-redsun82/swift-use-concepts
Revert "Swift: use C++20 constraints and concepts to simplify code"
2023-08-21 17:21:42 +01:00
Paolo Tranquilli
1daedd9fb6 Revert "Swift: use C++20 constraints and concepts to simplify code" 2023-08-21 17:40:15 +02:00
Henry Mercer
cbce0736c2 C#: Add "c#" alias to language pack
This will allow users to reference the C# extractor using
`--language c#` in future versions of the CLI.
2023-08-21 16:27:39 +01:00
Harry Maclean
414ae76ae1 Ruby: Add another splat flow test 2023-08-21 16:21:55 +01:00
Harry Maclean
c615f183c1 Ruby: Add test for spurious splat flow
We don't yet properly model splat flow when a positional argument
follows a splat argument.
2023-08-21 16:11:10 +01:00
Tamas Vajk
2575db356d Improve code quality: fix review findings 2023-08-21 16:07:56 +02:00
Paolo Tranquilli
6d85d0d0f7 Merge pull request #13991 from github/redsun82/swift-use-concepts
Swift: use C++20 constraints and concepts to simplify code
2023-08-21 15:45:44 +02:00
Mathias Vorreiter Pedersen
ef9d342a99 C++: Accept more test changes. 2023-08-21 14:02:18 +01:00
Mathias Vorreiter Pedersen
c46f9e4572 C++: Don't consider additional loads when reusing dataflow operands. 2023-08-21 12:51:41 +01:00
Mathias Vorreiter Pedersen
50190efe1c C++: Don't limit instruction and operand reuse to those cases where we have a result for 'isUseImpl'. 2023-08-21 12:51:00 +01:00
Tom Hvitved
12d1d04592 Merge pull request #13983 from hvitved/dataflow/reduced-dispatch-early-join
Data flow: Earlier call-context based dispatch filtering
2023-08-21 13:20:08 +02:00
Tom Hvitved
1b4520b058 Data flow: Update QL doc 2023-08-21 12:56:37 +02:00
Sid Shankar
671eb0f82f Updates requirements for TypeScript only
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2023-08-21 06:51:30 -04:00
Jeroen Ketema
2d0f73d7c2 Merge pull request #13881 from jketema/shared-taint-tracking
Introduce shared taint tracking library
2023-08-21 12:45:49 +02:00
Geoffrey White
6ef6be7291 Swift: UnsafeJSEval regression. 2023-08-21 11:28:48 +01:00
Geoffrey White
997984c529 Swift: Minor test .expected changes. 2023-08-21 11:15:43 +01:00
Geoffrey White
a54747f850 Swift: Fix mysterious taint flow issue. 2023-08-21 11:06:04 +01:00
Rasmus Wriedt Larsen
c8c69aac9b Merge pull request #13561 from amammad/amammad-python-WebAppsConstatntSecretKeys
Python: Flask & Django Constant Secret Key initialization
2023-08-21 11:39:19 +02:00
Mathias Vorreiter Pedersen
e776178be5 C++: Add some whitespace to make stuff appear in the diff. 2023-08-21 10:23:41 +01:00
Mathias Vorreiter Pedersen
0a41acc0a6 C++: Add change note. 2023-08-21 10:23:41 +01:00
Mathias Vorreiter Pedersen
70fdfc2ae3 C++: Set precision to medium and add security severity. 2023-08-21 10:23:23 +01:00
Mathias Vorreiter Pedersen
4daabdae2b C++: Promote 'cpp/invalid-pointer-deref' out of experimental. 2023-08-21 10:23:22 +01:00
Geoffrey White
b4db68af80 Swift: Add content to the string models. 2023-08-21 10:16:40 +01:00
Geoffrey White
a6f29fa417 Swift: Address pointer/pointee conflation in the string tests themselves. 2023-08-21 10:16:39 +01:00
Tamas Vajk
b5cdaa2f94 Fix compile issues after rebase 2023-08-21 10:43:36 +02:00
Tamas Vajk
62666915b4 Adjust integration test to opt into cshtml extraction 2023-08-21 10:38:22 +02:00
Tamas Vajk
84a78e7a8d Add opt-in environment variable for cshtml generation 2023-08-21 10:38:22 +02:00
Tamas Vajk
ba0cc76da1 Minor cleanup of dotnet CLI invocations 2023-08-21 10:38:22 +02:00
Tamas Vajk
ad3cc8e1c7 Change backslash to forward slash in file paths in the analyzer config file 2023-08-21 10:38:22 +02:00
Tamas Vajk
c2eb2e9c69 Add more logging 2023-08-21 10:38:22 +02:00
Tamas Vajk
a644133d8f Write CSC arguments to file and pass that to the execution 2023-08-21 10:38:22 +02:00
Michael Nebel
166633dac0 C#: Only apply Path.combine to OS agnostic parts of the path. 2023-08-21 10:38:21 +02:00
Michael Nebel
d48ab36273 C#: Run dotnet exec command silently. 2023-08-21 10:38:21 +02:00
Tamas Vajk
d391246f27 C#: Generate source files from .cshtml files in standalone 2023-08-21 10:38:21 +02:00
Tamas Vajk
ba0f07b66c C#: Add integration test for cshtml extraction in standalone mode 2023-08-21 10:38:21 +02:00
Tamas Vajk
af1a0b9a6c C#: Include cshtml files in integration test results 2023-08-21 10:38:21 +02:00
Jeroen Ketema
a2bb7dee18 Java: Delete copy of shared taint tracking library 2023-08-21 10:32:28 +02:00
Michael Nebel
51f166d71e Java: Address review comments. 2023-08-21 10:22:28 +02:00
Paolo Tranquilli
bda516e9ea C++: tweak dispatcher clauses 2023-08-21 10:01:45 +02:00
Michael Nebel
106ba11e10 Address review comments. 2023-08-21 09:59:02 +02:00
Michael Nebel
d66fe08661 Add QLDoc for the getKind predicate. 2023-08-21 09:59:02 +02:00
Michael Nebel
a9f7994b7d Swift: Sync files and make manual changes. 2023-08-21 09:59:01 +02:00
Michael Nebel
4c06fbdc65 Ruby: Sync files and make manual changes. 2023-08-21 09:59:01 +02:00
Michael Nebel
42c7006378 Python: Sync files and make manual changes. 2023-08-21 09:59:01 +02:00
Michael Nebel
25cc561e50 Go: Sync files and make manual adjustments. 2023-08-21 09:59:01 +02:00
Michael Nebel
764581cc3e C#: Update FlowSummaries expected output. 2023-08-21 09:59:01 +02:00
Michael Nebel
807faf2c70 C#: Only include Neutral summary callables in the FlowSummaries test case. 2023-08-21 09:59:01 +02:00
Michael Nebel
6840a6dafe C#: Re-factor NeutralCallable to include all neutrals and introduce NeutralSummaryCallable. Also include printing of the neutral kind in FlowSummaries testcase. 2023-08-21 09:59:00 +02:00
Michael Nebel
8b5b153a21 C#: Update outdated comments in supported external APIs test case file. 2023-08-21 09:59:00 +02:00
Michael Nebel
699ed107f3 Java: Update SupportedExternalApis expected test output. 2023-08-21 09:59:00 +02:00
Michael Nebel
5623ccf4a0 Java: Re-factor NeutralCallable to include all neutrals and introduce NeutralSummaryCallable. 2023-08-21 09:59:00 +02:00
Michael Nebel
6deeb36a97 Java: Update the comments in SupportedExternalApis to include the neutral kind and add a sink neutral example. 2023-08-21 09:58:59 +02:00
Michael Nebel
864f60f90f C#: Re-arrange using statements. 2023-08-21 09:41:28 +02:00
Tony Torralba
71a36fcf0f Merge pull request #14003 from github/workflow/coverage/update
Update CSV framework coverage reports
2023-08-21 09:28:05 +02:00
Michael Nebel
034db52c5c Merge pull request #13986 from michaelnebel/csharp/refactordepencyfetching
C#: Re-factor dependency fetching into a separate project.
2023-08-21 09:24:58 +02:00
Michael Nebel
4fb73ea191 C#: Address review comments. 2023-08-21 08:53:17 +02:00
Michael Nebel
1de86b4313 C#: Address review comments. 2023-08-21 07:37:27 +02:00
github-actions[bot]
181b3d0e33 Add changed framework coverage reports 2023-08-21 00:14:44 +00:00
Sid Shankar
79ab27bfed Clarifies JS and TS system requirements 2023-08-18 15:50:00 -04:00
Dave Bartolomeo
9798fcddfa Merge pull request #13998 from github/release-prep/2.14.3
Release preparation for version 2.14.3
2023-08-18 14:59:47 -04:00
github-actions[bot]
098dfb4242 Release preparation for version 2.14.3 2023-08-18 14:48:15 +00:00
Edward Minnix III
d109637e2d Merge pull request #13413 from egregius313/egregius313/trust-boundary
Java: Trust Boundary Violation Query
2023-08-18 10:33:32 -04:00
Michael B. Gale
a1c9deea61 Merge pull request #13867 from github/mbg/go/1.21-support
Go: Basic Go 1.21 support
2023-08-18 14:37:11 +01:00
Paolo Tranquilli
b78f12481f Swift: tweak priority of location information sources 2023-08-18 15:18:48 +02:00
Jeroen Ketema
1643a83678 Merge pull request #13996 from jbj/accept-BadlyBoundedWrite
C++: Accept regression in test after evaluator fix
2023-08-18 14:28:46 +02:00
Alex Denisov
7e36f7dcaf Swift: fix autobuilder crash 2023-08-18 14:26:16 +02:00
Paolo Tranquilli
386dedb9df Swift: fix location extractor hitting swift assertion 2023-08-18 14:21:30 +02:00
Tom Hvitved
deaa37d9d3 Ruby: Include more (hash)splat flow in type tracking 2023-08-18 14:07:12 +02:00
Paolo Tranquilli
c17a582b34 Revert "Swift: upgrade clang-formatting to 15.0.7"
This reverts commit 970b3d06be.
2023-08-18 13:59:41 +02:00
Tom Hvitved
da05e3e0e8 Ruby: Add more type tracking tests 2023-08-18 13:51:29 +02:00
Jonas Jensen
a002f59f58 C++: Undo BadlyBoundedWrite change from #13929
This rolls back the query change, ensuring that there is no need for a
change note.
2023-08-18 13:48:58 +02:00
Jonas Jensen
478a105e21 C++: delete change note
Since the previous commit removed the best evidence we had for the
change described in this note, I'm removing the note for now.
2023-08-18 13:35:32 +02:00
Jonas Jensen
cd1f196848 C++: Accept regression in test after evaluator fix 2023-08-18 13:30:20 +02:00
Alex Denisov
6a5e539833 Swift: update test expectations 2023-08-18 13:18:02 +02:00
Alex Denisov
202a4cd1a2 Swift: teach autobuilder about SPM, CocoaPods, and Carthage 2023-08-18 13:17:57 +02:00
Harry Maclean
0bbda992fb Ruby: Remove isSplatAll arg/parameter position
This is equivalent to isSplat(0).
2023-08-18 12:09:04 +01:00
Harry Maclean
222aa41bbf Merge pull request #13938 from hmac/splat-flow-2
Ruby: More precise flow into splat parameters
2023-08-18 12:07:58 +01:00
Erik Krogh Kristensen
08ef31d452 Merge pull request #13916 from erik-krogh/limit-java-field-reg
Java: limit field flow when tracking regex strings
2023-08-18 12:14:31 +02:00
Michael Nebel
d968a91799 C#: Introduce convenience constructor for the DependencyManager. 2023-08-18 11:49:07 +02:00
Michael Nebel
c0d1179c8a C#: Minimal update of relevant code to minimize project dependencies and hide some implementation details behind interfaces. 2023-08-18 11:42:12 +02:00
Michael Nebel
f47e59dff1 C#: Move dependency related files into a new project. 2023-08-18 11:42:12 +02:00
Michael Nebel
b48567f6a5 C#: Add shared dependency fetching project. 2023-08-18 11:42:12 +02:00
Michael Nebel
15dd130d31 C#: Remove unused parameter in DownloadMissingPackages. 2023-08-18 11:42:11 +02:00
Rasmus Wriedt Larsen
b579ab0694 Python: Accept .expected change 2023-08-18 11:12:55 +02:00
Tom Hvitved
81ed72c96a Data flow: Revert join order changes 2023-08-18 10:49:33 +02:00
Stephan Brandauer
480e3bf506 Java: update model exclusions logic to cope with new automodel test location 2023-08-18 10:28:51 +02:00
Rasmus Wriedt Larsen
38577e6a5c Python: Remove duplicated SSTI tests
Besides the Cheetah tests, which were missing from the query tests.
2023-08-18 10:20:16 +02:00
Rasmus Wriedt Larsen
33f8998c2e Python: Minor fix in test 2023-08-18 10:19:44 +02:00
Paolo Tranquilli
3c4e755233 Swift: fix macOS not having std::ranges::sized_range 2023-08-18 10:18:53 +02:00
Rasmus Wriedt Larsen
843f2681bb Python: Apply suggestions from code review
Co-authored-by: yoff <lerchedahl@gmail.com>
2023-08-18 10:09:45 +02:00
Paolo Tranquilli
8b3e32fa97 Swift: add missing include 2023-08-18 09:10:44 +02:00
Paolo Tranquilli
53ed39065c Swift: tweak location extractor using new concept 2023-08-18 06:45:11 +02:00
Paolo Tranquilli
eb8997dc7a Swift: fix print_unextracted 2023-08-18 06:44:42 +02:00
Tom Hvitved
4d951d8df1 Address review comments 2023-08-17 21:04:58 +02:00
Geoffrey White
86a73fa0e7 Swift: Accept fixed spurious test results. 2023-08-17 19:41:21 +01:00
Geoffrey White
0fd4f6180f Swift: Allow subscript content reads from collections. 2023-08-17 19:37:55 +01:00
Geoffrey White
1ac9d2c618 Swift: Update models with CollectionElement, value flow. 2023-08-17 18:49:19 +01:00
Michael B. Gale
9082fd218e Add taint flow tests for clear 2023-08-17 18:39:32 +01:00
Edward Minnix III
8d88af1af0 Apply docs review suggestions
Co-authored-by: Sam Browning <106113886+sabrowning1@users.noreply.github.com>
2023-08-17 13:05:38 -04:00
Ed Minnix
4eb1035dfe Documentation fixes 2023-08-17 13:05:38 -04:00
Ed Minnix
655a98452a Remove escapeHTML models 2023-08-17 13:05:37 -04:00
Ed Minnix
f53496b2a7 Added documentation for trust-boundary-violation sink 2023-08-17 13:05:37 -04:00
Ed Minnix
d468ea9e90 Add default sanitizers 2023-08-17 13:05:37 -04:00
Ed Minnix
b305962c9a Use more appropriate description 2023-08-17 13:05:37 -04:00
Ed Minnix
a36c12ff1f Add trust-boundary-violation sink kind 2023-08-17 13:05:37 -04:00
Ed Minnix
60642c52aa Use non-extending subtype 2023-08-17 13:05:37 -04:00
Ed Minnix
e22a67e7fe Remove unnecessary methods 2023-08-17 13:05:37 -04:00
Ed Minnix
a3a4c31911 Replace servlet source node with RemoteFlowSource 2023-08-17 13:05:37 -04:00
Edward Minnix III
929090a847 Typos and style fixes
Co-authored-by: Tony Torralba <atorralba@users.noreply.github.com>
2023-08-17 13:05:37 -04:00
Ed Minnix
52ebf9fff6 Java: Add trust boundary change note 2023-08-17 13:05:37 -04:00
Ed Minnix
172b8a6967 Documentation fixes 2023-08-17 13:05:37 -04:00
Ed Minnix
b567ec875a Documentation 2023-08-17 13:05:37 -04:00
Ed Minnix
55fae2daaa Added ESAPI sanitizer 2023-08-17 13:05:37 -04:00
Ed Minnix
97d6e82869 Stubs for org.owasp.esapi 2023-08-17 13:05:37 -04:00
Ed Minnix
f58590c6a9 Trust Boundary Work 2023-08-17 13:05:37 -04:00
Ed Minnix
2aba425464 TrustBoundary test ql file 2023-08-17 13:05:36 -04:00
Ed Minnix
ab9f0240d3 Add taint steps for HTML encoding methods 2023-08-17 13:05:36 -04:00
Ed Minnix
b9f2da7875 Comments and import fixes 2023-08-17 13:05:36 -04:00
Ed Minnix
3e7444cd66 Style fixes 2023-08-17 13:05:36 -04:00
Ed Minnix
15370506b8 Add missing security severity 2023-08-17 13:05:36 -04:00
Ed Minnix
a8b7e70d01 Convert trust boundary models to MaD 2023-08-17 13:05:36 -04:00
Ed Minnix
76438f13b6 Trust Boundary Query 2023-08-17 13:05:36 -04:00
Edward Minnix III
41a527cf72 Merge pull request #13934 from egregius313/egregius313/add-dashes-to-sha-algorithms
Java: Add dashes to SHA algorithm names in `Encryption.qll`
2023-08-17 13:03:15 -04:00
Michael B. Gale
109b96f038 Add comment explaining TaintStep test 2023-08-17 17:50:41 +01:00
Michael B. Gale
e65269be69 Add DefaultTaintSanitizer for clear 2023-08-17 17:49:46 +01:00
Geoffrey White
59e2b0482c Merge branch 'main' into closuremodels 2023-08-17 17:16:44 +01:00
Paolo Tranquilli
3de7b75853 Swift: remove uneeded include 2023-08-17 17:36:36 +02:00
Paolo Tranquilli
970b3d06be Swift: upgrade clang-formatting to 15.0.7 2023-08-17 17:24:42 +02:00
Paolo Tranquilli
7c764f3b50 Swift: use C++20 constraints and concepts to simplify code
This simplifies several instances of metaprogramming by leveraging
[constraints and concepts from C++20][1]. This:
* gets rid of `std::enable_if` by usage of `requires`, making it more
  readable and yield better compiler messages.
* uses `requires` instead of `static_assert` to enforce `TrapLabel`
  typing
* simplifies all compile-time tests for validity of a given expression
* uses some standard library concepts where possible
* generalizes and simplifies `SwiftLocationExtractor`

Notice that in order to use the `std::derived_from` concept, `virtual`
inheritance had to be added to the label tags, because diamond
inheritance is a problem otherwise. That's because
`std::derived_from<T, U>` requires that `T*` be convertible to `U*`,
which is false if there are multiple non-virtual inheritance paths from
`U` to `T`. As tags never get actually instantiated, there is no runtime
performance penalty in using `virtual` inheritance.

[1]: https://en.cppreference.com/w/cpp/language/constraints
2023-08-17 17:24:42 +02:00
Rasmus Wriedt Larsen
cf54d3f4ca Python: Move paramiko tests to own folder 2023-08-17 15:45:28 +02:00
Rasmus Wriedt Larsen
4c693b4fc3 Python: Port py/xslt-injection to new data-flow 2023-08-17 15:45:07 +02:00
Rasmus Wriedt Larsen
ef139f2ee9 Python: Delete XsltSinks.ql test 2023-08-17 15:45:07 +02:00
Rasmus Wriedt Larsen
779fe6498c Python: Rename to XsltInjection.ql 2023-08-17 15:45:07 +02:00
Rasmus Wriedt Larsen
0336c76871 Python: Rename template injection tests 2023-08-17 15:45:04 +02:00
Rasmus Wriedt Larsen
91edde72c4 Python: Port py/template-injection to new data-flow
I kept all the modeling in _one_ file, since that makes it easy to work
with such an external contribution... and I would certainly propose this
file setup for the future 👍
2023-08-17 15:44:26 +02:00
Paolo Tranquilli
700f383bab Merge pull request #13988 from github/redsun82/swift-version-macro
Swift: fix version check macro to be lexicographic
2023-08-17 15:34:04 +02:00
Anders Schack-Mulligen
e27aad9d6c Merge pull request #13987 from aschackmull/java/rangeanalysis-joinorder-fix
Java: Join-order fix in RangeAnalysis.
2023-08-17 14:47:26 +02:00
Mathias Vorreiter Pedersen
af7fe89c5a Merge pull request #13989 from MathiasVP/add-invalid-ptr-false-positive-3
C++: Add `cpp/invalid-pointer-deref` false positive
2023-08-17 12:50:55 +01:00
Mathias Vorreiter Pedersen
5f5a87e2c7 C++: Add false positive. 2023-08-17 12:13:16 +01:00
Paolo Tranquilli
75cc1d8f75 Swift: fix version check macro to be lexicographic 2023-08-17 12:19:28 +02:00
Anders Schack-Mulligen
f8a0b6cd22 Java: Add nomagic 2023-08-17 11:20:02 +02:00
Anders Starcke Henriksen
1b31c4dd4c Update filter to point to right pack. 2023-08-17 11:07:27 +02:00
Anders Schack-Mulligen
0afda68ba1 Java: Join-order fix in RangeAnalysis. 2023-08-17 11:07:24 +02:00
Rasmus Wriedt Larsen
4277be5819 Python: Add change-note 2023-08-17 10:46:36 +02:00
Tom Hvitved
7cc01ea8b5 Merge pull request #13595 from hvitved/csharp/use-shared-cfg-pack
C#: Adopt shared CFG construction library from shared `controlflow` pack
2023-08-17 10:37:09 +02:00
Rasmus Wriedt Larsen
24f9f13790 Python: Fix tests 2023-08-17 10:15:36 +02:00
Anders Starcke Henriksen
56871c77f5 Merge branch 'main' into starcke/automodel-pack 2023-08-17 10:04:44 +02:00
Tony Torralba
67c557115b Merge pull request #13915 from github/workflow/coverage/update
Update CSV framework coverage reports
2023-08-17 10:03:04 +02:00
Tom Hvitved
fe0f766994 Merge pull request #13966 from hvitved/csharp/mad-repr-fix
C#: Fix `getMadRepresentationSpecific`
2023-08-17 09:40:41 +02:00
Tom Hvitved
da8005dbd3 Code review suggestions 2023-08-17 09:26:58 +02:00
github-actions[bot]
b0da1ef892 Add changed framework coverage reports 2023-08-17 00:14:13 +00:00
Jeroen Ketema
33e8310625 Merge branch 'main' into shared-taint-tracking 2023-08-17 00:14:25 +02:00
Ian Lynagh
1fb4e13e0a Merge pull request #13960 from igfoo/igfoo/parent
Kotlin: Handle Kotlin 2 parents better
2023-08-16 16:27:15 +01:00
Mathias Vorreiter Pedersen
e56cd0b498 Merge pull request #13984 from MathiasVP/fix-expected-for-swift
Swift: Fix expected files after a semantic merge conflict
2023-08-16 15:06:27 +01:00
Maiky
5f502ec6bb rename change-note 2023-08-16 15:32:53 +02:00
yoff
7f2f6f14e7 Merge pull request #13729 from yoff/python/model-aws-lambdas
Python/JavaScript: Shared module for serverless functions
2023-08-16 15:14:08 +02:00
Rasmus Wriedt Larsen
0443057608 Merge branch 'main' into amammad-python-WebAppsConstatntSecretKeys 2023-08-16 15:06:08 +02:00
Mathias Vorreiter Pedersen
b2c7c57815 Swift: Fix expected files after a semantic merge conflict. 2023-08-16 13:52:06 +01:00
Mathias Vorreiter Pedersen
66d13dc0d5 Merge pull request #13981 from MathiasVP/fix-orig-delta-for-subtraction
C++: Fix original delta calculation for subtraction in new range analysis
2023-08-16 13:28:21 +01:00
Tom Hvitved
570654d1f0 Data flow: Earlier call-context based dispatch filtering 2023-08-16 14:24:45 +02:00
Mathias Vorreiter Pedersen
20df63f26d C++: Respond to review comments. 2023-08-16 12:50:41 +01:00
Jeroen Ketema
591565a0db Merge pull request #13971 from jketema/float
C++: Update test after float128 related extractor changes
2023-08-16 13:11:35 +02:00
Mathias Vorreiter Pedersen
5e14b5cca7 C++: 'origDelta' should always be 'odLeft' when deriving subtraction ranges. 2023-08-16 12:10:31 +01:00
yoff
b2988e5516 Update python/ql/lib/change-notes/2023-08-07-serverless-sources.md
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
2023-08-16 12:56:39 +02:00
Mathias Vorreiter Pedersen
986aa74db7 Merge pull request #13972 from MathiasVP/range-analysis-for-sub-expr
C++: Support subtraction in the new range analysis
2023-08-16 11:51:11 +01:00
Michael B. Gale
1bd536dd9e Rename getLocation to hasLocation 2023-08-16 11:21:35 +01:00
Rasmus Wriedt Larsen
c55b0982f7 Merge pull request #13819 from yoff/python/relax-module-resolution
Python: Relax module resolution
2023-08-16 12:04:49 +02:00
Michael Nebel
365b10183f Merge pull request #13744 from tamasvajk/standalone/integration-test
C#: Add integration test for standalone extraction
2023-08-16 10:50:12 +02:00
Stephan Brandauer
44a9cf93e0 Merge branch 'main' into kaeluka/add-provenance-to-metadata 2023-08-16 09:31:03 +02:00
Stephan Brandauer
808dc3e8d3 Java: Automodel framework mode: track exact ai- provenance in alreadyAiModeled meta data property 2023-08-16 09:25:03 +02:00
Stephan Brandauer
20254c3d0a Merge pull request #13886 from github/kaeluka/java-automodel-variadic-args
Java: automodel application mode: use endpoint class like in framework mode
2023-08-16 08:49:01 +02:00
Ed Minnix
cafd08521e Add change note 2023-08-15 23:46:12 -04:00
Ed Minnix
7cfe78a52d Add dashes to SHA algorithm names in Encryption.qll 2023-08-15 23:42:17 -04:00
Jeroen Ketema
4ada83c0ba C++: Update test after float128 related extractor changes 2023-08-15 22:10:05 +02:00
Rasmus Lerchedahl Petersen
6614e037ae Python: format 2023-08-15 21:40:20 +02:00
Michael B. Gale
c981fd714e Exclude String from TaintSteps
For `os.dirEntry` and `os.unixDirent` which are only available
on unix and Windows respectively.
2023-08-15 20:32:41 +01:00
Michael B. Gale
ee58dbc6f7 Add new built-ins to builtinFunction predicate
- `clear` isn't pure because it modifies a data structure in place
- `clear` may not be used correctly, but this is determined statically
2023-08-15 20:16:42 +01:00
Chris Smowton
b8372c2f95 Merge pull request #13973 from github/smowton/fix/go-version-comparison
Go: Don't warn when Go version exactly matches go.mod
2023-08-15 18:21:04 +01:00
Mathias Vorreiter Pedersen
49a5a39395 C++: Accept test changes. 2023-08-15 16:49:58 +01:00
Chris Smowton
3bcfbcdf68 Don't warn when Go version exactly matches go.mod
We had only previously tested this with e.g. installed go 1.20.5 >= go.mod request `go 1.20`; now we have go 1.21.0 which shouldn't elicit a warning because 1.21.0 is equal to the go.mod request `go 1.21`.
2023-08-15 16:49:42 +01:00
Paolo Tranquilli
234763efa6 Merge pull request #13959 from github/redsun82/cmake-fix
C++: make cmake generation work with internal rule `cc_binary_add_features`
2023-08-15 17:16:51 +02:00
Robert Marsh
3d20897725 Merge pull request #13910 from rdmarsh2/rdmarsh2/swift/for-await-cfg
Swift: CFG test for for-try-await
2023-08-15 11:16:07 -04:00
Mathias Vorreiter Pedersen
e145b81f58 C++: Accept test changes. 2023-08-15 16:12:44 +01:00
Mathias Vorreiter Pedersen
109e45e112 C++: Add precise range analysis for subtraction. 2023-08-15 16:12:40 +01:00
Mathias Vorreiter Pedersen
3fb024164b C++: Add a FP caused by bad range analysis for subtraction. 2023-08-15 16:00:35 +01:00
Mathias Vorreiter Pedersen
90888e592f Merge pull request #13965 from MathiasVP/better-certain-writes-and-invalid-ptr-deref-prep
C++: Remove more dataflow FPs after frontend upgrade
2023-08-15 15:43:55 +01:00
yoff
7eb41140ab Update python/ql/lib/semmle/python/Module.qll
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
2023-08-15 15:47:00 +02:00
Rasmus Lerchedahl Petersen
e6943ce98e Python: use standard test format 2023-08-15 15:26:18 +02:00
Michael B. Gale
b95effe916 Allow patch-level updates in Go CI 2023-08-15 14:13:36 +01:00
yoff
99bc050366 Update shared/yaml/codeql/serverless/ServerLess.qll
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
2023-08-15 15:09:30 +02:00
Kasper Svendsen
bb317bc558 Merge pull request #13968 from kaspersv/shadow-dbscheme
QL language specs: declarations can shadow dbscheme types and preds
2023-08-15 14:20:04 +02:00
Kasper Svendsen
30a813ab08 QL language specs: declarations can shadow dbscheme types and preds 2023-08-15 13:58:19 +02:00
Ian Lynagh
3b9bd16097 Kotlin: Mark some functions as private 2023-08-15 12:38:47 +01:00
Tom Hvitved
26b76171ca C#: Fix getMadRepresentationSpecific 2023-08-15 13:23:21 +02:00
Ian Lynagh
a8b69e5b55 Kotlin: Fix build on old versions 2023-08-15 11:30:23 +01:00
Mathias Vorreiter Pedersen
569f3c9b78 C++: Don't do indirect (instruction -> operand) flow when there's a store to the address in between the instruction and the operand. 2023-08-15 11:08:01 +01:00
Mathias Vorreiter Pedersen
f662cceb0b C++: Use value numbering to better detect whether a write is certain. 2023-08-15 11:07:14 +01:00
Rasmus Lerchedahl Petersen
8f70c9f950 Python: add comment about namespace packages 2023-08-15 12:02:02 +02:00
Tom Hvitved
44b734e120 Merge pull request #13955 from hvitved/ruby/type-tracking-capture-insensitive
Ruby: Make type tracking flow-insensitive for captured variables
2023-08-15 11:42:41 +02:00
Paolo Tranquilli
8e229ac31b Merge branch 'main' into redsun82/cmake-fix 2023-08-15 11:38:37 +02:00
Erik Krogh Kristensen
6a3b9e10eb Merge pull request #13914 from erik-krogh/escape-unicode
ReDoS: escape unicode chars in the output for the ReDoS queries
2023-08-15 11:21:21 +02:00
Mathias Vorreiter Pedersen
fec9626fe7 Merge pull request #13836 from github/alexdenisov/unresolved-dot-exprs
Swift: 'ParsedSequence' lacks proper types and yields 'Unresolved' AST nodes
2023-08-15 09:14:39 +01:00
Michael Nebel
a95aad51bd Merge pull request #13546 from michaelnebel/java/withoutelement
Java: Support for With[out]Element for MaD.
2023-08-15 10:03:03 +02:00
Rasmus Wriedt Larsen
d12743d7c3 Merge pull request #13941 from yoff/python/test-nice-location
Python: fix nice locations for import aliases
2023-08-14 21:37:23 +02:00
Tom Hvitved
061575ff77 Merge pull request #13937 from hvitved/ruby/for-loop-desugar
Ruby: Improve desugaring of `for` loops
2023-08-14 20:12:12 +02:00
Ian Lynagh
eb27428514 Kotlin: Handle IrExternalPackageFragment when dealing with external decls 2023-08-14 17:37:48 +01:00
Arthur Baars
77db0cf547 Merge pull request #13334 from aibaars/print-cfg-2
Ruby: printCfg: only show graph for selected CfgScope
2023-08-14 18:24:20 +02:00
Ian Lynagh
72af8ac1e2 Kotlin: Switch to useDeclarationParentOf
This lets us handle Kotlin 2 declarations whose parent is an
IrExternalPackageFragment, indicating that they are in a (multi)file
class.
2023-08-14 17:02:49 +01:00
Ian Lynagh
4f336820de Kotlin: Start handling IrExternalPackageFragment parents 2023-08-14 17:02:48 +01:00
Paolo Tranquilli
ef804c018d C++: make cmake generation work with internal rule cc_binary_add_features 2023-08-14 17:32:03 +02:00
Ian Lynagh
77451de9a3 Kotlin: Fix isExternalDeclaration for Kotlin 2 2023-08-14 15:01:13 +01:00
amammad
eb5529eac5 sanitize resutls exist in test/demo/example/sample directories 2023-08-14 23:48:03 +10:00
Mathias Vorreiter Pedersen
9359bea7b5 Merge pull request #13725 from MathiasVP/fix-barriers-in-invalid-pointer-deref
C++: Fix barriers in invalid pointer deref
2023-08-14 14:29:12 +01:00
Geoffrey White
5e940cd46f Merge pull request #13829 from geoffw0/typegetname
Swift: Correct the behaviour of Type.getName
2023-08-14 14:21:26 +01:00
Tom Hvitved
e96cbeb00a Ruby: Adjust locations of synthesized nodes 2023-08-14 14:37:47 +02:00
Tom Hvitved
c084a9b27a Ruby: Make type tracking flow-insensitive for captured variables 2023-08-14 13:44:37 +02:00
Stephan Brandauer
bc55afcee7 Java: Automodel framework mode: use new interface 2023-08-14 13:17:55 +02:00
Harry Maclean
d45e9101ba Ruby: Add change note 2023-08-14 11:20:58 +01:00
Rasmus Wriedt Larsen
1c3cc1fa29 Python: Remove flow through stdlib
This means tests can pass on any machine now 👍
2023-08-14 11:55:22 +02:00
Rasmus Wriedt Larsen
794d04e4c0 Python: Model os.getenv[b] 2023-08-14 11:55:00 +02:00
Michael Nebel
0e9f8c4b97 Merge pull request #13876 from michaelnebel/csharp/aspnetdlls
C#: Include ASP.NET assemblies in the standalone extraction.
2023-08-14 11:53:47 +02:00
Stephan Brandauer
551b34e3be Java: Automodel application mode: include candidates that are useful for regression testing 2023-08-14 11:46:40 +02:00
Rasmus Wriedt Larsen
6e168ff7d8 Python: Only interested in StrConst 2023-08-14 11:46:21 +02:00
Geoffrey White
b6dc2acc71 Merge branch 'main' into typegetname 2023-08-14 10:46:14 +01:00
Mathias Vorreiter Pedersen
e2f671e327 C++: Add more comments. 2023-08-14 10:44:46 +01:00
Rasmus Wriedt Larsen
0fba38c6d8 Merge branch 'main' into amammad-python-WebAppsConstatntSecretKeys 2023-08-14 11:29:56 +02:00
Rasmus Wriedt Larsen
eeefdc5dcd Python: Fix formatting 2023-08-14 11:29:38 +02:00
Michael Nebel
6ecbb400d7 C#: Turn initialize into a readonly field. 2023-08-14 11:19:42 +02:00
Tamas Vajk
01af74aeda C#: Add space to CMD metacharacters 2023-08-14 11:19:17 +02:00
Tamas Vajk
3680681e8b C#: Add integration test for standalone extraction 2023-08-14 11:19:00 +02:00
Michael Nebel
d76bb49b6a C#: Make some FileContent unit tests. 2023-08-14 11:18:19 +02:00
Michael Nebel
a0bad3ce15 C#: Re-factor FileContent to make it unit-testable and make an initializer class. 2023-08-14 11:18:19 +02:00
Michael Nebel
a362ce083d C#: Some file content regexp tweaking. 2023-08-14 11:18:19 +02:00
Michael Nebel
c95d219c84 C#: Re-factor the processing of all files into a helper class and make sure to only do one pass of the files. 2023-08-14 11:18:19 +02:00
Michael Nebel
db685e5fc4 C#: Tidy up. 2023-08-14 11:18:19 +02:00
Michael Nebel
e24fa4705a C#: Introduce caching or detecting the newest runtimes and fetching all file names in the source dir. 2023-08-14 11:18:19 +02:00
Michael Nebel
ddb50b8120 C#: Improve regular expressions and fix lowercase issue. 2023-08-14 11:18:19 +02:00
Michael Nebel
ca7fa2e7c8 C#: Use ASP.NET dlls when needed and available. 2023-08-14 11:18:19 +02:00
Michael Nebel
b71c41018c C#: Re-factor the GetRuntime method. 2023-08-14 11:18:19 +02:00
Michael Nebel
5bc8804242 C#: Introduce method to decide whether we need to include ASP.NET dlls in standalone compilation. 2023-08-14 11:18:19 +02:00
Michael Nebel
88b51e6ad3 C#: Re-factor logic for fetching info from group and remove a redundant continue statement. 2023-08-14 11:18:18 +02:00
Michael Nebel
881d86321e C#: Introduce regex for framework reference and project sdk and make some minor re-writes. 2023-08-14 11:18:18 +02:00
Michael Nebel
f5d776571b Merge pull request #13952 from michaelnebel/csharp/runtimewhitespacefix
C#: .NET Runtime path detection (bugfix).
2023-08-14 11:17:27 +02:00
Mathias Vorreiter Pedersen
df9c756369 C++: Add more comments. 2023-08-14 10:09:27 +01:00
yoff
d2a0b9a66c Update python/ql/lib/change-notes/2023-08-10-fix-alias-locations.md
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
2023-08-14 10:55:00 +02:00
Mathias Vorreiter Pedersen
c265113073 Update cpp/ql/lib/semmle/code/cpp/security/InvalidPointerDereference/InvalidPointerToDereference.qll
Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
2023-08-14 09:51:28 +01:00
Harry Maclean
ca5456a54a Ruby: Remove duplicate disjuncts 2023-08-14 09:45:57 +01:00
Michael Nebel
9e03a211a5 C#: Add unit test where path to dotnet frameworks contain whitespaces. 2023-08-14 10:40:00 +02:00
Michael Nebel
1942ea8396 C#: Paths can contain whitespace (this is indeed common on windows). 2023-08-14 10:40:00 +02:00
Michael Nebel
280a27d9ca C#: Log some more info during dotnet --list-runtimes execution. 2023-08-14 10:40:00 +02:00
Michael Nebel
78c732db97 C#: Re-factor of ProgressMonitor and introduce LogInfo. 2023-08-14 10:40:00 +02:00
Michael Nebel
ef9453e862 C#: Selected runtime location should be logged as information. 2023-08-14 10:40:00 +02:00
yoff
307f44339c Update python/ql/lib/change-notes/2023-08-08-relax-module-resolution.md
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
2023-08-14 10:23:47 +02:00
Stephan Brandauer
1a95a34441 Java: automodel: use the call for call context, rather than the argument 2023-08-14 09:54:44 +02:00
Stephan Brandauer
4107758c8a Java: automodel extraction: add strings to query selection 2023-08-14 09:49:50 +02:00
Mathias Vorreiter Pedersen
2c6bbd8060 C++: Replace 'left' with 'small' and 'right' with 'large' for consistency. 2023-08-13 22:53:41 +01:00
Robert Marsh
7053c62c41 Swift: update and sync tests 2023-08-11 18:52:37 +00:00
Henry Mercer
75e6fd9c8e Merge pull request #13918 from github/post-release-prep/codeql-cli-2.14.2
Post-release preparation for codeql-cli-2.14.2
2023-08-11 16:28:16 +01:00
Mathias Vorreiter Pedersen
efe3c0d34a C++: Rename n' to m. 2023-08-11 15:24:08 +01:00
Harry Maclean
6011d26823 Ruby: Restrict parameter nodes 2023-08-11 15:14:32 +01:00
Tom Hvitved
e39fb093e9 Merge pull request #13945 from hvitved/ruby/destruct-param-test
Ruby: Add test for documenting missing flow through destructured parameters
2023-08-11 15:11:39 +02:00
Mathias Vorreiter Pedersen
f4e6deeee0 C++: Remove 'ValidForStateConfig'. 2023-08-11 13:57:59 +01:00
Henry Mercer
1213eba630 Merge branch 'main' into post-release-prep/codeql-cli-2.14.2 2023-08-11 13:54:55 +01:00
Ian Lynagh
5161cd1a3c Merge pull request #13944 from igfoo/igfoo/getFunctionLabel
Kotlin: Handle null parent IDs in getFunctionLabel correctly
2023-08-11 12:28:32 +01:00
Mathias Vorreiter Pedersen
2164069eda C++: Add another testcase. 2023-08-11 12:00:43 +01:00
Michael B. Gale
513da82510 Model data flow for min and max 2023-08-11 11:51:07 +01:00
Mathias Vorreiter Pedersen
88d3fcb34b C++: Fix comment. 2023-08-11 11:50:50 +01:00
Mathias Vorreiter Pedersen
3d5b1986c9 C++: Fix a bug where 'boundedImpl' could give back multiple deltas. 2023-08-11 11:46:28 +01:00
Mathias Vorreiter Pedersen
c0a54e90c9 C++: Fix an inequality that should be strict, but wasn't. 2023-08-11 11:43:55 +01:00
Michael B. Gale
d189a15737 Exclude poly1305.mac.Write from TaintSteps
Not available on arm64
2023-08-11 11:33:52 +01:00
Tom Hvitved
c95b58673a Merge pull request #13939 from hvitved/ruby/captured-access-fix2
Ruby: Fix another bug in `isCapturedAccess`
2023-08-11 12:28:39 +02:00
Michael B. Gale
9f51f6f7ac Merge pull request #13948 from github/mbg/go/fix-compare-identical-values-arm64
Make `CompareIdenticalValues` test work on arm64
2023-08-11 11:22:49 +01:00
Michael B. Gale
a623733dfa Add location info to TaintSteps query 2023-08-11 11:10:39 +01:00
Michael B. Gale
ee0bfff9f4 Update expected test output for TaintStep 2023-08-11 10:57:11 +01:00
Michael B. Gale
bb56536bfa Update expected test output for LocalTaintStep 2023-08-11 10:57:10 +01:00
Michael B. Gale
14731e8fa3 Bump supported Go version to 1.21 2023-08-11 10:57:10 +01:00
Michael B. Gale
238049a870 Add Go 1.21 builtins 2023-08-11 10:57:10 +01:00
Michael B. Gale
4df4a0f51f Update expected test output for TypeParamType 2023-08-11 10:55:00 +01:00
Michael B. Gale
69589766ec Use Go 1.21 in CI 2023-08-11 10:55:00 +01:00
Michael B. Gale
48c35ce5e9 Use Go 1.21 for extractor 2023-08-11 10:55:00 +01:00
Michael B. Gale
13d4bd9c0a Make CompareIdenticalValues test work on arm64 2023-08-11 10:51:52 +01:00
Owen Mansel-Chan
c10d03e74e Merge pull request #13820 from owen-mc/go/refactor-data-flow-configurations
Go: Make flow configurations use new data flow API
2023-08-11 10:49:51 +01:00
Owen Mansel-Chan
35a300f894 Apply suggestions from code review
Co-authored-by: Michael B. Gale <mbg@github.com>
2023-08-11 10:06:14 +01:00
Owen Mansel-Chan
b7dfa2347c Put QLDoc on data flow and taint tracking modules
We preserve all old QLDocs, but move them from the
config to the Flow module. This makes more sense than
the Config module, which is often private, and is generally
not directly accessed.
2023-08-11 10:06:12 +01:00
Rasmus Wriedt Larsen
ca93f4d223 Python: Accept .expected changes 2023-08-11 10:36:05 +02:00
Stephan Brandauer
a9906f6f7b Java: fix - add extra $@
Co-authored-by: Jami <57204504+jcogs33@users.noreply.github.com>
2023-08-11 09:15:09 +02:00
Rasmus Lerchedahl Petersen
3457f23db5 Python: Add change note 2023-08-10 20:53:43 +02:00
Rasmus Lerchedahl Petersen
e5cd3e8f64 Python: nice locations for import aliases
These were computed wrongly before.
2023-08-10 20:27:06 +02:00
Tom Hvitved
b28f60ccd2 Ruby: Add test for documenting missing flow through destructured parameters 2023-08-10 20:22:11 +02:00
Robert Marsh
36bdadfc36 Merge pull request #13933 from geoffw0/madtuples
Swift: Models-as-data support for tuple content
2023-08-10 14:17:45 -04:00
Ian Lynagh
58da62e244 Kotlin: Handle null parent IDs in getFunctionLabel correctly 2023-08-10 18:49:10 +01:00
Erik Krogh Kristensen
3e2c6d69f9 Merge pull request #13940 from erik-krogh/rate-default
JS: change the defaults in the qhelp for missing-rate-limit to something more reasonable
2023-08-10 19:25:33 +02:00
Geoffrey White
94a5aa450c Swift: Edit the weak sensitive data hashing examples and qhelp to encourage use of HMAC and key derivation algorithms where appropriate. 2023-08-10 18:21:25 +01:00
Owen Mansel-Chan
08e1e8a120 Improve inaccurate deprecation comments 2023-08-10 15:50:08 +01:00
Owen Mansel-Chan
94c15f712a Remove unnecessary fieldFlowBranchLimit 2023-08-10 15:50:06 +01:00
Owen Mansel-Chan
0928fa6e1f Give MyFlowstate a less generic name 2023-08-10 15:50:05 +01:00
Owen Mansel-Chan
36b1a0dc54 Update for recent changes to DsnInjection 2023-08-10 15:50:03 +01:00
Owen Mansel-Chan
2578ef4786 Remove output from running query like a test 2023-08-10 15:50:02 +01:00
Owen Mansel-Chan
089ea010d7 Improve QLDoc for Config::FlowState in StringBreak 2023-08-10 15:50:01 +01:00
Owen Mansel-Chan
e33d303b48 Do not make unnecessary changes 2023-08-10 15:49:59 +01:00
Owen Mansel-Chan
e6c8a0b653 Use more descriptive names for merged path graphs 2023-08-10 15:49:58 +01:00
Owen Mansel-Chan
6b4bf12316 Revert edit to deprecated class 2023-08-10 15:49:57 +01:00
Owen Mansel-Chan
039925164d Keep newline at the end of identical-files.json
VS Code's JSON formatter removed it automatically. It turns out
that the easiest way to keep it is to use the
`files.insertFinalNewline` setting, which the JSON formatter obeys.
2023-08-10 15:49:55 +01:00
Owen Mansel-Chan
046e517c3f Remove unnecessary import 2023-08-10 15:49:54 +01:00
Owen Mansel-Chan
81d4149a17 Note deprecation in QLDoc for LogInjection 2023-08-10 15:49:52 +01:00
Owen Mansel-Chan
b6b7e1589c Make taint tracking tests use new API 2023-08-10 15:49:51 +01:00
Owen Mansel-Chan
c11da5bf67 Make taint tracking tests use InlineFlowTest 2023-08-10 15:49:50 +01:00
Owen Mansel-Chan
663fb2cc06 Make taint tracking tests use config from InlineFlowTest 2023-08-10 15:49:48 +01:00
Owen Mansel-Chan
8db3e4a9b4 Make IncorrectIntegerConversion use new API 2023-08-10 15:49:47 +01:00
Owen Mansel-Chan
6c0c8d6963 Make BadRedirectCheck use new API 2023-08-10 15:49:45 +01:00
Owen Mansel-Chan
442dfc1833 Make InsecureTLS use new API 2023-08-10 15:49:44 +01:00
Owen Mansel-Chan
b00e44725c Make CorsMisconfiguration use new API 2023-08-10 15:49:43 +01:00
Owen Mansel-Chan
9b19cde8ab Make SensitiveConditionBypass use new API 2023-08-10 15:49:42 +01:00
Owen Mansel-Chan
2d3d21d074 Make StackTraceExposure use new API 2023-08-10 15:49:40 +01:00
Owen Mansel-Chan
d9844bd4d6 Make WrongUsageOfUnsafe use new API 2023-08-10 15:49:39 +01:00
Owen Mansel-Chan
00ea023fdb Make ConditionalBypass use new API 2023-08-10 15:49:37 +01:00
Owen Mansel-Chan
1b4fef9c21 Make HTMLTemplateEscapingPassthrough use new API
Removed edges and nodes are mostly duplicates. They were only there
originally due to multiple configurations being in scope.
`DataFlow::PathNode` has union semantics for configurations. Nodes are
only generated if they are reachable from a source, but this includes
sources from other configurations.

No alerts are lost.
2023-08-10 15:49:36 +01:00
Owen Mansel-Chan
ea1f39683d Make DivideByZero use new API
The extra nodes in .expected files are due to the changes from
https://github.com/github/codeql/pull/13717, which are not applied to
configuration classes extending DataFlow::Configuration or
TaintTracking::Configuration.
2023-08-10 15:49:35 +01:00
Owen Mansel-Chan
045936b1fd Make PamAuthBypass use new API 2023-08-10 15:49:33 +01:00
Owen Mansel-Chan
cfc4a6a6b7 Make Timing use new API 2023-08-10 15:49:32 +01:00
Owen Mansel-Chan
39762da5e0 Make DsnInjection use new API 2023-08-10 15:49:31 +01:00
Owen Mansel-Chan
a53da376d1 Make LDAPInjection use new API 2023-08-10 15:49:29 +01:00
Owen Mansel-Chan
f60ca76eb2 Make EmailInjection use new API 2023-08-10 15:49:28 +01:00
Owen Mansel-Chan
1962aa3de4 Make SSRF use new API 2023-08-10 15:49:27 +01:00
Owen Mansel-Chan
71735c86c2 Make WeakCryptoAlgorithm use new API 2023-08-10 15:49:25 +01:00
Owen Mansel-Chan
46185e3a02 Make HardcodedKeys use new API 2023-08-10 15:49:24 +01:00
Owen Mansel-Chan
b5ac0c94c6 Make ZipSlip use new API 2023-08-10 15:49:23 +01:00
Owen Mansel-Chan
7341b6156d Make XPathInjection use new API 2023-08-10 15:49:21 +01:00
Owen Mansel-Chan
a6177b3c92 Make UnsafeUnzipSymlink use new API 2023-08-10 15:49:20 +01:00
Owen Mansel-Chan
7db1daba6e Make TaintedPath use new API 2023-08-10 15:49:19 +01:00
Owen Mansel-Chan
6c91f77776 Make StringBreak use new API 2023-08-10 15:49:17 +01:00
Owen Mansel-Chan
30ae34352b Make StoredXss use new API 2023-08-10 15:49:16 +01:00
Owen Mansel-Chan
4334a51cf3 Make StoredCommand use new API 2023-08-10 15:49:15 +01:00
Owen Mansel-Chan
ac1670c0af Make SqlInjection use new API
The extra nodes in .expected files are due to the changes from
https://github.com/github/codeql/pull/13717, which are not applied to
configuration classes extending DataFlow::Configuration or
TaintTracking::Configuration.
2023-08-10 15:49:13 +01:00
Owen Mansel-Chan
646e158813 Make tests use config from InlineFlowTest
For InterProceduralDataFlow, it's hard to get it to use InlineFlowTest
because you need to show both the source and the sink, and there are
problems with quoting when the source is already surrounded by quotes.
2023-08-10 15:49:12 +01:00
Owen Mansel-Chan
81854279bd Make tests use InlineFlowTest 2023-08-10 15:49:11 +01:00
Owen Mansel-Chan
d385113e11 Make InsufficientKeySize use new API 2023-08-10 15:49:09 +01:00
Owen Mansel-Chan
16ef11a3c3 Make ConstantOauth2State use new API
Removed edges were only there originally due to multiple configurations
being in scope. `DataFlow::PathNode` has union semantics for
configurations. Nodes are only generated if they are reachable from a
source, but this includes sources from other configurations.

No alerts are lost.
2023-08-10 15:49:08 +01:00
Owen Mansel-Chan
fbd0c4edd0 Make HostKeyCallbackAssignment use new API 2023-08-10 15:49:07 +01:00
Owen Mansel-Chan
a1a31bfd62 Make SuspiciousCharacterInRegexp use new API 2023-08-10 15:49:05 +01:00
Owen Mansel-Chan
8f644af769 Make MissingRegexpAnchor use new API 2023-08-10 15:49:04 +01:00
Owen Mansel-Chan
442f6875f5 Make IncompleteHostNameRegexp use new API 2023-08-10 15:49:03 +01:00
Owen Mansel-Chan
0e1383ddd7 Make UnhandledFileCloseWritableHandle use new API 2023-08-10 15:49:01 +01:00
Owen Mansel-Chan
00cc78dfe6 Make CookieWithoutHttpOnly use new API
The extra nodes in .expected files are due to the changes from
https://github.com/github/codeql/pull/13717, which are not applied to
configuration classes extending DataFlow::Configuration or
TaintTracking::Configuration.
2023-08-10 15:49:00 +01:00
Owen Mansel-Chan
a7382e06c2 Make ClearTextLogging use new API
The extra nodes in .expected files are due to the changes from
https://github.com/github/codeql/pull/13717, which are not applied to
configuration classes extending DataFlow::Configuration or
TaintTracking::Configuration.
2023-08-10 15:48:59 +01:00
Owen Mansel-Chan
653563fcbc Make StringsNewReplacer use new API
We don't have to keep a deprecated copy as this is private. This allows
us to delete a copy of the DataFlow library!
2023-08-10 15:48:57 +01:00
Owen Mansel-Chan
1f6cdc7eda Make OpenURLRedirect use new API
The extra nodes in .expected files are due to the changes from
https://github.com/github/codeql/pull/13717, which are not applied to
configuration classes extending DataFlow::Configuration or
TaintTracking::Configuration.

Removed nodes and edges were only there originally due to multiple
configurations being in scope. `DataFlow::PathNode` has union semantics
for configurations. Nodes are only generated if they are reachable from
a source, but this includes sources from other configurations.
2023-08-10 15:48:55 +01:00
Owen Mansel-Chan
d2a5d19439 Make SafeUrlFlow use new API 2023-08-10 15:48:54 +01:00
Owen Mansel-Chan
97c32970a0 Make RequestForgery use new API
The extra nodes in .expected files are due to the changes from
https://github.com/github/codeql/pull/13717, which are not applied to
configuration classes extending DataFlow::Configuration or
TaintTracking::Configuration.
2023-08-10 15:48:53 +01:00
Owen Mansel-Chan
1c2536321c Make ReflectedXss use new API 2023-08-10 15:48:51 +01:00
Owen Mansel-Chan
3d9f8d50bc Make InsecureRandomness use new API 2023-08-10 15:48:50 +01:00
Michael B. Gale
87c089e0a8 Make CommandInjection.qll use new API
The new `edges` and `nodes` sections in the .expected files are because
the PathGraph module was not imported in the tests before, and thus
these query predicates were not in scope.
2023-08-10 15:48:48 +01:00
Michael B. Gale
957757c271 Make UntrustedDataToUnknownExternalAPI use new API 2023-08-10 15:48:47 +01:00
Michael B. Gale
d6919dd57b Make UntrustedDataToExternalAPI use new API 2023-08-10 15:48:46 +01:00
Michael B. Gale
82a1b15d11 Make AllocationSizeOverflow use new API
The extra nodes in .expected files are due to the changes from
https://github.com/github/codeql/pull/13717, which are not applied to
configuration classes extending DataFlow::Configuration or
TaintTracking::Configuration.
2023-08-10 15:48:44 +01:00
Tom Hvitved
5a6ce293cc Merge pull request #13942 from hvitved/dataflow/variable-capture-consistency-fix 2023-08-10 16:20:28 +02:00
Tom Hvitved
9b38028e25 Data flow: Fix localWriteStep consistency query 2023-08-10 15:31:04 +02:00
Mathias Vorreiter Pedersen
9aae174942 C++: Move conjunct below comment. 2023-08-10 13:58:07 +01:00
Michael Nebel
f6aca58dbb Merge pull request #13885 from michaelnebel/csharp/linqforeach
C#: LINQ recommendation queries.
2023-08-10 14:55:11 +02:00
Rasmus Lerchedahl Petersen
eac44e89d9 Python: test nice locations
there are errors both on lines 2 and 3 due to
locations being computed wrongly.
2023-08-10 14:21:16 +02:00
Mathias Vorreiter Pedersen
6d949cbd39 C++: Rename 'getAFlowStateForNode' to 'getASizeAddend'. 2023-08-10 13:19:28 +01:00
Mathias Vorreiter Pedersen
a2b8eb924e C++: Remove the '+ 1' in 'getAFlowStateForNode'. 2023-08-10 13:17:47 +01:00
Mathias Vorreiter Pedersen
f9fc79b16f Merge pull request #13930 from geoffw0/uitextinput
Swift: Flow sources for UITextInput
2023-08-10 13:05:47 +01:00
Tom Hvitved
f19232f800 Ruby: Fix another bug in isCapturedAccess 2023-08-10 14:02:58 +02:00
erik-krogh
5ffce86768 change the defaults in the qhelp for missing-rate-limit to something more reasonable 2023-08-10 13:40:17 +02:00
Harry Maclean
b365ff095a Ruby: Fix SynthSplatParameterElementNode
Make this class into a proper subclass of `ParameterNodeImpl`, to
prevent some consistency test failures.
2023-08-10 12:35:12 +01:00
Tom Hvitved
77fca277fe Ruby: Improve desugaring of for loops 2023-08-10 13:22:01 +02:00
Ian Lynagh
f377d25c23 Merge pull request #13919 from igfoo/igfoo/useFunction
Kotlin: useFunction might return null
2023-08-10 12:17:20 +01:00
Tom Hvitved
4e954c29a2 Merge pull request #13936 from hvitved/ruby/captured-access-fix
Ruby: Fix bug in `isCapturedAccess`
2023-08-10 13:15:48 +02:00
Tom Hvitved
b99b6b85ba Merge pull request #13927 from hvitved/csharp/fix-bad-join
C#: Fix bad join order
2023-08-10 13:04:16 +02:00
Harry Maclean
5fff9fa8da More precise flow into splat parameters
We now precisely track flow from positional arguments to splat
parameters, provided that splat arguments are not used and there are no
positional parameters after the splat parameter. For example, in this
case:

    def f(x, y, *z); end

    f(a, b, c, d)

we get flow from `c` to `z[0]` and `d` to `z[1]`.

We get false flow if there are positional parameters after the splat
parameter. For example in this case:

    def g(x, y, *z, w); end

    g(a, b, c, d)

we get flow from `d` to `z[0]` instead of `w`.

We also track flow in this case

    def f(a, *b)
      sink b[0]
    end

    f(1, *[taint, 2])
2023-08-10 12:02:47 +01:00
Harry Maclean
a58aa17c7a Merge pull request #13878 from hmac/splat-flow
Ruby: Track flow from splat arguments to positional parameters
2023-08-10 12:01:38 +01:00
Mathias Vorreiter Pedersen
1455e8bd4c C++: Convert all '<'s to '<='s. 2023-08-10 11:55:57 +01:00
Mathias Vorreiter Pedersen
dcc1429ed8 C++: Get rid of '+ 1' in comments. 2023-08-10 11:38:40 +01:00
Mathias Vorreiter Pedersen
b750016bc1 C++: Fix more comments. 2023-08-10 11:31:30 +01:00
Rasmus Wriedt Larsen
46af77c1af Python: Include all assignments in data flow paths
Like Ruby did in https://github.com/github/codeql/pull/12566
2023-08-10 11:45:29 +02:00
Rasmus Wriedt Larsen
9bd5694c3f Python: Add tests of path-graph for dataflow/taint-tracking
Although this is actually using taint-tracking (so we can use the +=
statement), I would personally forget to check under the
dataflow/tainttracking folder to look for such a test, so I'm opting to
keep it under the dataflow/ folder.
2023-08-10 11:44:17 +02:00
Jeroen Ketema
2e338cc7b4 Merge pull request #13929 from jketema/buffer
C++: Only consider the maximum buffer size for badly bounded write
2023-08-10 10:40:37 +02:00
Tom Hvitved
e40f0a7350 Ruby: Fix bug in isCapturedAccess 2023-08-10 09:37:04 +02:00
Rasmus Lerchedahl Petersen
dbc60140e0 Python: move tests to data extensions
For these tests, we cannot use the same mechanism, as we want the
data extensions to be available for both tests.

Instead, we create a ql-pack for the test directory and point to
the data entensions from there. This makes the extensions
available for all tests in the directory.
2023-08-10 09:17:34 +02:00
Tom Hvitved
e7acf8c3a8 Ruby: Add test 2023-08-10 08:53:00 +02:00
Maiky
97f8d1fca9 add getValue() method 2023-08-10 00:39:35 +02:00
Maiky
e60fa6f1a7 Remove unnecesary } 2023-08-10 00:25:47 +02:00
Maiky
c5c2df4593 fix Singleton set literal 2023-08-10 00:13:02 +02:00
Rasmus Lerchedahl Petersen
168a1e01a4 Python: move test to data extensions
For this test, we can simply use the convention,
that a file called `[ql-file-stem].ext.yml` will be used
as data extensions exactly for the test represented by `ql-file`.
2023-08-09 21:22:17 +02:00
github-actions[bot]
432c21d4fb Post-release preparation for codeql-cli-2.14.2 2023-08-09 18:45:18 +00:00
Mathias Vorreiter Pedersen
ce9b018789 C++: Move bounds checkout out of 'operandGuardChecks' for clarity. 2023-08-09 18:37:17 +01:00
Geoffrey White
c20a17e7b7 Swift: Update the consistency test .expecteted as well. 2023-08-09 15:47:28 +01:00
Rasmus Wriedt Larsen
51a05286fa Merge pull request #13731 from pwntester/py/aiohttp_improvements
Python: Aiohttp improvements
2023-08-09 16:37:20 +02:00
Geoffrey White
23f0dd5542 Swift: Support MAD tuple content flow. 2023-08-09 15:08:11 +01:00
Harry Maclean
b03f6efa60 Ruby: Refactor 2023-08-09 15:01:40 +01:00
Harry Maclean
142393b599 Ruby: Handle unknown content in splat flow 2023-08-09 15:01:40 +01:00
Harry Maclean
4239268efd Ruby: Prevent some false flow into splat params
In cases where there are positional parameters after a splat parameter,
don't attempt to match the splat parameter to a splat argument. We need
more sophisticated modelling to handle these cases, which is future
work.
2023-08-09 15:01:40 +01:00
Harry Maclean
6f3e2cdde3 Ruby: Add change note 2023-08-09 15:01:40 +01:00
Harry Maclean
c0baa5116f Ruby: add test for example splat arg/param matches 2023-08-09 15:01:40 +01:00
Harry Maclean
72356d1515 Ruby: track flow from *args to positional params
This models flow in the following case:

    def foo(x, y)
      sink x # 1
      sink y # 2
    end

    args = [source 1, source 2]
    foo(*args)

We do this by introducing a SynthSplatParameterNode which accepts
content from the splat argument, if one is given at the callsite.
From this node we add read steps to each positional parameter.
2023-08-09 15:01:40 +01:00
Jeroen Ketema
e04d30a676 C++: Update expected test changes due to the line in test2.cpp having shifted 2023-08-09 15:50:07 +02:00
Jeroen Ketema
6100425274 C++: Add change note 2023-08-09 15:47:19 +02:00
Geoffrey White
b4b2338144 Swift: Test for MAD tuple content flow. 2023-08-09 14:41:32 +01:00
Mathias Vorreiter Pedersen
8a490775d8 Merge branch 'main' into fix-barriers-in-invalid-pointer-deref 2023-08-09 14:32:58 +01:00
Ian Lynagh
0eb6d1c76e Kotlin: useFunction might return null 2023-08-09 13:45:15 +01:00
Rasmus Lerchedahl Petersen
885e25ff2d Python: use file-name-convention of *.model.yml 2023-08-09 14:25:33 +02:00
erik-krogh
fe542565c3 fix performance 2023-08-09 13:48:07 +02:00
Michael B. Gale
01ff690d51 Merge pull request #13923 from github/mbg/go/bump-go-libraries 2023-08-09 11:36:35 +01:00
Mathias Vorreiter Pedersen
da66136ded Merge pull request #13911 from MathiasVP/fix-taint-for-frontend-upgrade
C++: Fix taint-flow in preparation for frontend upgrade
2023-08-09 11:30:07 +01:00
Jeroen Ketema
d0e7354a1b C++: Only consider the maximum buffer size for badly bounded write 2023-08-09 12:30:00 +02:00
Jeroen Ketema
9572b9d308 C++: Add test where buffer initialized with literal is reassigned an allocation 2023-08-09 12:26:10 +02:00
Rasmus Wriedt Larsen
c0dec21546 Merge pull request #13925 from RasmusWL/fixup-script
Misc: Fixup `accept-expected-changes-from-ci.py`
2023-08-09 11:45:34 +02:00
Tom Hvitved
7dac819730 C#: Fix bad join order
Before
```
Evaluated recursive predicate Stmt#3baf294a::TryStmt::getATriedElement#ff@8254eapb in 6096ms on iteration 4 (delta size: 592145).
Evaluated relational algebra for predicate Stmt#3baf294a::TryStmt::getATriedElement#ff@8254eapb on iteration 4 running pipeline standard with tuple counts:
          204507  ~0%    {2} r1 = SCAN Stmt#3baf294a::TryStmt::getATriedElement#ff#prev_delta OUTPUT In.1, In.0
          204507  ~0%    {3} r2 = JOIN r1 WITH _@callable#f_ControlFlowElement#9501aa28::ControlFlowElement::getEnclosingCallable#0#dispred#ff_10#j__#join_rhs ON FIRST 1 OUTPUT Rhs.1, Lhs.0, Lhs.1
        17844283  ~0%    {3} r3 = JOIN r2 WITH ControlFlowElement#9501aa28::ControlFlowElement::getEnclosingCallable#0#dispred#ff_10#join_rhs ON FIRST 1 OUTPUT Lhs.1, Rhs.1, Lhs.2
          592145  ~0%    {2} r4 = JOIN r3 WITH Element#baf0c59e::Element::getAChild#0#dispred#ff ON FIRST 2 OUTPUT Lhs.2, Lhs.1
          592145  ~0%    {2} r5 = r4 AND NOT Stmt#3baf294a::TryStmt::getATriedElement#ff#prev(Lhs.0, Lhs.1)
                         return r5
```

After
```
Evaluated recursive predicate Stmt#3baf294a::TryStmt::getATriedElement#ff@4adecd47 in 310ms on iteration 4 (delta size: 592145).
Evaluated relational algebra for predicate Stmt#3baf294a::TryStmt::getATriedElement#ff@4adecd47 on iteration 4 running pipeline standard with tuple counts:
        204507  ~0%    {2} r1 = SCAN Stmt#3baf294a::TryStmt::getATriedElement#ff#prev_delta OUTPUT In.1, In.0
        204507  ~0%    {2} r2 = r1 AND NOT _statements_10#join_rhs#antijoin_rhs#13(Lhs.0)
        592145  ~2%    {3} r3 = JOIN r2 WITH Element#baf0c59e::Element::getAChild#0#dispred#ff ON FIRST 1 OUTPUT Lhs.0, Lhs.1, Rhs.1
        592145  ~0%    {3} r4 = JOIN r3 WITH ControlFlowElement#9501aa28::ControlFlowElement::getEnclosingCallable#0#dispred#ff ON FIRST 1 OUTPUT Lhs.2, Rhs.1, Lhs.1
        592145  ~0%    {2} r5 = JOIN r4 WITH ControlFlowElement#9501aa28::ControlFlowElement::getEnclosingCallable#0#dispred#ff ON FIRST 2 OUTPUT Lhs.2, Lhs.0
        592145  ~0%    {2} r6 = r5 AND NOT Stmt#3baf294a::TryStmt::getATriedElement#ff#prev(Lhs.0, Lhs.1)
                       return r6
```
2023-08-09 11:28:06 +02:00
Rasmus Wriedt Larsen
69aa099ed1 Misc: Fixup accept-expected-changes-from-ci.py
I guess there has been a rename of the URL from `/jobs/` to `/job/`, since the script has been working previously.
2023-08-09 10:44:31 +02:00
Geoffrey White
e828d8dace Swift: Add UIKit to supported-frameworks.rst as well. 2023-08-09 09:25:43 +01:00
Geoffrey White
131b2b3e0c Swift: Change note. 2023-08-09 09:25:43 +01:00
Geoffrey White
09346c76e7 Swift: Add models. 2023-08-09 09:25:43 +01:00
Mathias Vorreiter Pedersen
499b6f35e5 C++: Also key SSA defs and uses by the base address. 2023-08-09 08:44:16 +01:00
Mathias Vorreiter Pedersen
e2feed78a0 C++: Generate SSA variables for all calls instead of just for calls to
allocators.
2023-08-09 08:44:10 +01:00
Stephan Brandauer
e927470961 Merge branch 'main' into kaeluka/java-automodel-variadic-args 2023-08-09 09:02:32 +02:00
Michael Nebel
560b876c01 Merge pull request #13891 from felickz/csharp-hardcoded-cred-identity-fp
cs/hardcoded-credentials - Removes false positive matches on benign Microsoft.AspNetCore.Identity properties
2023-08-09 08:32:36 +02:00
Chad Bentz
fa23a45f9d Merge branch 'main' into csharp-hardcoded-cred-identity-fp 2023-08-08 17:48:27 -04:00
Geoffrey White
cb6aed18f3 Swift: Add tests. 2023-08-08 22:29:53 +01:00
Michael B. Gale
9da749ad77 Bump Go extractor dependencies 2023-08-08 22:23:47 +01:00
erik-krogh
0bce42410a support arbitrary codepoints in NfaUtils.qll 2023-08-08 22:14:51 +02:00
erik-krogh
859e1bfabc add constraint that i should be between 0 and 65535 2023-08-08 21:11:59 +02:00
Mathias Vorreiter Pedersen
389294bded Merge pull request #13920 from MathiasVP/fix-out-nodes
C++: Remove unnecessary predicates
2023-08-08 20:11:36 +01:00
erik-krogh
0391e063ca move to4digitHex to Numbers.qll 2023-08-08 21:10:58 +02:00
Geoffrey White
a1234d4235 Merge pull request #13905 from geoffw0/forceunwrap
Swift: Flow through ForceValueExpr on LHS of assignment
2023-08-08 18:36:50 +01:00
Mathias Vorreiter Pedersen
2a1d5b7481 Merge branch 'main' into fix-out-nodes 2023-08-08 16:32:03 +01:00
Geoffrey White
2b0fcab182 Swift: Update test annotations following merge. 2023-08-08 16:06:52 +01:00
Geoffrey White
e9f0b535ea Merge branch 'main' into forceunwrap 2023-08-08 16:03:31 +01:00
Anders Schack-Mulligen
0ca3f3308b Merge pull request #13478 from aschackmull/java/varcapture
Java: Add proper support for variable capture flow.
2023-08-08 16:22:56 +02:00
Anders Starcke Henriksen
3918e57ffe Take filter pack into account. 2023-08-08 15:10:12 +02:00
Anders Starcke Henriksen
8d34ab6d18 Merge branch 'main' into starcke/automodel-pack 2023-08-08 15:02:33 +02:00
Anders Starcke Henriksen
7da6da1c93 Merge pull request #13852 from github/starcke/automodel-package-filter
Add option to filter automodel queries
2023-08-08 14:59:00 +02:00
Alex Denisov
cebaca328e Swift: 'ParsedSequence' lacks proper types and yields 'Unresolved' AST nodes 2023-08-08 14:41:15 +02:00
Anders Schack-Mulligen
1cd32722be Java: More review fixes. 2023-08-08 14:32:48 +02:00
Mathias Vorreiter Pedersen
f4f5d43bcb C++: indirectReturnOutNodeOperand0 and indirectReturnOutNodeInstruction0
were broken and for some reason only handled the case where calls mapped
to raw indirect nodes :wat:. It turns out these predicates weren't
actually needed anyway.
2023-08-08 13:23:10 +01:00
Alexandre Boulgakov
28863f39b0 Merge pull request #13917 from github/revert-13869-sashabu/swift-logging-compiler
Revert "Swift: Route compiler diagnostics through our log."
2023-08-08 12:45:58 +01:00
Anders Schack-Mulligen
9d59f50340 Java: Review fixes. 2023-08-08 13:37:40 +02:00
Rasmus Lerchedahl Petersen
e47e77c438 Python: add change note 2023-08-08 12:17:23 +02:00
Rasmus Lerchedahl Petersen
f33aff42ad Python: missing result was fixed 2023-08-08 12:14:57 +02:00
Geoffrey White
c95432457d Swift: Correct a test case (but preserve the original as well since it's interesting). 2023-08-08 10:41:21 +01:00
Geoffrey White
6ccf47ece9 Swift: Accept test changes resulting from merge. 2023-08-08 10:28:29 +01:00
AlexDenisov
75dad4764f Revert "Swift: Route compiler diagnostics through our log." 2023-08-08 11:25:13 +02:00
Rasmus Lerchedahl Petersen
f865fa3050 Python: simplify using getSubscript 2023-08-08 11:16:35 +02:00
Michael Nebel
0ed724eb13 Java: Make a flow summary for Set.clear using WithoutElement and introduce appropriate tests. 2023-08-08 11:10:08 +02:00
Rasmus Wriedt Larsen
4f47461f60 Python: Add requested test 2023-08-08 10:44:48 +02:00
Geoffrey White
063ab1c13f Merge branch 'main' into closuremodels 2023-08-08 09:40:27 +01:00
Michael Nebel
f67d5e1dc6 C#: Add tests for the LINQ missed-where and missed-cast queries. 2023-08-08 10:32:16 +02:00
Michael Nebel
1a511c2d52 C#: Update the queries that provide LINQ recommendation. 2023-08-08 10:31:33 +02:00
Anders Schack-Mulligen
ab334f6c1b Java: Always apply heuristic query regardless of existing models. 2023-08-08 10:01:43 +02:00
Anders Schack-Mulligen
cd22bb3505 Java: Add another test case. 2023-08-08 10:00:55 +02:00
erik-krogh
03fbd387df way better hex conversion 2023-08-08 09:08:39 +02:00
erik-krogh
45c39e6072 limit field flow when tracking regex strings in Java 2023-08-08 09:01:23 +02:00
erik-krogh
92db7b047c escape unicode chars in the output for the ReDoS queries 2023-08-08 00:15:54 +02:00
Chad Bentz
d4b5a4d4f4 Merge branch 'main' into csharp-hardcoded-cred-identity-fp 2023-08-07 15:09:01 -04:00
Chad Bentz
7b33574b85 pull dependencies from Microsoft.AspNetCore.App 2023-08-07 18:45:16 +00:00
Geoffrey White
022a06659c Merge pull request #13838 from rdmarsh2/rdmarsh2/swift/set-content
Swift: add SetContent for data flow
2023-08-07 19:15:30 +01:00
Ian Lynagh
3e86c4c39e Kotlin: Allow extractNewExpr to return null 2023-08-07 18:59:51 +01:00
Robert Marsh
65fbcc570c Swift: CFG test for for-try-await 2023-08-07 17:44:57 +00:00
Robert Marsh
eeaa361b12 Merge pull request #13907 from MathiasVP/cleanup-ssa-internals
C++: Small cleanup of `SsaInternals`
2023-08-07 13:16:59 -04:00
Robert Marsh
07650af357 Swift: accept test for CollectionContent rename 2023-08-07 15:04:21 +00:00
Mathias Vorreiter Pedersen
60f2e8a676 C++: Fix QLDoc. 2023-08-07 15:55:43 +01:00
Robert Marsh
146c50049c Finish CollectionContent rename
Co-authored-by: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
2023-08-07 10:26:40 -04:00
Mathias Vorreiter Pedersen
f2f4e1f882 C++: Add more QLDoc. 2023-08-07 15:22:46 +01:00
Mathias Vorreiter Pedersen
291f1a189d C++: Unify the two branches. 2023-08-07 14:23:35 +01:00
Jeroen Ketema
8b6a7985db Refactor the traint-tracking library to follow the dataflow library refactoring 2023-08-07 15:23:15 +02:00
Jeroen Ketema
5d2984b7a5 Merge branch 'main' into shared-taint-tracking 2023-08-07 15:22:29 +02:00
Rasmus Lerchedahl Petersen
957c0d6387 Python: move change note 2023-08-07 14:28:53 +02:00
Mathias Vorreiter Pedersen
6e6e118d4b C++: Make the branches more identical. 2023-08-07 13:22:46 +01:00
Geoffrey White
dc98dec5b6 Swift: Change note. 2023-08-07 13:16:00 +01:00
Stephan Brandauer
3433437034 Java: automodel application mode: only extract the first argument corresponding to a varargs array 2023-08-07 14:15:17 +02:00
Geoffrey White
ab3f3d03c5 Swift: Model taint into optionals via ForceValueExpr. 2023-08-07 13:11:29 +01:00
Stephan Brandauer
e1a5eba61b Java: automodel application mode: refactor varargs endpoint class to rely on normal argument node for nicer extracted examples 2023-08-07 12:18:52 +02:00
Stephan Brandauer
650ff8db87 Java: automodel comments 2023-08-07 12:18:51 +02:00
Stephan Brandauer
0781cb78e8 Java: automodel application mode: add isVarargsArray metadata value 2023-08-07 12:18:51 +02:00
Stephan Brandauer
5abf7769a7 Java: automodel application mode: use endpoint class like in framework mode 2023-08-07 12:18:51 +02:00
Tony Torralba
fb0102b763 Java: New models for JAX-RS 2023-08-07 11:52:23 +02:00
Rasmus Lerchedahl Petersen
2f9172046b Python: change-note 2023-08-07 11:50:13 +02:00
Rasmus Lerchedahl Petersen
ef1a5cb0fa shared: change-note 2023-08-07 11:50:03 +02:00
Rasmus Lerchedahl Petersen
4dbaed9ec2 Python: add qldoc 2023-08-07 11:31:22 +02:00
Rasmus Lerchedahl Petersen
b8717b3046 Python: remove incorrect use of "stem" 2023-08-07 11:25:31 +02:00
Anders Starcke Henriksen
0d78eeb871 Address comments. 2023-08-07 10:47:59 +02:00
Tony Torralba
43b9199734 Java: Improved JaxWsEndpoint::getARemoteMethod 2023-08-07 10:21:58 +02:00
Mathias Vorreiter Pedersen
33e991b037 C++: Fix QLDoc. 2023-08-06 20:50:19 +01:00
Mathias Vorreiter Pedersen
af07efe14f C++: Accept test changes. 2023-08-05 21:59:08 +02:00
Mathias Vorreiter Pedersen
f0a1742ad6 C++: Fix barriers in 'AllocationToInvalidPointer.qll'. 2023-08-05 21:58:24 +02:00
Mathias Vorreiter Pedersen
7c9d41d3b9 C++: Make 'SizeBarrier' private as promised. 2023-08-05 21:57:57 +02:00
Mathias Vorreiter Pedersen
835b5e349b C++: Accept test changes. 2023-08-05 21:56:51 +02:00
Mathias Vorreiter Pedersen
0f285ccce0 C++: Fix QLDoc. 2023-08-05 21:55:00 +02:00
Mathias Vorreiter Pedersen
c0828a488f C++: Fix barriers in 'InvalidPointerToDereference.qll'. 2023-08-05 21:55:00 +02:00
Chad Bentz
e2e9c810bf Add lib change-notes 2023-08-04 22:11:36 +00:00
Chad Bentz
5a106fd5d6 Removes false positive creds from NetCore Identity 2023-08-04 21:46:35 +00:00
Jeroen Ketema
c4a65e58bb Add change note 2023-08-04 22:53:33 +02:00
Jeroen Ketema
747cd1745a Update all languages to use the shared taint-tracking library 2023-08-04 22:53:25 +02:00
Jeroen Ketema
20b792545d Add missing QLDoc 2023-08-04 22:52:05 +02:00
Jeroen Ketema
7ba2f7a22a Address review comments 2023-08-04 22:52:05 +02:00
Jeroen Ketema
bdd64ce86d Introduce shared taint tracking library 2023-08-04 22:51:55 +02:00
Robert Marsh
3ebbb80a9e Swift: Change note for CollectionContent 2023-08-04 20:19:35 +00:00
Robert Marsh
10bbf441dc Swift: QLDoc for Set.qll 2023-08-04 20:17:56 +00:00
Robert Marsh
ccc3094267 Swift: autoformat 2023-08-04 20:17:08 +00:00
Geoffrey White
c7fb8de5f9 Swift: Test ForceValueExpr content reads. 2023-08-04 21:15:15 +01:00
Robert Marsh
6f38769a9b Swift: rename SetContent to CollectionContent 2023-08-04 18:46:43 +00:00
Robert Marsh
024c5cfe2f Swift: add MaD print support for EnumElement 2023-08-04 18:44:42 +00:00
Robert Marsh
0142309cab Swift: add summary read steps in dataflow 2023-08-04 18:44:42 +00:00
Robert Marsh
b301092e34 Swift: model updates for Set 2023-08-04 18:44:42 +00:00
Robert Marsh
de0ec3e3f7 Swift: WIP SetContent for dataflow 2023-08-04 18:44:42 +00:00
Michael Nebel
d3eb9c1325 Java: Add release note and address review comments. 2023-08-04 13:36:43 +02:00
Geoffrey White
af8d4e5ab2 Swift: Change note. 2023-08-04 09:42:53 +01:00
Anders Starcke Henriksen
3ef82c1091 Address comments. 2023-08-04 10:22:17 +02:00
Geoffrey White
d24db3fcd3 Swift: Use .ArrayElement in the models, where appropriate. 2023-08-04 09:18:37 +01:00
Geoffrey White
b41d47b910 Swift: Array.withUnsafeBytes doesn't reliably match ContiguousBytes, so define models there as well. 2023-08-04 09:18:36 +01:00
Geoffrey White
c48d47484a Swift: Fix mistake in the string taint test. 2023-08-04 09:18:36 +01:00
Geoffrey White
664dc01c48 Swift: Add closure function models. 2023-08-04 09:18:36 +01:00
Geoffrey White
49d1556c29 Swift: Model update(repeating:), to support the tests. 2023-08-04 09:18:36 +01:00
Geoffrey White
315cb32f6c Swift: Remove special case from UnsafeJsEval query. 2023-08-04 09:18:35 +01:00
Geoffrey White
feadd7127b Swift: Add tests with some different container types. 2023-08-04 09:18:35 +01:00
Geoffrey White
63c71f0b77 Swift: Add tests of with* closure methods. 2023-08-04 09:18:34 +01:00
Maiky
0cd1c1e2e5 Make private
Co-authored-by: Alex Ford <alexrford@users.noreply.github.com>
2023-08-03 17:08:50 +02:00
Maiky
0dec4876f1 Replace cast to DataFlow::CallNode
Co-authored-by: Alex Ford <alexrford@users.noreply.github.com>
2023-08-03 17:08:35 +02:00
Maiky
6f1b406b3a typo
Co-authored-by: Alex Ford <alexrford@users.noreply.github.com>
2023-08-03 17:08:10 +02:00
Maiky
0237f37842 typo
Co-authored-by: Alex Ford <alexrford@users.noreply.github.com>
2023-08-03 17:07:58 +02:00
Maiky
c54561e775 Merge branch 'main' into maikypedia/ldap-improper-auth 2023-08-03 16:49:30 +02:00
Maiky
fd649c1702 Fix getHost() (ldap.host = ip is not covered) 2023-08-03 16:37:48 +02:00
Maiky
f7a662814d simplify usesSsl() 2023-08-03 16:20:20 +02:00
Maiky
2d87489dfa change useSsl() to usesSsl() 2023-08-03 16:18:44 +02:00
Anders Starcke Henriksen
e7ca2330cb Update workspace. 2023-08-03 15:55:42 +02:00
Geoffrey White
deb97a6ccc Swift: Improve regex performance with possessive matching (i.e. don't backtrack). 2023-08-03 13:57:49 +01:00
Tom Hvitved
b69188fee9 C#: Adopt shared CFG construction library from shared controlflow pack 2023-08-03 14:12:24 +02:00
Anders Starcke Henriksen
e2abd3ff13 Create separate automodel pack. 2023-08-03 13:55:15 +02:00
Anders Schack-Mulligen
0ae81eace3 Java: update fixed test 2023-08-03 10:07:00 +02:00
Anders Schack-Mulligen
72171972c3 Apply suggestions from code review
Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
2023-08-03 10:04:06 +02:00
Anders Schack-Mulligen
84316c41a3 Java: Add more qldoc. 2023-08-03 10:04:06 +02:00
Anders Schack-Mulligen
90052a3ca2 Java: Add proper types for capture nodes. 2023-08-03 10:04:06 +02:00
Anders Schack-Mulligen
e2a0849a0e Java: Add more qldoc. 2023-08-03 10:04:06 +02:00
Anders Schack-Mulligen
37455ec29e Java: Replace ratpack test fix with general heuristic summary. 2023-08-03 10:04:06 +02:00
Anders Schack-Mulligen
c5990311ca Java: Redesign and reimplement variable capture flow. 2023-08-03 10:04:06 +02:00
Anders Schack-Mulligen
70bef64e2a Java: Fix ratpack flow. 2023-08-03 10:04:05 +02:00
Anders Schack-Mulligen
f4a05c183b Shared: Add some qldoc. 2023-08-03 10:04:05 +02:00
Anders Schack-Mulligen
15daa51ee5 Shared: Address review comments and QL4QL alerts. 2023-08-03 10:04:05 +02:00
Anders Schack-Mulligen
a23e77ca58 Java: Disregard heap parameter in any-argument and any-parameter specs. 2023-08-03 10:04:05 +02:00
Anders Schack-Mulligen
9a4de208ef Java: Fix qltests. 2023-08-03 10:04:05 +02:00
Anders Schack-Mulligen
d1a616a70a Java: Add proper support for variable capture flow. 2023-08-03 10:04:02 +02:00
Anders Starcke Henriksen
131ae1aae9 Fix name in predicate. 2023-08-03 09:53:40 +02:00
Anders Starcke Henriksen
1c425a5602 Change from package to endpoint. 2023-08-03 09:50:23 +02:00
Anders Starcke Henriksen
9b8d7df370 Add option to filter automodel queries by package. 2023-08-03 09:50:23 +02:00
Kevin Stubbings
8960453662 Add sanitizer to remove http.Error sink 2023-08-02 16:56:14 -07:00
Geoffrey White
5f7e5b946d Swift: Codegen. 2023-08-01 16:38:27 +01:00
Geoffrey White
e30ac42e3e Merge branch 'main' into typegetname 2023-08-01 16:36:31 +01:00
Geoffrey White
c8f5ada594 Swift: Fix errors in queries. 2023-08-01 15:50:15 +01:00
Geoffrey White
116006d280 Swift: Fix for type names containing '...'. 2023-08-01 13:57:46 +01:00
Geoffrey White
40219aad88 Swift: More robust Type.getName(). 2023-08-01 13:24:10 +01:00
Geoffrey White
655f238017 Swift: Accept test changes. 2023-08-01 13:14:14 +01:00
Michael Nebel
ffd1456d67 Java: Update MaD external documentation related to With and Without Element. 2023-08-01 12:03:44 +02:00
Michael Nebel
a8ccc8d980 Java: Update MaD internal documentation. 2023-08-01 12:03:44 +02:00
Michael Nebel
fc66b6ef9c Java: Update test comments to reflect the MaD syntax. 2023-08-01 12:03:44 +02:00
Michael Nebel
99ac98bffc Java: Re-factor a model to use WithElement (this model is already tested in collections/B.java). 2023-08-01 12:03:44 +02:00
Michael Nebel
e97a4a1aea Java: Update telemetry test expected output. 2023-08-01 12:03:44 +02:00
Michael Nebel
0604a85bb1 Java: Add WithoutElement model for List.clear and add appropriate test. 2023-08-01 12:03:44 +02:00
Michael Nebel
21ec83a197 Java: Add MaD support for With[out]Element. 2023-08-01 12:03:44 +02:00
Geoffrey White
b500d8baa1 Swift: QLDoc TupleType. 2023-08-01 11:01:05 +01:00
Tony Torralba
2cbb7ed296 Java: Add XXE sinks for MDHT 2023-07-31 11:13:17 +02:00
Geoffrey White
20b0969a97 Swift: Restore original Type.toString() behaviour. 2023-07-31 09:51:55 +01:00
Geoffrey White
beacade499 Swift: Autoformat. 2023-07-27 22:48:23 +01:00
Geoffrey White
15244e0ee1 Swift: Expand NominalType.getFullName to Type.getFullName (so it is a suitble substitute for the old Type.getName behaviour). 2023-07-27 22:41:46 +01:00
Geoffrey White
e2740fef73 Swift: Add explanatory comment. 2023-07-27 22:12:49 +01:00
Geoffrey White
2ba983bf4a Swift: Change note. 2023-07-27 22:04:07 +01:00
Geoffrey White
57a55eda75 Swift: QL solution (arguably clearer, seems more performant). 2023-07-27 20:51:49 +01:00
Geoffrey White
82057513c5 Swift: Implement Type.getName() as different from Type.getFullName() (regex solution). 2023-07-27 20:50:21 +01:00
Geoffrey White
aa6d7c088b Swift: Add some more diverse test cases. 2023-07-27 19:35:13 +01:00
Geoffrey White
9588e68115 Swift: Add detail and spacing to the NoominalType tests. 2023-07-27 19:17:51 +01:00
amammad
bee8e6ff0d remove unused saniter 2023-07-27 01:41:31 +10:00
amammad
591d81b5f9 remove saniter which was responsible for a defensive technique 2023-07-26 02:39:10 +10:00
yoff
2067d393e1 Update shared/yaml/codeql/serverless/ServerLess.qll
Co-authored-by: Alex Ford <alexrford@users.noreply.github.com>
2023-07-25 17:27:45 +02:00
Rasmus Lerchedahl Petersen
b2688bba7d Python: Relax module resolution
Do not require modules to reside in a package
2023-07-25 17:24:04 +02:00
jorgectf
8f8c064632 Modify test 2023-07-24 17:50:22 +02:00
amammad
1e1d42fa35 fix a mistake :( 2023-07-25 00:11:23 +10:00
amammad
7aff0079f5 better safe Flask example 2023-07-25 00:08:51 +10:00
Rasmus Lerchedahl Petersen
21937e6a27 python: address review comments
- rename `normalise` to `normalizePath`
- factor out `lookupValueOrEmpty`
2023-07-24 16:04:01 +02:00
yoff
c0407ae0be Apply suggestions from code review
Co-authored-by: Alex Ford <alexrford@users.noreply.github.com>
2023-07-24 15:51:27 +02:00
amammad
0e8f83460c a little bit change on flask example 2023-07-24 21:41:54 +10:00
amammad
bbba906ff1 a little bit change on flask example 2023-07-24 21:41:44 +10:00
amammad
6f8ec118df fix qlhelp and qldoc bugs 2023-07-24 17:15:43 +10:00
amammad
c704158150 remove sources which are contained from environment variables, fix some bugs thanks to @yoff 2023-07-24 17:06:27 +10:00
jorgectf
3ac94c33b2 Add change note 2023-07-20 15:47:18 +02:00
jorgectf
55648ac4de Add shlex.quote as sanitizer 2023-07-20 15:34:54 +02:00
Geoffrey White
a0b784e7b1 Python: QLDoc. 2023-07-20 11:56:13 +01:00
Geoffrey White
aaf9907a27 Python: Change note. 2023-07-20 11:23:15 +01:00
Geoffrey White
bb16731b86 Python: Fix for multiple parse mode flags. 2023-07-20 11:16:14 +01:00
Geoffrey White
dbde99df91 Python: Add test cases. 2023-07-20 11:06:00 +01:00
Geoffrey White
cb6276e5e2 Python: Test layout. 2023-07-19 18:44:15 +01:00
Rasmus Wriedt Larsen
13fa08a90a Python: Move source modeling to shared file 2023-07-14 14:47:50 +02:00
Rasmus Wriedt Larsen
aa8ed91993 Python: Accept .expected changes
but it's kinda bad, since it has paths to stdlib in there :(
2023-07-14 14:47:27 +02:00
Rasmus Wriedt Larsen
9e0f985e23 Python: Fix qlref 2023-07-14 14:33:17 +02:00
Rasmus Wriedt Larsen
8279cf7c9c Merge branch 'main' into amammad-python-WebAppsConstatntSecretKeys 2023-07-14 14:32:43 +02:00
Rasmus Wriedt Larsen
0db535bdd7 Python: Minor naming update 2023-07-14 12:54:54 +02:00
Rasmus Wriedt Larsen
991d5cc54b Python: Fix test of HttpResponse.getBody() 2023-07-13 13:57:08 +02:00
Rasmus Wriedt Larsen
64a7206f3e Python: Improve aiohttp FileResponse/StreamResponse modeling
However, notice that the concepts tests use the HttpResponse location
for the `responseBody` tag, which seems a little odd in this situation,
where they are actually separate. Will fix in next commit.
2023-07-13 13:57:08 +02:00
Rasmus Wriedt Larsen
15269c9166 Python: Add StreamResponse test 2023-07-13 13:57:08 +02:00
Rasmus Wriedt Larsen
0f9ab8f53e Python: Fixup tests
But notice that keyword argument is not handled yet
2023-07-13 13:57:08 +02:00
Alvaro Muñoz
362e8f7dd2 remove unrelated file 2023-07-13 13:29:06 +02:00
Alvaro Muñoz
ee1ba71e5d add tests 2023-07-13 13:07:12 +02:00
Alvaro Muñoz
10cd649ba7 address code review feedback 2023-07-13 12:24:19 +02:00
Alvaro Muñoz
69efddbaef Apply suggestions from code review
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
2023-07-13 12:23:00 +02:00
Alvaro Muñoz
7a717555aa fix qldocs 2023-07-12 17:27:17 +02:00
Alvaro Muñoz
733e625080 fix change note 2023-07-12 17:26:12 +02:00
Alvaro Muñoz
f2cc2af276 aiohttp improvements 2023-07-12 17:19:56 +02:00
yoff
76455d628e Update python/ql/lib/semmle/python/frameworks/ServerLess.qll
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
2023-07-12 16:50:13 +02:00
Rasmus Lerchedahl Petersen
02c41f3dcf JavaScript: Use shared library for serverless 2023-07-12 16:46:34 +02:00
Rasmus Lerchedahl Petersen
4d2ce6b2e0 python: create shared serverless module and use it
Modelled on the javascript serverless module, but
- The predicate that reports YAML files is now public
  so languages can implement their own file conventions.
- It also reports framework and runtime.
- The conveninece predicates with files still exist,
  but they only report the path.
- Handler mapping conventions are now documented.
- Use parameterised serverless module in Python,
  tests now pass.
2023-07-12 16:42:01 +02:00
Rasmus Lerchedahl Petersen
a892e83c8e python: add simple test for AWS lambda
made space for other serverless frameworks in the directory `serverless`
2023-07-12 16:42:00 +02:00
amammad
2ba83022c7 delete old qhelp file 2023-07-01 04:49:35 +10:00
amammad
931f492df2 cleaning up mistakes 2023-06-30 23:03:29 +10:00
amammad
9fc28d5aba Merge branch 'github:main' into amammad-python-WebAppsConstatntSecretKeys 2023-06-30 22:54:22 +10:00
amammad
6f34c3225b Merge branch 'github:main' into amammad-python-WebAppsConstatntSecretKeys 2023-06-30 22:36:45 +10:00
amammad
a988ccb7d5 Merge branch 'main' of https://github.com/amammad/codeql into amammad-python-WebAppsConstatntSecretKeys 2023-06-30 22:24:08 +10:00
amammad
816799c4ba upgrade query to detect redash CVE too 2023-06-30 22:14:50 +10:00
amammad
7a17b99c17 V2 2023-06-29 20:55:51 +10:00
amammad
e3e0307db7 V1 2023-06-25 20:36:28 +10:00
Arthur Baars
e93b44670f Ruby: printCfg: only show graph for selected CfgScope 2023-05-31 16:08:01 +02:00
Maiky
345f43fbae fix concepts 2023-05-29 21:17:48 +02:00
Maiky
62353122c0 Add Improper LDAP Authentication query (CWE-287) 2023-05-29 21:16:13 +02:00
1867 changed files with 76336 additions and 49906 deletions

View File

@@ -7,15 +7,17 @@ on:
- .github/workflows/go-tests-other-os.yml
- .github/actions/**
- codeql-workspace.yml
env:
GO_VERSION: '~1.21.0'
jobs:
test-mac:
name: Test MacOS
runs-on: macos-latest
steps:
- name: Set up Go 1.20
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: ${{ env.GO_VERSION }}
id: go
- name: Check out code
@@ -47,10 +49,10 @@ jobs:
name: Test Windows
runs-on: windows-latest-xl
steps:
- name: Set up Go 1.20
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: ${{ env.GO_VERSION }}
id: go
- name: Check out code

View File

@@ -15,15 +15,17 @@ on:
- .github/workflows/go-tests.yml
- .github/actions/**
- codeql-workspace.yml
env:
GO_VERSION: '~1.21.0'
jobs:
test-linux:
name: Test Linux (Ubuntu)
runs-on: ubuntu-latest-xl
steps:
- name: Set up Go 1.20
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: ${{ env.GO_VERSION }}
id: go
- name: Check out code

View File

@@ -14,6 +14,7 @@ on:
pull_request:
paths:
- "ruby/**"
- "shared/**"
- .github/workflows/ruby-qltest.yml
- .github/actions/fetch-codeql/action.yml
- codeql-workspace.yml

View File

@@ -4,6 +4,8 @@ provide:
- "*/ql/test/qlpack.yml"
- "*/ql/examples/qlpack.yml"
- "*/ql/consistency-queries/qlpack.yml"
- "*/ql/automodel/src/qlpack.yml"
- "*/ql/automodel/test/qlpack.yml"
- "shared/*/qlpack.yml"
- "cpp/ql/test/query-tests/Security/CWE/CWE-190/semmle/tainted/qlpack.yml"
- "go/ql/config/legacy-support/qlpack.yml"

View File

@@ -22,7 +22,6 @@
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowImpl5.qll",
"go/ql/lib/semmle/go/dataflow/internal/DataFlowImpl1.qll",
"go/ql/lib/semmle/go/dataflow/internal/DataFlowImpl2.qll",
"go/ql/lib/semmle/go/dataflow/internal/DataFlowImplForStringsNewReplacer.qll",
"python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImpl1.qll",
"python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImpl2.qll",
"python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImpl3.qll",
@@ -33,16 +32,6 @@
"ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowImplForPathname.qll",
"swift/ql/lib/codeql/swift/dataflow/internal/DataFlowImpl1.qll"
],
"TaintTracking Java/C++/C#/Go/Python/Ruby/Swift": [
"cpp/ql/lib/semmle/code/cpp/dataflow/internal/tainttracking1/TaintTracking.qll",
"cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/tainttracking1/TaintTracking.qll",
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/tainttracking1/TaintTracking.qll",
"go/ql/lib/semmle/go/dataflow/internal/tainttracking1/TaintTracking.qll",
"java/ql/lib/semmle/code/java/dataflow/internal/tainttracking1/TaintTracking.qll",
"python/ql/lib/semmle/python/dataflow/new/internal/tainttracking1/TaintTracking.qll",
"ruby/ql/lib/codeql/ruby/dataflow/internal/tainttracking1/TaintTracking.qll",
"swift/ql/lib/codeql/swift/dataflow/internal/tainttracking1/TaintTracking.qll"
],
"TaintTracking Legacy Configuration Java/C++/C#/Go/Python/Ruby/Swift": [
"cpp/ql/lib/semmle/code/cpp/dataflow/internal/tainttracking1/TaintTrackingImpl.qll",
"cpp/ql/lib/semmle/code/cpp/dataflow/internal/tainttracking2/TaintTrackingImpl.qll",
@@ -66,15 +55,6 @@
"ruby/ql/lib/codeql/ruby/dataflow/internal/tainttracking1/TaintTrackingImpl.qll",
"swift/ql/lib/codeql/swift/dataflow/internal/tainttracking1/TaintTrackingImpl.qll"
],
"DataFlow Java/C++/C#/Python/Ruby/Swift Consistency checks": [
"java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImplConsistency.qll",
"cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImplConsistency.qll",
"cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowImplConsistency.qll",
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowImplConsistency.qll",
"python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImplConsistency.qll",
"ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowImplConsistency.qll",
"swift/ql/lib/codeql/swift/dataflow/internal/DataFlowImplConsistency.qll"
],
"DataFlow Java/C#/Go/Ruby/Python/Swift Flow Summaries": [
"java/ql/lib/semmle/code/java/dataflow/internal/FlowSummaryImpl.qll",
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/FlowSummaryImpl.qll",
@@ -484,10 +464,6 @@
"ruby/ql/lib/codeql/ruby/security/internal/SensitiveDataHeuristics.qll",
"swift/ql/lib/codeql/swift/security/internal/SensitiveDataHeuristics.qll"
],
"CFG": [
"csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraphImplShared.qll",
"swift/ql/lib/codeql/swift/controlflow/internal/ControlFlowGraphImplShared.qll"
],
"TypeTracker": [
"python/ql/lib/semmle/python/dataflow/new/internal/TypeTracker.qll",
"ruby/ql/lib/codeql/ruby/typetracking/TypeTracker.qll"
@@ -571,5 +547,9 @@
"EncryptionKeySizes Python/Java": [
"python/ql/lib/semmle/python/security/internal/EncryptionKeySizes.qll",
"java/ql/lib/semmle/code/java/security/internal/EncryptionKeySizes.qll"
],
"Python model summaries test extension": [
"python/ql/test/experimental/dataflow/model-summaries/InlineTaintTest.ext.yml",
"python/ql/test/experimental/dataflow/model-summaries/NormalDataflowTest.ext.yml"
]
}

View File

@@ -327,7 +327,7 @@ namespace Semmle.Autobuild.Cpp.Tests
{
Actions.RunProcess[@"cmd.exe /C nuget restore C:\Project\test.sln -DisableParallelProcessing"] = 1;
Actions.RunProcess[@"cmd.exe /C C:\Project\.nuget\nuget.exe restore C:\Project\test.sln -DisableParallelProcessing"] = 0;
Actions.RunProcess[@"cmd.exe /C CALL ^""C:\Program Files ^(x86^)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat^"" && set Platform=&& type NUL && msbuild C:\Project\test.sln /t:rebuild /p:Platform=""x86"" /p:Configuration=""Release"""] = 0;
Actions.RunProcess[@"cmd.exe /C CALL ^""C:\Program^ Files^ ^(x86^)\Microsoft^ Visual^ Studio^ 14.0\VC\vcvarsall.bat^"" && set Platform=&& type NUL && msbuild C:\Project\test.sln /t:rebuild /p:Platform=""x86"" /p:Configuration=""Release"""] = 0;
Actions.RunProcessOut[@"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe -prerelease -legacy -property installationPath"] = "";
Actions.RunProcess[@"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe -prerelease -legacy -property installationPath"] = 1;
Actions.RunProcess[@"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe -prerelease -legacy -property installationVersion"] = 0;

View File

@@ -1,3 +1,22 @@
## 0.9.2
### Deprecated APIs
* `getAllocatorCall` on `DeleteExpr` and `DeleteArrayExpr` has been deprecated. `getDeallocatorCall` should be used instead.
### New Features
* Added `DeleteOrDeleteArrayExpr` as a super type of `DeleteExpr` and `DeleteArrayExpr`
### Minor Analysis Improvements
* `delete` and `delete[]` are now modeled as calls to the relevant `operator delete` in the IR. In the case of a dynamic delete call a new instruction `VirtualDeleteFunctionAddress` is used to represent a function that dispatches to the correct delete implementation.
* Only the 2 level indirection of `argv` (corresponding to `**argv`) is consided for `FlowSource`.
## 0.9.1
No user-facing changes.
## 0.9.0
### Breaking Changes

View File

@@ -0,0 +1,3 @@
## 0.9.1
No user-facing changes.

View File

@@ -0,0 +1,14 @@
## 0.9.2
### Deprecated APIs
* `getAllocatorCall` on `DeleteExpr` and `DeleteArrayExpr` has been deprecated. `getDeallocatorCall` should be used instead.
### New Features
* Added `DeleteOrDeleteArrayExpr` as a super type of `DeleteExpr` and `DeleteArrayExpr`
### Minor Analysis Improvements
* `delete` and `delete[]` are now modeled as calls to the relevant `operator delete` in the IR. In the case of a dynamic delete call a new instruction `VirtualDeleteFunctionAddress` is used to represent a function that dispatches to the correct delete implementation.
* Only the 2 level indirection of `argv` (corresponding to `**argv`) is consided for `FlowSource`.

View File

@@ -1,2 +1,2 @@
---
lastReleaseVersion: 0.9.0
lastReleaseVersion: 0.9.2

View File

@@ -1,5 +1,5 @@
name: codeql/cpp-all
version: 0.9.0
version: 0.9.2
groups: cpp
dbscheme: semmlecode.cpp.dbscheme
extractor: cpp

View File

@@ -826,17 +826,11 @@ private predicate namedExprChildPredicates(Expr expr, Element ele, string pred)
or
expr.(Conversion).getExpr() = ele and pred = "getExpr()"
or
expr.(DeleteArrayExpr).getAllocatorCall() = ele and pred = "getAllocatorCall()"
expr.(DeleteOrDeleteArrayExpr).getDeallocatorCall() = ele and pred = "getDeallocatorCall()"
or
expr.(DeleteArrayExpr).getDestructorCall() = ele and pred = "getDestructorCall()"
expr.(DeleteOrDeleteArrayExpr).getDestructorCall() = ele and pred = "getDestructorCall()"
or
expr.(DeleteArrayExpr).getExpr() = ele and pred = "getExpr()"
or
expr.(DeleteExpr).getAllocatorCall() = ele and pred = "getAllocatorCall()"
or
expr.(DeleteExpr).getDestructorCall() = ele and pred = "getDestructorCall()"
or
expr.(DeleteExpr).getExpr() = ele and pred = "getExpr()"
expr.(DeleteOrDeleteArrayExpr).getExpr() = ele and pred = "getExpr()"
or
expr.(DestructorFieldDestruction).getExpr() = ele and pred = "getExpr()"
or

View File

@@ -332,21 +332,12 @@ private Node getControlOrderChildSparse(Node n, int i) {
n = any(ConditionDeclExpr cd | i = 0 and result = cd.getInitializingExpr())
or
n =
any(DeleteExpr del |
any(DeleteOrDeleteArrayExpr del |
i = 0 and result = del.getExpr()
or
i = 1 and result = del.getDestructorCall()
or
i = 2 and result = del.getAllocatorCall()
)
or
n =
any(DeleteArrayExpr del |
i = 0 and result = del.getExpr()
or
i = 1 and result = del.getDestructorCall()
or
i = 2 and result = del.getAllocatorCall()
i = 2 and result = del.getDeallocatorCall()
)
or
n =

View File

@@ -25,6 +25,10 @@ import semmle.code.cpp.dataflow.DataFlow2
* global (inter-procedural) taint-tracking analyses.
*/
deprecated module TaintTracking {
import semmle.code.cpp.dataflow.internal.tainttracking1.TaintTracking
import semmle.code.cpp.dataflow.internal.tainttracking1.TaintTrackingParameter::Public
private import semmle.code.cpp.dataflow.internal.DataFlowImplSpecific
private import semmle.code.cpp.dataflow.internal.TaintTrackingImplSpecific
private import codeql.dataflow.TaintTracking
import TaintFlowMake<CppOldDataFlow, CppOldTaintTracking>
import semmle.code.cpp.dataflow.internal.tainttracking1.TaintTrackingImpl
}

View File

@@ -3,297 +3,25 @@
* data-flow classes and predicates.
*/
private import DataFlowImplSpecific::Private
private import DataFlowImplSpecific::Public
private import tainttracking1.TaintTrackingParameter::Private
private import tainttracking1.TaintTrackingParameter::Public
private import cpp
private import DataFlowImplSpecific
private import TaintTrackingImplSpecific
private import codeql.dataflow.internal.DataFlowImplConsistency
module Consistency {
private newtype TConsistencyConfiguration = MkConsistencyConfiguration()
/** A class for configuring the consistency queries. */
class ConsistencyConfiguration extends TConsistencyConfiguration {
string toString() { none() }
/** Holds if `n` should be excluded from the consistency test `uniqueEnclosingCallable`. */
predicate uniqueEnclosingCallableExclude(Node n) { none() }
/** Holds if `call` should be excluded from the consistency test `uniqueCallEnclosingCallable`. */
predicate uniqueCallEnclosingCallableExclude(DataFlowCall call) { none() }
/** Holds if `n` should be excluded from the consistency test `uniqueNodeLocation`. */
predicate uniqueNodeLocationExclude(Node n) { none() }
/** Holds if `n` should be excluded from the consistency test `missingLocation`. */
predicate missingLocationExclude(Node n) { none() }
/** Holds if `n` should be excluded from the consistency test `postWithInFlow`. */
predicate postWithInFlowExclude(Node n) { none() }
/** Holds if `n` should be excluded from the consistency test `argHasPostUpdate`. */
predicate argHasPostUpdateExclude(ArgumentNode n) { none() }
/** Holds if `n` should be excluded from the consistency test `reverseRead`. */
predicate reverseReadExclude(Node n) { none() }
/** Holds if `n` should be excluded from the consistency test `postHasUniquePre`. */
predicate postHasUniquePreExclude(PostUpdateNode n) { none() }
/** Holds if `n` should be excluded from the consistency test `uniquePostUpdate`. */
predicate uniquePostUpdateExclude(Node n) { none() }
/** Holds if `(call, ctx)` should be excluded from the consistency test `viableImplInCallContextTooLargeExclude`. */
predicate viableImplInCallContextTooLargeExclude(
DataFlowCall call, DataFlowCall ctx, DataFlowCallable callable
) {
none()
}
/** Holds if `(c, pos, p)` should be excluded from the consistency test `uniqueParameterNodeAtPosition`. */
predicate uniqueParameterNodeAtPositionExclude(DataFlowCallable c, ParameterPosition pos, Node p) {
none()
}
/** Holds if `(c, pos, p)` should be excluded from the consistency test `uniqueParameterNodePosition`. */
predicate uniqueParameterNodePositionExclude(DataFlowCallable c, ParameterPosition pos, Node p) {
none()
}
/** Holds if `n` should be excluded from the consistency test `identityLocalStep`. */
predicate identityLocalStepExclude(Node n) { none() }
}
private class RelevantNode extends Node {
RelevantNode() {
this instanceof ArgumentNode or
this instanceof ParameterNode or
this instanceof ReturnNode or
this = getAnOutNode(_, _) or
simpleLocalFlowStep(this, _) or
simpleLocalFlowStep(_, this) or
jumpStep(this, _) or
jumpStep(_, this) or
storeStep(this, _, _) or
storeStep(_, _, this) or
readStep(this, _, _) or
readStep(_, _, this) or
defaultAdditionalTaintStep(this, _) or
defaultAdditionalTaintStep(_, this)
}
}
query predicate uniqueEnclosingCallable(Node n, string msg) {
exists(int c |
n instanceof RelevantNode and
c = count(nodeGetEnclosingCallable(n)) and
c != 1 and
not any(ConsistencyConfiguration conf).uniqueEnclosingCallableExclude(n) and
msg = "Node should have one enclosing callable but has " + c + "."
)
}
query predicate uniqueCallEnclosingCallable(DataFlowCall call, string msg) {
exists(int c |
c = count(call.getEnclosingCallable()) and
c != 1 and
not any(ConsistencyConfiguration conf).uniqueCallEnclosingCallableExclude(call) and
msg = "Call should have one enclosing callable but has " + c + "."
)
}
query predicate uniqueType(Node n, string msg) {
exists(int c |
n instanceof RelevantNode and
c = count(getNodeType(n)) and
c != 1 and
msg = "Node should have one type but has " + c + "."
)
}
query predicate uniqueNodeLocation(Node n, string msg) {
exists(int c |
c =
count(string filepath, int startline, int startcolumn, int endline, int endcolumn |
n.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
) and
c != 1 and
not any(ConsistencyConfiguration conf).uniqueNodeLocationExclude(n) and
msg = "Node should have one location but has " + c + "."
)
}
query predicate missingLocation(string msg) {
exists(int c |
c =
strictcount(Node n |
not n.hasLocationInfo(_, _, _, _, _) and
not any(ConsistencyConfiguration conf).missingLocationExclude(n)
) and
msg = "Nodes without location: " + c
)
}
query predicate uniqueNodeToString(Node n, string msg) {
exists(int c |
c = count(n.toString()) and
c != 1 and
msg = "Node should have one toString but has " + c + "."
)
}
query predicate missingToString(string msg) {
exists(int c |
c = strictcount(Node n | not exists(n.toString())) and
msg = "Nodes without toString: " + c
)
}
query predicate parameterCallable(ParameterNode p, string msg) {
exists(DataFlowCallable c | isParameterNode(p, c, _) and c != nodeGetEnclosingCallable(p)) and
msg = "Callable mismatch for parameter."
}
query predicate localFlowIsLocal(Node n1, Node n2, string msg) {
simpleLocalFlowStep(n1, n2) and
nodeGetEnclosingCallable(n1) != nodeGetEnclosingCallable(n2) and
msg = "Local flow step does not preserve enclosing callable."
}
query predicate readStepIsLocal(Node n1, Node n2, string msg) {
readStep(n1, _, n2) and
nodeGetEnclosingCallable(n1) != nodeGetEnclosingCallable(n2) and
msg = "Read step does not preserve enclosing callable."
}
query predicate storeStepIsLocal(Node n1, Node n2, string msg) {
storeStep(n1, _, n2) and
nodeGetEnclosingCallable(n1) != nodeGetEnclosingCallable(n2) and
msg = "Store step does not preserve enclosing callable."
}
private DataFlowType typeRepr() { result = getNodeType(_) }
query predicate compatibleTypesReflexive(DataFlowType t, string msg) {
t = typeRepr() and
not compatibleTypes(t, t) and
msg = "Type compatibility predicate is not reflexive."
}
query predicate unreachableNodeCCtx(Node n, DataFlowCall call, string msg) {
isUnreachableInCall(n, call) and
exists(DataFlowCallable c |
c = nodeGetEnclosingCallable(n) and
not viableCallable(call) = c
) and
msg = "Call context for isUnreachableInCall is inconsistent with call graph."
}
query predicate localCallNodes(DataFlowCall call, Node n, string msg) {
(
n = getAnOutNode(call, _) and
msg = "OutNode and call does not share enclosing callable."
or
n.(ArgumentNode).argumentOf(call, _) and
msg = "ArgumentNode and call does not share enclosing callable."
) and
nodeGetEnclosingCallable(n) != call.getEnclosingCallable()
}
// This predicate helps the compiler forget that in some languages
// it is impossible for a result of `getPreUpdateNode` to be an
// instance of `PostUpdateNode`.
private Node getPre(PostUpdateNode n) {
result = n.getPreUpdateNode()
private module Input implements InputSig<CppOldDataFlow> {
predicate argHasPostUpdateExclude(Private::ArgumentNode n) {
// Is the null pointer (or something that's not really a pointer)
exists(n.asExpr().getValue())
or
none()
}
query predicate postIsNotPre(PostUpdateNode n, string msg) {
getPre(n) = n and
msg = "PostUpdateNode should not equal its pre-update node."
}
query predicate postHasUniquePre(PostUpdateNode n, string msg) {
not any(ConsistencyConfiguration conf).postHasUniquePreExclude(n) and
exists(int c |
c = count(n.getPreUpdateNode()) and
c != 1 and
msg = "PostUpdateNode should have one pre-update node but has " + c + "."
// Isn't a pointer or is a pointer to const
forall(DerivedType dt | dt = n.asExpr().getActualType() |
dt.getBaseType().isConst()
or
dt.getBaseType() instanceof RoutineType
)
}
query predicate uniquePostUpdate(Node n, string msg) {
not any(ConsistencyConfiguration conf).uniquePostUpdateExclude(n) and
1 < strictcount(PostUpdateNode post | post.getPreUpdateNode() = n) and
msg = "Node has multiple PostUpdateNodes."
}
query predicate postIsInSameCallable(PostUpdateNode n, string msg) {
nodeGetEnclosingCallable(n) != nodeGetEnclosingCallable(n.getPreUpdateNode()) and
msg = "PostUpdateNode does not share callable with its pre-update node."
}
private predicate hasPost(Node n) { exists(PostUpdateNode post | post.getPreUpdateNode() = n) }
query predicate reverseRead(Node n, string msg) {
exists(Node n2 | readStep(n, _, n2) and hasPost(n2) and not hasPost(n)) and
not any(ConsistencyConfiguration conf).reverseReadExclude(n) and
msg = "Origin of readStep is missing a PostUpdateNode."
}
query predicate argHasPostUpdate(ArgumentNode n, string msg) {
not hasPost(n) and
not any(ConsistencyConfiguration c).argHasPostUpdateExclude(n) and
msg = "ArgumentNode is missing PostUpdateNode."
}
// This predicate helps the compiler forget that in some languages
// it is impossible for a `PostUpdateNode` to be the target of
// `simpleLocalFlowStep`.
private predicate isPostUpdateNode(Node n) { n instanceof PostUpdateNode or none() }
query predicate postWithInFlow(Node n, string msg) {
isPostUpdateNode(n) and
not clearsContent(n, _) and
simpleLocalFlowStep(_, n) and
not any(ConsistencyConfiguration c).postWithInFlowExclude(n) and
msg = "PostUpdateNode should not be the target of local flow."
}
query predicate viableImplInCallContextTooLarge(
DataFlowCall call, DataFlowCall ctx, DataFlowCallable callable
) {
callable = viableImplInCallContext(call, ctx) and
not callable = viableCallable(call) and
not any(ConsistencyConfiguration c).viableImplInCallContextTooLargeExclude(call, ctx, callable)
}
query predicate uniqueParameterNodeAtPosition(
DataFlowCallable c, ParameterPosition pos, Node p, string msg
) {
not any(ConsistencyConfiguration conf).uniqueParameterNodeAtPositionExclude(c, pos, p) and
isParameterNode(p, c, pos) and
not exists(unique(Node p0 | isParameterNode(p0, c, pos))) and
msg = "Parameters with overlapping positions."
}
query predicate uniqueParameterNodePosition(
DataFlowCallable c, ParameterPosition pos, Node p, string msg
) {
not any(ConsistencyConfiguration conf).uniqueParameterNodePositionExclude(c, pos, p) and
isParameterNode(p, c, pos) and
not exists(unique(ParameterPosition pos0 | isParameterNode(p, c, pos0))) and
msg = "Parameter node with multiple positions."
}
query predicate uniqueContentApprox(Content c, string msg) {
not exists(unique(ContentApprox approx | approx = getContentApprox(c))) and
msg = "Non-unique content approximation."
}
query predicate identityLocalStep(Node n, string msg) {
simpleLocalFlowStep(n, n) and
not any(ConsistencyConfiguration c).identityLocalStepExclude(n) and
msg = "Node steps to itself"
// The above list of cases isn't exhaustive, but it narrows down the
// consistency alerts enough that most of them are interesting.
}
}
module Consistency = MakeConsistency<CppOldDataFlow, CppOldTaintTracking, Input>;

View File

@@ -2,7 +2,6 @@ private import cpp
private import DataFlowUtil
private import DataFlowDispatch
private import FlowVar
private import DataFlowImplConsistency
private import codeql.util.Unit
/** Gets the callable in which this node occurs. */
@@ -297,22 +296,6 @@ class ContentApprox = Unit;
pragma[inline]
ContentApprox getContentApprox(Content c) { any() }
private class MyConsistencyConfiguration extends Consistency::ConsistencyConfiguration {
override predicate argHasPostUpdateExclude(ArgumentNode n) {
// Is the null pointer (or something that's not really a pointer)
exists(n.asExpr().getValue())
or
// Isn't a pointer or is a pointer to const
forall(DerivedType dt | dt = n.asExpr().getActualType() |
dt.getBaseType().isConst()
or
dt.getBaseType() instanceof RoutineType
)
// The above list of cases isn't exhaustive, but it narrows down the
// consistency alerts enough that most of them are interesting.
}
}
/**
* Gets an additional term that is added to the `join` and `branch` computations to reflect
* an additional forward or backwards branching factor that is not taken into account

View File

@@ -0,0 +1,10 @@
/**
* Provides C++-specific definitions for use in the taint tracking library.
*/
private import codeql.dataflow.TaintTracking
private import DataFlowImplSpecific
module CppOldTaintTracking implements InputSig<CppOldDataFlow> {
import TaintTrackingUtil
}

View File

@@ -39,7 +39,7 @@ predicate defaultAdditionalTaintStep(DataFlow::Node src, DataFlow::Node sink) {
* of `c` at sinks and inputs to additional taint steps.
*/
bindingset[node]
predicate defaultImplicitTaintRead(DataFlow::Node node, DataFlow::Content c) { none() }
predicate defaultImplicitTaintRead(DataFlow::Node node, DataFlow::ContentSet c) { none() }
/**
* Holds if `node` should be a sanitizer in all global taint flow configurations

View File

@@ -1,75 +0,0 @@
/**
* Provides classes for performing local (intra-procedural) and
* global (inter-procedural) taint-tracking analyses.
*/
import TaintTrackingParameter::Public
private import TaintTrackingParameter::Private
private module AddTaintDefaults<DataFlowInternal::FullStateConfigSig Config> implements
DataFlowInternal::FullStateConfigSig
{
import Config
predicate isBarrier(DataFlow::Node node) {
Config::isBarrier(node) or defaultTaintSanitizer(node)
}
predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
Config::isAdditionalFlowStep(node1, node2) or
defaultAdditionalTaintStep(node1, node2)
}
predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
Config::allowImplicitRead(node, c)
or
(
Config::isSink(node) or
Config::isSink(node, _) or
Config::isAdditionalFlowStep(node, _) or
Config::isAdditionalFlowStep(node, _, _, _)
) and
defaultImplicitTaintRead(node, c)
}
}
/**
* Constructs a global taint tracking computation.
*/
module Global<DataFlow::ConfigSig Config> implements DataFlow::GlobalFlowSig {
private module Config0 implements DataFlowInternal::FullStateConfigSig {
import DataFlowInternal::DefaultState<Config>
import Config
}
private module C implements DataFlowInternal::FullStateConfigSig {
import AddTaintDefaults<Config0>
}
import DataFlowInternal::Impl<C>
}
/** DEPRECATED: Use `Global` instead. */
deprecated module Make<DataFlow::ConfigSig Config> implements DataFlow::GlobalFlowSig {
import Global<Config>
}
/**
* Constructs a global taint tracking computation using flow state.
*/
module GlobalWithState<DataFlow::StateConfigSig Config> implements DataFlow::GlobalFlowSig {
private module Config0 implements DataFlowInternal::FullStateConfigSig {
import Config
}
private module C implements DataFlowInternal::FullStateConfigSig {
import AddTaintDefaults<Config0>
}
import DataFlowInternal::Impl<C>
}
/** DEPRECATED: Use `GlobalWithState` instead. */
deprecated module MakeWithState<DataFlow::StateConfigSig Config> implements DataFlow::GlobalFlowSig {
import GlobalWithState<Config>
}

View File

@@ -23,6 +23,10 @@ import semmle.code.cpp.dataflow.new.DataFlow2
* global (inter-procedural) taint-tracking analyses.
*/
module TaintTracking {
import semmle.code.cpp.ir.dataflow.internal.tainttracking1.TaintTracking
import semmle.code.cpp.ir.dataflow.internal.tainttracking1.TaintTrackingParameter::Public
private import semmle.code.cpp.ir.dataflow.internal.DataFlowImplSpecific
private import semmle.code.cpp.ir.dataflow.internal.TaintTrackingImplSpecific
private import codeql.dataflow.TaintTracking
import TaintFlowMake<CppDataFlow, CppTaintTracking>
import semmle.code.cpp.ir.dataflow.internal.tainttracking1.TaintTrackingImpl
}

View File

@@ -932,19 +932,91 @@ class NewArrayExpr extends NewOrNewArrayExpr, @new_array_expr {
Expr getExtent() { result = this.getChild(2) }
}
private class TDeleteOrDeleteArrayExpr = @delete_expr or @delete_array_expr;
/**
* A C++ `delete` or `delete[]` expression.
*/
class DeleteOrDeleteArrayExpr extends Expr, TDeleteOrDeleteArrayExpr {
override int getPrecedence() { result = 16 }
/**
* Gets the call to a destructor that occurs prior to the object's memory being deallocated, if any.
*
* In the case of `delete[]` at runtime, the destructor will be called once for each element in the array, but the
* destructor call only exists once in the AST.
*/
DestructorCall getDestructorCall() { result = this.getChild(1) }
/**
* Gets the destructor to be called to destroy the object or array, if any.
*/
Destructor getDestructor() { result = this.getDestructorCall().getTarget() }
/**
* Gets the `operator delete` or `operator delete[]` that deallocates storage.
* Does not hold if the type being destroyed has a virtual destructor. In that case, the
* `operator delete` that will be called is determined at runtime based on the
* dynamic type of the object.
*/
Function getDeallocator() {
expr_deallocator(underlyingElement(this), unresolveElement(result), _)
}
/**
* DEPRECATED: use `getDeallocatorCall` instead.
*/
deprecated FunctionCall getAllocatorCall() { result = this.getChild(0) }
/**
* Gets the call to a non-default `operator delete`/`delete[]` that deallocates storage, if any.
*
* This will only be present when the type being deleted has a custom `operator delete` and
* does not have a virtual destructor.
*/
FunctionCall getDeallocatorCall() { result = this.getChild(0) }
/**
* Holds if the deallocation function expects a size argument.
*/
predicate hasSizedDeallocation() {
exists(int form |
expr_deallocator(underlyingElement(this), _, form) and
form.bitAnd(1) != 0 // Bit zero is the "size" bit
)
}
/**
* Holds if the deallocation function expects an alignment argument.
*/
predicate hasAlignedDeallocation() {
exists(int form |
expr_deallocator(underlyingElement(this), _, form) and
form.bitAnd(2) != 0 // Bit one is the "alignment" bit
)
}
/**
* Gets the object or array being deleted.
*/
Expr getExpr() {
// If there is a destructor call, the object being deleted is the qualifier
// otherwise it is the third child.
result = this.getChild(3) or result = this.getDestructorCall().getQualifier()
}
}
/**
* A C++ `delete` (non-array) expression.
* ```
* delete ptr;
* ```
*/
class DeleteExpr extends Expr, @delete_expr {
class DeleteExpr extends DeleteOrDeleteArrayExpr, @delete_expr {
override string toString() { result = "delete" }
override string getAPrimaryQlClass() { result = "DeleteExpr" }
override int getPrecedence() { result = 16 }
/**
* Gets the compile-time type of the object being deleted.
*/
@@ -957,58 +1029,6 @@ class DeleteExpr extends Expr, @delete_expr {
.(PointerType)
.getBaseType()
}
/**
* Gets the call to a destructor that occurs prior to the object's memory being deallocated, if any.
*/
DestructorCall getDestructorCall() { result = this.getChild(1) }
/**
* Gets the destructor to be called to destroy the object, if any.
*/
Destructor getDestructor() { result = this.getDestructorCall().getTarget() }
/**
* Gets the `operator delete` that deallocates storage. Does not hold
* if the type being destroyed has a virtual destructor. In that case, the
* `operator delete` that will be called is determined at runtime based on the
* dynamic type of the object.
*/
Function getDeallocator() {
expr_deallocator(underlyingElement(this), unresolveElement(result), _)
}
/**
* Holds if the deallocation function expects a size argument.
*/
predicate hasSizedDeallocation() {
exists(int form |
expr_deallocator(underlyingElement(this), _, form) and
form.bitAnd(1) != 0 // Bit zero is the "size" bit
)
}
/**
* Holds if the deallocation function expects an alignment argument.
*/
predicate hasAlignedDeallocation() {
exists(int form |
expr_deallocator(underlyingElement(this), _, form) and
form.bitAnd(2) != 0 // Bit one is the "alignment" bit
)
}
/**
* Gets the call to a non-default `operator delete` that deallocates storage, if any.
*
* This will only be present when the type being deleted has a custom `operator delete`.
*/
FunctionCall getAllocatorCall() { result = this.getChild(0) }
/**
* Gets the object being deleted.
*/
Expr getExpr() { result = this.getChild(3) or result = this.getChild(1).getChild(-1) }
}
/**
@@ -1017,13 +1037,11 @@ class DeleteExpr extends Expr, @delete_expr {
* delete[] arr;
* ```
*/
class DeleteArrayExpr extends Expr, @delete_array_expr {
class DeleteArrayExpr extends DeleteOrDeleteArrayExpr, @delete_array_expr {
override string toString() { result = "delete[]" }
override string getAPrimaryQlClass() { result = "DeleteArrayExpr" }
override int getPrecedence() { result = 16 }
/**
* Gets the element type of the array being deleted.
*/
@@ -1036,58 +1054,6 @@ class DeleteArrayExpr extends Expr, @delete_array_expr {
.(PointerType)
.getBaseType()
}
/**
* Gets the call to a destructor that occurs prior to the array's memory being deallocated, if any.
*
* At runtime, the destructor will be called once for each element in the array, but the
* destructor call only exists once in the AST.
*/
DestructorCall getDestructorCall() { result = this.getChild(1) }
/**
* Gets the destructor to be called to destroy each element in the array, if any.
*/
Destructor getDestructor() { result = this.getDestructorCall().getTarget() }
/**
* Gets the `operator delete[]` that deallocates storage.
*/
Function getDeallocator() {
expr_deallocator(underlyingElement(this), unresolveElement(result), _)
}
/**
* Holds if the deallocation function expects a size argument.
*/
predicate hasSizedDeallocation() {
exists(int form |
expr_deallocator(underlyingElement(this), _, form) and
form.bitAnd(1) != 0 // Bit zero is the "size" bit
)
}
/**
* Holds if the deallocation function expects an alignment argument.
*/
predicate hasAlignedDeallocation() {
exists(int form |
expr_deallocator(underlyingElement(this), _, form) and
form.bitAnd(2) != 0 // Bit one is the "alignment" bit
)
}
/**
* Gets the call to a non-default `operator delete` that deallocates storage, if any.
*
* This will only be present when the type being deleted has a custom `operator delete`.
*/
FunctionCall getAllocatorCall() { result = this.getChild(0) }
/**
* Gets the array being deleted.
*/
Expr getExpr() { result = this.getChild(3) or result = this.getChild(1).getChild(-1) }
}
/**

View File

@@ -19,6 +19,10 @@ import semmle.code.cpp.ir.dataflow.DataFlow
import semmle.code.cpp.ir.dataflow.DataFlow2
module TaintTracking {
import semmle.code.cpp.ir.dataflow.internal.tainttracking1.TaintTracking
import semmle.code.cpp.ir.dataflow.internal.tainttracking1.TaintTrackingParameter::Public
private import semmle.code.cpp.ir.dataflow.internal.DataFlowImplSpecific
private import semmle.code.cpp.ir.dataflow.internal.TaintTrackingImplSpecific
private import codeql.dataflow.TaintTracking
import TaintFlowMake<CppDataFlow, CppTaintTracking>
import semmle.code.cpp.ir.dataflow.internal.tainttracking1.TaintTrackingImpl
}

View File

@@ -3,297 +3,17 @@
* data-flow classes and predicates.
*/
private import DataFlowImplSpecific::Private
private import DataFlowImplSpecific::Public
private import tainttracking1.TaintTrackingParameter::Private
private import tainttracking1.TaintTrackingParameter::Public
private import cpp
private import DataFlowImplSpecific
private import TaintTrackingImplSpecific
private import codeql.dataflow.internal.DataFlowImplConsistency
module Consistency {
private newtype TConsistencyConfiguration = MkConsistencyConfiguration()
/** A class for configuring the consistency queries. */
class ConsistencyConfiguration extends TConsistencyConfiguration {
string toString() { none() }
/** Holds if `n` should be excluded from the consistency test `uniqueEnclosingCallable`. */
predicate uniqueEnclosingCallableExclude(Node n) { none() }
/** Holds if `call` should be excluded from the consistency test `uniqueCallEnclosingCallable`. */
predicate uniqueCallEnclosingCallableExclude(DataFlowCall call) { none() }
/** Holds if `n` should be excluded from the consistency test `uniqueNodeLocation`. */
predicate uniqueNodeLocationExclude(Node n) { none() }
/** Holds if `n` should be excluded from the consistency test `missingLocation`. */
predicate missingLocationExclude(Node n) { none() }
/** Holds if `n` should be excluded from the consistency test `postWithInFlow`. */
predicate postWithInFlowExclude(Node n) { none() }
/** Holds if `n` should be excluded from the consistency test `argHasPostUpdate`. */
predicate argHasPostUpdateExclude(ArgumentNode n) { none() }
/** Holds if `n` should be excluded from the consistency test `reverseRead`. */
predicate reverseReadExclude(Node n) { none() }
/** Holds if `n` should be excluded from the consistency test `postHasUniquePre`. */
predicate postHasUniquePreExclude(PostUpdateNode n) { none() }
/** Holds if `n` should be excluded from the consistency test `uniquePostUpdate`. */
predicate uniquePostUpdateExclude(Node n) { none() }
/** Holds if `(call, ctx)` should be excluded from the consistency test `viableImplInCallContextTooLargeExclude`. */
predicate viableImplInCallContextTooLargeExclude(
DataFlowCall call, DataFlowCall ctx, DataFlowCallable callable
) {
none()
}
/** Holds if `(c, pos, p)` should be excluded from the consistency test `uniqueParameterNodeAtPosition`. */
predicate uniqueParameterNodeAtPositionExclude(DataFlowCallable c, ParameterPosition pos, Node p) {
none()
}
/** Holds if `(c, pos, p)` should be excluded from the consistency test `uniqueParameterNodePosition`. */
predicate uniqueParameterNodePositionExclude(DataFlowCallable c, ParameterPosition pos, Node p) {
none()
}
/** Holds if `n` should be excluded from the consistency test `identityLocalStep`. */
predicate identityLocalStepExclude(Node n) { none() }
}
private class RelevantNode extends Node {
RelevantNode() {
this instanceof ArgumentNode or
this instanceof ParameterNode or
this instanceof ReturnNode or
this = getAnOutNode(_, _) or
simpleLocalFlowStep(this, _) or
simpleLocalFlowStep(_, this) or
jumpStep(this, _) or
jumpStep(_, this) or
storeStep(this, _, _) or
storeStep(_, _, this) or
readStep(this, _, _) or
readStep(_, _, this) or
defaultAdditionalTaintStep(this, _) or
defaultAdditionalTaintStep(_, this)
}
}
query predicate uniqueEnclosingCallable(Node n, string msg) {
exists(int c |
n instanceof RelevantNode and
c = count(nodeGetEnclosingCallable(n)) and
c != 1 and
not any(ConsistencyConfiguration conf).uniqueEnclosingCallableExclude(n) and
msg = "Node should have one enclosing callable but has " + c + "."
)
}
query predicate uniqueCallEnclosingCallable(DataFlowCall call, string msg) {
exists(int c |
c = count(call.getEnclosingCallable()) and
c != 1 and
not any(ConsistencyConfiguration conf).uniqueCallEnclosingCallableExclude(call) and
msg = "Call should have one enclosing callable but has " + c + "."
)
}
query predicate uniqueType(Node n, string msg) {
exists(int c |
n instanceof RelevantNode and
c = count(getNodeType(n)) and
c != 1 and
msg = "Node should have one type but has " + c + "."
)
}
query predicate uniqueNodeLocation(Node n, string msg) {
exists(int c |
c =
count(string filepath, int startline, int startcolumn, int endline, int endcolumn |
n.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
) and
c != 1 and
not any(ConsistencyConfiguration conf).uniqueNodeLocationExclude(n) and
msg = "Node should have one location but has " + c + "."
)
}
query predicate missingLocation(string msg) {
exists(int c |
c =
strictcount(Node n |
not n.hasLocationInfo(_, _, _, _, _) and
not any(ConsistencyConfiguration conf).missingLocationExclude(n)
) and
msg = "Nodes without location: " + c
)
}
query predicate uniqueNodeToString(Node n, string msg) {
exists(int c |
c = count(n.toString()) and
c != 1 and
msg = "Node should have one toString but has " + c + "."
)
}
query predicate missingToString(string msg) {
exists(int c |
c = strictcount(Node n | not exists(n.toString())) and
msg = "Nodes without toString: " + c
)
}
query predicate parameterCallable(ParameterNode p, string msg) {
exists(DataFlowCallable c | isParameterNode(p, c, _) and c != nodeGetEnclosingCallable(p)) and
msg = "Callable mismatch for parameter."
}
query predicate localFlowIsLocal(Node n1, Node n2, string msg) {
simpleLocalFlowStep(n1, n2) and
nodeGetEnclosingCallable(n1) != nodeGetEnclosingCallable(n2) and
msg = "Local flow step does not preserve enclosing callable."
}
query predicate readStepIsLocal(Node n1, Node n2, string msg) {
readStep(n1, _, n2) and
nodeGetEnclosingCallable(n1) != nodeGetEnclosingCallable(n2) and
msg = "Read step does not preserve enclosing callable."
}
query predicate storeStepIsLocal(Node n1, Node n2, string msg) {
storeStep(n1, _, n2) and
nodeGetEnclosingCallable(n1) != nodeGetEnclosingCallable(n2) and
msg = "Store step does not preserve enclosing callable."
}
private DataFlowType typeRepr() { result = getNodeType(_) }
query predicate compatibleTypesReflexive(DataFlowType t, string msg) {
t = typeRepr() and
not compatibleTypes(t, t) and
msg = "Type compatibility predicate is not reflexive."
}
query predicate unreachableNodeCCtx(Node n, DataFlowCall call, string msg) {
isUnreachableInCall(n, call) and
exists(DataFlowCallable c |
c = nodeGetEnclosingCallable(n) and
not viableCallable(call) = c
) and
msg = "Call context for isUnreachableInCall is inconsistent with call graph."
}
query predicate localCallNodes(DataFlowCall call, Node n, string msg) {
(
n = getAnOutNode(call, _) and
msg = "OutNode and call does not share enclosing callable."
or
n.(ArgumentNode).argumentOf(call, _) and
msg = "ArgumentNode and call does not share enclosing callable."
) and
nodeGetEnclosingCallable(n) != call.getEnclosingCallable()
}
// This predicate helps the compiler forget that in some languages
// it is impossible for a result of `getPreUpdateNode` to be an
// instance of `PostUpdateNode`.
private Node getPre(PostUpdateNode n) {
result = n.getPreUpdateNode()
or
none()
}
query predicate postIsNotPre(PostUpdateNode n, string msg) {
getPre(n) = n and
msg = "PostUpdateNode should not equal its pre-update node."
}
query predicate postHasUniquePre(PostUpdateNode n, string msg) {
not any(ConsistencyConfiguration conf).postHasUniquePreExclude(n) and
exists(int c |
c = count(n.getPreUpdateNode()) and
c != 1 and
msg = "PostUpdateNode should have one pre-update node but has " + c + "."
)
}
query predicate uniquePostUpdate(Node n, string msg) {
not any(ConsistencyConfiguration conf).uniquePostUpdateExclude(n) and
1 < strictcount(PostUpdateNode post | post.getPreUpdateNode() = n) and
msg = "Node has multiple PostUpdateNodes."
}
query predicate postIsInSameCallable(PostUpdateNode n, string msg) {
nodeGetEnclosingCallable(n) != nodeGetEnclosingCallable(n.getPreUpdateNode()) and
msg = "PostUpdateNode does not share callable with its pre-update node."
}
private predicate hasPost(Node n) { exists(PostUpdateNode post | post.getPreUpdateNode() = n) }
query predicate reverseRead(Node n, string msg) {
exists(Node n2 | readStep(n, _, n2) and hasPost(n2) and not hasPost(n)) and
not any(ConsistencyConfiguration conf).reverseReadExclude(n) and
msg = "Origin of readStep is missing a PostUpdateNode."
}
query predicate argHasPostUpdate(ArgumentNode n, string msg) {
not hasPost(n) and
not any(ConsistencyConfiguration c).argHasPostUpdateExclude(n) and
msg = "ArgumentNode is missing PostUpdateNode."
}
// This predicate helps the compiler forget that in some languages
// it is impossible for a `PostUpdateNode` to be the target of
// `simpleLocalFlowStep`.
private predicate isPostUpdateNode(Node n) { n instanceof PostUpdateNode or none() }
query predicate postWithInFlow(Node n, string msg) {
isPostUpdateNode(n) and
not clearsContent(n, _) and
simpleLocalFlowStep(_, n) and
not any(ConsistencyConfiguration c).postWithInFlowExclude(n) and
msg = "PostUpdateNode should not be the target of local flow."
}
query predicate viableImplInCallContextTooLarge(
DataFlowCall call, DataFlowCall ctx, DataFlowCallable callable
) {
callable = viableImplInCallContext(call, ctx) and
not callable = viableCallable(call) and
not any(ConsistencyConfiguration c).viableImplInCallContextTooLargeExclude(call, ctx, callable)
}
query predicate uniqueParameterNodeAtPosition(
DataFlowCallable c, ParameterPosition pos, Node p, string msg
) {
not any(ConsistencyConfiguration conf).uniqueParameterNodeAtPositionExclude(c, pos, p) and
isParameterNode(p, c, pos) and
not exists(unique(Node p0 | isParameterNode(p0, c, pos))) and
msg = "Parameters with overlapping positions."
}
query predicate uniqueParameterNodePosition(
DataFlowCallable c, ParameterPosition pos, Node p, string msg
) {
not any(ConsistencyConfiguration conf).uniqueParameterNodePositionExclude(c, pos, p) and
isParameterNode(p, c, pos) and
not exists(unique(ParameterPosition pos0 | isParameterNode(p, c, pos0))) and
msg = "Parameter node with multiple positions."
}
query predicate uniqueContentApprox(Content c, string msg) {
not exists(unique(ContentApprox approx | approx = getContentApprox(c))) and
msg = "Non-unique content approximation."
}
query predicate identityLocalStep(Node n, string msg) {
simpleLocalFlowStep(n, n) and
not any(ConsistencyConfiguration c).identityLocalStepExclude(n) and
msg = "Node steps to itself"
private module Input implements InputSig<CppDataFlow> {
predicate argHasPostUpdateExclude(Private::ArgumentNode n) {
// The rules for whether an IR argument gets a post-update node are too
// complex to model here.
any()
}
}
module Consistency = MakeConsistency<CppDataFlow, CppTaintTracking, Input>;

View File

@@ -2,7 +2,6 @@ private import cpp as Cpp
private import DataFlowUtil
private import semmle.code.cpp.ir.IR
private import DataFlowDispatch
private import DataFlowImplConsistency
private import semmle.code.cpp.ir.internal.IRCppLanguage
private import SsaInternals as Ssa
private import DataFlowImplCommon as DataFlowImplCommon
@@ -220,9 +219,10 @@ private module IndirectOperands {
int indirectionIndex;
IndirectOperandFromIRRepr() {
exists(Operand repr |
repr = Ssa::getIRRepresentationOfIndirectOperand(operand, indirectionIndex) and
nodeHasOperand(this, repr, indirectionIndex - 1)
exists(Operand repr, int indirectionIndexRepr |
Ssa::hasIRRepresentationOfIndirectOperand(operand, indirectionIndex, repr,
indirectionIndexRepr) and
nodeHasOperand(this, repr, indirectionIndexRepr)
)
}
@@ -262,9 +262,10 @@ private module IndirectInstructions {
int indirectionIndex;
IndirectInstructionFromIRRepr() {
exists(Instruction repr |
repr = Ssa::getIRRepresentationOfIndirectInstruction(instr, indirectionIndex) and
nodeHasInstruction(this, repr, indirectionIndex - 1)
exists(Instruction repr, int indirectionIndexRepr |
Ssa::hasIRRepresentationOfIndirectInstruction(instr, indirectionIndex, repr,
indirectionIndexRepr) and
nodeHasInstruction(this, repr, indirectionIndexRepr)
)
}
@@ -690,7 +691,7 @@ predicate storeStep(Node node1, ContentSet c, Node node2) { storeStepImpl(node1,
private predicate numberOfLoadsFromOperandRec(
Operand operandFrom, Operand operandTo, int ind, boolean certain
) {
exists(Instruction load | Ssa::isDereference(load, operandFrom) |
exists(Instruction load | Ssa::isDereference(load, operandFrom, _) |
operandTo = operandFrom and ind = 0 and certain = true
or
numberOfLoadsFromOperand(load.getAUse(), operandTo, ind - 1, certain)
@@ -714,7 +715,7 @@ private predicate numberOfLoadsFromOperand(
) {
numberOfLoadsFromOperandRec(operandFrom, operandTo, n, certain)
or
not Ssa::isDereference(_, operandFrom) and
not Ssa::isDereference(_, operandFrom, _) and
not conversionFlow(operandFrom, _, _, _) and
operandFrom = operandTo and
n = 0 and
@@ -1011,14 +1012,6 @@ ContentApprox getContentApprox(Content c) {
)
}
private class MyConsistencyConfiguration extends Consistency::ConsistencyConfiguration {
override predicate argHasPostUpdateExclude(ArgumentNode n) {
// The rules for whether an IR argument gets a post-update node are too
// complex to model here.
any()
}
}
/**
* A local flow relation that includes both local steps, read steps and
* argument-to-return flow through summarized functions.
@@ -1078,7 +1071,7 @@ private IRVariable getIRVariableForParameterNode(ParameterNode p) {
/** Holds if `v` is the source variable corresponding to the parameter represented by `p`. */
pragma[nomagic]
private predicate parameterNodeHasSourceVariable(ParameterNode p, Ssa::SourceIRVariable v) {
private predicate parameterNodeHasSourceVariable(ParameterNode p, Ssa::SourceVariable v) {
v.getIRVariable() = getIRVariableForParameterNode(p) and
exists(Position pos | p.isParameterOf(_, pos) |
pos instanceof DirectPosition and

View File

@@ -550,11 +550,14 @@ class SsaPhiNode extends Node, TSsaPhiNode {
* `fromBackEdge` is true if data flows along a back-edge,
* and `false` otherwise.
*/
cached
final Node getAnInput(boolean fromBackEdge) {
localFlowStep(result, this) and
if phi.getBasicBlock().dominates(result.getBasicBlock())
then fromBackEdge = true
else fromBackEdge = false
exists(IRBlock bPhi, IRBlock bResult |
bPhi = phi.getBasicBlock() and bResult = result.getBasicBlock()
|
if bPhi.dominates(bResult) then fromBackEdge = true else fromBackEdge = false
)
}
/** Gets a node that is used as input to this phi node. */
@@ -781,26 +784,12 @@ class IndirectArgumentOutNode extends Node, TIndirectArgumentOutNode, PartialDef
override Expr getDefinedExpr() { result = operand.getDef().getUnconvertedResultExpression() }
}
pragma[nomagic]
predicate indirectReturnOutNodeOperand0(CallInstruction call, Operand operand, int indirectionIndex) {
Ssa::hasRawIndirectInstruction(call, indirectionIndex) and
operandForFullyConvertedCall(operand, call)
}
pragma[nomagic]
predicate indirectReturnOutNodeInstruction0(
CallInstruction call, Instruction instr, int indirectionIndex
) {
Ssa::hasRawIndirectInstruction(call, indirectionIndex) and
instructionForFullyConvertedCall(instr, call)
}
/**
* Holds if `node` is an indirect operand with columns `(operand, indirectionIndex)`, and
* `operand` represents a use of the fully converted value of `call`.
*/
private predicate hasOperand(Node node, CallInstruction call, int indirectionIndex, Operand operand) {
indirectReturnOutNodeOperand0(call, operand, indirectionIndex) and
operandForFullyConvertedCall(operand, call) and
hasOperandAndIndex(node, operand, indirectionIndex)
}
@@ -813,7 +802,7 @@ private predicate hasOperand(Node node, CallInstruction call, int indirectionInd
private predicate hasInstruction(
Node node, CallInstruction call, int indirectionIndex, Instruction instr
) {
indirectReturnOutNodeInstruction0(call, instr, indirectionIndex) and
instructionForFullyConvertedCall(instr, call) and
hasInstructionAndIndex(node, instr, indirectionIndex)
}
@@ -1534,6 +1523,25 @@ private module Cached {
)
}
/**
* Holds if `operand.getDef() = instr`, but there exists a `StoreInstruction` that
* writes to an address that is equivalent to the value computed by `instr` in
* between `instr` and `operand`, and therefore there should not be flow from `*instr`
* to `*operand`.
*/
pragma[nomagic]
private predicate isStoredToBetween(Instruction instr, Operand operand) {
simpleOperandLocalFlowStep(pragma[only_bind_into](instr), pragma[only_bind_into](operand)) and
exists(StoreInstruction store, IRBlock block, int storeIndex, int instrIndex, int operandIndex |
store.getDestinationAddress() = instr and
block.getInstruction(storeIndex) = store and
block.getInstruction(instrIndex) = instr and
block.getInstruction(operandIndex) = operand.getUse() and
instrIndex < storeIndex and
storeIndex < operandIndex
)
}
private predicate indirectionInstructionFlow(
RawIndirectInstruction nodeFrom, IndirectOperand nodeTo
) {
@@ -1543,7 +1551,8 @@ private module Cached {
simpleOperandLocalFlowStep(pragma[only_bind_into](instr), pragma[only_bind_into](operand))
|
hasOperandAndIndex(nodeTo, operand, pragma[only_bind_into](indirectionIndex)) and
hasInstructionAndIndex(nodeFrom, instr, pragma[only_bind_into](indirectionIndex))
hasInstructionAndIndex(nodeFrom, instr, pragma[only_bind_into](indirectionIndex)) and
not isStoredToBetween(instr, operand)
)
}

View File

@@ -87,6 +87,30 @@ module ProductFlow {
* dataflow graph.
*/
default predicate isBarrierIn2(DataFlow::Node node) { none() }
/**
* Gets the virtual dispatch branching limit when calculating field flow in the first
* projection of the product dataflow graph.
*
* This can be overridden to a smaller value to improve performance (a
* value of 0 disables field flow), or a larger value to get more results.
*/
default int fieldFlowBranchLimit1() {
// NOTE: This should be synchronized with the default value in the shared dataflow library
result = 2
}
/**
* Gets the virtual dispatch branching limit when calculating field flow in the second
* projection of the product dataflow graph.
*
* This can be overridden to a smaller value to improve performance (a
* value of 0 disables field flow), or a larger value to get more results.
*/
default int fieldFlowBranchLimit2() {
// NOTE: This should be synchronized with the default value in the shared dataflow library
result = 2
}
}
/**
@@ -272,6 +296,30 @@ module ProductFlow {
* dataflow graph.
*/
default predicate isBarrierIn2(DataFlow::Node node) { none() }
/**
* Gets the virtual dispatch branching limit when calculating field flow in the first
* projection of the product dataflow graph.
*
* This can be overridden to a smaller value to improve performance (a
* value of 0 disables field flow), or a larger value to get more results.
*/
default int fieldFlowBranchLimit1() {
// NOTE: This should be synchronized with the default value in the shared dataflow library
result = 2
}
/**
* Gets the virtual dispatch branching limit when calculating field flow in the second
* projection of the product dataflow graph.
*
* This can be overridden to a smaller value to improve performance (a
* value of 0 disables field flow), or a larger value to get more results.
*/
default int fieldFlowBranchLimit2() {
// NOTE: This should be synchronized with the default value in the shared dataflow library
result = 2
}
}
/**
@@ -335,6 +383,8 @@ module ProductFlow {
}
predicate isBarrierIn(DataFlow::Node node) { Config::isBarrierIn1(node) }
int fieldFlowBranchLimit() { result = Config::fieldFlowBranchLimit1() }
}
private module Flow1 = DataFlow::GlobalWithState<Config1>;
@@ -367,6 +417,8 @@ module ProductFlow {
}
predicate isBarrierIn(DataFlow::Node node) { Config::isBarrierIn2(node) }
int fieldFlowBranchLimit() { result = Config::fieldFlowBranchLimit2() }
}
private module Flow2 = DataFlow::GlobalWithState<Config2>;

View File

@@ -10,32 +10,35 @@ private import ssa0.SsaInternals as SsaInternals0
import SsaInternalsCommon
private module SourceVariables {
int getMaxIndirectionForIRVariable(IRVariable var) {
exists(Type type, boolean isGLValue |
var.getLanguageType().hasType(type, isGLValue) and
if isGLValue = true
then result = 1 + getMaxIndirectionsForType(type)
else result = getMaxIndirectionsForType(type)
)
}
cached
private newtype TSourceVariable =
TSourceIRVariable(BaseIRVariable baseVar, int ind) {
ind = [0 .. getMaxIndirectionForIRVariable(baseVar.getIRVariable())]
} or
TCallVariable(AllocationInstruction call, int ind) {
ind = [0 .. countIndirectionsForCppType(getResultLanguageType(call))]
TMkSourceVariable(SsaInternals0::SourceVariable base, int ind) {
ind = [0 .. countIndirectionsForCppType(base.getLanguageType()) + 1]
}
abstract class SourceVariable extends TSourceVariable {
class SourceVariable extends TSourceVariable {
SsaInternals0::SourceVariable base;
int ind;
bindingset[ind]
SourceVariable() { any() }
SourceVariable() { this = TMkSourceVariable(base, ind) }
/** Gets the IR variable associated with this `SourceVariable`, if any. */
IRVariable getIRVariable() { result = base.(BaseIRVariable).getIRVariable() }
/**
* Gets the base source variable (i.e., the variable without any
* indirections) of this source variable.
*/
SsaInternals0::SourceVariable getBaseVariable() { result = base }
/** Gets a textual representation of this element. */
abstract string toString();
string toString() {
ind = 0 and
result = this.getBaseVariable().toString()
or
ind > 0 and
result = this.getBaseVariable().toString() + " indirection"
}
/**
* Gets the number of loads performed on the base source variable
@@ -43,65 +46,19 @@ private module SourceVariables {
*/
int getIndirection() { result = ind }
/**
* Gets the base source variable (i.e., the variable without any
* indirections) of this source variable.
*/
abstract BaseSourceVariable getBaseVariable();
/** Holds if this variable is a glvalue. */
predicate isGLValue() { none() }
predicate isGLValue() { ind = 0 }
/**
* Gets the type of this source variable. If `isGLValue()` holds, then
* the type of this source variable should be thought of as "pointer
* to `getType()`".
*/
abstract DataFlowType getType();
}
class SourceIRVariable extends SourceVariable, TSourceIRVariable {
BaseIRVariable var;
SourceIRVariable() { this = TSourceIRVariable(var, ind) }
IRVariable getIRVariable() { result = var.getIRVariable() }
override BaseIRVariable getBaseVariable() { result.getIRVariable() = this.getIRVariable() }
override string toString() {
ind = 0 and
result = this.getIRVariable().toString()
or
ind > 0 and
result = this.getIRVariable().toString() + " indirection"
DataFlowType getType() {
if this.isGLValue()
then result = base.getType()
else result = getTypeImpl(base.getType(), ind - 1)
}
override predicate isGLValue() { ind = 0 }
override DataFlowType getType() {
if ind = 0 then result = var.getType() else result = getTypeImpl(var.getType(), ind - 1)
}
}
class CallVariable extends SourceVariable, TCallVariable {
AllocationInstruction call;
CallVariable() { this = TCallVariable(call, ind) }
AllocationInstruction getCall() { result = call }
override BaseCallVariable getBaseVariable() { result.getCallInstruction() = call }
override string toString() {
ind = 0 and
result = "Call"
or
ind > 0 and
result = "Call indirection"
}
override DataFlowType getType() { result = getTypeImpl(call.getResultType(), ind) }
}
}
@@ -117,7 +74,7 @@ predicate hasRawIndirectOperand(Operand op, int indirectionIndex) {
type = getLanguageType(op) and
m = countIndirectionsForCppType(type) and
indirectionIndex = [1 .. m] and
not exists(getIRRepresentationOfIndirectOperand(op, indirectionIndex))
not hasIRRepresentationOfIndirectOperand(op, indirectionIndex, _, _)
)
}
@@ -131,14 +88,15 @@ predicate hasRawIndirectInstruction(Instruction instr, int indirectionIndex) {
type = getResultLanguageType(instr) and
m = countIndirectionsForCppType(type) and
indirectionIndex = [1 .. m] and
not exists(getIRRepresentationOfIndirectInstruction(instr, indirectionIndex))
not hasIRRepresentationOfIndirectInstruction(instr, indirectionIndex, _, _)
)
}
cached
private newtype TDefOrUseImpl =
TDefImpl(Operand address, int indirectionIndex) {
exists(Instruction base | isDef(_, _, address, base, _, indirectionIndex) |
TDefImpl(BaseSourceVariableInstruction base, Operand address, int indirectionIndex) {
isDef(_, _, address, base, _, indirectionIndex) and
(
// We only include the definition if the SSA pruning stage
// concluded that the definition is live after the write.
any(SsaInternals0::Def def).getAddressOperand() = address
@@ -148,9 +106,9 @@ private newtype TDefOrUseImpl =
base.(VariableAddressInstruction).getAstVariable() instanceof GlobalLikeVariable
)
} or
TUseImpl(Operand operand, int indirectionIndex) {
isUse(_, operand, _, _, indirectionIndex) and
not isDef(_, _, operand, _, _, _)
TUseImpl(BaseSourceVariableInstruction base, Operand operand, int indirectionIndex) {
isUse(_, operand, base, _, indirectionIndex) and
not isDef(true, _, operand, _, _, _)
} or
TGlobalUse(GlobalLikeVariable v, IRFunction f, int indirectionIndex) {
// Represents a final "use" of a global variable to ensure that
@@ -236,7 +194,7 @@ abstract private class DefOrUseImpl extends TDefOrUseImpl {
/**
* Gets the instruction that computes the base of this definition or use.
* This is always a `VariableAddressInstruction` or an `AllocationInstruction`.
* This is always a `VariableAddressInstruction` or an `CallInstruction`.
*/
abstract BaseSourceVariableInstruction getBase();
@@ -308,15 +266,17 @@ abstract class DefImpl extends DefOrUseImpl {
}
private class DirectDef extends DefImpl, TDefImpl {
DirectDef() { this = TDefImpl(address, ind) }
BaseSourceVariableInstruction base;
override BaseSourceVariableInstruction getBase() { isDef(_, _, address, result, _, _) }
DirectDef() { this = TDefImpl(base, address, ind) }
override int getIndirection() { isDef(_, _, address, _, result, ind) }
override BaseSourceVariableInstruction getBase() { result = base }
override Node0Impl getValue() { isDef(_, result, address, _, _, _) }
override int getIndirection() { isDef(_, _, address, base, result, ind) }
override predicate isCertain() { isDef(true, _, address, _, _, ind) }
override Node0Impl getValue() { isDef(_, result, address, base, _, _) }
override predicate isCertain() { isDef(true, _, address, base, _, ind) }
}
private class IteratorDef extends DefImpl, TIteratorDef {
@@ -359,6 +319,7 @@ abstract class UseImpl extends DefOrUseImpl {
abstract private class OperandBasedUse extends UseImpl {
Operand operand;
BaseSourceVariableInstruction base;
bindingset[ind]
OperandBasedUse() { any() }
@@ -366,50 +327,44 @@ abstract private class OperandBasedUse extends UseImpl {
final override predicate hasIndexInBlock(IRBlock block, int index) {
// See the comment in `ssa0`'s `OperandBasedUse` for an explanation of this
// predicate's implementation.
exists(BaseSourceVariableInstruction base | base = this.getBase() |
if base.getAst() = any(Cpp::PostfixCrementOperation c).getOperand()
then
exists(Operand op, int indirectionIndex, int indirection |
indirectionIndex = this.getIndirectionIndex() and
indirection = this.getIndirection() and
op =
min(Operand cand, int i |
isUse(_, cand, base, indirection, indirectionIndex) and
block.getInstruction(i) = cand.getUse()
|
cand order by i
) and
block.getInstruction(index) = op.getUse()
)
else operand.getUse() = block.getInstruction(index)
)
if base.getAst() = any(Cpp::PostfixCrementOperation c).getOperand()
then
exists(Operand op, int indirectionIndex, int indirection |
indirectionIndex = this.getIndirectionIndex() and
indirection = this.getIndirection() and
op =
min(Operand cand, int i |
isUse(_, cand, base, indirection, indirectionIndex) and
block.getInstruction(i) = cand.getUse()
|
cand order by i
) and
block.getInstruction(index) = op.getUse()
)
else operand.getUse() = block.getInstruction(index)
}
final override BaseSourceVariableInstruction getBase() { result = base }
final Operand getOperand() { result = operand }
final override Cpp::Location getLocation() { result = operand.getLocation() }
}
private class DirectUse extends OperandBasedUse, TUseImpl {
DirectUse() { this = TUseImpl(operand, ind) }
DirectUse() { this = TUseImpl(base, operand, ind) }
override int getIndirection() { isUse(_, operand, _, result, ind) }
override int getIndirection() { isUse(_, operand, base, result, ind) }
override BaseSourceVariableInstruction getBase() { isUse(_, operand, result, _, ind) }
override predicate isCertain() { isUse(true, operand, _, _, ind) }
override predicate isCertain() { isUse(true, operand, base, _, ind) }
override Node getNode() { nodeHasOperand(result, operand, ind) }
}
private class IteratorUse extends OperandBasedUse, TIteratorUse {
BaseSourceVariableInstruction container;
IteratorUse() { this = TIteratorUse(operand, base, ind) }
IteratorUse() { this = TIteratorUse(operand, container, ind) }
override int getIndirection() { isIteratorUse(container, operand, result, ind) }
override BaseSourceVariableInstruction getBase() { result = container }
override int getIndirection() { isIteratorUse(base, operand, result, ind) }
override predicate isCertain() { none() }
@@ -655,7 +610,7 @@ private predicate indirectConversionFlowStep(Node nFrom, Node nTo) {
hasOperandAndIndex(nFrom, op1, pragma[only_bind_into](indirectionIndex)) and
hasOperandAndIndex(nTo, op2, indirectionIndex - 1) and
instr = op2.getDef() and
isDereference(instr, op1)
isDereference(instr, op1, _)
)
)
}
@@ -683,12 +638,24 @@ private predicate adjustForPointerArith(PostUpdateNode pun, UseOrPhi use) {
)
}
/**
* Holds if `nodeFrom` flows to `nodeTo` because there is `def-use` or
* `use-use` flow from `defOrUse` to `use`.
*
* `uncertain` is `true` if the `defOrUse` is an uncertain definition.
*/
private predicate localSsaFlow(
SsaDefOrUse defOrUse, Node nodeFrom, UseOrPhi use, Node nodeTo, boolean uncertain
) {
nodeToDefOrUse(nodeFrom, defOrUse, uncertain) and
adjacentDefRead(defOrUse, use) and
useToNode(use, nodeTo) and
nodeFrom != nodeTo
}
private predicate ssaFlowImpl(SsaDefOrUse defOrUse, Node nodeFrom, Node nodeTo, boolean uncertain) {
exists(UseOrPhi use |
nodeToDefOrUse(nodeFrom, defOrUse, uncertain) and
adjacentDefRead(defOrUse, use) and
useToNode(use, nodeTo) and
nodeFrom != nodeTo
localSsaFlow(defOrUse, nodeFrom, use, nodeTo, uncertain)
or
// Initial global variable value to a first use
nodeFrom.(InitialGlobalValue).getGlobalDef() = defOrUse and
@@ -729,19 +696,99 @@ predicate ssaFlow(Node nodeFrom, Node nodeTo) {
)
}
private predicate isArgumentOfCallable(DataFlowCall call, ArgumentNode arg) {
arg.argumentOf(call, _)
private predicate isArgumentOfCallableInstruction(DataFlowCall call, Instruction instr) {
isArgumentOfCallableOperand(call, unique( | | getAUse(instr)))
}
/** Holds if there is def-use or use-use flow from `pun` to `nodeTo`. */
predicate postUpdateFlow(PostUpdateNode pun, Node nodeTo) {
exists(UseOrPhi use, Node preUpdate |
private predicate isArgumentOfCallableOperand(DataFlowCall call, Operand operand) {
operand.(ArgumentOperand).getCall() = call
or
exists(FieldAddressInstruction fai |
fai.getObjectAddressOperand() = operand and
isArgumentOfCallableInstruction(call, fai)
)
or
exists(Instruction deref |
isArgumentOfCallableInstruction(call, deref) and
isDereference(deref, operand, _)
)
or
exists(Instruction instr |
isArgumentOfCallableInstruction(call, instr) and
conversionFlow(operand, instr, _, _)
)
}
private predicate isArgumentOfCallable(DataFlowCall call, Node n) {
isArgumentOfCallableOperand(call, n.asOperand())
or
exists(Operand op |
n.(IndirectOperand).hasOperandAndIndirectionIndex(op, _) and
isArgumentOfCallableOperand(call, op)
)
or
exists(Instruction instr |
n.(IndirectInstruction).hasInstructionAndIndirectionIndex(instr, _) and
isArgumentOfCallableInstruction(call, instr)
)
}
/**
* Holds if there is use-use flow from `pun`'s pre-update node to `n`.
*/
private predicate postUpdateNodeToFirstUse(PostUpdateNode pun, Node n) {
exists(UseOrPhi use |
adjustForPointerArith(pun, use) and
useToNode(use, nodeTo) and
useToNode(use, n)
)
}
private predicate stepUntilNotInCall(DataFlowCall call, Node n1, Node n2) {
isArgumentOfCallable(call, n1) and
exists(Node mid | localSsaFlow(_, n1, _, mid, _) |
isArgumentOfCallable(call, mid) and
stepUntilNotInCall(call, mid, n2)
or
not isArgumentOfCallable(call, mid) and
mid = n2
)
}
bindingset[n1, n2]
pragma[inline_late]
private predicate isArgumentOfSameCall(DataFlowCall call, Node n1, Node n2) {
isArgumentOfCallable(call, n1) and isArgumentOfCallable(call, n2)
}
/**
* Holds if there is def-use or use-use flow from `pun` to `nodeTo`.
*
* Note: This is more complex than it sounds. Consider a call such as:
* ```cpp
* write_first_argument(x, x);
* sink(x);
* ```
* Assume flow comes out of the first argument to `write_first_argument`. We
* don't want flow to go to the `x` that's also an argument to
* `write_first_argument` (because we just flowed out of that function, and we
* don't want to flow back into it again).
*
* We do, however, want flow from the output argument to `x` on the next line, and
* similarly we want flow from the second argument of `write_first_argument` to `x`
* on the next line.
*/
predicate postUpdateFlow(PostUpdateNode pun, Node nodeTo) {
exists(Node preUpdate, Node mid |
preUpdate = pun.getPreUpdateNode() and
not exists(DataFlowCall call |
isArgumentOfCallable(call, preUpdate) and isArgumentOfCallable(call, nodeTo)
postUpdateNodeToFirstUse(pun, mid)
|
exists(DataFlowCall call |
isArgumentOfSameCall(call, preUpdate, mid) and
stepUntilNotInCall(call, mid, nodeTo)
)
or
not isArgumentOfSameCall(_, preUpdate, mid) and
nodeTo = mid
)
}

View File

@@ -6,6 +6,7 @@ private import DataFlowImplCommon as DataFlowImplCommon
private import DataFlowUtil
private import semmle.code.cpp.models.interfaces.PointerWrapper
private import DataFlowPrivate
private import semmle.code.cpp.ir.ValueNumbering
/**
* Holds if `operand` is an operand that is not used by the dataflow library.
@@ -146,14 +147,6 @@ int countIndirectionsForCppType(LanguageType langType) {
)
}
/**
* A `CallInstruction` that calls an allocation function such
* as `malloc` or `operator new`.
*/
class AllocationInstruction extends CallInstruction {
AllocationInstruction() { this.getStaticCallTarget() instanceof Cpp::AllocationFunction }
}
private predicate isIndirectionType(Type t) { t instanceof Indirection }
private predicate hasUnspecifiedBaseType(Indirection t, Type base) {
@@ -327,10 +320,20 @@ private module IteratorIndirections {
}
}
predicate isDereference(Instruction deref, Operand address) {
any(Indirection ind).isAdditionalDereference(deref, address)
/**
* Holds if `deref` is the result of loading the value at the address
* represented by `address`.
*
* If `additional = true` then the dereference comes from an `Indirection`
* class (such as a call to an iterator's `operator*`), and if
* `additional = false` the dereference is a `LoadInstruction`.
*/
predicate isDereference(Instruction deref, Operand address, boolean additional) {
any(Indirection ind).isAdditionalDereference(deref, address) and
additional = true
or
deref.(LoadInstruction).getSourceAddressOperand() = address
deref.(LoadInstruction).getSourceAddressOperand() = address and
additional = false
}
predicate isWrite(Node0Impl value, Operand address, boolean certain) {
@@ -368,17 +371,22 @@ newtype TBaseSourceVariable =
// Each IR variable gets its own source variable
TBaseIRVariable(IRVariable var) or
// Each allocation gets its own source variable
TBaseCallVariable(AllocationInstruction call)
TBaseCallVariable(CallInstruction call) { not call.getResultIRType() instanceof IRVoidType }
abstract class BaseSourceVariable extends TBaseSourceVariable {
abstract private class AbstractBaseSourceVariable extends TBaseSourceVariable {
/** Gets a textual representation of this element. */
abstract string toString();
/** Gets the type of this base source variable. */
abstract DataFlowType getType();
final DataFlowType getType() { this.getLanguageType().hasUnspecifiedType(result, _) }
/** Gets the `CppType` of this base source variable. */
abstract CppType getLanguageType();
}
class BaseIRVariable extends BaseSourceVariable, TBaseIRVariable {
final class BaseSourceVariable = AbstractBaseSourceVariable;
class BaseIRVariable extends AbstractBaseSourceVariable, TBaseIRVariable {
IRVariable var;
IRVariable getIRVariable() { result = var }
@@ -387,19 +395,19 @@ class BaseIRVariable extends BaseSourceVariable, TBaseIRVariable {
override string toString() { result = var.toString() }
override DataFlowType getType() { result = var.getType() }
override CppType getLanguageType() { result = var.getLanguageType() }
}
class BaseCallVariable extends BaseSourceVariable, TBaseCallVariable {
AllocationInstruction call;
class BaseCallVariable extends AbstractBaseSourceVariable, TBaseCallVariable {
CallInstruction call;
BaseCallVariable() { this = TBaseCallVariable(call) }
AllocationInstruction getCallInstruction() { result = call }
CallInstruction getCallInstruction() { result = call }
override string toString() { result = call.toString() }
override DataFlowType getType() { result = call.getResultType() }
override CppType getLanguageType() { result = getResultLanguageType(call) }
}
/**
@@ -499,8 +507,7 @@ private class BaseIRVariableInstruction extends BaseSourceVariableInstruction,
override BaseIRVariable getBaseSourceVariable() { result.getIRVariable() = this.getIRVariable() }
}
private class BaseAllocationInstruction extends BaseSourceVariableInstruction, AllocationInstruction
{
private class BaseCallInstruction extends BaseSourceVariableInstruction, CallInstruction {
override BaseCallVariable getBaseSourceVariable() { result.getCallInstruction() = this }
}
@@ -548,7 +555,7 @@ private module Cached {
isDef(_, value, iteratorDerefAddress, iteratorBase, numberOfLoads + 2, 0) and
isUse(_, iteratorAddress, iteratorBase, numberOfLoads + 1, 0) and
iteratorBase.getResultType() instanceof Interfaces::Iterator and
isDereference(iteratorAddress.getDef(), read.getArgumentDef().getAUse()) and
isDereference(iteratorAddress.getDef(), read.getArgumentDef().getAUse(), _) and
memory = read.getSideEffectOperand().getAnyDef()
)
}
@@ -784,11 +791,14 @@ private module Cached {
* instead associated with the operand returned by this predicate.
*/
cached
Operand getIRRepresentationOfIndirectOperand(Operand operand, int indirectionIndex) {
predicate hasIRRepresentationOfIndirectOperand(
Operand operand, int indirectionIndex, Operand operandRepr, int indirectionIndexRepr
) {
indirectionIndex = [1 .. countIndirectionsForCppType(getLanguageType(operand))] and
exists(Instruction load |
isDereference(load, operand) and
result = unique( | | getAUse(load)) and
isUseImpl(operand, _, indirectionIndex - 1)
isDereference(load, operand, false) and
operandRepr = unique( | | getAUse(load)) and
indirectionIndexRepr = indirectionIndex - 1
)
}
@@ -800,12 +810,15 @@ private module Cached {
* instead associated with the instruction returned by this predicate.
*/
cached
Instruction getIRRepresentationOfIndirectInstruction(Instruction instr, int indirectionIndex) {
predicate hasIRRepresentationOfIndirectInstruction(
Instruction instr, int indirectionIndex, Instruction instrRepr, int indirectionIndexRepr
) {
indirectionIndex = [1 .. countIndirectionsForCppType(getResultLanguageType(instr))] and
exists(Instruction load, Operand address |
address.getDef() = instr and
isDereference(load, address) and
isUseImpl(address, _, indirectionIndex - 1) and
result = load
isDereference(load, address, false) and
instrRepr = load and
indirectionIndexRepr = indirectionIndex - 1
)
}
@@ -826,7 +839,7 @@ private module Cached {
or
exists(int ind0 |
exists(Operand address |
isDereference(operand.getDef(), address) and
isDereference(operand.getDef(), address, _) and
isUseImpl(address, base, ind0)
)
or
@@ -868,7 +881,7 @@ private module Cached {
* to a specific address.
*/
private predicate isCertainAddress(Operand operand) {
operand.getDef() instanceof VariableAddressInstruction
valueNumberOfOperand(operand).getAnInstruction() instanceof VariableAddressInstruction
or
operand.getType() instanceof Cpp::ReferenceType
}
@@ -896,7 +909,7 @@ private module Cached {
)
or
exists(Operand address, boolean certain0 |
isDereference(operand.getDef(), address) and
isDereference(operand.getDef(), address, _) and
isDefImpl(address, base, ind - 1, certain0)
|
if isCertainAddress(operand) then certain = certain0 else certain = false

View File

@@ -0,0 +1,10 @@
/**
* Provides C++-specific definitions for use in the taint tracking library.
*/
private import codeql.dataflow.TaintTracking
private import DataFlowImplSpecific
module CppTaintTracking implements InputSig<CppDataFlow> {
import TaintTrackingUtil
}

View File

@@ -57,7 +57,7 @@ private predicate operandToInstructionTaintStep(Operand opFrom, Instruction inst
)
or
// Taint flow from an address to its dereference.
Ssa::isDereference(instrTo, opFrom)
Ssa::isDereference(instrTo, opFrom, _)
or
// Unary instructions tend to preserve enough information in practice that we
// want taint to flow through.
@@ -112,7 +112,7 @@ predicate defaultAdditionalTaintStep(DataFlow::Node src, DataFlow::Node sink) {
* of `c` at sinks and inputs to additional taint steps.
*/
bindingset[node]
predicate defaultImplicitTaintRead(DataFlow::Node node, DataFlow::Content c) { none() }
predicate defaultImplicitTaintRead(DataFlow::Node node, DataFlow::ContentSet c) { none() }
/**
* Holds if `node` should be a sanitizer in all global taint flow configurations

View File

@@ -15,15 +15,12 @@ private import semmle.code.cpp.ir.dataflow.internal.DataFlowUtil
private import semmle.code.cpp.ir.dataflow.internal.SsaInternalsCommon
private module SourceVariables {
class SourceVariable instanceof BaseSourceVariable {
string toString() { result = BaseSourceVariable.super.toString() }
class SourceVariable extends BaseSourceVariable {
/**
* Gets the base source variable of this `SourceVariable`.
*/
BaseSourceVariable getBaseVariable() { result = this }
}
class SourceIRVariable = BaseIRVariable;
class CallVariable = BaseCallVariable;
}
import SourceVariables

View File

@@ -1,75 +0,0 @@
/**
* Provides classes for performing local (intra-procedural) and
* global (inter-procedural) taint-tracking analyses.
*/
import TaintTrackingParameter::Public
private import TaintTrackingParameter::Private
private module AddTaintDefaults<DataFlowInternal::FullStateConfigSig Config> implements
DataFlowInternal::FullStateConfigSig
{
import Config
predicate isBarrier(DataFlow::Node node) {
Config::isBarrier(node) or defaultTaintSanitizer(node)
}
predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
Config::isAdditionalFlowStep(node1, node2) or
defaultAdditionalTaintStep(node1, node2)
}
predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
Config::allowImplicitRead(node, c)
or
(
Config::isSink(node) or
Config::isSink(node, _) or
Config::isAdditionalFlowStep(node, _) or
Config::isAdditionalFlowStep(node, _, _, _)
) and
defaultImplicitTaintRead(node, c)
}
}
/**
* Constructs a global taint tracking computation.
*/
module Global<DataFlow::ConfigSig Config> implements DataFlow::GlobalFlowSig {
private module Config0 implements DataFlowInternal::FullStateConfigSig {
import DataFlowInternal::DefaultState<Config>
import Config
}
private module C implements DataFlowInternal::FullStateConfigSig {
import AddTaintDefaults<Config0>
}
import DataFlowInternal::Impl<C>
}
/** DEPRECATED: Use `Global` instead. */
deprecated module Make<DataFlow::ConfigSig Config> implements DataFlow::GlobalFlowSig {
import Global<Config>
}
/**
* Constructs a global taint tracking computation using flow state.
*/
module GlobalWithState<DataFlow::StateConfigSig Config> implements DataFlow::GlobalFlowSig {
private module Config0 implements DataFlowInternal::FullStateConfigSig {
import Config
}
private module C implements DataFlowInternal::FullStateConfigSig {
import AddTaintDefaults<Config0>
}
import DataFlowInternal::Impl<C>
}
/** DEPRECATED: Use `GlobalWithState` instead. */
deprecated module MakeWithState<DataFlow::StateConfigSig Config> implements DataFlow::GlobalFlowSig {
import GlobalWithState<Config>
}

View File

@@ -55,6 +55,7 @@ private newtype TOpcode =
TVariableAddress() or
TFieldAddress() or
TFunctionAddress() or
TVirtualDeleteFunctionAddress() or
TElementsAddress() or
TConstant() or
TStringConstant() or
@@ -887,6 +888,15 @@ module Opcode {
final override string toString() { result = "FunctionAddress" }
}
/**
* The `Opcode` for a `VirtualDeleteFunctionAddress`.
*
* See the `VirtualDeleteFunctionAddressInstruction` documentation for more details.
*/
class VirtualDeleteFunctionAddress extends Opcode, TVirtualDeleteFunctionAddress {
final override string toString() { result = "VirtualDeleteFunctionAddress" }
}
/**
* The `Opcode` for a `ConstantInstruction`.
*

View File

@@ -576,6 +576,22 @@ class FunctionAddressInstruction extends FunctionInstruction {
FunctionAddressInstruction() { this.getOpcode() instanceof Opcode::FunctionAddress }
}
/**
* An instruction that returns the address of a "virtual" delete function.
*
* This function, which does not actually exist in the source code, is used to
* delete objects of a class with a virtual destructor. In that case the deacllocation
* function is selected at runtime based on the dynamic type of the object. So this
* function dynamically dispatches to the correct deallocation function.
* It also should pass in the required extra arguments to the deallocation function
* which may differ dynamically depending on the type of the object.
*/
class VirtualDeleteFunctionAddressInstruction extends Instruction {
VirtualDeleteFunctionAddressInstruction() {
this.getOpcode() instanceof Opcode::VirtualDeleteFunctionAddress
}
}
/**
* An instruction that initializes a parameter of the enclosing function with the value of the
* corresponding argument passed by the caller.

View File

@@ -576,6 +576,22 @@ class FunctionAddressInstruction extends FunctionInstruction {
FunctionAddressInstruction() { this.getOpcode() instanceof Opcode::FunctionAddress }
}
/**
* An instruction that returns the address of a "virtual" delete function.
*
* This function, which does not actually exist in the source code, is used to
* delete objects of a class with a virtual destructor. In that case the deacllocation
* function is selected at runtime based on the dynamic type of the object. So this
* function dynamically dispatches to the correct deallocation function.
* It also should pass in the required extra arguments to the deallocation function
* which may differ dynamically depending on the type of the object.
*/
class VirtualDeleteFunctionAddressInstruction extends Instruction {
VirtualDeleteFunctionAddressInstruction() {
this.getOpcode() instanceof Opcode::VirtualDeleteFunctionAddress
}
}
/**
* An instruction that initializes a parameter of the enclosing function with the value of the
* corresponding argument passed by the caller.

View File

@@ -120,9 +120,9 @@ private predicate hasDefaultSideEffect(Call call, ParameterIndex i, boolean buff
}
/**
* A `Call` or `NewOrNewArrayExpr`.
* A `Call` or `NewOrNewArrayExpr` or `DeleteOrDeleteArrayExpr`.
*
* Both kinds of expression invoke a function as part of their evaluation. This class provides a
* All kinds of expression invoke a function as part of their evaluation. This class provides a
* way to treat both kinds of function similarly, and to get the invoked `Function`.
*/
class CallOrAllocationExpr extends Expr {
@@ -130,6 +130,8 @@ class CallOrAllocationExpr extends Expr {
this instanceof Call
or
this instanceof NewOrNewArrayExpr
or
this instanceof DeleteOrDeleteArrayExpr
}
/** Gets the `Function` invoked by this expression, if known. */
@@ -137,6 +139,8 @@ class CallOrAllocationExpr extends Expr {
result = this.(Call).getTarget()
or
result = this.(NewOrNewArrayExpr).getAllocator()
or
result = this.(DeleteOrDeleteArrayExpr).getDeallocator()
}
}

View File

@@ -350,6 +350,9 @@ class TranslatedCallSideEffects extends TranslatedSideEffects, TTranslatedCallSi
or
expr instanceof NewOrNewArrayExpr and
result = getTranslatedAllocatorCall(expr).getInstruction(CallTag())
or
expr instanceof DeleteOrDeleteArrayExpr and
result = getTranslatedDeleteOrDeleteArray(expr).getInstruction(CallTag())
}
}

View File

@@ -77,17 +77,17 @@ private predicate ignoreExprAndDescendants(Expr expr) {
newExpr.getInitializer().getFullyConverted() = expr
)
or
exists(DeleteOrDeleteArrayExpr deleteExpr |
// Ignore the deallocator call, because we always synthesize it.
deleteExpr.getDeallocatorCall() = expr
)
or
// Do not translate input/output variables in GNU asm statements
// getRealParent(expr) instanceof AsmStmt
// or
ignoreExprAndDescendants(getRealParent(expr)) // recursive case
or
// We do not yet translate destructors properly, so for now we ignore any
// custom deallocator call, if present.
exists(DeleteExpr deleteExpr | deleteExpr.getAllocatorCall() = expr)
or
exists(DeleteArrayExpr deleteArrayExpr | deleteArrayExpr.getAllocatorCall() = expr)
or
// va_start doesn't evaluate its argument, so we don't need to translate it.
exists(BuiltInVarArgsStart vaStartExpr |
vaStartExpr.getLastNamedParameter().getFullyConverted() = expr
)
@@ -104,6 +104,12 @@ private predicate ignoreExprOnly(Expr expr) {
newExpr.getAllocatorCall() = expr
)
or
exists(DeleteOrDeleteArrayExpr deleteExpr |
// Ignore the destructor call as we don't model it yet. Don't ignore
// its arguments, though, as they are the arguments to the deallocator.
deleteExpr.getDestructorCall() = expr
)
or
// The extractor deliberately emits an `ErrorExpr` as the first argument to
// the allocator call, if any, of a `NewOrNewArrayExpr`. That `ErrorExpr`
// should not be translated.
@@ -111,13 +117,6 @@ private predicate ignoreExprOnly(Expr expr) {
or
not translateFunction(getEnclosingFunction(expr)) and
not Raw::varHasIRFunc(getEnclosingVariable(expr))
or
// We do not yet translate destructors properly, so for now we ignore the
// destructor call. We do, however, translate the expression being
// destructed, and that expression can be a child of the destructor call.
exists(DeleteExpr deleteExpr | deleteExpr.getDestructorCall() = expr)
or
exists(DeleteArrayExpr deleteArrayExpr | deleteArrayExpr.getDestructorCall() = expr)
}
/**
@@ -416,7 +415,9 @@ predicate hasTranslatedLoad(Expr expr) {
not ignoreExpr(expr) and
not isNativeCondition(expr) and
not isFlexibleCondition(expr) and
not ignoreLoad(expr)
not ignoreLoad(expr) and
// don't insert a load since we'll just substitute the constant value.
not isIRConstant(expr)
}
/**

View File

@@ -2017,6 +2017,66 @@ TranslatedAllocatorCall getTranslatedAllocatorCall(NewOrNewArrayExpr newExpr) {
result.getAst() = newExpr
}
/**
* The IR translation of a `delete` or `delete[]`
* expression.
*/
class TranslatedDeleteOrDeleteArrayExpr extends TranslatedNonConstantExpr, TranslatedCall {
override DeleteOrDeleteArrayExpr expr;
final override Instruction getFirstCallTargetInstruction() {
result = this.getInstruction(CallTargetTag())
}
final override Instruction getCallTargetResult() { result = this.getInstruction(CallTargetTag()) }
override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
TranslatedCall.super.hasInstruction(opcode, tag, resultType)
or
tag = CallTargetTag() and
resultType = getFunctionGLValueType() and
if exists(expr.getDeallocator())
then opcode instanceof Opcode::FunctionAddress
else opcode instanceof Opcode::VirtualDeleteFunctionAddress
}
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
result = TranslatedCall.super.getInstructionSuccessor(tag, kind)
or
tag = CallTargetTag() and
kind instanceof GotoEdge and
result = this.getFirstArgumentOrCallInstruction()
}
override Function getInstructionFunction(InstructionTag tag) {
tag = CallTargetTag() and result = expr.getDeallocator()
}
final override Type getCallResultType() { result = expr.getType() }
final override TranslatedExpr getQualifier() { none() }
final override predicate hasArguments() {
// All deallocator calls have at least one argument.
any()
}
final override int getNumberOfArguments() {
// We ignore the other arguments for now as we would have to synthesize them.
result = 1
}
final override TranslatedExpr getArgument(int index) {
// The only argument we define is the pointer to be deallocated.
index = 0 and
result = getTranslatedExpr(expr.getExpr().getFullyConverted())
}
}
TranslatedDeleteOrDeleteArrayExpr getTranslatedDeleteOrDeleteArray(DeleteOrDeleteArrayExpr newExpr) {
result.getAst() = newExpr
}
/**
* Abstract class implemented by any `TranslatedElement` that has a child
* expression that is a call to a constructor or destructor, in order to
@@ -2954,78 +3014,6 @@ class TranslatedNewArrayExpr extends TranslatedNewOrNewArrayExpr {
}
}
/**
* A placeholder for the translation of a `delete[]` expression.
*
* Proper translation is not yet implemented, but this stub implementation
* ensures that code following a `delete[]` is not unreachable.
*/
class TranslatedDeleteArrayExprPlaceHolder extends TranslatedSingleInstructionExpr {
override DeleteArrayExpr expr;
final override Instruction getFirstInstruction() {
result = this.getOperand().getFirstInstruction()
}
final override TranslatedElement getChild(int id) { id = 0 and result = this.getOperand() }
final override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = OnlyInstructionTag() and
result = this.getParent().getChildSuccessor(this) and
kind instanceof GotoEdge
}
final override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getOperand() and result = this.getInstruction(OnlyInstructionTag())
}
final override Instruction getInstructionRegisterOperand(InstructionTag tag, OperandTag operandTag) {
none()
}
final override Opcode getOpcode() { result instanceof Opcode::NoOp }
private TranslatedExpr getOperand() {
result = getTranslatedExpr(expr.getExpr().getFullyConverted())
}
}
/**
* A placeholder for the translation of a `delete` expression.
*
* Proper translation is not yet implemented, but this stub implementation
* ensures that code following a `delete` is not unreachable.
*/
class TranslatedDeleteExprPlaceHolder extends TranslatedSingleInstructionExpr {
override DeleteExpr expr;
final override Instruction getFirstInstruction() {
result = this.getOperand().getFirstInstruction()
}
final override TranslatedElement getChild(int id) { id = 0 and result = this.getOperand() }
final override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = OnlyInstructionTag() and
result = this.getParent().getChildSuccessor(this) and
kind instanceof GotoEdge
}
final override Instruction getChildSuccessor(TranslatedElement child) {
child = this.getOperand() and result = this.getInstruction(OnlyInstructionTag())
}
final override Instruction getInstructionRegisterOperand(InstructionTag tag, OperandTag operandTag) {
none()
}
final override Opcode getOpcode() { result instanceof Opcode::NoOp }
private TranslatedExpr getOperand() {
result = getTranslatedExpr(expr.getExpr().getFullyConverted())
}
}
/**
* The IR translation of a `ConditionDeclExpr`, which represents the value of the declared variable
* after conversion to `bool` in code such as:

View File

@@ -576,6 +576,22 @@ class FunctionAddressInstruction extends FunctionInstruction {
FunctionAddressInstruction() { this.getOpcode() instanceof Opcode::FunctionAddress }
}
/**
* An instruction that returns the address of a "virtual" delete function.
*
* This function, which does not actually exist in the source code, is used to
* delete objects of a class with a virtual destructor. In that case the deacllocation
* function is selected at runtime based on the dynamic type of the object. So this
* function dynamically dispatches to the correct deallocation function.
* It also should pass in the required extra arguments to the deallocation function
* which may differ dynamically depending on the type of the object.
*/
class VirtualDeleteFunctionAddressInstruction extends Instruction {
VirtualDeleteFunctionAddressInstruction() {
this.getOpcode() instanceof Opcode::VirtualDeleteFunctionAddress
}
}
/**
* An instruction that initializes a parameter of the enclosing function with the value of the
* corresponding argument passed by the caller.

View File

@@ -1,6 +1,6 @@
/**
* This file contains the range-analysis specific parts of the `cpp/invalid-pointer-deref` query
* that is used by both `AllocationToInvalidPointer.qll` and `InvalidPointerToDereference.qll`.
* This file contains the range-analysis specific parts of the `cpp/invalid-pointer-deref`
* and `cpp/overrun-write` query.
*/
private import cpp
@@ -18,7 +18,7 @@ private Instruction getABoundIn(SemBound b, IRFunction func) {
* Holds if `i <= b + delta`.
*/
pragma[inline]
private predicate boundedImpl(Instruction i, Instruction b, int delta) {
private predicate boundedImplCand(Instruction i, Instruction b, int delta) {
exists(SemBound bound, IRFunction func |
semBounded(getSemanticExpr(i), bound, delta, true, _) and
b = getABoundIn(bound, func) and
@@ -26,6 +26,15 @@ private predicate boundedImpl(Instruction i, Instruction b, int delta) {
)
}
/**
* Holds if `i <= b + delta` and `delta` is the smallest integer that satisfies
* this condition.
*/
pragma[inline]
private predicate boundedImpl(Instruction i, Instruction b, int delta) {
delta = min(int cand | boundedImplCand(i, b, cand))
}
/**
* Holds if `i <= b + delta`.
*

View File

@@ -39,6 +39,7 @@ predicate semImplies_v2(SemGuard g1, boolean b1, SemGuard g2, boolean b2) {
* Holds if `guard` directly controls the position `controlled` with the
* value `testIsTrue`.
*/
pragma[nomagic]
predicate semGuardDirectlyControlsSsaRead(
SemGuard guard, SemSsaReadPosition controlled, boolean testIsTrue
) {

View File

@@ -17,19 +17,27 @@ private import RangeUtils
private import RangeAnalysisStage
module ModulusAnalysis<DeltaSig D, BoundSig<D> Bounds, UtilSig<D> U> {
/**
* Holds if `e + delta` equals `v` at `pos`.
*/
private predicate valueFlowStepSsa(SemSsaVariable v, SemSsaReadPosition pos, SemExpr e, int delta) {
U::semSsaUpdateStep(v, e, D::fromInt(delta)) and pos.hasReadOfVar(v)
or
pragma[nomagic]
private predicate valueFlowStepSsaEqFlowCond(
SemSsaReadPosition pos, SemSsaVariable v, SemExpr e, int delta
) {
exists(SemGuard guard, boolean testIsTrue |
pos.hasReadOfVar(v) and
guard = U::semEqFlowCond(v, e, D::fromInt(delta), true, testIsTrue) and
semGuardDirectlyControlsSsaRead(guard, pos, testIsTrue)
)
}
/**
* Holds if `e + delta` equals `v` at `pos`.
*/
pragma[nomagic]
private predicate valueFlowStepSsa(SemSsaVariable v, SemSsaReadPosition pos, SemExpr e, int delta) {
U::semSsaUpdateStep(v, e, D::fromInt(delta)) and pos.hasReadOfVar(v)
or
pos.hasReadOfVar(v) and
valueFlowStepSsaEqFlowCond(pos, v, e, delta)
}
/**
* Holds if `add` is the addition of `larg` and `rarg`, neither of which are
* `ConstantIntegerExpr`s.

View File

@@ -574,16 +574,6 @@ module RangeStage<
)
}
/** Holds if `e >= 1` as determined by sign analysis. */
private predicate strictlyPositiveIntegralExpr(SemExpr e) {
semStrictlyPositive(e) and getTrackedType(e) instanceof SemIntegerType
}
/** Holds if `e <= -1` as determined by sign analysis. */
private predicate strictlyNegativeIntegralExpr(SemExpr e) {
semStrictlyNegative(e) and getTrackedType(e) instanceof SemIntegerType
}
/**
* Holds if `e1 + delta` is a valid bound for `e2`.
* - `upper = true` : `e2 <= e1 + delta`
@@ -597,27 +587,6 @@ module RangeStage<
delta = D::fromInt(0) and
(upper = true or upper = false)
or
exists(SemExpr x, SemSubExpr sub |
e2 = sub and
sub.getLeftOperand() = e1 and
sub.getRightOperand() = x
|
// `x instanceof ConstantIntegerExpr` is covered by valueFlowStep
not x instanceof SemConstantIntegerExpr and
if strictlyPositiveIntegralExpr(x)
then upper = true and delta = D::fromInt(-1)
else
if semPositive(x)
then upper = true and delta = D::fromInt(0)
else
if strictlyNegativeIntegralExpr(x)
then upper = false and delta = D::fromInt(1)
else
if semNegative(x)
then upper = false and delta = D::fromInt(0)
else none()
)
or
e2.(SemRemExpr).getRightOperand() = e1 and
semPositive(e1) and
delta = D::fromInt(-1) and
@@ -691,7 +660,7 @@ module RangeStage<
* - `upper = false` : `v >= b + delta`
*/
private predicate boundedSsa(
SemSsaVariable v, SemSsaReadPosition pos, SemBound b, D::Delta delta, boolean upper,
SemSsaVariable v, SemBound b, D::Delta delta, SemSsaReadPosition pos, boolean upper,
boolean fromBackEdge, D::Delta origdelta, SemReason reason
) {
exists(SemExpr mid, D::Delta d1, D::Delta d2, SemReason r1, SemReason r2 |
@@ -704,10 +673,13 @@ module RangeStage<
)
or
exists(D::Delta d, SemReason r1, SemReason r2 |
boundedSsa(v, pos, b, d, upper, fromBackEdge, origdelta, r2) or
boundedPhi(v, b, d, upper, fromBackEdge, origdelta, r2)
boundedSsa(pragma[only_bind_into](v), pragma[only_bind_into](b), pragma[only_bind_into](d),
pragma[only_bind_into](pos), upper, fromBackEdge, origdelta, r2)
or
boundedPhi(pragma[only_bind_into](v), pragma[only_bind_into](b), pragma[only_bind_into](d),
upper, fromBackEdge, origdelta, r2)
|
unequalIntegralSsa(v, pos, b, d, r1) and
unequalIntegralSsa(v, b, d, pos, r1) and
(
upper = true and delta = D::fromFloat(D::toFloat(d) - 1)
or
@@ -725,7 +697,7 @@ module RangeStage<
* Holds if `v != b + delta` at `pos` and `v` is of integral type.
*/
private predicate unequalIntegralSsa(
SemSsaVariable v, SemSsaReadPosition pos, SemBound b, D::Delta delta, SemReason reason
SemSsaVariable v, SemBound b, D::Delta delta, SemSsaReadPosition pos, SemReason reason
) {
exists(SemExpr e, D::Delta d1, D::Delta d2 |
unequalFlowStepIntegralSsa(v, pos, e, d1, reason) and
@@ -777,7 +749,7 @@ module RangeStage<
) {
edge.phiInput(phi, inp) and
exists(D::Delta d, boolean fromBackEdge0 |
boundedSsa(inp, edge, b, d, upper, fromBackEdge0, origdelta, reason)
boundedSsa(inp, b, d, edge, upper, fromBackEdge0, origdelta, reason)
or
boundedPhi(inp, b, d, upper, fromBackEdge0, origdelta, reason)
or
@@ -1053,7 +1025,7 @@ module RangeStage<
reason = TSemNoReason()
or
exists(SemSsaVariable v, SemSsaReadPositionBlock bb |
boundedSsa(v, bb, b, delta, upper, fromBackEdge, origdelta, reason) and
boundedSsa(v, b, delta, bb, upper, fromBackEdge, origdelta, reason) and
e = v.getAUse() and
bb.getBlock() = e.getBasicBlock()
)
@@ -1137,6 +1109,23 @@ module RangeStage<
b = bRight and origdelta = odRight and reason = rRight and bLeft instanceof SemZeroBound
)
or
exists(D::Delta dLeft, D::Delta dRight, boolean fbeLeft, boolean fbeRight |
boundedSubOperandLeft(e, upper, b, dLeft, fbeLeft, origdelta, reason) and
boundedSubOperandRight(e, upper, dRight, fbeRight) and
// when `upper` is `true` we have:
// left <= b + dLeft
// right >= 0 + dRight
// left - right <= b + dLeft - (0 + dRight)
// = b + (dLeft - dRight)
// and when `upper` is `false` we have:
// left >= b + dLeft
// right <= 0 + dRight
// left - right >= b + dLeft - (0 + dRight)
// = b + (dLeft - dRight)
delta = D::fromFloat(D::toFloat(dLeft) - D::toFloat(dRight)) and
fromBackEdge = fbeLeft.booleanOr(fbeRight)
)
or
exists(
SemRemExpr rem, D::Delta d_max, D::Delta d1, D::Delta d2, boolean fbe1, boolean fbe2,
D::Delta od1, D::Delta od2, SemReason r1, SemReason r2
@@ -1201,6 +1190,37 @@ module RangeStage<
)
}
/**
* Holds if `sub = left - right` and `left <= b + delta` if `upper` is `true`
* and `left >= b + delta` is `upper` is `false`.
*/
pragma[nomagic]
private predicate boundedSubOperandLeft(
SemSubExpr sub, boolean upper, SemBound b, D::Delta delta, boolean fromBackEdge,
D::Delta origdelta, SemReason reason
) {
// `semValueFlowStep` already handles the case where one of the operands is a constant.
not semValueFlowStep(sub, _, _) and
bounded(sub.getLeftOperand(), b, delta, upper, fromBackEdge, origdelta, reason)
}
/**
* Holds if `sub = left - right` and `right <= 0 + delta` if `upper` is `false`
* and `right >= 0 + delta` is `upper` is `true`.
*
* Note that the boolean value of `upper` is flipped compared to many other predicates in
* this file. This ensures a clean join at the call-site.
*/
pragma[nomagic]
private predicate boundedSubOperandRight(
SemSubExpr sub, boolean upper, D::Delta delta, boolean fromBackEdge
) {
// `semValueFlowStep` already handles the case where one of the operands is a constant.
not semValueFlowStep(sub, _, _) and
bounded(sub.getRightOperand(), any(SemZeroBound zb), delta, upper.booleanNot(), fromBackEdge, _,
_)
}
pragma[nomagic]
private predicate boundedRemExpr(
SemRemExpr rem, boolean upper, D::Delta delta, boolean fromBackEdge, D::Delta origdelta,

View File

@@ -49,6 +49,7 @@ module RangeUtil<Range::DeltaSig D, Range::LangSig<D> Lang> implements Range::Ut
* - `isEq = true` : `v == e + delta`
* - `isEq = false` : `v != e + delta`
*/
pragma[nomagic]
SemGuard semEqFlowCond(
SemSsaVariable v, SemExpr e, D::Delta delta, boolean isEq, boolean testIsTrue
) {

View File

@@ -53,7 +53,7 @@ private class ArgvSource extends LocalFlowSource {
exists(Function main, Parameter argv |
main.hasGlobalName("main") and
main.getParameter(1) = argv and
this.asParameter(_) = argv
this.asParameter(2) = argv
)
}

View File

@@ -56,7 +56,7 @@ private import semmle.code.cpp.ir.dataflow.internal.ProductFlow
private import semmle.code.cpp.ir.ValueNumbering
private import semmle.code.cpp.controlflow.IRGuards
private import codeql.util.Unit
private import RangeAnalysisUtil
private import semmle.code.cpp.rangeanalysis.new.RangeAnalysisUtil
private VariableAccess getAVariableAccess(Expr e) { e.getAChild*() = result }
@@ -77,6 +77,15 @@ predicate hasSize(HeuristicAllocationExpr alloc, DataFlow::Node n, int state) {
)
}
/**
* Gets the virtual dispatch branching limit when calculating field flow while searching
* for flow from an allocation to the construction of an out-of-bounds pointer.
*
* This can be overridden to a smaller value to improve performance (a
* value of 0 disables field flow), or a larger value to get more results.
*/
int allocationToInvalidPointerFieldFlowBranchLimit() { result = 0 }
/**
* A module that encapsulates a barrier guard to remove false positives from flow like:
* ```cpp
@@ -96,43 +105,71 @@ predicate hasSize(HeuristicAllocationExpr alloc, DataFlow::Node n, int state) {
* but because there's a strict comparison that compares `n` against the size of the allocation this
* snippet is fine.
*/
module SizeBarrier {
private module SizeBarrier {
private module SizeBarrierConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) {
// The sources is the same as in the sources for the second
// projection in the `AllocToInvalidPointerConfig` module.
hasSize(_, source, _)
hasSize(_, source, _) and
InterestingPointerAddInstruction::isInterestingSize(source)
}
int fieldFlowBranchLimit() { result = allocationToInvalidPointerFieldFlowBranchLimit() }
/**
* Holds if `small <= large + k` holds if `g` evaluates to `testIsTrue`.
*/
additional predicate isSink(
DataFlow::Node left, DataFlow::Node right, IRGuardCondition g, int k, boolean testIsTrue
DataFlow::Node small, DataFlow::Node large, IRGuardCondition g, int k, boolean testIsTrue
) {
// The sink is any "large" side of a relational comparison. i.e., the `right` expression
// in a guard such as `left < right + k`.
g.comparesLt(left.asOperand(), right.asOperand(), k, true, testIsTrue)
// The sink is any "large" side of a relational comparison. i.e., the `large` expression
// in a guard such as `small <= large + k`.
g.comparesLt(small.asOperand(), large.asOperand(), k + 1, true, testIsTrue)
}
predicate isSink(DataFlow::Node sink) { isSink(_, sink, _, _, _) }
}
private import DataFlow::Global<SizeBarrierConfig>
module SizeBarrierFlow = DataFlow::Global<SizeBarrierConfig>;
private int getAFlowStateForNode(DataFlow::Node node) {
private int getASizeAddend(DataFlow::Node node) {
exists(DataFlow::Node source |
flow(source, node) and
SizeBarrierFlow::flow(source, node) and
hasSize(_, source, result)
)
}
/**
* Holds if `small <= large + k` holds if `g` evaluates to `edge`.
*/
private predicate operandGuardChecks(
IRGuardCondition g, Operand left, Operand right, int state, boolean edge
IRGuardCondition g, Operand small, DataFlow::Node large, int k, boolean edge
) {
exists(DataFlow::Node nLeft, DataFlow::Node nRight, int k |
nRight.asOperand() = right and
nLeft.asOperand() = left and
SizeBarrierConfig::isSink(nLeft, nRight, g, k, edge) and
state = getAFlowStateForNode(nRight) and
k <= state
SizeBarrierFlow::flowTo(large) and
SizeBarrierConfig::isSink(DataFlow::operandNode(small), large, g, k, edge)
}
/**
* Gets an instruction `instr` that is guarded by a check such as `instr <= small + delta` where
* `small <= _ + k` and `small` is the "small side" of of a relational comparison that checks
* whether `small <= size` where `size` is the size of an allocation.
*/
Instruction getABarrierInstruction0(int delta, int k) {
exists(
IRGuardCondition g, ValueNumber value, Operand small, boolean edge, DataFlow::Node large
|
// We know:
// 1. result <= value + delta (by `bounded`)
// 2. value <= large + k (by `operandGuardChecks`).
// So:
// result <= value + delta (by 1.)
// <= large + k + delta (by 2.)
small = value.getAUse() and
operandGuardChecks(pragma[only_bind_into](g), pragma[only_bind_into](small), large,
pragma[only_bind_into](k), pragma[only_bind_into](edge)) and
bounded(result, value.getAnInstruction(), delta) and
g.controls(result.getBlock(), edge) and
k < getASizeAddend(large)
)
}
@@ -140,13 +177,14 @@ module SizeBarrier {
* Gets an instruction that is guarded by a guard condition which ensures that
* the value of the instruction is upper-bounded by size of some allocation.
*/
bindingset[state]
pragma[inline_late]
Instruction getABarrierInstruction(int state) {
exists(IRGuardCondition g, ValueNumber value, Operand use, boolean edge |
use = value.getAUse() and
operandGuardChecks(pragma[only_bind_into](g), pragma[only_bind_into](use), _,
pragma[only_bind_into](state), pragma[only_bind_into](edge)) and
result = value.getAnInstruction() and
g.controls(result.getBlock(), edge)
exists(int delta, int k |
state > k + delta and
// result <= "size of allocation" + delta + k
// < "size of allocation" + state
result = getABarrierInstruction0(delta, k)
)
}
@@ -155,14 +193,16 @@ module SizeBarrier {
* the value of the node is upper-bounded by size of some allocation.
*/
DataFlow::Node getABarrierNode(int state) {
result.asOperand() = getABarrierInstruction(state).getAUse()
exists(DataFlow::Node source, int delta, int k |
SizeBarrierFlow::flow(source, result) and
hasSize(_, source, state) and
result.asInstruction() = SizeBarrier::getABarrierInstruction0(delta, k) and
state > k + delta
// so now we have:
// result <= "size of allocation" + delta + k
// < "size of allocation" + state
)
}
/**
* Gets the block of a node that is guarded (see `getABarrierInstruction` or
* `getABarrierNode` for the definition of what it means to be guarded).
*/
IRBlock getABarrierBlock(int state) { result.getAnInstruction() = getABarrierInstruction(state) }
}
private module InterestingPointerAddInstruction {
@@ -173,6 +213,8 @@ private module InterestingPointerAddInstruction {
hasSize(source.asConvertedExpr(), _, _)
}
int fieldFlowBranchLimit() { result = allocationToInvalidPointerFieldFlowBranchLimit() }
predicate isSink(DataFlow::Node sink) {
sink.asInstruction() = any(PointerAddInstruction pai).getLeft()
}
@@ -192,6 +234,19 @@ private module InterestingPointerAddInstruction {
flowTo(n)
)
}
/**
* Holds if `n` is a size of an allocation whose result flows to the left operand
* of a pointer-arithmetic instruction.
*
* This predicate is used to reduce the set of tuples in `SizeBarrierConfig::isSource`.
*/
predicate isInterestingSize(DataFlow::Node n) {
exists(DataFlow::Node alloc |
hasSize(alloc.asConvertedExpr(), n, _) and
flow(alloc, _)
)
}
}
/**
@@ -216,6 +271,10 @@ private module Config implements ProductFlow::StateConfigSig {
hasSize(allocSource.asConvertedExpr(), sizeSource, sizeAddend)
}
int fieldFlowBranchLimit1() { result = allocationToInvalidPointerFieldFlowBranchLimit() }
int fieldFlowBranchLimit2() { result = allocationToInvalidPointerFieldFlowBranchLimit() }
predicate isSinkPair(
DataFlow::Node allocSink, FlowState1 unit, DataFlow::Node sizeSink, FlowState2 sizeAddend
) {

View File

@@ -66,11 +66,14 @@
* module. Since the node we are tracking is not necessarily _equal_ to the pointer-arithmetic instruction, but rather satisfies
* `node.asInstruction() <= pai + deltaDerefSourceAndPai`, we need to account for the delta when checking if a guard is sufficiently
* strong to infer that a future dereference is safe. To do this, we check that the guard guarantees that a node `n` satisfies
* `n < node + k` where `node` is a node we know is equal to the value of the dereference source (i.e., it satisfies
* `node.asInstruction() <= pai + deltaDerefSourceAndPai`) and `k <= deltaDerefSourceAndPai`. Combining this we have
* `n < node + k <= node + deltaDerefSourceAndPai <= pai + 2*deltaDerefSourceAndPai` (TODO: Oops. This math doesn't quite work out.
* I think this is because we need to redefine the `BarrierConfig` to start flow at the pointer-arithmetic instruction instead of
* at the dereference source. When combined with TODO above it's easy to show that this guard ensures that the dereference is safe).
* `n < node + k` where `node` is a node such that `node <= pai`. Thus, we know that any node `m` such that `m <= n + delta` where
* `delta + k <= 0` will be safe because:
* ```
* m <= n + delta
* < node + k + delta
* <= pai + k + delta
* <= pai
* ```
*/
private import cpp
@@ -78,80 +81,120 @@ private import semmle.code.cpp.dataflow.new.DataFlow
private import semmle.code.cpp.ir.ValueNumbering
private import semmle.code.cpp.controlflow.IRGuards
private import AllocationToInvalidPointer as AllocToInvalidPointer
private import RangeAnalysisUtil
private import semmle.code.cpp.rangeanalysis.new.RangeAnalysisUtil
/**
* Gets the virtual dispatch branching limit when calculating field flow while
* searching for flow from an out-of-bounds pointer to a dereference of the
* pointer.
*
* This can be overridden to a smaller value to improve performance (a
* value of 0 disables field flow), or a larger value to get more results.
*/
int invalidPointerToDereferenceFieldFlowBranchLimit() { result = 0 }
private module InvalidPointerToDerefBarrier {
private module BarrierConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) {
// The sources is the same as in the sources for `InvalidPointerToDerefConfig`.
invalidPointerToDerefSource(_, _, source, _)
additional predicate isSource(DataFlow::Node source, PointerArithmeticInstruction pai) {
invalidPointerToDerefSource(_, pai, _, _) and
// source <= pai
bounded2(source.asInstruction(), pai, any(int d | d <= 0))
}
predicate isSource(DataFlow::Node source) { isSource(source, _) }
additional predicate isSink(
DataFlow::Node left, DataFlow::Node right, IRGuardCondition g, int k, boolean testIsTrue
DataFlow::Node small, DataFlow::Node large, IRGuardCondition g, int k, boolean testIsTrue
) {
// The sink is any "large" side of a relational comparison.
g.comparesLt(left.asOperand(), right.asOperand(), k, true, testIsTrue)
g.comparesLt(small.asOperand(), large.asOperand(), k, true, testIsTrue)
}
predicate isSink(DataFlow::Node sink) { isSink(_, sink, _, _, _) }
int fieldFlowBranchLimit() { result = invalidPointerToDereferenceFieldFlowBranchLimit() }
}
private module BarrierFlow = DataFlow::Global<BarrierConfig>;
private int getInvalidPointerToDerefSourceDelta(DataFlow::Node node) {
exists(DataFlow::Node source |
BarrierFlow::flow(source, node) and
invalidPointerToDerefSource(_, _, source, result)
)
}
/**
* Holds if `g` ensures that `small < large + k` if `g` evaluates to `edge`.
*
* Additionally, it also holds that `large <= pai`. Thus, when `g` evaluates to `edge`
* it holds that `small < pai + k`.
*/
private predicate operandGuardChecks(
IRGuardCondition g, Operand left, Operand right, int state, boolean edge
PointerArithmeticInstruction pai, IRGuardCondition g, Operand small, int k, boolean edge
) {
exists(DataFlow::Node nLeft, DataFlow::Node nRight, int k |
nRight.asOperand() = right and
nLeft.asOperand() = left and
BarrierConfig::isSink(nLeft, nRight, g, k, edge) and
state = getInvalidPointerToDerefSourceDelta(nRight) and
k <= state
exists(DataFlow::Node source, DataFlow::Node nSmall, DataFlow::Node nLarge |
nSmall.asOperand() = small and
BarrierConfig::isSource(source, pai) and
BarrierFlow::flow(source, nLarge) and
BarrierConfig::isSink(nSmall, nLarge, g, k, edge)
)
}
Instruction getABarrierInstruction(int state) {
exists(IRGuardCondition g, ValueNumber value, Operand use, boolean edge |
/**
* Gets an instruction `instr` such that `instr < pai`.
*/
Instruction getABarrierInstruction(PointerArithmeticInstruction pai) {
exists(IRGuardCondition g, ValueNumber value, Operand use, boolean edge, int delta, int k |
use = value.getAUse() and
operandGuardChecks(pragma[only_bind_into](g), pragma[only_bind_into](use), _, state,
pragma[only_bind_into](edge)) and
result = value.getAnInstruction() and
g.controls(result.getBlock(), edge)
// value < pai + k
operandGuardChecks(pai, pragma[only_bind_into](g), pragma[only_bind_into](use),
pragma[only_bind_into](k), pragma[only_bind_into](edge)) and
// result <= value + delta
bounded(result, value.getAnInstruction(), delta) and
g.controls(result.getBlock(), edge) and
delta + k <= 0
// combining the above we have: result < pai + k + delta <= pai
)
}
DataFlow::Node getABarrierNode() { result.asOperand() = getABarrierInstruction(_).getAUse() }
DataFlow::Node getABarrierNode(PointerArithmeticInstruction pai) {
result.asOperand() = getABarrierInstruction(pai).getAUse()
}
pragma[nomagic]
IRBlock getABarrierBlock(int state) { result.getAnInstruction() = getABarrierInstruction(state) }
/**
* Gets an address operand whose definition `instr` satisfies `instr < pai`.
*/
AddressOperand getABarrierAddressOperand(PointerArithmeticInstruction pai) {
result.getDef() = getABarrierInstruction(pai)
}
}
/**
* A configuration to track flow from a pointer-arithmetic operation found
* by `AllocToInvalidPointerConfig` to a dereference of the pointer.
*/
private module InvalidPointerToDerefConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { invalidPointerToDerefSource(_, _, source, _) }
private module InvalidPointerToDerefConfig implements DataFlow::StateConfigSig {
class FlowState extends PointerArithmeticInstruction {
FlowState() { invalidPointerToDerefSource(_, this, _, _) }
}
predicate isSource(DataFlow::Node source, FlowState pai) {
invalidPointerToDerefSource(_, pai, source, _)
}
pragma[inline]
predicate isSink(DataFlow::Node sink) { isInvalidPointerDerefSink(sink, _, _, _) }
predicate isSink(DataFlow::Node sink) { isInvalidPointerDerefSink(sink, _, _, _, _) }
predicate isSink(DataFlow::Node sink, FlowState pai) { none() }
predicate isBarrier(DataFlow::Node node) {
node = any(DataFlow::SsaPhiNode phi | not phi.isPhiRead()).getAnInput(true)
or
node = InvalidPointerToDerefBarrier::getABarrierNode()
}
predicate isBarrier(DataFlow::Node node, FlowState pai) {
// `node = getABarrierNode(pai)` ensures that node < pai, so this node is safe to dereference.
// Note that this is the only place where the `FlowState` is used in this configuration.
node = InvalidPointerToDerefBarrier::getABarrierNode(pai)
}
int fieldFlowBranchLimit() { result = invalidPointerToDereferenceFieldFlowBranchLimit() }
}
private import DataFlow::Global<InvalidPointerToDerefConfig>
private import DataFlow::GlobalWithState<InvalidPointerToDerefConfig>
/**
* Holds if `allocSource` is dataflow node that represents an allocation that flows to the
@@ -165,19 +208,14 @@ private predicate invalidPointerToDerefSource(
DataFlow::Node allocSource, PointerArithmeticInstruction pai, DataFlow::Node derefSource,
int deltaDerefSourceAndPai
) {
exists(int rhsSizeDelta |
// Note that `deltaDerefSourceAndPai` is not necessarily equal to `rhsSizeDelta`:
// `rhsSizeDelta` is the constant offset added to the size of the allocation, and
// `deltaDerefSourceAndPai` is the constant difference between the pointer-arithmetic instruction
// and the instruction computing the address for which we will search for a dereference.
AllocToInvalidPointer::pointerAddInstructionHasBounds(allocSource, pai, _, rhsSizeDelta) and
bounded2(derefSource.asInstruction(), pai, deltaDerefSourceAndPai) and
deltaDerefSourceAndPai >= 0 and
// TODO: This condition will go away once #13725 is merged, and then we can make `SizeBarrier`
// private to `AllocationToInvalidPointer.qll`.
not derefSource.getBasicBlock() =
AllocToInvalidPointer::SizeBarrier::getABarrierBlock(rhsSizeDelta)
)
// Note that `deltaDerefSourceAndPai` is not necessarily equal to `rhsSizeDelta`:
// `rhsSizeDelta` is the constant offset added to the size of the allocation, and
// `deltaDerefSourceAndPai` is the constant difference between the pointer-arithmetic instruction
// and the instruction computing the address for which we will search for a dereference.
AllocToInvalidPointer::pointerAddInstructionHasBounds(allocSource, pai, _, _) and
// derefSource <= pai + deltaDerefSourceAndPai
bounded2(derefSource.asInstruction(), pai, deltaDerefSourceAndPai) and
deltaDerefSourceAndPai >= 0
}
/**
@@ -187,15 +225,14 @@ private predicate invalidPointerToDerefSource(
*/
pragma[inline]
private predicate isInvalidPointerDerefSink(
DataFlow::Node sink, Instruction i, string operation, int deltaDerefSinkAndDerefAddress
DataFlow::Node sink, AddressOperand addr, Instruction i, string operation,
int deltaDerefSinkAndDerefAddress
) {
exists(AddressOperand addr, Instruction s, IRBlock b |
exists(Instruction s |
s = sink.asInstruction() and
bounded(addr.getDef(), s, deltaDerefSinkAndDerefAddress) and
deltaDerefSinkAndDerefAddress >= 0 and
i.getAnOperand() = addr and
b = i.getBlock() and
not b = InvalidPointerToDerefBarrier::getABarrierBlock(deltaDerefSinkAndDerefAddress)
i.getAnOperand() = addr
|
i instanceof StoreInstruction and
operation = "write"
@@ -221,9 +258,11 @@ private Instruction getASuccessor(Instruction instr) {
instr.getBlock().getASuccessor+() = result.getBlock()
}
private predicate paiForDereferenceSink(PointerArithmeticInstruction pai, DataFlow::Node derefSink) {
private predicate paiForDereferenceSink(
PointerArithmeticInstruction pai, DataFlow::Node derefSink, int deltaDerefSourceAndPai
) {
exists(DataFlow::Node derefSource |
invalidPointerToDerefSource(_, pai, derefSource, _) and
invalidPointerToDerefSource(_, pai, derefSource, deltaDerefSourceAndPai) and
flow(derefSource, derefSink)
)
}
@@ -235,13 +274,15 @@ private predicate paiForDereferenceSink(PointerArithmeticInstruction pai, DataFl
*/
private predicate derefSinkToOperation(
DataFlow::Node derefSink, PointerArithmeticInstruction pai, DataFlow::Node operation,
string description, int deltaDerefSinkAndDerefAddress
string description, int deltaDerefSourceAndPai, int deltaDerefSinkAndDerefAddress
) {
exists(Instruction operationInstr |
paiForDereferenceSink(pai, pragma[only_bind_into](derefSink)) and
isInvalidPointerDerefSink(derefSink, operationInstr, description, deltaDerefSinkAndDerefAddress) and
exists(Instruction operationInstr, AddressOperand addr |
paiForDereferenceSink(pai, pragma[only_bind_into](derefSink), deltaDerefSourceAndPai) and
isInvalidPointerDerefSink(derefSink, addr, operationInstr, description,
deltaDerefSinkAndDerefAddress) and
operationInstr = getASuccessor(derefSink.asInstruction()) and
operation.asInstruction() = operationInstr
operation.asInstruction() = operationInstr and
not addr = InvalidPointerToDerefBarrier::getABarrierAddressOperand(pai)
)
}
@@ -260,7 +301,8 @@ predicate operationIsOffBy(
exists(int deltaDerefSourceAndPai, int deltaDerefSinkAndDerefAddress |
invalidPointerToDerefSource(allocation, pai, derefSource, deltaDerefSourceAndPai) and
flow(derefSource, derefSink) and
derefSinkToOperation(derefSink, pai, operation, description, deltaDerefSinkAndDerefAddress) and
derefSinkToOperation(derefSink, pai, operation, description, deltaDerefSourceAndPai,
deltaDerefSinkAndDerefAddress) and
delta = deltaDerefSourceAndPai + deltaDerefSinkAndDerefAddress
)
}

View File

@@ -1,3 +1,19 @@
## 0.7.4
### New Queries
* Added a new query, `cpp/invalid-pointer-deref`, to detect out-of-bounds pointer reads and writes.
### Minor Analysis Improvements
* The "Comparison where assignment was intended" query (`cpp/compare-where-assign-meant`) no longer reports comparisons that appear in macro expansions.
* Some queries that had repeated results corresponding to different levels of indirection for `argv` now only have a single result.
* The `cpp/non-constant-format` query no longer considers an assignment on the right-hand side of another assignment to be a source of non-constant format strings. As a result, the query may now produce fewer results.
## 0.7.3
No user-facing changes.
## 0.7.2
No user-facing changes.

View File

@@ -105,8 +105,6 @@ predicate isNonConst(DataFlow::Node node, boolean isIndirect) {
or
e instanceof NewArrayExpr
or
e instanceof AssignExpr
or
exists(Variable v | v = e.(VariableAccess).getTarget() |
v.getType().(ArrayType).getBaseType() instanceof CharType and
exists(AssignExpr ae |

View File

@@ -16,6 +16,7 @@ import cpp
from ExprInVoidContext op
where
not op.isUnevaluated() and
not inMacroExpansion(op) and
(
op instanceof EQExpr
or

View File

@@ -14,9 +14,11 @@
import cpp
import semmle.code.cpp.security.Security
import semmle.code.cpp.security.FlowSources
import semmle.code.cpp.security.FunctionWithWrappers
import semmle.code.cpp.ir.dataflow.internal.DefaultTaintTrackingImpl
import TaintedWithPath
import semmle.code.cpp.ir.IR
import semmle.code.cpp.ir.dataflow.TaintTracking
import SqlTainted::PathGraph
class SqlLikeFunction extends FunctionWithWrappers {
SqlLikeFunction() { sqlArgument(this.getName(), _) }
@@ -24,31 +26,43 @@ class SqlLikeFunction extends FunctionWithWrappers {
override predicate interestingArg(int arg) { sqlArgument(this.getName(), arg) }
}
class Configuration extends TaintTrackingConfiguration {
override predicate isSink(Element tainted) {
exists(SqlLikeFunction runSql | runSql.outermostWrapperFunctionCall(tainted, _))
Expr asSinkExpr(DataFlow::Node node) {
result = node.asIndirectArgument()
or
// We want the conversion so we only get one node for the expression
result = node.asConvertedExpr()
}
module SqlTaintedConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node node) { node instanceof FlowSource }
predicate isSink(DataFlow::Node node) {
exists(SqlLikeFunction runSql | runSql.outermostWrapperFunctionCall(asSinkExpr(node), _))
}
override predicate isBarrier(Expr e) {
super.isBarrier(e)
or
e.getUnspecifiedType() instanceof IntegralType
or
predicate isBarrier(DataFlow::Node node) {
node.asExpr().getUnspecifiedType() instanceof IntegralType
}
predicate isBarrierIn(DataFlow::Node node) {
exists(SqlBarrierFunction sql, int arg, FunctionInput input |
e = sql.getACallToThisFunction().getArgument(arg) and
node.asIndirectArgument() = sql.getACallToThisFunction().getArgument(arg) and
input.isParameterDeref(arg) and
sql.barrierSqlArgument(input, _)
)
}
}
module SqlTainted = TaintTracking::Global<SqlTaintedConfig>;
from
SqlLikeFunction runSql, Expr taintedArg, Expr taintSource, PathNode sourceNode, PathNode sinkNode,
string taintCause, string callChain
SqlLikeFunction runSql, Expr taintedArg, FlowSource taintSource, SqlTainted::PathNode sourceNode,
SqlTainted::PathNode sinkNode, string callChain
where
runSql.outermostWrapperFunctionCall(taintedArg, callChain) and
taintedWithPath(taintSource, taintedArg, sourceNode, sinkNode) and
isUserInput(taintSource, taintCause)
SqlTainted::flowPath(sourceNode, sinkNode) and
taintedArg = asSinkExpr(sinkNode.getNode()) and
taintSource = sourceNode.getNode()
select taintedArg, sourceNode, sinkNode,
"This argument to a SQL query function is derived from $@ and then passed to " + callChain + ".",
taintSource, "user input (" + taintCause + ")"
taintSource, "user input (" + taintSource.getSourceType() + ")"

View File

@@ -20,28 +20,10 @@ import semmle.code.cpp.models.interfaces.Allocation
import semmle.code.cpp.models.interfaces.ArrayFunction
import semmle.code.cpp.rangeanalysis.new.internal.semantic.analysis.RangeAnalysis
import semmle.code.cpp.rangeanalysis.new.internal.semantic.SemanticExprSpecific
import semmle.code.cpp.rangeanalysis.new.RangeAnalysisUtil
import StringSizeFlow::PathGraph1
import codeql.util.Unit
pragma[nomagic]
Instruction getABoundIn(SemBound b, IRFunction func) {
getSemanticExpr(result) = b.getExpr(0) and
result.getEnclosingIRFunction() = func
}
/**
* Holds if `i <= b + delta`.
*/
bindingset[i]
pragma[inline_late]
predicate bounded(Instruction i, Instruction b, int delta) {
exists(SemBound bound, IRFunction func |
semBounded(getSemanticExpr(i), bound, delta, true, _) and
b = getABoundIn(bound, func) and
i.getEnclosingIRFunction() = func
)
}
VariableAccess getAVariableAccess(Expr e) { e.getAChild*() = result }
/**

View File

@@ -3,7 +3,7 @@
"qhelp.dtd">
<qhelp>
<overview>
<p>The program performs an out-of-bounds read or write operation. In addition to causing program instability, techniques exist which may allow an attacker to use this vulnerability to execute arbitrary code.</p>
<p>The program performs an out-of-bounds read or write operation, which can cause program instability. In addition, attackers may take advantage of the situation, and implement techniques to use this vulnerability to execute arbitrary code.</p>
</overview>
<recommendation>
@@ -13,7 +13,7 @@
</recommendation>
<example>
<p>The first example allocates a buffer of size <code>size</code> and creates a local variable that stores the location that is one byte past the end of the allocation.
This local variable is then dereferenced which results in an out-of-bounds write.
This local variable is then dereferenced, which results in an out-of-bounds write.
The second example subtracts one from the <code>end</code> variable before dereferencing it. This subtraction ensures that the write correctly updates the final byte of the allocation.</p>
<sample src="InvalidPointerDeref.cpp" />

View File

@@ -1,10 +1,10 @@
/**
* @name Invalid pointer dereference
* @description Dereferencing a pointer that points past it allocation is undefined behavior
* and may lead to security vulnerabilities.
* @description Dereferencing an out-of-bounds pointer is undefined behavior and may lead to security vulnerabilities.
* @kind path-problem
* @problem.severity error
* @precision high
* @security-severity 9.3
* @precision medium
* @id cpp/invalid-pointer-deref
* @tags reliability
* security
@@ -94,6 +94,12 @@ module FinalConfig implements DataFlow::StateConfigSig {
)
}
int fieldFlowBranchLimit() {
result =
allocationToInvalidPointerFieldFlowBranchLimit()
.maximum(invalidPointerToDereferenceFieldFlowBranchLimit())
}
predicate isAdditionalFlowStep(
DataFlow::Node node1, FlowState state1, DataFlow::Node node2, FlowState state2
) {

View File

@@ -17,21 +17,6 @@ import cpp
import semmle.code.cpp.valuenumbering.GlobalValueNumbering
import semmle.code.cpp.controlflow.Guards
/**
* A C++ `delete` or `delete[]` expression.
*/
class DeleteOrDeleteArrayExpr extends Expr {
DeleteOrDeleteArrayExpr() { this instanceof DeleteExpr or this instanceof DeleteArrayExpr }
DeallocationFunction getDeallocator() {
result = [this.(DeleteExpr).getDeallocator(), this.(DeleteArrayExpr).getDeallocator()]
}
Destructor getDestructor() {
result = [this.(DeleteExpr).getDestructor(), this.(DeleteArrayExpr).getDestructor()]
}
}
/** Gets the `Constructor` invoked when `newExpr` allocates memory. */
Constructor getConstructorForAllocation(NewOrNewArrayExpr newExpr) {
result.getACallToThisFunction() = newExpr.getInitializer()

View File

@@ -0,0 +1,3 @@
## 0.7.3
No user-facing changes.

View File

@@ -0,0 +1,11 @@
## 0.7.4
### New Queries
* Added a new query, `cpp/invalid-pointer-deref`, to detect out-of-bounds pointer reads and writes.
### Minor Analysis Improvements
* The "Comparison where assignment was intended" query (`cpp/compare-where-assign-meant`) no longer reports comparisons that appear in macro expansions.
* Some queries that had repeated results corresponding to different levels of indirection for `argv` now only have a single result.
* The `cpp/non-constant-format` query no longer considers an assignment on the right-hand side of another assignment to be a source of non-constant format strings. As a result, the query may now produce fewer results.

View File

@@ -1,2 +1,2 @@
---
lastReleaseVersion: 0.7.2
lastReleaseVersion: 0.7.4

View File

@@ -40,7 +40,7 @@ module WordexpTaintConfig implements DataFlow::ConfigSig {
predicate isSink(DataFlow::Node sink) {
exists(FunctionCall fc | fc.getTarget() instanceof WordexpFunction |
fc.getArgument(0) = sink.asExpr() and
fc.getArgument(0) = sink.asIndirectArgument(1) and
not isCommandSubstitutionDisabled(fc)
)
}

View File

@@ -1,5 +1,5 @@
name: codeql/cpp-queries
version: 0.7.2
version: 0.7.4
groups:
- cpp
- queries

View File

@@ -1,16 +1,8 @@
edges
| test.cpp:22:27:22:30 | argv | test.cpp:29:13:29:20 | filePath |
| test.cpp:22:27:22:30 | argv | test.cpp:29:13:29:20 | filePath |
| test.cpp:22:27:22:30 | argv indirection | test.cpp:29:13:29:20 | filePath |
| test.cpp:22:27:22:30 | argv indirection | test.cpp:29:13:29:20 | filePath |
| test.cpp:22:27:22:30 | argv indirection | test.cpp:29:13:29:20 | filePath indirection |
nodes
| test.cpp:22:27:22:30 | argv | semmle.label | argv |
| test.cpp:22:27:22:30 | argv indirection | semmle.label | argv indirection |
| test.cpp:29:13:29:20 | filePath | semmle.label | filePath |
| test.cpp:29:13:29:20 | filePath | semmle.label | filePath |
| test.cpp:29:13:29:20 | filePath indirection | semmle.label | filePath indirection |
subpaths
#select
| test.cpp:29:13:29:20 | filePath | test.cpp:22:27:22:30 | argv | test.cpp:29:13:29:20 | filePath | Using user-supplied data in a `wordexp` command, without disabling command substitution, can make code vulnerable to command injection. |
| test.cpp:29:13:29:20 | filePath | test.cpp:22:27:22:30 | argv | test.cpp:29:13:29:20 | filePath | Using user-supplied data in a `wordexp` command, without disabling command substitution, can make code vulnerable to command injection. |
| test.cpp:29:13:29:20 | filePath | test.cpp:22:27:22:30 | argv indirection | test.cpp:29:13:29:20 | filePath | Using user-supplied data in a `wordexp` command, without disabling command substitution, can make code vulnerable to command injection. |
| test.cpp:29:13:29:20 | filePath | test.cpp:22:27:22:30 | argv indirection | test.cpp:29:13:29:20 | filePath | Using user-supplied data in a `wordexp` command, without disabling command substitution, can make code vulnerable to command injection. |
| test.cpp:29:13:29:20 | filePath indirection | test.cpp:22:27:22:30 | argv indirection | test.cpp:29:13:29:20 | filePath indirection | Using user-supplied data in a `wordexp` command, without disabling command substitution, can make code vulnerable to command injection. |

View File

@@ -9,44 +9,35 @@ edges
| test.cpp:22:5:22:7 | arr indirection [p] | test.cpp:19:9:19:16 | mk_array indirection [p] |
| test.cpp:28:19:28:26 | call to mk_array [p] | test.cpp:31:9:31:11 | arr indirection [p] |
| test.cpp:28:19:28:26 | call to mk_array [p] | test.cpp:35:9:35:11 | arr indirection [p] |
| test.cpp:31:9:31:11 | arr indirection [p] | test.cpp:31:13:31:13 | p indirection |
| test.cpp:31:13:31:13 | p indirection | test.cpp:31:13:31:13 | p |
| test.cpp:35:9:35:11 | arr indirection [p] | test.cpp:35:13:35:13 | p indirection |
| test.cpp:35:13:35:13 | p indirection | test.cpp:35:13:35:13 | p |
| test.cpp:31:9:31:11 | arr indirection [p] | test.cpp:31:13:31:13 | p |
| test.cpp:35:9:35:11 | arr indirection [p] | test.cpp:35:13:35:13 | p |
| test.cpp:39:27:39:29 | arr [p] | test.cpp:41:9:41:11 | arr indirection [p] |
| test.cpp:39:27:39:29 | arr [p] | test.cpp:45:9:45:11 | arr indirection [p] |
| test.cpp:41:9:41:11 | arr indirection [p] | test.cpp:41:13:41:13 | p indirection |
| test.cpp:41:13:41:13 | p indirection | test.cpp:41:13:41:13 | p |
| test.cpp:45:9:45:11 | arr indirection [p] | test.cpp:45:13:45:13 | p indirection |
| test.cpp:45:13:45:13 | p indirection | test.cpp:45:13:45:13 | p |
| test.cpp:41:9:41:11 | arr indirection [p] | test.cpp:41:13:41:13 | p |
| test.cpp:45:9:45:11 | arr indirection [p] | test.cpp:45:13:45:13 | p |
| test.cpp:50:18:50:25 | call to mk_array [p] | test.cpp:39:27:39:29 | arr [p] |
| test.cpp:55:5:55:24 | ... = ... | test.cpp:55:9:55:9 | arr indirection [post update] [p] |
| test.cpp:55:9:55:9 | arr indirection [post update] [p] | test.cpp:56:5:56:7 | arr indirection [p] |
| test.cpp:55:13:55:18 | call to malloc | test.cpp:55:5:55:24 | ... = ... |
| test.cpp:56:5:56:7 | arr indirection [p] | test.cpp:59:9:59:11 | arr indirection [p] |
| test.cpp:56:5:56:7 | arr indirection [p] | test.cpp:63:9:63:11 | arr indirection [p] |
| test.cpp:59:9:59:11 | arr indirection [p] | test.cpp:59:13:59:13 | p indirection |
| test.cpp:59:13:59:13 | p indirection | test.cpp:59:13:59:13 | p |
| test.cpp:63:9:63:11 | arr indirection [p] | test.cpp:63:13:63:13 | p indirection |
| test.cpp:63:13:63:13 | p indirection | test.cpp:63:13:63:13 | p |
| test.cpp:59:9:59:11 | arr indirection [p] | test.cpp:59:13:59:13 | p |
| test.cpp:63:9:63:11 | arr indirection [p] | test.cpp:63:13:63:13 | p |
| test.cpp:67:10:67:19 | mk_array_p indirection [p] | test.cpp:76:20:76:29 | call to mk_array_p indirection [p] |
| test.cpp:67:10:67:19 | mk_array_p indirection [p] | test.cpp:98:18:98:27 | call to mk_array_p indirection [p] |
| test.cpp:69:5:69:25 | ... = ... | test.cpp:69:10:69:10 | arr indirection [post update] [p] |
| test.cpp:69:10:69:10 | arr indirection [post update] [p] | test.cpp:70:5:70:7 | arr indirection [p] |
| test.cpp:69:14:69:19 | call to malloc | test.cpp:69:5:69:25 | ... = ... |
| test.cpp:70:5:70:7 | arr indirection [p] | test.cpp:67:10:67:19 | mk_array_p indirection [p] |
| test.cpp:70:5:70:7 | arr indirection [p] | test.cpp:70:5:70:7 | arr indirection [p] |
| test.cpp:76:20:76:29 | call to mk_array_p indirection [p] | test.cpp:79:9:79:11 | arr indirection [p] |
| test.cpp:76:20:76:29 | call to mk_array_p indirection [p] | test.cpp:83:9:83:11 | arr indirection [p] |
| test.cpp:79:9:79:11 | arr indirection [p] | test.cpp:79:14:79:14 | p indirection |
| test.cpp:79:14:79:14 | p indirection | test.cpp:79:14:79:14 | p |
| test.cpp:83:9:83:11 | arr indirection [p] | test.cpp:83:14:83:14 | p indirection |
| test.cpp:83:14:83:14 | p indirection | test.cpp:83:14:83:14 | p |
| test.cpp:79:9:79:11 | arr indirection [p] | test.cpp:79:14:79:14 | p |
| test.cpp:83:9:83:11 | arr indirection [p] | test.cpp:83:14:83:14 | p |
| test.cpp:87:28:87:30 | arr indirection [p] | test.cpp:89:9:89:11 | arr indirection [p] |
| test.cpp:87:28:87:30 | arr indirection [p] | test.cpp:93:9:93:11 | arr indirection [p] |
| test.cpp:89:9:89:11 | arr indirection [p] | test.cpp:89:14:89:14 | p indirection |
| test.cpp:89:14:89:14 | p indirection | test.cpp:89:14:89:14 | p |
| test.cpp:93:9:93:11 | arr indirection [p] | test.cpp:93:14:93:14 | p indirection |
| test.cpp:93:14:93:14 | p indirection | test.cpp:93:14:93:14 | p |
| test.cpp:89:9:89:11 | arr indirection [p] | test.cpp:89:14:89:14 | p |
| test.cpp:93:9:93:11 | arr indirection [p] | test.cpp:93:14:93:14 | p |
| test.cpp:98:18:98:27 | call to mk_array_p indirection [p] | test.cpp:87:28:87:30 | arr indirection [p] |
nodes
| test.cpp:4:17:4:22 | call to malloc | semmle.label | call to malloc |
@@ -60,17 +51,13 @@ nodes
| test.cpp:28:19:28:26 | call to mk_array [p] | semmle.label | call to mk_array [p] |
| test.cpp:31:9:31:11 | arr indirection [p] | semmle.label | arr indirection [p] |
| test.cpp:31:13:31:13 | p | semmle.label | p |
| test.cpp:31:13:31:13 | p indirection | semmle.label | p indirection |
| test.cpp:35:9:35:11 | arr indirection [p] | semmle.label | arr indirection [p] |
| test.cpp:35:13:35:13 | p | semmle.label | p |
| test.cpp:35:13:35:13 | p indirection | semmle.label | p indirection |
| test.cpp:39:27:39:29 | arr [p] | semmle.label | arr [p] |
| test.cpp:41:9:41:11 | arr indirection [p] | semmle.label | arr indirection [p] |
| test.cpp:41:13:41:13 | p | semmle.label | p |
| test.cpp:41:13:41:13 | p indirection | semmle.label | p indirection |
| test.cpp:45:9:45:11 | arr indirection [p] | semmle.label | arr indirection [p] |
| test.cpp:45:13:45:13 | p | semmle.label | p |
| test.cpp:45:13:45:13 | p indirection | semmle.label | p indirection |
| test.cpp:50:18:50:25 | call to mk_array [p] | semmle.label | call to mk_array [p] |
| test.cpp:55:5:55:24 | ... = ... | semmle.label | ... = ... |
| test.cpp:55:9:55:9 | arr indirection [post update] [p] | semmle.label | arr indirection [post update] [p] |
@@ -78,10 +65,8 @@ nodes
| test.cpp:56:5:56:7 | arr indirection [p] | semmle.label | arr indirection [p] |
| test.cpp:59:9:59:11 | arr indirection [p] | semmle.label | arr indirection [p] |
| test.cpp:59:13:59:13 | p | semmle.label | p |
| test.cpp:59:13:59:13 | p indirection | semmle.label | p indirection |
| test.cpp:63:9:63:11 | arr indirection [p] | semmle.label | arr indirection [p] |
| test.cpp:63:13:63:13 | p | semmle.label | p |
| test.cpp:63:13:63:13 | p indirection | semmle.label | p indirection |
| test.cpp:67:10:67:19 | mk_array_p indirection [p] | semmle.label | mk_array_p indirection [p] |
| test.cpp:69:5:69:25 | ... = ... | semmle.label | ... = ... |
| test.cpp:69:10:69:10 | arr indirection [post update] [p] | semmle.label | arr indirection [post update] [p] |
@@ -90,17 +75,13 @@ nodes
| test.cpp:76:20:76:29 | call to mk_array_p indirection [p] | semmle.label | call to mk_array_p indirection [p] |
| test.cpp:79:9:79:11 | arr indirection [p] | semmle.label | arr indirection [p] |
| test.cpp:79:14:79:14 | p | semmle.label | p |
| test.cpp:79:14:79:14 | p indirection | semmle.label | p indirection |
| test.cpp:83:9:83:11 | arr indirection [p] | semmle.label | arr indirection [p] |
| test.cpp:83:14:83:14 | p | semmle.label | p |
| test.cpp:83:14:83:14 | p indirection | semmle.label | p indirection |
| test.cpp:87:28:87:30 | arr indirection [p] | semmle.label | arr indirection [p] |
| test.cpp:89:9:89:11 | arr indirection [p] | semmle.label | arr indirection [p] |
| test.cpp:89:14:89:14 | p | semmle.label | p |
| test.cpp:89:14:89:14 | p indirection | semmle.label | p indirection |
| test.cpp:93:9:93:11 | arr indirection [p] | semmle.label | arr indirection [p] |
| test.cpp:93:14:93:14 | p | semmle.label | p |
| test.cpp:93:14:93:14 | p indirection | semmle.label | p indirection |
| test.cpp:98:18:98:27 | call to mk_array_p indirection [p] | semmle.label | call to mk_array_p indirection [p] |
subpaths
#select

View File

@@ -69,12 +69,6 @@ edges
| test.cpp:322:19:322:27 | ... + ... | test.cpp:325:24:325:26 | end |
| test.cpp:324:23:324:26 | temp | test.cpp:324:23:324:32 | ... + ... |
| test.cpp:324:23:324:32 | ... + ... | test.cpp:325:15:325:19 | temp2 |
| test.cpp:351:9:351:11 | arr | test.cpp:351:9:351:14 | access to array |
| test.cpp:351:9:351:11 | arr | test.cpp:351:18:351:25 | access to array |
| test.cpp:351:18:351:20 | arr | test.cpp:351:9:351:14 | access to array |
| test.cpp:351:18:351:20 | arr | test.cpp:351:18:351:25 | access to array |
| test.cpp:351:29:351:31 | arr | test.cpp:351:9:351:14 | access to array |
| test.cpp:351:29:351:31 | arr | test.cpp:351:18:351:25 | access to array |
nodes
| test.cpp:34:5:34:24 | access to array | semmle.label | access to array |
| test.cpp:34:10:34:12 | buf | semmle.label | buf |
@@ -167,11 +161,6 @@ nodes
| test.cpp:325:15:325:19 | temp2 | semmle.label | temp2 |
| test.cpp:325:24:325:26 | end | semmle.label | end |
| test.cpp:325:24:325:26 | end | semmle.label | end |
| test.cpp:351:9:351:11 | arr | semmle.label | arr |
| test.cpp:351:9:351:14 | access to array | semmle.label | access to array |
| test.cpp:351:18:351:20 | arr | semmle.label | arr |
| test.cpp:351:18:351:25 | access to array | semmle.label | access to array |
| test.cpp:351:29:351:31 | arr | semmle.label | arr |
subpaths
#select
| test.cpp:35:5:35:22 | PointerAdd: access to array | test.cpp:35:10:35:12 | buf | test.cpp:35:5:35:22 | access to array | This pointer arithmetic may have an off-by-1 error allowing it to overrun $@ at this $@. | test.cpp:15:9:15:11 | buf | buf | test.cpp:35:5:35:26 | Store: ... = ... | write |
@@ -194,6 +183,3 @@ subpaths
| test.cpp:322:19:322:27 | PointerAdd: ... + ... | test.cpp:322:19:322:22 | temp | test.cpp:325:24:325:26 | end | This pointer arithmetic may have an off-by-1 error allowing it to overrun $@ at this $@. | test.cpp:314:10:314:13 | temp | temp | test.cpp:330:13:330:24 | Store: ... = ... | write |
| test.cpp:322:19:322:27 | PointerAdd: ... + ... | test.cpp:322:19:322:22 | temp | test.cpp:325:24:325:26 | end | This pointer arithmetic may have an off-by-1 error allowing it to overrun $@ at this $@. | test.cpp:314:10:314:13 | temp | temp | test.cpp:331:13:331:24 | Store: ... = ... | write |
| test.cpp:322:19:322:27 | PointerAdd: ... + ... | test.cpp:322:19:322:22 | temp | test.cpp:325:24:325:26 | end | This pointer arithmetic may have an off-by-1 error allowing it to overrun $@ at this $@. | test.cpp:314:10:314:13 | temp | temp | test.cpp:333:13:333:24 | Store: ... = ... | write |
| test.cpp:351:18:351:25 | PointerAdd: access to array | test.cpp:351:9:351:11 | arr | test.cpp:351:18:351:25 | access to array | This pointer arithmetic may have an off-by-1 error allowing it to overrun $@ at this $@. | test.cpp:348:9:348:11 | arr | arr | test.cpp:351:18:351:25 | Load: access to array | read |
| test.cpp:351:18:351:25 | PointerAdd: access to array | test.cpp:351:18:351:20 | arr | test.cpp:351:18:351:25 | access to array | This pointer arithmetic may have an off-by-1 error allowing it to overrun $@ at this $@. | test.cpp:348:9:348:11 | arr | arr | test.cpp:351:18:351:25 | Load: access to array | read |
| test.cpp:351:18:351:25 | PointerAdd: access to array | test.cpp:351:29:351:31 | arr | test.cpp:351:18:351:25 | access to array | This pointer arithmetic may have an off-by-1 error allowing it to overrun $@ at this $@. | test.cpp:348:9:348:11 | arr | arr | test.cpp:351:18:351:25 | Load: access to array | read |

View File

@@ -348,7 +348,7 @@ int positiveRange(int x) {
int arr[128];
for(int i=127-offset; i>= 0; i--) {
arr[i] = arr[i+1] + arr[i+offset]; // GOOD [FALSE POSITIVE]
arr[i] = arr[i+1] + arr[i+offset]; // GOOD
}
return arr[0];
}

View File

@@ -1 +0,0 @@
experimental/Security/CWE/CWE-193/InvalidPointerDeref.ql

View File

@@ -34,11 +34,11 @@ newArrayExprDeallocators
| allocators.cpp:108:3:108:19 | new[] | FailedInit | void FailedInit::operator delete[](void*, size_t) | 1 | 1 | sized |
| allocators.cpp:110:3:110:37 | new[] | FailedInitOveraligned | void FailedInitOveraligned::operator delete[](void*, std::align_val_t, float) | 128 | 128 | aligned |
deleteExprs
| allocators.cpp:59:3:59:35 | delete | int | void operator delete(void*, unsigned long) | 4 | 4 | sized |
| allocators.cpp:60:3:60:38 | delete | String | void operator delete(void*, unsigned long) | 8 | 8 | sized |
| allocators.cpp:61:3:61:44 | delete | SizedDealloc | void SizedDealloc::operator delete(void*, size_t) | 32 | 1 | sized |
| allocators.cpp:62:3:62:43 | delete | Overaligned | void operator delete(void*, unsigned long, std::align_val_t) | 256 | 128 | sized aligned |
| allocators.cpp:64:3:64:44 | delete | const String | void operator delete(void*, unsigned long) | 8 | 8 | sized |
| allocators.cpp:59:3:59:35 | delete | int | void operator delete(void*, unsigned long) | 4 | 4 | sized | false |
| allocators.cpp:60:3:60:38 | delete | String | void operator delete(void*, unsigned long) | 8 | 8 | sized | false |
| allocators.cpp:61:3:61:44 | delete | SizedDealloc | void SizedDealloc::operator delete(void*, size_t) | 32 | 1 | sized | true |
| allocators.cpp:62:3:62:43 | delete | Overaligned | void operator delete(void*, unsigned long, std::align_val_t) | 256 | 128 | sized aligned | false |
| allocators.cpp:64:3:64:44 | delete | const String | void operator delete(void*, unsigned long) | 8 | 8 | sized | false |
deleteArrayExprs
| allocators.cpp:78:3:78:37 | delete[] | int | void operator delete[](void*, unsigned long) | 4 | 4 | sized |
| allocators.cpp:79:3:79:40 | delete[] | String | void operator delete[](void*, unsigned long) | 8 | 8 | sized |

View File

@@ -77,7 +77,8 @@ query predicate newArrayExprDeallocators(
}
query predicate deleteExprs(
DeleteExpr expr, string type, string sig, int size, int alignment, string form
DeleteExpr expr, string type, string sig, int size, int alignment, string form,
boolean hasDeallocatorCall
) {
exists(Function deallocator, Type deletedType |
expr.getDeallocator() = deallocator and
@@ -90,7 +91,10 @@ query predicate deleteExprs(
(if expr.hasAlignedDeallocation() then aligned = "aligned" else aligned = "") and
(if expr.hasSizedDeallocation() then sized = "sized" else sized = "") and
form = sized + " " + aligned
)
) and
if exists(expr.getDeallocatorCall())
then hasDeallocatorCall = true
else hasDeallocatorCall = false
)
}

View File

@@ -1,4 +1,4 @@
WARNING: Module TaintedWithPath has been deprecated and may be removed in future (tainted.ql:10,8-47)
WARNING: Predicate tainted has been deprecated and may be removed in future (tainted.ql:21,3-28)
failures
testFailures
failures

View File

@@ -0,0 +1,14 @@
namespace {
struct Foo {
char string[10];
};
void acquire(char*);
Foo* test_self_argument_flow() {
Foo *info;
acquire(info->string); // clean
return info;
}
}

View File

@@ -732,7 +732,7 @@ void test_does_not_write_source_to_dereference()
{
int x;
does_not_write_source_to_dereference(&x);
sink(x); // $ ast,ir=733:7 SPURIOUS: ast,ir=726:11
sink(x); // $ ast=733:7 ir SPURIOUS: ast=726:11
}
void sometimes_calls_sink_eq(int x, int n) {
@@ -788,4 +788,12 @@ void test_sometimes_calls_sink_switch() {
sometimes_calls_sink_switch(source(), 1);
sometimes_calls_sink_switch(0, 0);
sometimes_calls_sink_switch(source(), 0);
}
void intPointerSource(int *ref_source, const int* another_arg);
void test() {
MyStruct a;
intPointerSource(a.content, a.content);
indirect_sink(a.content); // $ ast ir
}

View File

@@ -5,5 +5,5 @@ WARNING: Module DataFlow has been deprecated and may be removed in future (test.
WARNING: Module DataFlow has been deprecated and may be removed in future (test.ql:40,25-33)
WARNING: Module DataFlow has been deprecated and may be removed in future (test.ql:42,17-25)
WARNING: Module DataFlow has been deprecated and may be removed in future (test.ql:46,20-28)
failures
testFailures
failures

View File

@@ -0,0 +1,2 @@
testFailures
failures

View File

@@ -0,0 +1,33 @@
import cpp
import semmle.code.cpp.dataflow.new.DataFlow
import TestUtilities.InlineExpectationsTest
module TestConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) {
source.getLocation().getFile().getBaseName() = "self_argument_flow.cpp" and
source.asDefiningArgument() =
any(Call call | call.getTarget().hasName("acquire")).getAnArgument()
}
predicate isSink(DataFlow::Node sink) {
sink.asIndirectArgument() = any(Call call | call.getTarget().hasName("acquire")).getAnArgument()
}
}
import DataFlow::Global<TestConfig>
module TestSelfArgumentFlow implements TestSig {
string getARelevantTag() { result = "self-arg-flow" }
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(DataFlow::Node sink |
flowTo(sink) and
location = sink.getLocation() and
element = sink.toString() and
tag = "self-arg-flow" and
value = ""
)
}
}
import MakeTest<TestSelfArgumentFlow>

View File

@@ -14,6 +14,8 @@
| ref.cpp:120:17:120:18 | x3 | ref.cpp:129:10:129:11 | x3 |
| ref.cpp:120:21:120:22 | x4 | ref.cpp:131:15:131:16 | x4 |
| ref.cpp:120:21:120:22 | x4 | ref.cpp:132:10:132:11 | x4 |
| self_argument_flow.cpp:9:10:9:13 | info | self_argument_flow.cpp:10:13:10:16 | info |
| self_argument_flow.cpp:9:10:9:13 | info | self_argument_flow.cpp:12:12:12:15 | info |
| test.cpp:75:7:75:8 | u1 | test.cpp:76:8:76:9 | u1 |
| test.cpp:83:7:83:8 | u2 | test.cpp:84:13:84:14 | u2 |
| test.cpp:83:7:83:8 | u2 | test.cpp:85:8:85:9 | u2 |
@@ -44,3 +46,6 @@
| test.cpp:595:8:595:9 | xs | test.cpp:597:9:597:10 | xs |
| test.cpp:733:7:733:7 | x | test.cpp:734:41:734:41 | x |
| test.cpp:733:7:733:7 | x | test.cpp:735:8:735:8 | x |
| test.cpp:796:12:796:12 | a | test.cpp:797:20:797:20 | a |
| test.cpp:796:12:796:12 | a | test.cpp:797:31:797:31 | a |
| test.cpp:796:12:796:12 | a | test.cpp:798:17:798:17 | a |

View File

@@ -1,2 +1,2 @@
failures
testFailures
failures

View File

@@ -134,7 +134,7 @@ void pointer_test() {
sink(*p3); // $ ast,ir
*p3 = 0;
sink(*p3); // $ SPURIOUS: ast,ir
sink(*p3); // $ SPURIOUS: ast
}
// --- return values ---

View File

@@ -3,5 +3,5 @@ WARNING: Module DataFlow has been deprecated and may be removed in future (taint
WARNING: Module DataFlow has been deprecated and may be removed in future (taint.ql:61,22-30)
WARNING: Module DataFlow has been deprecated and may be removed in future (taint.ql:68,25-33)
WARNING: Module TaintTracking has been deprecated and may be removed in future (taint.ql:73,20-33)
failures
testFailures
failures

View File

@@ -1,3 +0,0 @@
| file://:0:0:0:0 | There was an error during this compilation |
| float128.cpp:1:39:1:39 | 128-bit floating-point types are not supported in this configuration |
| float128.cpp:2:30:2:30 | 128-bit floating-point types are not supported in this configuration |

View File

@@ -1,4 +0,0 @@
import cpp
from Diagnostic d
select d

View File

@@ -1,5 +1,5 @@
typedef _Complex float __attribute__((mode(TC))) _Complex128; // [COMPILER ERROR AND ERROR-TYPE DUE TO __float128 BEING DISABLED]
typedef float __attribute__((mode(TF))) _Float128; // [COMPILER ERROR AND ERROR-TYPE DUE TO __float128 BEING DISABLED]
typedef _Complex float __attribute__((mode(TC))) _Complex128;
typedef float __attribute__((mode(TF))) _Float128;
int main() {
__float128 f = 1.0f;
@@ -25,4 +25,3 @@ __float128 id(__float128 q)
{
return q;
}
// semmle-extractor-options: --expect_errors

View File

@@ -1,5 +1,5 @@
| float128.cpp:1:50:1:60 | _Complex128 | file://:0:0:0:0 | <error-type> |
| float128.cpp:2:41:2:49 | _Float128 | file://:0:0:0:0 | <error-type> |
| float128.cpp:1:50:1:60 | _Complex128 | file://:0:0:0:0 | float __complex__ |
| float128.cpp:2:41:2:49 | _Float128 | file://:0:0:0:0 | __float128 |
| float128.cpp:13:29:13:54 | __is_floating_point_helper<T> | float128.cpp:10:8:10:17 | false_type |
| float128.cpp:14:19:14:51 | __is_floating_point_helper<float> | float128.cpp:11:8:11:16 | true_type |
| float128.cpp:15:19:15:52 | __is_floating_point_helper<double> | float128.cpp:11:8:11:16 | true_type |

View File

@@ -1798,6 +1798,23 @@ ir.c:
# 10| Type = [CTypedefType] MyCoords
# 10| ValueCategory = lvalue
# 11| getStmt(3): [ReturnStmt] return ...
# 13| [TopLevelFunction] void CStyleCast(void*)
# 13| <params>:
# 13| getParameter(0): [Parameter] src
# 13| Type = [VoidPointerType] void *
# 14| getEntryPoint(): [BlockStmt] { ... }
# 15| getStmt(0): [DeclStmt] declaration
# 15| getDeclarationEntry(0): [VariableDeclarationEntry] definition of dst
# 15| Type = [CharPointerType] char *
# 15| getVariable().getInitializer(): [Initializer] initializer for dst
# 15| getExpr(): [VariableAccess] src
# 15| Type = [VoidPointerType] void *
# 15| ValueCategory = prvalue(load)
# 15| getExpr().getFullyConverted(): [CStyleCast] (char *)...
# 15| Conversion = [PointerConversion] pointer conversion
# 15| Type = [CharPointerType] char *
# 15| ValueCategory = prvalue
# 16| getStmt(1): [ReturnStmt] return ...
ir.cpp:
# 1| [TopLevelFunction] void Constants()
# 1| <params>:
@@ -8460,7 +8477,7 @@ ir.cpp:
# 1018| getExpr(): [DeleteExpr] delete
# 1018| Type = [VoidType] void
# 1018| ValueCategory = prvalue
# 1018| getAllocatorCall(): [FunctionCall] call to operator delete
# 1018| getDeallocatorCall(): [FunctionCall] call to operator delete
# 1018| Type = [VoidType] void
# 1018| ValueCategory = prvalue
# 1018| getExpr(): [Literal] 0
@@ -8538,7 +8555,7 @@ ir.cpp:
# 1027| getExpr(): [DeleteArrayExpr] delete[]
# 1027| Type = [VoidType] void
# 1027| ValueCategory = prvalue
# 1027| getAllocatorCall(): [FunctionCall] call to operator delete[]
# 1027| getDeallocatorCall(): [FunctionCall] call to operator delete[]
# 1027| Type = [VoidType] void
# 1027| ValueCategory = prvalue
# 1027| getExpr(): [Literal] 0
@@ -15536,6 +15553,193 @@ ir.cpp:
# 2030| Type = [IntType] int
# 2030| ValueCategory = prvalue
# 2031| getStmt(2): [ReturnStmt] return ...
# 2033| [TopLevelFunction] void NewDeleteMem()
# 2033| <params>:
# 2033| getEntryPoint(): [BlockStmt] { ... }
# 2034| getStmt(0): [DeclStmt] declaration
# 2034| getDeclarationEntry(0): [VariableDeclarationEntry] definition of x
# 2034| Type = [IntPointerType] int *
# 2034| getVariable().getInitializer(): [Initializer] initializer for x
# 2034| getExpr(): [NewExpr] new
# 2034| Type = [IntPointerType] int *
# 2034| ValueCategory = prvalue
# 2035| getStmt(1): [ExprStmt] ExprStmt
# 2035| getExpr(): [AssignExpr] ... = ...
# 2035| Type = [IntType] int
# 2035| ValueCategory = lvalue
# 2035| getLValue(): [PointerDereferenceExpr] * ...
# 2035| Type = [IntType] int
# 2035| ValueCategory = lvalue
# 2035| getOperand(): [VariableAccess] x
# 2035| Type = [IntPointerType] int *
# 2035| ValueCategory = prvalue(load)
# 2035| getRValue(): [Literal] 6
# 2035| Type = [IntType] int
# 2035| Value = [Literal] 6
# 2035| ValueCategory = prvalue
# 2036| getStmt(2): [ExprStmt] ExprStmt
# 2036| getExpr(): [DeleteExpr] delete
# 2036| Type = [VoidType] void
# 2036| ValueCategory = prvalue
# 2036| getExpr(): [VariableAccess] x
# 2036| Type = [IntPointerType] int *
# 2036| ValueCategory = prvalue(load)
# 2037| getStmt(3): [ReturnStmt] return ...
# 2039| [CopyAssignmentOperator] Base2& Base2::operator=(Base2 const&)
# 2039| <params>:
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
#-----| Type = [LValueReferenceType] const Base2 &
# 2039| [Constructor] void Base2::Base2()
# 2039| <params>:
# 2039| <initializations>:
# 2039| getEntryPoint(): [BlockStmt] { ... }
# 2039| getStmt(0): [ReturnStmt] return ...
# 2039| [CopyConstructor] void Base2::Base2(Base2 const&)
# 2039| <params>:
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
#-----| Type = [LValueReferenceType] const Base2 &
# 2041| [MemberFunction] void Base2::operator delete(void*)
# 2041| <params>:
# 2041| getParameter(0): [Parameter] p
# 2041| Type = [VoidPointerType] void *
# 2041| getEntryPoint(): [BlockStmt] { ... }
# 2042| getStmt(0): [ReturnStmt] return ...
# 2043| [Destructor,VirtualFunction] void Base2::~Base2()
# 2043| <params>:
# 2043| getEntryPoint(): [BlockStmt] { ... }
# 2043| getStmt(0): [ReturnStmt] return ...
# 2043| <destructions>:
# 2046| [CopyAssignmentOperator] Derived2& Derived2::operator=(Derived2 const&)
# 2046| <params>:
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
#-----| Type = [LValueReferenceType] const Derived2 &
# 2046| [Constructor] void Derived2::Derived2()
# 2046| <params>:
# 2046| <initializations>:
# 2046| getInitializer(0): [ConstructorDirectInit] call to Base2
# 2046| Type = [VoidType] void
# 2046| ValueCategory = prvalue
# 2046| getEntryPoint(): [BlockStmt] { ... }
# 2046| getStmt(0): [ReturnStmt] return ...
# 2046| [CopyConstructor] void Derived2::Derived2(Derived2 const&)
# 2046| <params>:
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
#-----| Type = [LValueReferenceType] const Derived2 &
# 2049| [Destructor,VirtualFunction] void Derived2::~Derived2()
# 2049| <params>:
# 2049| getEntryPoint(): [BlockStmt] { ... }
# 2049| getStmt(0): [ReturnStmt] return ...
# 2049| <destructions>:
# 2049| getDestruction(0): [DestructorDirectDestruction] call to ~Base2
# 2049| Type = [VoidType] void
# 2049| ValueCategory = prvalue
# 2051| [MemberFunction] void Derived2::operator delete(void*)
# 2051| <params>:
# 2051| getParameter(0): [Parameter] p
# 2051| Type = [VoidPointerType] void *
# 2051| getEntryPoint(): [BlockStmt] { ... }
# 2052| getStmt(0): [ReturnStmt] return ...
# 2056| [TopLevelFunction] int virtual_delete()
# 2056| <params>:
# 2057| getEntryPoint(): [BlockStmt] { ... }
# 2058| getStmt(0): [DeclStmt] declaration
# 2058| getDeclarationEntry(0): [VariableDeclarationEntry] definition of b1
# 2058| Type = [PointerType] Base2 *
# 2058| getVariable().getInitializer(): [Initializer] initializer for b1
# 2058| getExpr(): [NewExpr] new
# 2058| Type = [PointerType] Base2 *
# 2058| ValueCategory = prvalue
# 2058| getInitializer(): [ConstructorCall] call to Base2
# 2058| Type = [VoidType] void
# 2058| ValueCategory = prvalue
# 2059| getStmt(1): [ExprStmt] ExprStmt
# 2059| getExpr(): [DeleteExpr] delete
# 2059| Type = [VoidType] void
# 2059| ValueCategory = prvalue
# 2059| getDeallocatorCall(): [FunctionCall] call to operator delete
# 2059| Type = [VoidType] void
# 2059| ValueCategory = prvalue
# 2059| getDestructorCall(): [DestructorCall] call to ~Base2
# 2059| Type = [VoidType] void
# 2059| ValueCategory = prvalue
# 2059| getQualifier(): [VariableAccess] b1
# 2059| Type = [PointerType] Base2 *
# 2059| ValueCategory = prvalue(load)
# 2061| getStmt(2): [DeclStmt] declaration
# 2061| getDeclarationEntry(0): [VariableDeclarationEntry] definition of b2
# 2061| Type = [PointerType] Base2 *
# 2061| getVariable().getInitializer(): [Initializer] initializer for b2
# 2061| getExpr(): [NewExpr] new
# 2061| Type = [PointerType] Derived2 *
# 2061| ValueCategory = prvalue
# 2061| getInitializer(): [ConstructorCall] call to Derived2
# 2061| Type = [VoidType] void
# 2061| ValueCategory = prvalue
# 2061| getExpr().getFullyConverted(): [CStyleCast] (Base2 *)...
# 2061| Conversion = [BaseClassConversion] base class conversion
# 2061| Type = [PointerType] Base2 *
# 2061| ValueCategory = prvalue
# 2062| getStmt(3): [ExprStmt] ExprStmt
# 2062| getExpr(): [DeleteExpr] delete
# 2062| Type = [VoidType] void
# 2062| ValueCategory = prvalue
# 2062| getDeallocatorCall(): [FunctionCall] call to operator delete
# 2062| Type = [VoidType] void
# 2062| ValueCategory = prvalue
# 2062| getDestructorCall(): [DestructorCall] call to ~Base2
# 2062| Type = [VoidType] void
# 2062| ValueCategory = prvalue
# 2062| getQualifier(): [VariableAccess] b2
# 2062| Type = [PointerType] Base2 *
# 2062| ValueCategory = prvalue(load)
# 2064| getStmt(4): [DeclStmt] declaration
# 2064| getDeclarationEntry(0): [VariableDeclarationEntry] definition of d
# 2064| Type = [PointerType] Derived2 *
# 2064| getVariable().getInitializer(): [Initializer] initializer for d
# 2064| getExpr(): [NewExpr] new
# 2064| Type = [PointerType] Derived2 *
# 2064| ValueCategory = prvalue
# 2064| getInitializer(): [ConstructorCall] call to Derived2
# 2064| Type = [VoidType] void
# 2064| ValueCategory = prvalue
# 2065| getStmt(5): [ExprStmt] ExprStmt
# 2065| getExpr(): [DeleteExpr] delete
# 2065| Type = [VoidType] void
# 2065| ValueCategory = prvalue
# 2065| getDeallocatorCall(): [FunctionCall] call to operator delete
# 2065| Type = [VoidType] void
# 2065| ValueCategory = prvalue
# 2065| getDestructorCall(): [DestructorCall] call to ~Derived2
# 2065| Type = [VoidType] void
# 2065| ValueCategory = prvalue
# 2065| getQualifier(): [VariableAccess] d
# 2065| Type = [PointerType] Derived2 *
# 2065| ValueCategory = prvalue(load)
# 2066| getStmt(6): [ReturnStmt] return ...
# 2068| [TopLevelFunction] void test_constant_folding_use(int)
# 2068| <params>:
# 2068| getParameter(0): [Parameter] (unnamed parameter 0)
# 2068| Type = [IntType] int
# 2070| [TopLevelFunction] void test_constant_folding()
# 2070| <params>:
# 2070| getEntryPoint(): [BlockStmt] { ... }
# 2071| getStmt(0): [DeclStmt] declaration
# 2071| getDeclarationEntry(0): [VariableDeclarationEntry] definition of x
# 2071| Type = [SpecifiedType] const int
# 2071| getVariable().getInitializer(): [Initializer] initializer for x
# 2071| getExpr(): [Literal] 116
# 2071| Type = [IntType] int
# 2071| Value = [Literal] 116
# 2071| ValueCategory = prvalue
# 2072| getStmt(1): [ExprStmt] ExprStmt
# 2072| getExpr(): [FunctionCall] call to test_constant_folding_use
# 2072| Type = [VoidType] void
# 2072| ValueCategory = prvalue
# 2072| getArgument(0): [VariableAccess] x
# 2072| Type = [IntType] int
# 2072| Value = [VariableAccess] 116
# 2072| ValueCategory = prvalue(load)
# 2073| getStmt(2): [ReturnStmt] return ...
perf-regression.cpp:
# 4| [CopyAssignmentOperator] Big& Big::operator=(Big const&)
# 4| <params>:

View File

@@ -9,3 +9,10 @@ void MyCoordsTest(int pos) {
coords.x = coords.y = pos + 1;
coords.x = getX(&coords);
}
void CStyleCast(void *src)
{
char *dst = (char*)src;
}
// semmle-extractor-options: --microsoft

View File

@@ -2030,4 +2030,46 @@ unsigned int CommaTest(unsigned int x) {
(CommaTestHelper(x), 10);
}
void NewDeleteMem() {
int* x = new int; // No constructor
*x = 6;
delete x;
}
class Base2 {
public:
void operator delete(void* p) {
}
virtual ~Base2() {};
};
class Derived2 : public Base2 {
int i;
public:
~Derived2() {};
void operator delete(void* p) {
}
};
// Delete is kind-of virtual in these cases
int virtual_delete()
{
Base2* b1 = new Base2{};
delete b1;
Base2* b2 = new Derived2{};
delete b2;
Derived2* d = new Derived2{};
delete d;
}
void test_constant_folding_use(int);
void test_constant_folding() {
const int x = 116;
test_constant_folding_use(x);
}
// semmle-extractor-options: -std=c++17 --clang

View File

@@ -978,6 +978,20 @@
| ir.c:10:19:10:25 | ChiTotal | total:m9_13 |
| ir.c:10:19:10:25 | SideEffect | ~m9_13 |
| ir.c:10:20:10:25 | Unary | r10_2 |
| ir.c:13:6:13:15 | ChiPartial | partial:m13_3 |
| ir.c:13:6:13:15 | ChiTotal | total:m13_2 |
| ir.c:13:6:13:15 | SideEffect | m13_3 |
| ir.c:13:23:13:25 | Address | &:r13_5 |
| ir.c:13:23:13:25 | Address | &:r13_5 |
| ir.c:13:23:13:25 | Address | &:r13_7 |
| ir.c:13:23:13:25 | Address | &:r13_7 |
| ir.c:13:23:13:25 | Load | m13_6 |
| ir.c:13:23:13:25 | SideEffect | m13_8 |
| ir.c:15:11:15:13 | Address | &:r15_1 |
| ir.c:15:17:15:26 | StoreValue | r15_4 |
| ir.c:15:24:15:26 | Address | &:r15_2 |
| ir.c:15:24:15:26 | Load | m13_6 |
| ir.c:15:24:15:26 | Unary | r15_3 |
| ir.cpp:1:6:1:14 | ChiPartial | partial:m1_3 |
| ir.cpp:1:6:1:14 | ChiTotal | total:m1_2 |
| ir.cpp:1:6:1:14 | SideEffect | m1_3 |
@@ -4873,10 +4887,60 @@
| ir.cpp:1011:12:1011:12 | Unary | r1011_3 |
| ir.cpp:1015:6:1015:19 | ChiPartial | partial:m1015_3 |
| ir.cpp:1015:6:1015:19 | ChiTotal | total:m1015_2 |
| ir.cpp:1015:6:1015:19 | SideEffect | m1015_3 |
| ir.cpp:1015:6:1015:19 | SideEffect | ~m1020_5 |
| ir.cpp:1016:3:1016:35 | CallTarget | func:r1016_1 |
| ir.cpp:1016:3:1016:35 | ChiPartial | partial:m1016_4 |
| ir.cpp:1016:3:1016:35 | ChiTotal | total:m1015_4 |
| ir.cpp:1016:3:1016:35 | SideEffect | ~m1015_4 |
| ir.cpp:1016:10:1016:35 | Arg(0) | 0:r1016_2 |
| ir.cpp:1017:3:1017:38 | CallTarget | func:r1017_1 |
| ir.cpp:1017:3:1017:38 | ChiPartial | partial:m1017_4 |
| ir.cpp:1017:3:1017:38 | ChiTotal | total:m1016_5 |
| ir.cpp:1017:3:1017:38 | SideEffect | ~m1016_5 |
| ir.cpp:1017:10:1017:38 | Arg(0) | 0:r1017_2 |
| ir.cpp:1018:3:1018:44 | CallTarget | func:r1018_1 |
| ir.cpp:1018:3:1018:44 | ChiPartial | partial:m1018_4 |
| ir.cpp:1018:3:1018:44 | ChiTotal | total:m1017_5 |
| ir.cpp:1018:3:1018:44 | SideEffect | ~m1017_5 |
| ir.cpp:1018:10:1018:44 | Arg(0) | 0:r1018_2 |
| ir.cpp:1019:3:1019:43 | CallTarget | func:r1019_1 |
| ir.cpp:1019:3:1019:43 | ChiPartial | partial:m1019_4 |
| ir.cpp:1019:3:1019:43 | ChiTotal | total:m1018_5 |
| ir.cpp:1019:3:1019:43 | SideEffect | ~m1018_5 |
| ir.cpp:1019:10:1019:43 | Arg(0) | 0:r1019_2 |
| ir.cpp:1020:3:1020:47 | CallTarget | func:r1020_1 |
| ir.cpp:1020:3:1020:47 | ChiPartial | partial:m1020_4 |
| ir.cpp:1020:3:1020:47 | ChiTotal | total:m1019_5 |
| ir.cpp:1020:3:1020:47 | SideEffect | ~m1019_5 |
| ir.cpp:1020:10:1020:47 | Arg(0) | 0:r1020_2 |
| ir.cpp:1024:6:1024:24 | ChiPartial | partial:m1024_3 |
| ir.cpp:1024:6:1024:24 | ChiTotal | total:m1024_2 |
| ir.cpp:1024:6:1024:24 | SideEffect | m1024_3 |
| ir.cpp:1024:6:1024:24 | SideEffect | ~m1029_5 |
| ir.cpp:1025:3:1025:37 | CallTarget | func:r1025_1 |
| ir.cpp:1025:3:1025:37 | ChiPartial | partial:m1025_4 |
| ir.cpp:1025:3:1025:37 | ChiTotal | total:m1024_4 |
| ir.cpp:1025:3:1025:37 | SideEffect | ~m1024_4 |
| ir.cpp:1025:12:1025:37 | Arg(0) | 0:r1025_2 |
| ir.cpp:1026:3:1026:40 | CallTarget | func:r1026_1 |
| ir.cpp:1026:3:1026:40 | ChiPartial | partial:m1026_4 |
| ir.cpp:1026:3:1026:40 | ChiTotal | total:m1025_5 |
| ir.cpp:1026:3:1026:40 | SideEffect | ~m1025_5 |
| ir.cpp:1026:12:1026:40 | Arg(0) | 0:r1026_2 |
| ir.cpp:1027:3:1027:46 | CallTarget | func:r1027_1 |
| ir.cpp:1027:3:1027:46 | ChiPartial | partial:m1027_4 |
| ir.cpp:1027:3:1027:46 | ChiTotal | total:m1026_5 |
| ir.cpp:1027:3:1027:46 | SideEffect | ~m1026_5 |
| ir.cpp:1027:12:1027:46 | Arg(0) | 0:r1027_2 |
| ir.cpp:1028:3:1028:45 | CallTarget | func:r1028_1 |
| ir.cpp:1028:3:1028:45 | ChiPartial | partial:m1028_4 |
| ir.cpp:1028:3:1028:45 | ChiTotal | total:m1027_5 |
| ir.cpp:1028:3:1028:45 | SideEffect | ~m1027_5 |
| ir.cpp:1028:12:1028:45 | Arg(0) | 0:r1028_2 |
| ir.cpp:1029:3:1029:49 | CallTarget | func:r1029_1 |
| ir.cpp:1029:3:1029:49 | ChiPartial | partial:m1029_4 |
| ir.cpp:1029:3:1029:49 | ChiTotal | total:m1028_5 |
| ir.cpp:1029:3:1029:49 | SideEffect | ~m1028_5 |
| ir.cpp:1029:12:1029:49 | Arg(0) | 0:r1029_2 |
| ir.cpp:1034:6:1034:20 | ChiPartial | partial:m1034_3 |
| ir.cpp:1034:6:1034:20 | ChiTotal | total:m1034_2 |
| ir.cpp:1034:6:1034:20 | SideEffect | m1034_3 |
@@ -9562,6 +9626,186 @@
| ir.cpp:2030:22:2030:22 | Arg(0) | 0:r2030_3 |
| ir.cpp:2030:22:2030:22 | Load | m2026_6 |
| ir.cpp:2030:26:2030:27 | Unary | r2030_7 |
| ir.cpp:2033:6:2033:17 | ChiPartial | partial:m2033_3 |
| ir.cpp:2033:6:2033:17 | ChiTotal | total:m2033_2 |
| ir.cpp:2033:6:2033:17 | SideEffect | ~m2036_6 |
| ir.cpp:2034:8:2034:8 | Address | &:r2034_1 |
| ir.cpp:2034:12:2034:18 | Address | &:r2034_4 |
| ir.cpp:2034:12:2034:18 | Arg(0) | 0:r2034_3 |
| ir.cpp:2034:12:2034:18 | CallTarget | func:r2034_2 |
| ir.cpp:2034:12:2034:18 | ChiPartial | partial:m2034_5 |
| ir.cpp:2034:12:2034:18 | ChiTotal | total:m2033_4 |
| ir.cpp:2034:12:2034:18 | SideEffect | ~m2033_4 |
| ir.cpp:2034:12:2034:18 | StoreValue | r2034_8 |
| ir.cpp:2034:12:2034:18 | Unary | r2034_4 |
| ir.cpp:2035:3:2035:4 | Address | &:r2035_4 |
| ir.cpp:2035:3:2035:8 | ChiPartial | partial:m2035_5 |
| ir.cpp:2035:3:2035:8 | ChiTotal | total:m2034_7 |
| ir.cpp:2035:4:2035:4 | Address | &:r2035_2 |
| ir.cpp:2035:4:2035:4 | Load | m2034_9 |
| ir.cpp:2035:4:2035:4 | Unary | r2035_3 |
| ir.cpp:2035:8:2035:8 | StoreValue | r2035_1 |
| ir.cpp:2036:3:2036:10 | CallTarget | func:r2036_1 |
| ir.cpp:2036:3:2036:10 | ChiPartial | partial:m2036_5 |
| ir.cpp:2036:3:2036:10 | ChiTotal | total:m2034_6 |
| ir.cpp:2036:3:2036:10 | SideEffect | ~m2034_6 |
| ir.cpp:2036:10:2036:10 | Address | &:r2036_2 |
| ir.cpp:2036:10:2036:10 | Arg(0) | 0:r2036_3 |
| ir.cpp:2036:10:2036:10 | Load | m2034_9 |
| ir.cpp:2039:7:2039:7 | Address | &:r2039_5 |
| ir.cpp:2039:7:2039:7 | Address | &:r2039_5 |
| ir.cpp:2039:7:2039:7 | Address | &:r2039_7 |
| ir.cpp:2039:7:2039:7 | Address | &:r2039_7 |
| ir.cpp:2039:7:2039:7 | ChiPartial | partial:m2039_3 |
| ir.cpp:2039:7:2039:7 | ChiTotal | total:m2039_2 |
| ir.cpp:2039:7:2039:7 | Load | m2039_6 |
| ir.cpp:2039:7:2039:7 | SideEffect | m2039_3 |
| ir.cpp:2039:7:2039:7 | SideEffect | m2039_8 |
| ir.cpp:2041:10:2041:24 | ChiPartial | partial:m2041_3 |
| ir.cpp:2041:10:2041:24 | ChiTotal | total:m2041_2 |
| ir.cpp:2041:10:2041:24 | SideEffect | m2041_3 |
| ir.cpp:2041:32:2041:32 | Address | &:r2041_5 |
| ir.cpp:2041:32:2041:32 | Address | &:r2041_5 |
| ir.cpp:2041:32:2041:32 | Address | &:r2041_7 |
| ir.cpp:2041:32:2041:32 | Address | &:r2041_7 |
| ir.cpp:2041:32:2041:32 | Load | m2041_6 |
| ir.cpp:2041:32:2041:32 | SideEffect | m2041_8 |
| ir.cpp:2043:13:2043:18 | Address | &:r2043_5 |
| ir.cpp:2043:13:2043:18 | Address | &:r2043_5 |
| ir.cpp:2043:13:2043:18 | Address | &:r2043_7 |
| ir.cpp:2043:13:2043:18 | Address | &:r2043_7 |
| ir.cpp:2043:13:2043:18 | ChiPartial | partial:m2043_3 |
| ir.cpp:2043:13:2043:18 | ChiTotal | total:m2043_2 |
| ir.cpp:2043:13:2043:18 | Load | m2043_6 |
| ir.cpp:2043:13:2043:18 | SideEffect | m2043_3 |
| ir.cpp:2043:13:2043:18 | SideEffect | m2043_8 |
| ir.cpp:2046:7:2046:7 | Address | &:r2046_5 |
| ir.cpp:2046:7:2046:7 | Address | &:r2046_5 |
| ir.cpp:2046:7:2046:7 | Address | &:r2046_7 |
| ir.cpp:2046:7:2046:7 | Address | &:r2046_7 |
| ir.cpp:2046:7:2046:7 | Address | &:r2046_9 |
| ir.cpp:2046:7:2046:7 | Arg(this) | this:r2046_9 |
| ir.cpp:2046:7:2046:7 | CallTarget | func:r2046_10 |
| ir.cpp:2046:7:2046:7 | ChiPartial | partial:m2046_3 |
| ir.cpp:2046:7:2046:7 | ChiPartial | partial:m2046_12 |
| ir.cpp:2046:7:2046:7 | ChiPartial | partial:m2046_14 |
| ir.cpp:2046:7:2046:7 | ChiTotal | total:m2046_2 |
| ir.cpp:2046:7:2046:7 | ChiTotal | total:m2046_4 |
| ir.cpp:2046:7:2046:7 | ChiTotal | total:m2046_8 |
| ir.cpp:2046:7:2046:7 | Load | m2046_6 |
| ir.cpp:2046:7:2046:7 | SideEffect | m2046_15 |
| ir.cpp:2046:7:2046:7 | SideEffect | ~m2046_4 |
| ir.cpp:2046:7:2046:7 | SideEffect | ~m2046_13 |
| ir.cpp:2046:7:2046:7 | Unary | m2046_6 |
| ir.cpp:2049:5:2049:13 | Address | &:r2049_5 |
| ir.cpp:2049:5:2049:13 | Address | &:r2049_5 |
| ir.cpp:2049:5:2049:13 | Address | &:r2049_7 |
| ir.cpp:2049:5:2049:13 | Address | &:r2049_7 |
| ir.cpp:2049:5:2049:13 | ChiPartial | partial:m2049_3 |
| ir.cpp:2049:5:2049:13 | ChiTotal | total:m2049_2 |
| ir.cpp:2049:5:2049:13 | Load | m2049_6 |
| ir.cpp:2049:5:2049:13 | SideEffect | m2049_8 |
| ir.cpp:2049:5:2049:13 | SideEffect | ~m2049_14 |
| ir.cpp:2049:5:2049:13 | Unary | m2049_6 |
| ir.cpp:2049:18:2049:18 | Arg(this) | this:r2049_10 |
| ir.cpp:2049:18:2049:18 | CallTarget | func:r2049_11 |
| ir.cpp:2049:18:2049:18 | ChiPartial | partial:m2049_13 |
| ir.cpp:2049:18:2049:18 | ChiTotal | total:m2049_4 |
| ir.cpp:2049:18:2049:18 | SideEffect | ~m2049_4 |
| ir.cpp:2051:10:2051:24 | ChiPartial | partial:m2051_3 |
| ir.cpp:2051:10:2051:24 | ChiTotal | total:m2051_2 |
| ir.cpp:2051:10:2051:24 | SideEffect | m2051_3 |
| ir.cpp:2051:32:2051:32 | Address | &:r2051_5 |
| ir.cpp:2051:32:2051:32 | Address | &:r2051_5 |
| ir.cpp:2051:32:2051:32 | Address | &:r2051_7 |
| ir.cpp:2051:32:2051:32 | Address | &:r2051_7 |
| ir.cpp:2051:32:2051:32 | Load | m2051_6 |
| ir.cpp:2051:32:2051:32 | SideEffect | m2051_8 |
| ir.cpp:2056:5:2056:18 | ChiPartial | partial:m2056_3 |
| ir.cpp:2056:5:2056:18 | ChiTotal | total:m2056_2 |
| ir.cpp:2058:12:2058:13 | Address | &:r2058_1 |
| ir.cpp:2058:17:2058:27 | Address | &:r2058_4 |
| ir.cpp:2058:17:2058:27 | Address | &:r2058_8 |
| ir.cpp:2058:17:2058:27 | Arg(0) | 0:r2058_3 |
| ir.cpp:2058:17:2058:27 | Arg(this) | this:r2058_8 |
| ir.cpp:2058:17:2058:27 | CallTarget | func:r2058_2 |
| ir.cpp:2058:17:2058:27 | CallTarget | func:r2058_9 |
| ir.cpp:2058:17:2058:27 | ChiPartial | partial:m2058_5 |
| ir.cpp:2058:17:2058:27 | ChiPartial | partial:m2058_11 |
| ir.cpp:2058:17:2058:27 | ChiPartial | partial:m2058_13 |
| ir.cpp:2058:17:2058:27 | ChiTotal | total:m2056_4 |
| ir.cpp:2058:17:2058:27 | ChiTotal | total:m2058_6 |
| ir.cpp:2058:17:2058:27 | ChiTotal | total:m2058_7 |
| ir.cpp:2058:17:2058:27 | SideEffect | ~m2056_4 |
| ir.cpp:2058:17:2058:27 | SideEffect | ~m2058_6 |
| ir.cpp:2058:17:2058:27 | StoreValue | r2058_8 |
| ir.cpp:2058:17:2058:27 | Unary | r2058_4 |
| ir.cpp:2059:5:2059:13 | CallTarget | func:r2059_1 |
| ir.cpp:2059:5:2059:13 | ChiPartial | partial:m2059_5 |
| ir.cpp:2059:5:2059:13 | ChiTotal | total:m2058_12 |
| ir.cpp:2059:5:2059:13 | SideEffect | ~m2058_12 |
| ir.cpp:2059:12:2059:13 | Address | &:r2059_2 |
| ir.cpp:2059:12:2059:13 | Arg(0) | 0:r2059_3 |
| ir.cpp:2059:12:2059:13 | Load | m2058_15 |
| ir.cpp:2061:12:2061:13 | Address | &:r2061_1 |
| ir.cpp:2061:17:2061:30 | Address | &:r2061_4 |
| ir.cpp:2061:17:2061:30 | Address | &:r2061_8 |
| ir.cpp:2061:17:2061:30 | Arg(0) | 0:r2061_3 |
| ir.cpp:2061:17:2061:30 | Arg(this) | this:r2061_8 |
| ir.cpp:2061:17:2061:30 | CallTarget | func:r2061_2 |
| ir.cpp:2061:17:2061:30 | CallTarget | func:r2061_9 |
| ir.cpp:2061:17:2061:30 | ChiPartial | partial:m2061_5 |
| ir.cpp:2061:17:2061:30 | ChiPartial | partial:m2061_11 |
| ir.cpp:2061:17:2061:30 | ChiPartial | partial:m2061_13 |
| ir.cpp:2061:17:2061:30 | ChiTotal | total:m2059_6 |
| ir.cpp:2061:17:2061:30 | ChiTotal | total:m2061_6 |
| ir.cpp:2061:17:2061:30 | ChiTotal | total:m2061_7 |
| ir.cpp:2061:17:2061:30 | SideEffect | ~m2059_6 |
| ir.cpp:2061:17:2061:30 | SideEffect | ~m2061_6 |
| ir.cpp:2061:17:2061:30 | StoreValue | r2061_15 |
| ir.cpp:2061:17:2061:30 | Unary | r2061_4 |
| ir.cpp:2061:17:2061:30 | Unary | r2061_8 |
| ir.cpp:2062:5:2062:13 | CallTarget | func:r2062_1 |
| ir.cpp:2062:5:2062:13 | ChiPartial | partial:m2062_5 |
| ir.cpp:2062:5:2062:13 | ChiTotal | total:m2061_12 |
| ir.cpp:2062:5:2062:13 | SideEffect | ~m2061_12 |
| ir.cpp:2062:12:2062:13 | Address | &:r2062_2 |
| ir.cpp:2062:12:2062:13 | Arg(0) | 0:r2062_3 |
| ir.cpp:2062:12:2062:13 | Load | m2061_16 |
| ir.cpp:2064:15:2064:15 | Address | &:r2064_1 |
| ir.cpp:2064:19:2064:32 | Address | &:r2064_4 |
| ir.cpp:2064:19:2064:32 | Address | &:r2064_8 |
| ir.cpp:2064:19:2064:32 | Arg(0) | 0:r2064_3 |
| ir.cpp:2064:19:2064:32 | Arg(this) | this:r2064_8 |
| ir.cpp:2064:19:2064:32 | CallTarget | func:r2064_2 |
| ir.cpp:2064:19:2064:32 | CallTarget | func:r2064_9 |
| ir.cpp:2064:19:2064:32 | ChiPartial | partial:m2064_5 |
| ir.cpp:2064:19:2064:32 | ChiPartial | partial:m2064_11 |
| ir.cpp:2064:19:2064:32 | ChiPartial | partial:m2064_13 |
| ir.cpp:2064:19:2064:32 | ChiTotal | total:m2062_6 |
| ir.cpp:2064:19:2064:32 | ChiTotal | total:m2064_6 |
| ir.cpp:2064:19:2064:32 | ChiTotal | total:m2064_7 |
| ir.cpp:2064:19:2064:32 | SideEffect | ~m2062_6 |
| ir.cpp:2064:19:2064:32 | SideEffect | ~m2064_6 |
| ir.cpp:2064:19:2064:32 | StoreValue | r2064_8 |
| ir.cpp:2064:19:2064:32 | Unary | r2064_4 |
| ir.cpp:2065:5:2065:12 | CallTarget | func:r2065_1 |
| ir.cpp:2065:5:2065:12 | ChiPartial | partial:m2065_5 |
| ir.cpp:2065:5:2065:12 | ChiTotal | total:m2064_12 |
| ir.cpp:2065:5:2065:12 | SideEffect | ~m2064_12 |
| ir.cpp:2065:12:2065:12 | Address | &:r2065_2 |
| ir.cpp:2065:12:2065:12 | Arg(0) | 0:r2065_3 |
| ir.cpp:2065:12:2065:12 | Load | m2064_15 |
| ir.cpp:2070:6:2070:26 | ChiPartial | partial:m2070_3 |
| ir.cpp:2070:6:2070:26 | ChiTotal | total:m2070_2 |
| ir.cpp:2070:6:2070:26 | SideEffect | ~m2072_5 |
| ir.cpp:2071:13:2071:13 | Address | &:r2071_1 |
| ir.cpp:2071:16:2071:19 | StoreValue | r2071_2 |
| ir.cpp:2072:3:2072:27 | CallTarget | func:r2072_1 |
| ir.cpp:2072:3:2072:27 | ChiPartial | partial:m2072_4 |
| ir.cpp:2072:3:2072:27 | ChiTotal | total:m2070_4 |
| ir.cpp:2072:3:2072:27 | SideEffect | ~m2070_4 |
| ir.cpp:2072:29:2072:29 | Arg(0) | 0:r2072_2 |
| perf-regression.cpp:6:3:6:5 | Address | &:r6_5 |
| perf-regression.cpp:6:3:6:5 | Address | &:r6_5 |
| perf-regression.cpp:6:3:6:5 | Address | &:r6_7 |

View File

@@ -766,6 +766,26 @@ ir.c:
# 7| v7_7(void) = AliasedUse : ~m?
# 7| v7_8(void) = ExitFunction :
# 13| void CStyleCast(void*)
# 13| Block 0
# 13| v13_1(void) = EnterFunction :
# 13| mu13_2(unknown) = AliasedDefinition :
# 13| mu13_3(unknown) = InitializeNonLocal :
# 13| r13_4(glval<void *>) = VariableAddress[src] :
# 13| mu13_5(void *) = InitializeParameter[src] : &:r13_4
# 13| r13_6(void *) = Load[src] : &:r13_4, ~m?
# 13| mu13_7(unknown) = InitializeIndirection[src] : &:r13_6
# 15| r15_1(glval<char *>) = VariableAddress[dst] :
# 15| r15_2(glval<void *>) = VariableAddress[src] :
# 15| r15_3(void *) = Load[src] : &:r15_2, ~m?
# 15| r15_4(char *) = Convert : r15_3
# 15| mu15_5(char *) = Store[dst] : &:r15_1, r15_4
# 16| v16_1(void) = NoOp :
# 13| v13_8(void) = ReturnIndirection[src] : &:r13_6, ~m?
# 13| v13_9(void) = ReturnVoid :
# 13| v13_10(void) = AliasedUse : ~m?
# 13| v13_11(void) = ExitFunction :
ir.cpp:
# 1| void Constants()
# 1| Block 0
@@ -5643,43 +5663,63 @@ ir.cpp:
# 1015| void OperatorDelete()
# 1015| Block 0
# 1015| v1015_1(void) = EnterFunction :
# 1015| mu1015_2(unknown) = AliasedDefinition :
# 1015| mu1015_3(unknown) = InitializeNonLocal :
# 1016| r1016_1(int *) = Constant[0] :
# 1016| v1016_2(void) = NoOp :
# 1017| r1017_1(String *) = Constant[0] :
# 1017| v1017_2(void) = NoOp :
# 1018| r1018_1(SizedDealloc *) = Constant[0] :
# 1018| v1018_2(void) = NoOp :
# 1019| r1019_1(Overaligned *) = Constant[0] :
# 1019| v1019_2(void) = NoOp :
# 1020| r1020_1(PolymorphicBase *) = Constant[0] :
# 1020| v1020_2(void) = NoOp :
# 1021| v1021_1(void) = NoOp :
# 1015| v1015_4(void) = ReturnVoid :
# 1015| v1015_5(void) = AliasedUse : ~m?
# 1015| v1015_6(void) = ExitFunction :
# 1015| v1015_1(void) = EnterFunction :
# 1015| mu1015_2(unknown) = AliasedDefinition :
# 1015| mu1015_3(unknown) = InitializeNonLocal :
# 1016| r1016_1(glval<unknown>) = FunctionAddress[operator delete] :
# 1016| r1016_2(int *) = Constant[0] :
# 1016| v1016_3(void) = Call[operator delete] : func:r1016_1, 0:r1016_2
# 1016| mu1016_4(unknown) = ^CallSideEffect : ~m?
# 1017| r1017_1(glval<unknown>) = FunctionAddress[operator delete] :
# 1017| r1017_2(String *) = Constant[0] :
# 1017| v1017_3(void) = Call[operator delete] : func:r1017_1, 0:r1017_2
# 1017| mu1017_4(unknown) = ^CallSideEffect : ~m?
# 1018| r1018_1(glval<unknown>) = FunctionAddress[operator delete] :
# 1018| r1018_2(SizedDealloc *) = Constant[0] :
# 1018| v1018_3(void) = Call[operator delete] : func:r1018_1, 0:r1018_2
# 1018| mu1018_4(unknown) = ^CallSideEffect : ~m?
# 1019| r1019_1(glval<unknown>) = FunctionAddress[operator delete] :
# 1019| r1019_2(Overaligned *) = Constant[0] :
# 1019| v1019_3(void) = Call[operator delete] : func:r1019_1, 0:r1019_2
# 1019| mu1019_4(unknown) = ^CallSideEffect : ~m?
# 1020| r1020_1(glval<unknown>) = VirtualDeleteFunctionAddress :
# 1020| r1020_2(PolymorphicBase *) = Constant[0] :
# 1020| v1020_3(void) = Call[?] : func:r1020_1, 0:r1020_2
# 1020| mu1020_4(unknown) = ^CallSideEffect : ~m?
# 1021| v1021_1(void) = NoOp :
# 1015| v1015_4(void) = ReturnVoid :
# 1015| v1015_5(void) = AliasedUse : ~m?
# 1015| v1015_6(void) = ExitFunction :
# 1024| void OperatorDeleteArray()
# 1024| Block 0
# 1024| v1024_1(void) = EnterFunction :
# 1024| mu1024_2(unknown) = AliasedDefinition :
# 1024| mu1024_3(unknown) = InitializeNonLocal :
# 1025| r1025_1(int *) = Constant[0] :
# 1025| v1025_2(void) = NoOp :
# 1026| r1026_1(String *) = Constant[0] :
# 1026| v1026_2(void) = NoOp :
# 1027| r1027_1(SizedDealloc *) = Constant[0] :
# 1027| v1027_2(void) = NoOp :
# 1028| r1028_1(Overaligned *) = Constant[0] :
# 1028| v1028_2(void) = NoOp :
# 1029| r1029_1(PolymorphicBase *) = Constant[0] :
# 1029| v1029_2(void) = NoOp :
# 1030| v1030_1(void) = NoOp :
# 1024| v1024_4(void) = ReturnVoid :
# 1024| v1024_5(void) = AliasedUse : ~m?
# 1024| v1024_6(void) = ExitFunction :
# 1024| v1024_1(void) = EnterFunction :
# 1024| mu1024_2(unknown) = AliasedDefinition :
# 1024| mu1024_3(unknown) = InitializeNonLocal :
# 1025| r1025_1(glval<unknown>) = FunctionAddress[operator delete[]] :
# 1025| r1025_2(int *) = Constant[0] :
# 1025| v1025_3(void) = Call[operator delete[]] : func:r1025_1, 0:r1025_2
# 1025| mu1025_4(unknown) = ^CallSideEffect : ~m?
# 1026| r1026_1(glval<unknown>) = FunctionAddress[operator delete[]] :
# 1026| r1026_2(String *) = Constant[0] :
# 1026| v1026_3(void) = Call[operator delete[]] : func:r1026_1, 0:r1026_2
# 1026| mu1026_4(unknown) = ^CallSideEffect : ~m?
# 1027| r1027_1(glval<unknown>) = FunctionAddress[operator delete[]] :
# 1027| r1027_2(SizedDealloc *) = Constant[0] :
# 1027| v1027_3(void) = Call[operator delete[]] : func:r1027_1, 0:r1027_2
# 1027| mu1027_4(unknown) = ^CallSideEffect : ~m?
# 1028| r1028_1(glval<unknown>) = FunctionAddress[operator delete[]] :
# 1028| r1028_2(Overaligned *) = Constant[0] :
# 1028| v1028_3(void) = Call[operator delete[]] : func:r1028_1, 0:r1028_2
# 1028| mu1028_4(unknown) = ^CallSideEffect : ~m?
# 1029| r1029_1(glval<unknown>) = FunctionAddress[operator delete[]] :
# 1029| r1029_2(PolymorphicBase *) = Constant[0] :
# 1029| v1029_3(void) = Call[operator delete[]] : func:r1029_1, 0:r1029_2
# 1029| mu1029_4(unknown) = ^CallSideEffect : ~m?
# 1030| v1030_1(void) = NoOp :
# 1024| v1024_4(void) = ReturnVoid :
# 1024| v1024_5(void) = AliasedUse : ~m?
# 1024| v1024_6(void) = ExitFunction :
# 1034| void EmptyStructInit()
# 1034| Block 0
@@ -11071,6 +11111,215 @@ ir.cpp:
# 2028| mu2028_13(unsigned int) = Store[#temp2028:7] : &:r2028_12, r2030_8
#-----| Goto -> Block 2
# 2033| void NewDeleteMem()
# 2033| Block 0
# 2033| v2033_1(void) = EnterFunction :
# 2033| mu2033_2(unknown) = AliasedDefinition :
# 2033| mu2033_3(unknown) = InitializeNonLocal :
# 2034| r2034_1(glval<int *>) = VariableAddress[x] :
# 2034| r2034_2(glval<unknown>) = FunctionAddress[operator new] :
# 2034| r2034_3(unsigned long) = Constant[4] :
# 2034| r2034_4(void *) = Call[operator new] : func:r2034_2, 0:r2034_3
# 2034| mu2034_5(unknown) = ^CallSideEffect : ~m?
# 2034| mu2034_6(unknown) = ^InitializeDynamicAllocation : &:r2034_4
# 2034| r2034_7(int *) = Convert : r2034_4
# 2034| mu2034_8(int *) = Store[x] : &:r2034_1, r2034_7
# 2035| r2035_1(int) = Constant[6] :
# 2035| r2035_2(glval<int *>) = VariableAddress[x] :
# 2035| r2035_3(int *) = Load[x] : &:r2035_2, ~m?
# 2035| r2035_4(glval<int>) = CopyValue : r2035_3
# 2035| mu2035_5(int) = Store[?] : &:r2035_4, r2035_1
# 2036| r2036_1(glval<unknown>) = FunctionAddress[operator delete] :
# 2036| r2036_2(glval<int *>) = VariableAddress[x] :
# 2036| r2036_3(int *) = Load[x] : &:r2036_2, ~m?
# 2036| v2036_4(void) = Call[operator delete] : func:r2036_1, 0:r2036_3
# 2036| mu2036_5(unknown) = ^CallSideEffect : ~m?
# 2037| v2037_1(void) = NoOp :
# 2033| v2033_4(void) = ReturnVoid :
# 2033| v2033_5(void) = AliasedUse : ~m?
# 2033| v2033_6(void) = ExitFunction :
# 2039| void Base2::Base2()
# 2039| Block 0
# 2039| v2039_1(void) = EnterFunction :
# 2039| mu2039_2(unknown) = AliasedDefinition :
# 2039| mu2039_3(unknown) = InitializeNonLocal :
# 2039| r2039_4(glval<unknown>) = VariableAddress[#this] :
# 2039| mu2039_5(glval<Base2>) = InitializeParameter[#this] : &:r2039_4
# 2039| r2039_6(glval<Base2>) = Load[#this] : &:r2039_4, ~m?
# 2039| mu2039_7(Base2) = InitializeIndirection[#this] : &:r2039_6
# 2039| v2039_8(void) = NoOp :
# 2039| v2039_9(void) = ReturnIndirection[#this] : &:r2039_6, ~m?
# 2039| v2039_10(void) = ReturnVoid :
# 2039| v2039_11(void) = AliasedUse : ~m?
# 2039| v2039_12(void) = ExitFunction :
# 2041| void Base2::operator delete(void*)
# 2041| Block 0
# 2041| v2041_1(void) = EnterFunction :
# 2041| mu2041_2(unknown) = AliasedDefinition :
# 2041| mu2041_3(unknown) = InitializeNonLocal :
# 2041| r2041_4(glval<void *>) = VariableAddress[p] :
# 2041| mu2041_5(void *) = InitializeParameter[p] : &:r2041_4
# 2041| r2041_6(void *) = Load[p] : &:r2041_4, ~m?
# 2041| mu2041_7(unknown) = InitializeIndirection[p] : &:r2041_6
# 2042| v2042_1(void) = NoOp :
# 2041| v2041_8(void) = ReturnIndirection[p] : &:r2041_6, ~m?
# 2041| v2041_9(void) = ReturnVoid :
# 2041| v2041_10(void) = AliasedUse : ~m?
# 2041| v2041_11(void) = ExitFunction :
# 2043| void Base2::~Base2()
# 2043| Block 0
# 2043| v2043_1(void) = EnterFunction :
# 2043| mu2043_2(unknown) = AliasedDefinition :
# 2043| mu2043_3(unknown) = InitializeNonLocal :
# 2043| r2043_4(glval<unknown>) = VariableAddress[#this] :
# 2043| mu2043_5(glval<Base2>) = InitializeParameter[#this] : &:r2043_4
# 2043| r2043_6(glval<Base2>) = Load[#this] : &:r2043_4, ~m?
# 2043| mu2043_7(Base2) = InitializeIndirection[#this] : &:r2043_6
# 2043| v2043_8(void) = NoOp :
# 2043| v2043_9(void) = ReturnIndirection[#this] : &:r2043_6, ~m?
# 2043| v2043_10(void) = ReturnVoid :
# 2043| v2043_11(void) = AliasedUse : ~m?
# 2043| v2043_12(void) = ExitFunction :
# 2046| void Derived2::Derived2()
# 2046| Block 0
# 2046| v2046_1(void) = EnterFunction :
# 2046| mu2046_2(unknown) = AliasedDefinition :
# 2046| mu2046_3(unknown) = InitializeNonLocal :
# 2046| r2046_4(glval<unknown>) = VariableAddress[#this] :
# 2046| mu2046_5(glval<Derived2>) = InitializeParameter[#this] : &:r2046_4
# 2046| r2046_6(glval<Derived2>) = Load[#this] : &:r2046_4, ~m?
# 2046| mu2046_7(Derived2) = InitializeIndirection[#this] : &:r2046_6
# 2046| r2046_8(glval<Base2>) = ConvertToNonVirtualBase[Derived2 : Base2] : mu2046_5
# 2046| r2046_9(glval<unknown>) = FunctionAddress[Base2] :
# 2046| v2046_10(void) = Call[Base2] : func:r2046_9, this:r2046_8
# 2046| mu2046_11(unknown) = ^CallSideEffect : ~m?
# 2046| mu2046_12(Base2) = ^IndirectMayWriteSideEffect[-1] : &:r2046_8
# 2046| v2046_13(void) = NoOp :
# 2046| v2046_14(void) = ReturnIndirection[#this] : &:r2046_6, ~m?
# 2046| v2046_15(void) = ReturnVoid :
# 2046| v2046_16(void) = AliasedUse : ~m?
# 2046| v2046_17(void) = ExitFunction :
# 2049| void Derived2::~Derived2()
# 2049| Block 0
# 2049| v2049_1(void) = EnterFunction :
# 2049| mu2049_2(unknown) = AliasedDefinition :
# 2049| mu2049_3(unknown) = InitializeNonLocal :
# 2049| r2049_4(glval<unknown>) = VariableAddress[#this] :
# 2049| mu2049_5(glval<Derived2>) = InitializeParameter[#this] : &:r2049_4
# 2049| r2049_6(glval<Derived2>) = Load[#this] : &:r2049_4, ~m?
# 2049| mu2049_7(Derived2) = InitializeIndirection[#this] : &:r2049_6
# 2049| v2049_8(void) = NoOp :
# 2049| r2049_9(glval<Base2>) = ConvertToNonVirtualBase[Derived2 : Base2] : mu2049_5
# 2049| r2049_10(glval<unknown>) = FunctionAddress[~Base2] :
# 2049| v2049_11(void) = Call[~Base2] : func:r2049_10, this:r2049_9
# 2049| mu2049_12(unknown) = ^CallSideEffect : ~m?
# 2049| v2049_13(void) = ReturnIndirection[#this] : &:r2049_6, ~m?
# 2049| v2049_14(void) = ReturnVoid :
# 2049| v2049_15(void) = AliasedUse : ~m?
# 2049| v2049_16(void) = ExitFunction :
# 2051| void Derived2::operator delete(void*)
# 2051| Block 0
# 2051| v2051_1(void) = EnterFunction :
# 2051| mu2051_2(unknown) = AliasedDefinition :
# 2051| mu2051_3(unknown) = InitializeNonLocal :
# 2051| r2051_4(glval<void *>) = VariableAddress[p] :
# 2051| mu2051_5(void *) = InitializeParameter[p] : &:r2051_4
# 2051| r2051_6(void *) = Load[p] : &:r2051_4, ~m?
# 2051| mu2051_7(unknown) = InitializeIndirection[p] : &:r2051_6
# 2052| v2052_1(void) = NoOp :
# 2051| v2051_8(void) = ReturnIndirection[p] : &:r2051_6, ~m?
# 2051| v2051_9(void) = ReturnVoid :
# 2051| v2051_10(void) = AliasedUse : ~m?
# 2051| v2051_11(void) = ExitFunction :
# 2056| int virtual_delete()
# 2056| Block 0
# 2056| v2056_1(void) = EnterFunction :
# 2056| mu2056_2(unknown) = AliasedDefinition :
# 2056| mu2056_3(unknown) = InitializeNonLocal :
# 2058| r2058_1(glval<Base2 *>) = VariableAddress[b1] :
# 2058| r2058_2(glval<unknown>) = FunctionAddress[operator new] :
# 2058| r2058_3(unsigned long) = Constant[8] :
# 2058| r2058_4(void *) = Call[operator new] : func:r2058_2, 0:r2058_3
# 2058| mu2058_5(unknown) = ^CallSideEffect : ~m?
# 2058| mu2058_6(unknown) = ^InitializeDynamicAllocation : &:r2058_4
# 2058| r2058_7(Base2 *) = Convert : r2058_4
# 2058| r2058_8(glval<unknown>) = FunctionAddress[Base2] :
# 2058| v2058_9(void) = Call[Base2] : func:r2058_8, this:r2058_7
# 2058| mu2058_10(unknown) = ^CallSideEffect : ~m?
# 2058| mu2058_11(Base2) = ^IndirectMayWriteSideEffect[-1] : &:r2058_7
# 2058| mu2058_12(Base2 *) = Store[b1] : &:r2058_1, r2058_7
# 2059| r2059_1(glval<unknown>) = VirtualDeleteFunctionAddress :
# 2059| r2059_2(glval<Base2 *>) = VariableAddress[b1] :
# 2059| r2059_3(Base2 *) = Load[b1] : &:r2059_2, ~m?
# 2059| v2059_4(void) = Call[?] : func:r2059_1, 0:r2059_3
# 2059| mu2059_5(unknown) = ^CallSideEffect : ~m?
# 2061| r2061_1(glval<Base2 *>) = VariableAddress[b2] :
# 2061| r2061_2(glval<unknown>) = FunctionAddress[operator new] :
# 2061| r2061_3(unsigned long) = Constant[16] :
# 2061| r2061_4(void *) = Call[operator new] : func:r2061_2, 0:r2061_3
# 2061| mu2061_5(unknown) = ^CallSideEffect : ~m?
# 2061| mu2061_6(unknown) = ^InitializeDynamicAllocation : &:r2061_4
# 2061| r2061_7(Derived2 *) = Convert : r2061_4
# 2061| r2061_8(glval<unknown>) = FunctionAddress[Derived2] :
# 2061| v2061_9(void) = Call[Derived2] : func:r2061_8, this:r2061_7
# 2061| mu2061_10(unknown) = ^CallSideEffect : ~m?
# 2061| mu2061_11(Derived2) = ^IndirectMayWriteSideEffect[-1] : &:r2061_7
# 2061| r2061_12(Base2 *) = ConvertToNonVirtualBase[Derived2 : Base2] : r2061_7
# 2061| mu2061_13(Base2 *) = Store[b2] : &:r2061_1, r2061_12
# 2062| r2062_1(glval<unknown>) = VirtualDeleteFunctionAddress :
# 2062| r2062_2(glval<Base2 *>) = VariableAddress[b2] :
# 2062| r2062_3(Base2 *) = Load[b2] : &:r2062_2, ~m?
# 2062| v2062_4(void) = Call[?] : func:r2062_1, 0:r2062_3
# 2062| mu2062_5(unknown) = ^CallSideEffect : ~m?
# 2064| r2064_1(glval<Derived2 *>) = VariableAddress[d] :
# 2064| r2064_2(glval<unknown>) = FunctionAddress[operator new] :
# 2064| r2064_3(unsigned long) = Constant[16] :
# 2064| r2064_4(void *) = Call[operator new] : func:r2064_2, 0:r2064_3
# 2064| mu2064_5(unknown) = ^CallSideEffect : ~m?
# 2064| mu2064_6(unknown) = ^InitializeDynamicAllocation : &:r2064_4
# 2064| r2064_7(Derived2 *) = Convert : r2064_4
# 2064| r2064_8(glval<unknown>) = FunctionAddress[Derived2] :
# 2064| v2064_9(void) = Call[Derived2] : func:r2064_8, this:r2064_7
# 2064| mu2064_10(unknown) = ^CallSideEffect : ~m?
# 2064| mu2064_11(Derived2) = ^IndirectMayWriteSideEffect[-1] : &:r2064_7
# 2064| mu2064_12(Derived2 *) = Store[d] : &:r2064_1, r2064_7
# 2065| r2065_1(glval<unknown>) = VirtualDeleteFunctionAddress :
# 2065| r2065_2(glval<Derived2 *>) = VariableAddress[d] :
# 2065| r2065_3(Derived2 *) = Load[d] : &:r2065_2, ~m?
# 2065| v2065_4(void) = Call[?] : func:r2065_1, 0:r2065_3
# 2065| mu2065_5(unknown) = ^CallSideEffect : ~m?
# 2066| v2066_1(void) = Unreached :
# 2056| Block 1
# 2056| r2056_4(glval<int>) = VariableAddress[#return] :
# 2056| v2056_5(void) = ReturnValue : &:r2056_4, ~m?
# 2056| v2056_6(void) = AliasedUse : ~m?
# 2056| v2056_7(void) = ExitFunction :
# 2070| void test_constant_folding()
# 2070| Block 0
# 2070| v2070_1(void) = EnterFunction :
# 2070| mu2070_2(unknown) = AliasedDefinition :
# 2070| mu2070_3(unknown) = InitializeNonLocal :
# 2071| r2071_1(glval<int>) = VariableAddress[x] :
# 2071| r2071_2(int) = Constant[116] :
# 2071| mu2071_3(int) = Store[x] : &:r2071_1, r2071_2
# 2072| r2072_1(glval<unknown>) = FunctionAddress[test_constant_folding_use] :
# 2072| r2072_2(int) = Constant[116] :
# 2072| v2072_3(void) = Call[test_constant_folding_use] : func:r2072_1, 0:r2072_2
# 2072| mu2072_4(unknown) = ^CallSideEffect : ~m?
# 2073| v2073_1(void) = NoOp :
# 2070| v2070_4(void) = ReturnVoid :
# 2070| v2070_5(void) = AliasedUse : ~m?
# 2070| v2070_6(void) = ExitFunction :
perf-regression.cpp:
# 6| void Big::Big()
# 6| Block 0

View File

@@ -10,7 +10,7 @@ void m(int i, bool cond, int x, int y) {
int seven = 7;
if (mul % c2 == seven) {
mod(mul); // congruent 3 mod 42, 7 mod 43
mod(mul); // $ mod=0,3,42
}
int j = cond
@@ -19,13 +19,11 @@ void m(int i, bool cond, int x, int y) {
mod(j); // $ mod=0,3,4
if (x % c1 == 3 && y % c1 == 7) {
// Need implies_v2
mod(x + y); // $ MISSING: 0,10,42
mod(x + y); // $ mod=0,10,42
}
if (x % c1 == 3 && y % c1 == 7) {
// Need implies_v2
mod(x - y); // $ MISSING: mod=0,38,42
mod(x - y); // $ mod=0,38,42
}
if (cond) {

View File

@@ -1008,12 +1008,12 @@ label:
void test_overflow() {
const int x = 2147483647; // 2^31-1
range(x);
range(x); // $ range===2147483647
const int y = 256;
range(y);
range(y); // $ range===256
if ((x + y) <= 512) {
range(x);
range(y);
range(x); // $ range===2147483647
range(y); // $ range===256
range(x + y); // $ range===-2147483393
}
}

View File

@@ -95,3 +95,25 @@ void gotoLoop(bool b1, bool b2)
}
}
}
void test_sub(int x, int y, int n) {
if(x > 0 && x < 500) {
if(y > 0 && y < 10) {
range(x - y); // $ range=<=498 range=>=-8
}
if(n > 0 && n < 100) {
for (int i = 0; i < n; i++)
{
range(n - i); // $ range=">=Phi: i-97" range=<=99 range=>=-97
range(i - n); // $ range="<=Phi: i-1" range=">=Phi: i-99" range=<=97 range=>=-99
}
for (int i = n; i != 0; i--)
{
range(n - i); // $ SPURIOUS: overflow=+
range(i - n); // $ range=">=Phi: i-99"
}
}
}
}

View File

@@ -18,6 +18,7 @@ edges
| test_free.cpp:69:10:69:10 | a | test_free.cpp:72:14:72:14 | a |
| test_free.cpp:69:10:69:10 | a | test_free.cpp:72:14:72:14 | a |
| test_free.cpp:69:10:69:10 | a | test_free.cpp:72:14:72:14 | a |
| test_free.cpp:83:12:83:12 | a | test_free.cpp:85:12:85:12 | a |
| test_free.cpp:101:10:101:10 | a | test_free.cpp:103:10:103:10 | a |
| test_free.cpp:128:10:128:11 | * ... | test_free.cpp:129:10:129:11 | * ... |
| test_free.cpp:152:27:152:27 | a | test_free.cpp:154:10:154:10 | a |
@@ -28,6 +29,8 @@ edges
| test_free.cpp:207:10:207:10 | a | test_free.cpp:209:10:209:10 | a |
| test_free.cpp:207:10:207:10 | a | test_free.cpp:209:10:209:10 | a |
| test_free.cpp:207:10:207:10 | a | test_free.cpp:209:10:209:10 | a |
| test_free.cpp:252:7:252:7 | p | test_free.cpp:255:10:255:10 | p |
| test_free.cpp:260:9:260:9 | p | test_free.cpp:263:12:263:12 | p |
nodes
| test_free.cpp:11:10:11:10 | a | semmle.label | a |
| test_free.cpp:11:10:11:10 | a | semmle.label | a |
@@ -51,6 +54,8 @@ nodes
| test_free.cpp:69:10:69:10 | a | semmle.label | a |
| test_free.cpp:72:14:72:14 | a | semmle.label | a |
| test_free.cpp:72:14:72:14 | a | semmle.label | a |
| test_free.cpp:83:12:83:12 | a | semmle.label | a |
| test_free.cpp:85:12:85:12 | a | semmle.label | a |
| test_free.cpp:101:10:101:10 | a | semmle.label | a |
| test_free.cpp:103:10:103:10 | a | semmle.label | a |
| test_free.cpp:128:10:128:11 | * ... | semmle.label | * ... |
@@ -63,6 +68,10 @@ nodes
| test_free.cpp:207:10:207:10 | a | semmle.label | a |
| test_free.cpp:209:10:209:10 | a | semmle.label | a |
| test_free.cpp:209:10:209:10 | a | semmle.label | a |
| test_free.cpp:252:7:252:7 | p | semmle.label | p |
| test_free.cpp:255:10:255:10 | p | semmle.label | p |
| test_free.cpp:260:9:260:9 | p | semmle.label | p |
| test_free.cpp:263:12:263:12 | p | semmle.label | p |
subpaths
#select
| test_free.cpp:14:10:14:10 | a | test_free.cpp:11:10:11:10 | a | test_free.cpp:14:10:14:10 | a | Memory pointed to by 'a' may already have been freed by $@. | test_free.cpp:11:5:11:8 | call to free | call to free |
@@ -84,6 +93,7 @@ subpaths
| test_free.cpp:72:14:72:14 | a | test_free.cpp:69:10:69:10 | a | test_free.cpp:72:14:72:14 | a | Memory pointed to by 'a' may already have been freed by $@. | test_free.cpp:69:5:69:8 | call to free | call to free |
| test_free.cpp:72:14:72:14 | a | test_free.cpp:69:10:69:10 | a | test_free.cpp:72:14:72:14 | a | Memory pointed to by 'a' may already have been freed by $@. | test_free.cpp:69:5:69:8 | call to free | call to free |
| test_free.cpp:72:14:72:14 | a | test_free.cpp:69:10:69:10 | a | test_free.cpp:72:14:72:14 | a | Memory pointed to by 'a' may already have been freed by $@. | test_free.cpp:69:5:69:8 | call to free | call to free |
| test_free.cpp:85:12:85:12 | a | test_free.cpp:83:12:83:12 | a | test_free.cpp:85:12:85:12 | a | Memory pointed to by 'a' may already have been freed by $@. | test_free.cpp:83:5:83:13 | delete | delete |
| test_free.cpp:103:10:103:10 | a | test_free.cpp:101:10:101:10 | a | test_free.cpp:103:10:103:10 | a | Memory pointed to by 'a' may already have been freed by $@. | test_free.cpp:101:5:101:8 | call to free | call to free |
| test_free.cpp:129:10:129:11 | * ... | test_free.cpp:128:10:128:11 | * ... | test_free.cpp:129:10:129:11 | * ... | Memory pointed to by '* ...' may already have been freed by $@. | test_free.cpp:128:5:128:8 | call to free | call to free |
| test_free.cpp:154:10:154:10 | a | test_free.cpp:152:27:152:27 | a | test_free.cpp:154:10:154:10 | a | Memory pointed to by 'a' may already have been freed by $@. | test_free.cpp:152:22:152:25 | call to free | call to free |
@@ -94,3 +104,5 @@ subpaths
| test_free.cpp:209:10:209:10 | a | test_free.cpp:207:10:207:10 | a | test_free.cpp:209:10:209:10 | a | Memory pointed to by 'a' may already have been freed by $@. | test_free.cpp:207:5:207:8 | call to free | call to free |
| test_free.cpp:209:10:209:10 | a | test_free.cpp:207:10:207:10 | a | test_free.cpp:209:10:209:10 | a | Memory pointed to by 'a' may already have been freed by $@. | test_free.cpp:207:5:207:8 | call to free | call to free |
| test_free.cpp:209:10:209:10 | a | test_free.cpp:207:10:207:10 | a | test_free.cpp:209:10:209:10 | a | Memory pointed to by 'a' may already have been freed by $@. | test_free.cpp:207:5:207:8 | call to free | call to free |
| test_free.cpp:255:10:255:10 | p | test_free.cpp:252:7:252:7 | p | test_free.cpp:255:10:255:10 | p | Memory pointed to by 'p' may already have been freed by $@. | test_free.cpp:252:2:252:5 | call to free | call to free |
| test_free.cpp:263:12:263:12 | p | test_free.cpp:260:9:260:9 | p | test_free.cpp:263:12:263:12 | p | Memory pointed to by 'p' may already have been freed by $@. | test_free.cpp:260:2:260:9 | delete | delete |

View File

@@ -92,6 +92,10 @@
| test_free.cpp:233:14:233:15 | * ... |
| test_free.cpp:239:14:239:15 | * ... |
| test_free.cpp:245:10:245:11 | * ... |
| test_free.cpp:252:7:252:7 | p |
| test_free.cpp:255:10:255:10 | p |
| test_free.cpp:260:9:260:9 | p |
| test_free.cpp:263:12:263:12 | p |
| virtual.cpp:18:10:18:10 | a |
| virtual.cpp:19:10:19:10 | c |
| virtual.cpp:38:10:38:10 | b |

View File

@@ -12,3 +12,5 @@
| test.cpp:157:3:157:26 | new[] | This memory is never freed. |
| test.cpp:169:14:169:19 | call to strdup | This memory is never freed. |
| test_free.cpp:167:15:167:21 | call to realloc | This memory is never freed. |
| test_free.cpp:253:14:253:19 | call to malloc | This memory is never freed. |
| test_free.cpp:261:6:261:12 | new | This memory is never freed. |

View File

@@ -9,6 +9,7 @@ edges
| test_free.cpp:44:27:44:27 | a | test_free.cpp:45:5:45:5 | a |
| test_free.cpp:69:10:69:10 | a | test_free.cpp:71:9:71:9 | a |
| test_free.cpp:69:10:69:10 | a | test_free.cpp:71:9:71:9 | a |
| test_free.cpp:83:12:83:12 | a | test_free.cpp:84:5:84:5 | a |
| test_free.cpp:90:10:90:10 | a | test_free.cpp:91:5:91:5 | a |
| test_free.cpp:90:10:90:10 | a | test_free.cpp:91:5:91:5 | a |
| test_free.cpp:95:10:95:10 | a | test_free.cpp:96:9:96:9 | a |
@@ -27,6 +28,8 @@ edges
| test_free.cpp:245:10:245:11 | * ... | test_free.cpp:246:9:246:10 | * ... |
| test_free.cpp:245:10:245:11 | * ... | test_free.cpp:246:9:246:10 | * ... |
| test_free.cpp:245:10:245:11 | * ... | test_free.cpp:246:9:246:10 | * ... |
| test_free.cpp:252:7:252:7 | p | test_free.cpp:254:6:254:6 | p |
| test_free.cpp:260:9:260:9 | p | test_free.cpp:262:6:262:6 | p |
nodes
| test_free.cpp:11:10:11:10 | a | semmle.label | a |
| test_free.cpp:11:10:11:10 | a | semmle.label | a |
@@ -41,6 +44,8 @@ nodes
| test_free.cpp:69:10:69:10 | a | semmle.label | a |
| test_free.cpp:69:10:69:10 | a | semmle.label | a |
| test_free.cpp:71:9:71:9 | a | semmle.label | a |
| test_free.cpp:83:12:83:12 | a | semmle.label | a |
| test_free.cpp:84:5:84:5 | a | semmle.label | a |
| test_free.cpp:90:10:90:10 | a | semmle.label | a |
| test_free.cpp:90:10:90:10 | a | semmle.label | a |
| test_free.cpp:91:5:91:5 | a | semmle.label | a |
@@ -63,6 +68,10 @@ nodes
| test_free.cpp:245:10:245:11 | * ... | semmle.label | * ... |
| test_free.cpp:246:9:246:10 | * ... | semmle.label | * ... |
| test_free.cpp:246:9:246:10 | * ... | semmle.label | * ... |
| test_free.cpp:252:7:252:7 | p | semmle.label | p |
| test_free.cpp:254:6:254:6 | p | semmle.label | p |
| test_free.cpp:260:9:260:9 | p | semmle.label | p |
| test_free.cpp:262:6:262:6 | p | semmle.label | p |
subpaths
#select
| test_free.cpp:12:5:12:5 | a | test_free.cpp:11:10:11:10 | a | test_free.cpp:12:5:12:5 | a | Memory may have been previously freed by $@. | test_free.cpp:11:5:11:8 | call to free | call to free |
@@ -75,6 +84,7 @@ subpaths
| test_free.cpp:45:5:45:5 | a | test_free.cpp:44:27:44:27 | a | test_free.cpp:45:5:45:5 | a | Memory may have been previously freed by $@. | test_free.cpp:44:22:44:25 | call to free | call to free |
| test_free.cpp:71:9:71:9 | a | test_free.cpp:69:10:69:10 | a | test_free.cpp:71:9:71:9 | a | Memory may have been previously freed by $@. | test_free.cpp:69:5:69:8 | call to free | call to free |
| test_free.cpp:71:9:71:9 | a | test_free.cpp:69:10:69:10 | a | test_free.cpp:71:9:71:9 | a | Memory may have been previously freed by $@. | test_free.cpp:69:5:69:8 | call to free | call to free |
| test_free.cpp:84:5:84:5 | a | test_free.cpp:83:12:83:12 | a | test_free.cpp:84:5:84:5 | a | Memory may have been previously freed by $@. | test_free.cpp:83:5:83:13 | delete | delete |
| test_free.cpp:91:5:91:5 | a | test_free.cpp:90:10:90:10 | a | test_free.cpp:91:5:91:5 | a | Memory may have been previously freed by $@. | test_free.cpp:90:5:90:8 | call to free | call to free |
| test_free.cpp:91:5:91:5 | a | test_free.cpp:90:10:90:10 | a | test_free.cpp:91:5:91:5 | a | Memory may have been previously freed by $@. | test_free.cpp:90:5:90:8 | call to free | call to free |
| test_free.cpp:96:9:96:9 | a | test_free.cpp:95:10:95:10 | a | test_free.cpp:96:9:96:9 | a | Memory may have been previously freed by $@. | test_free.cpp:95:5:95:8 | call to free | call to free |
@@ -93,3 +103,5 @@ subpaths
| test_free.cpp:246:9:246:10 | * ... | test_free.cpp:245:10:245:11 | * ... | test_free.cpp:246:9:246:10 | * ... | Memory may have been previously freed by $@. | test_free.cpp:245:5:245:8 | call to free | call to free |
| test_free.cpp:246:9:246:10 | * ... | test_free.cpp:245:10:245:11 | * ... | test_free.cpp:246:9:246:10 | * ... | Memory may have been previously freed by $@. | test_free.cpp:245:5:245:8 | call to free | call to free |
| test_free.cpp:246:9:246:10 | * ... | test_free.cpp:245:10:245:11 | * ... | test_free.cpp:246:9:246:10 | * ... | Memory may have been previously freed by $@. | test_free.cpp:245:5:245:8 | call to free | call to free |
| test_free.cpp:254:6:254:6 | p | test_free.cpp:252:7:252:7 | p | test_free.cpp:254:6:254:6 | p | Memory may have been previously freed by $@. | test_free.cpp:252:2:252:5 | call to free | call to free |
| test_free.cpp:262:6:262:6 | p | test_free.cpp:260:9:260:9 | p | test_free.cpp:262:6:262:6 | p | Memory may have been previously freed by $@. | test_free.cpp:260:2:260:9 | delete | delete |

View File

@@ -81,8 +81,8 @@ public:
void test_new1() {
A *a = new A();
delete(a);
a->f(); // BAD [NOT DETECTED]
delete(a); // BAD [NOT DETECTED]
a->f(); // BAD
delete(a); // BAD
}
void test_dereference1(A *a) {
@@ -244,4 +244,21 @@ void test_loop3(char ** a, char ** b) {
void test_deref(char **a) {
free(*a);
use(*a); // GOOD [FALSE POSITIVE]
}
// Refs
void test_ref(char *&p) {
free(p);
p = (char *)malloc(sizeof(char)*10);
use(p); // GOOD [FALSE POSITIVE]
free(p); // GOOD [FALSE POSITIVE]
}
void test_ref_delete(int *&p) {
delete p;
p = new int;
use(p); // GOOD [FALSE POSITIVE]
delete p; // GOOD [FALSE POSITIVE]
}

View File

@@ -156,3 +156,10 @@ void fmt_via_strcpy(char *data) {
strcpy(data, "some string");
printf(data); // BAD
}
void fmt_with_assignment() {
const char *x, *y;
x = y = "a";
printf(y); // GOOD
}

View File

@@ -6,3 +6,5 @@
| test.cpp:39:23:39:28 | ... == ... | This '==' operator has no effect. The assignment ('=') operator was probably intended. |
| test.cpp:42:23:42:28 | ... == ... | This '==' operator has no effect. The assignment ('=') operator was probably intended. |
| test.cpp:51:13:51:13 | call to operator== | This '==' operator has no effect. The assignment ('=') operator was probably intended. |
| test.cpp:72:3:72:8 | ... == ... | This '==' operator has no effect. The assignment ('=') operator was probably intended. |
| test.cpp:73:3:73:12 | ... == ... | This '==' operator has no effect. The assignment ('=') operator was probably intended. |

View File

@@ -61,3 +61,14 @@ template<typename T1, typename T2>
auto sfinaeTrick(T1 x1, T2 x2) -> decltype(x1 == x2, bool()) { // GOOD
return x1 == x2;
}
void report_error(const char*);
#define DOES_NOT_THROW(E) do { try { E; } catch (...) { report_error(""); } } while(0)
#define ID(X) (X)
void test_inside_macro_expansion(int x, int y) {
DOES_NOT_THROW(x == y); // GOOD
x == y; // BAD
x == ID(y); // BAD
}

Some files were not shown because too many files have changed in this diff Show More