Commit Graph

4509 Commits

Author SHA1 Message Date
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
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
Geoffrey White
0cb00c9091 Swift: Change note. 2023-08-31 15:50:54 +01:00
Geoffrey White
93c39c5fdd Swift: Add data flow through OpenExistentialExpr. 2023-08-31 15:50:32 +01:00
Geoffrey White
b8d29e8fc1 Swift: Add a more realistic test case as well. 2023-08-31 15:46:47 +01:00
Geoffrey White
aeeafd75bf Swift: Add a test for flow through OpenExistentialExpr. 2023-08-31 15:27:18 +01:00
Alex Denisov
c1da2dfa73 Swift: fix autobuild.sh 2023-08-31 09:40:13 +02:00
Alex Denisov
803adae9c6 Swift: rename autobuilder. NFC 2023-08-31 08:12:52 +02:00
Tom Hvitved
9af706c2a5 Swift: Use data flow consistency checks from shared pack 2023-08-30 15:29:41 +02: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
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
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
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
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
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
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
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
Paolo Tranquilli
e3d6b3e537 Swift: route compiler diagnostics through our log
(cherry picked from commit b8c55612e5)
2023-08-24 14:20:15 +01: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
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
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
Geoffrey White
d594de8190 Swift: Test dataflow on fields a bit more. 2023-08-23 10:49:03 +01:00
Geoffrey White
efcadbda69 Swift: Get the IncompleteHostnameRegex query working for Swift. 2023-08-23 10:32:10 +01:00
Geoffrey White
6deaf4e5f8 Swift: Rework ParsedStringRegex and introduce the needed RegexPatternSource class. 2023-08-23 09:01:15 +01:00
Geoffrey White
6fb1058e73 Swift: Copy IncompleteHostnameRegex query from JS. 2023-08-23 08:46:13 +01:00
Alex Denisov
b657301d39 Swift: update test expectations 2023-08-22 18:03:19 +02:00
Alex Denisov
e9fdbfabea Swift: extract nextCall from ForEachStmt 2023-08-22 17:36:40 +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
Robert Marsh
e94781fa8f Swift: fix comment 2023-08-22 13:27:17 +00: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
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
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
Geoffrey White
317757b7ae Swift: Create proper models for JavaScriptCore. 2023-08-21 18:24:26 +01:00
Paolo Tranquilli
1daedd9fb6 Revert "Swift: use C++20 constraints and concepts to simplify code" 2023-08-21 17:40:15 +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
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