Commit Graph

837 Commits

Author SHA1 Message Date
Mathias Vorreiter Pedersen
2593120300 Merge pull request #10597 from geoffw0/swifttaintsource
Swift: URL taint sources
2022-10-04 09:22:27 +01:00
Geoffrey White
1248810e35 Swift: Add model for URL.resourceBytes and URL.lines. 2022-09-27 18:58:56 +01:00
Geoffrey White
fa5e03a53d Swift: Add tests of URL.resourceBytes and URL.lines. 2022-09-27 18:58:56 +01:00
Geoffrey White
69dd2c0eec Swift: Add a test of taint sources. 2022-09-27 18:58:56 +01:00
Geoffrey White
3ffb2a3ee6 Swift: Fix. 2022-09-27 18:39:03 +01:00
Geoffrey White
286fcb672c Swift: Additional test results. 2022-09-27 18:31:43 +01:00
Paolo Tranquilli
69dfdf5a34 Swift: fix IfConfigDecl in QL libraries
This fixes `IfConfigDecl` for both the AST printer and control flow
libraries.

It turns out that the active lements of an `IfConfigDecl` are already
listed in the enclosing scope (like a `BraceStmt`), so they should not
be listed as children, and `IfConfigDecl` can be jsut a leaf in the
control flow.
2022-09-21 12:12:55 +02:00
Paolo Tranquilli
48761b8667 Merge pull request #10233 from github/redsun82/swift-conversions-in-print-ast
Swift: show conversions in `PrintAst`
2022-09-02 16:13:21 +02:00
Paolo Tranquilli
2234070bfe Swift: ...and accept the test 2022-09-02 15:36:46 +02:00
Paolo Tranquilli
c842ae40f6 Swift: make node properties consistent with other languages 2022-09-02 15:31:37 +02:00
Paolo Tranquilli
e3e9774956 Swift: print conversions similarly to C++ 2022-09-02 15:31:37 +02:00
Mathias Vorreiter Pedersen
f846c262dc Merge pull request #10157 from MathiasVP/swift-field-flow-2
Swift: Add field flow
2022-08-31 10:42:00 +01:00
Paolo Tranquilli
30049f622d Swift: move new code down in tests 2022-08-31 11:38:32 +02:00
Paolo Tranquilli
aa54e4bb46 Swift: add some typing information to PrintAst 2022-08-31 11:31:15 +02:00
Paolo Tranquilli
a237f691b5 Swift: show conversions in PrintAst
This also showcases the customizability of the `PrintAst` infrastructure
resting on generated code.
2022-08-31 11:28:17 +02:00
Paolo Tranquilli
281cd79b48 Swift: add generics to ast tests 2022-08-31 11:09:35 +02:00
Paolo Tranquilli
742cf0a593 Swift: hide orphaned DeclRefExpr nodes 2022-08-31 08:35:00 +02:00
Paolo Tranquilli
8f09485414 Swift: enhance PrintAst testing
The `ParentChild` tests have been generalized to test all `PrintAst`
by factoring out `PrintAstNode` into a separate file.

The `child.ql` and `parent.ql` tests have been removed as they are
subsumed by `PrintAst.ql`. Also, a new `no_parent_child_loops` is
added to detect back edges to a root node (back edges to a non-root
node are already detected by `no_double_parents.ql`).
2022-08-31 06:54:30 +02:00
Paolo Tranquilli
cd632dcfee Swift: minor tweaks
Replace string singleton with a newtype-based one, and fix some doc
comment cosmetics.
2022-08-31 06:39:35 +02:00
Mathias Vorreiter Pedersen
a4209df239 Merge branch 'main' into swift-field-flow-2 2022-08-30 18:52:23 +01:00
Paolo Tranquilli
47b905bfaf Swift: add PrintAst 2022-08-30 18:04:55 +02:00
Paolo Tranquilli
6914c4469c Swift: accept tests after children changes 2022-08-30 17:36:39 +02:00
Paolo Tranquilli
38d65d3fae Swift: make ConstructorDecl's name include params
In order to distinguish overloads of the constructor and for consistency
with other function calls, `ConstructorDecl` string representation uses
the name which includes parentheses and parameter labels.

For consistency also the destructor got the same change, which means
all `DestructorDecl`s will now show as `deinit()` rather than `deinit`.
2022-08-30 11:11:50 +02:00
Paolo Tranquilli
beb0472811 Swift: fix ParentChild generation
There was an issue in case multiple inheritance from classes with
children was involved, where indexes would overlap.

The generated code structure has been reshuffled a bit, with
`Impl::getImmediateChildOf<Class>` predicates giving 0-based children
for a given class, including those coming from bases, and the final
`Impl::getImmediateChild` disjuncting the above on final classes only.

