Commit Graph

4437 Commits

Author SHA1 Message Date
Paolo Tranquilli
3ce76e6c08 Swift: preserve base order in code generation 2022-08-31 10:45:22 +02:00
Paolo Tranquilli
bb845c6d7f Swift: rename printast.ql->printAst.ql 2022-08-31 08:55:40 +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
Geoffrey White
3e4a6be53f Swift: Add missing test annotations. 2022-08-30 18:12:26 +01:00
Geoffrey White
430a8e141d Swift: Fix issues. 2022-08-30 18:04:12 +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
4825e6b8ba Swift: change some children
* made `members` children of an `IterableDeclContext`
* removed `elements` from the children of `EnumCaseDecl`, as they are
  already children of the enclosing `EnumDecl`
* removed `base` from the children of `SelfApplyExpr`, as they currently
  are already descendants via `getArgument(0).getExpr()`. We should
  maybe consider either removing `base` from the schema and add it as
  a shortcut on QL, or finish up replacing all `SelfApplyExpr` instances
  with synthesized types.
2022-08-30 17:30:39 +02:00
Geoffrey White
4984d8f6f2 Apply suggestions from code review
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
2022-08-30 12:26:06 +01:00
Geoffrey White
645364e8b8 Update swift/ql/src/queries/Security/CWE-311/CleartextStorageDatabase.qhelp
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
2022-08-30 12:24:49 +01:00
Paolo Tranquilli
57b8830972 Swift: fix integration tests 2022-08-30 11:46:27 +02:00
Paolo Tranquilli
fc919841ed Merge pull request #10218 from github/redsun82/swift-add-params-to-init-name
Swift: make `ConstructorDecl`'s name include params
2022-08-30 11:34:56 +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
75a7bcd3b1 Swift: add missing qlgen.py docstring 2022-08-30 11:03:23 +02:00
Paolo Tranquilli
9102cb5d0d Swift: make some ParentChild predicates private 2022-08-30 10:35:08 +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
3f4a330658 Swift: make ParentChild::Impl module private 2022-08-29 17:35:16 +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
b5aad04f65 Swift: add indexes to generated parent-child library 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
Paolo Tranquilli
0aecbc2a01 Swift: reorganize some children in schema.yml 2022-08-29 14:52:14 +02:00
Paolo Tranquilli
7887f669c1 Merge pull request #10175 from github/redsun82/swift-missing-extractions
Swift: fix missing extractions
2022-08-26 14:09:09 +02:00
Paolo Tranquilli
b5d18b05e2 Swift: accept new module type in tests 2022-08-26 13:52:24 +02:00
Paolo Tranquilli
c9b14b4459 Swift: address review comments 2022-08-26 12:49:19 +02:00
Paolo Tranquilli
ced36ffc61 Swift: run swift instead of swift-frontend on Linux 2022-08-26 12:12:21 +02:00
Paolo Tranquilli
c7c42acbf5 Swift: port frontend-invocations test to linux
`swift-frontend` will be in `$PATH` on Linux, and apparently it does
not require the `-sdk` option.
2022-08-26 12:03:18 +02:00
Paolo Tranquilli
ebc7432f46 Swift: implement imported_ and exported_modules
This has expanded the required builtin symbols.
2022-08-26 11:37:14 +02:00
Paolo Tranquilli
2e9d9cfb20 Swift: add imported modules properties to ModuleDecl 2022-08-26 11:23:02 +02:00
Paolo Tranquilli
a5a58d3dc5 Swift: start with loaded modules for extraction 2022-08-26 11:23:02 +02:00
Paolo Tranquilli
0971ca6a82 Swift: emit <Builtin>.trap instead of .trap 2022-08-26 09:35:19 +02:00
Paolo Tranquilli
2c153f68e1 Swift: replace processed with seen in module visiting 2022-08-26 09:28:38 +02:00
Paolo Tranquilli
d5af30d28d Swift: add comment to getBuiltinDecls 2022-08-26 09:28:02 +02:00
Geoffrey White
2d57786dae Merge branch 'main' into cleartext 2022-08-25 23:10:36 +01:00
Geoffrey White
7fd64f1d9c Swift: Make QL-for-QL happy. 2022-08-25 23:06:03 +01:00
Geoffrey White
926da4bedc Swift: Query descriptions and metadata. 2022-08-25 22:52:19 +01:00
Geoffrey White
9a53a40ac6 Swift: Qhelp and examples for both queries. 2022-08-25 22:52:18 +01:00
Geoffrey White
2690732c75 Swift: Special cases to get taint flow working. 2022-08-25 22:15:19 +01:00
Geoffrey White
698a9e2e2e Swift: Realm database support. 2022-08-25 22:15:18 +01:00
Geoffrey White
3126fb930d Swift: Core Data support. 2022-08-25 22:15:18 +01:00
Geoffrey White
456ab980a5 Swift: Fix duplicate results. 2022-08-25 22:15:17 +01:00
Geoffrey White
0cd2efc1b1 Swift: CleartextTransmission query. 2022-08-25 22:15:16 +01:00
Geoffrey White
dacb7f5f25 Swift: Add a SensitiveExprs lib (and test it). 2022-08-25 22:15:15 +01:00
Geoffrey White
2aa6dd20ff Swift: Make tests more accurate and don't use 'pwd' as a variable name (it has alternative meanings so is not a good test). 2022-08-25 22:15:14 +01:00
Geoffrey White
1c5283628b Swift: Additional test cases. 2022-08-25 22:15:13 +01:00
Paolo Tranquilli
df3dc9677f Swift: fix missing extractions from Builtin
There were missing extractions from the Builtin (and other) modules.

This was actually caused by two issues:
* we did not visit all required modules, as for example the `Builtin`
  module does not appear as being imported by anybody (together with
  another mysterious `__Objc` module)
* moreover the `Builtin` module works internally by only creating
  declarations on demand, and does not provide a list of its top level
  declarations.

The first problem was solved by moving module collection to the actual
visiting. This may mean we extract less modules, as we only extract the
modules we actually use something from (recursively). This change can
be reverted if we feel we need it.

The second one was solved by explicitly listing the builtin symbols
encountered during a normal extraction. This does mean this list needs
to be kept up to date.
2022-08-25 15:18:24 +02:00