This removes the need of `getMaximumChildrenIndex<Class>`, and also
removes the code scanning alerts.

Also, comments were fixed addressing the review.
2022-08-30 10:15:11 +02:00
Paolo Tranquilli
20e94b8a38 Swift: add more tests for the generated parent-child relationship 2022-08-29 17:10:46 +02:00
Paolo Tranquilli
105c0d0dce Swift: update after generated parent-child changes 2022-08-29 17:10:46 +02:00
Paolo Tranquilli
7b50c958f7 Swift: fix Cfg.expected 2022-08-29 17:09:42 +02:00
Paolo Tranquilli
4e453b1ac5 Swift: accept test changes 2022-08-29 14:57:03 +02:00
Mathias Vorreiter Pedersen
f2d9393928 Swift: Only test local-flow step relations for nodes with proper location information. 2022-08-24 17:14:11 +01:00
Mathias Vorreiter Pedersen
2d90940111 Swift: Add field flow. 2022-08-24 14:52:36 +01:00
Mathias Vorreiter Pedersen
edb29b498d Swift: Teach 'DataFlowDispatch' about property getters, observers and setters. 2022-08-24 13:08:26 +01:00
Mathias Vorreiter Pedersen
de03fbdc49 Swift: Accept test changes. 2022-08-24 10:03:21 +01:00
Mathias Vorreiter Pedersen
997d9e8559 Swift: Include 'self' parameter declaration in the CFG. 2022-08-24 10:01:25 +01:00
Mathias Vorreiter Pedersen
6e148a4c3f Swift: Use the inline testing framework for dataflow tests. 2022-08-23 16:31:05 +01:00
Paolo Tranquilli
9b50336e47 Swift: synthesize MethodRefExpr
This introduces a `MethodRefExpr` node synthesized out of
`DotSyntaxCallExpr` under the `LookupExpr` hierarchy. This means that
much like
```free_function(1, 2)```
is a `CallExpr` with `getFunction` giving a `DeclRefExpr`,
```foo.method(1, 2)```
is now a `CallExpr` with `getFunction` giving a `MethodRefExpr`.

`ApplyExpr::getStaticTarget` has been made work with it (as well as
`ConstructorRefCallExpr` which for the moment has been left where it
is), a new `MethodApplyExpr` has been introduced deriving from it,
and control and data flow libraries have adapted.

A small but was fixed in `qlgen` where the default constructor for DB
types was not correctly subtracting derived IPA types depending on the
order of definitions in `schema.yml`.

There are still some occurrences of `DotSyntaxCallExpr`, and as already
mentioned the other `SelfApply` class (`ConstructorRefCallExpr`) was
left alone. Their treatment is left for a future PR.
2022-08-19 14:48:36 +02:00
erik-krogh
2e44fba67d add explicit this 2022-08-17 13:33:31 +02:00
Paolo Tranquilli
6dc90bc46c Swift: accept test change 2022-08-15 11:53:18 +02:00
Paolo Tranquilli
176009ca88 Merge branch 'main' into redsun82/swift-first-prototype-of-generated-ipa-layer 2022-08-15 10:18:41 +02:00
Geoffrey White
1dcc44ff2f Swift: taintedFromLine -> tainted. 2022-08-11 11:01:05 +01:00
Geoffrey White
d16a7754e1 Swift: Take out common code. 2022-08-10 19:04:01 +01:00
Geoffrey White
d7f50eafae Swift: Minor fixes. 2022-08-10 19:03:52 +01:00
Geoffrey White
11f45cf20c Swift: Add expectation annotations. 2022-08-10 18:53:45 +01:00
Geoffrey White
c2ee5fe258 Swift: Add inlineExpectations test. 2022-08-10 18:47:46 +01:00
Geoffrey White
f3499e98a4 Swift: Move try, ! to dataflow. 2022-08-10 15:13:04 +01:00
Geoffrey White
6f696ccc3c Swift: Effect of merging with main to get the AnyTryExpr fix. 2022-08-09 19:02:59 +01:00
Geoffrey White
efcc696e6e Merge branch 'main' into defaulttaint 2022-08-09 18:59:36 +01:00
Geoffrey White
36f410b9f7 Swift: Move taint logic from isAdditionalTaintStep to defaultAdditionalTaintStep. 2022-08-09 17:42:28 +01:00
Geoffrey White
242dc80907 Swift: Add taint test of try. 2022-08-09 17:42:25 +01:00
Geoffrey White
3bda9af97a Swift: Add taint test of Data. 2022-08-09 17:42:24 +01:00
Geoffrey White
42c3e29a29 Swift: Add taint test of URL. 2022-08-09 17:42:23 +01:00