Skip to content

Commit 6dc6e13

Browse files
committed
Swift: Hide 'DynamicSelfType' from the main AST.
1 parent 11aff55 commit 6dc6e13

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
21
private import codeql.swift.generated.type.DynamicSelfType
32

4-
class DynamicSelfType extends Generated::DynamicSelfType { }
3+
class DynamicSelfType extends Generated::DynamicSelfType {
4+
override Type getResolveStep() {
5+
// The type of qualifiers in a Swift constructor is assigned the type `Self` by the Swift compiler
6+
// This `getResolveStep` replaces that `Self` type with the type of the enclosing class.
7+
result = this.getImmediateStaticSelfType()
8+
}
9+
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
| Self | getName: | Self | getCanonicalType: | Self | getStaticSelfType: | X |

swift/ql/test/library-tests/dataflow/dataflow/DataFlow.expected

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ edges
235235
| test.swift:536:10:536:13 | s : | test.swift:537:13:537:13 | s : |
236236
| test.swift:537:7:537:7 | [post] self [str] : | test.swift:536:5:538:5 | self[return] [str] : |
237237
| test.swift:537:13:537:13 | s : | test.swift:537:7:537:7 | [post] self [str] : |
238-
| test.swift:542:17:545:5 | self[return] [str] : | test.swift:550:13:550:41 | call to Self.init(contentsOfFile:) [str] : |
238+
| test.swift:542:17:545:5 | self[return] [str] : | test.swift:550:13:550:41 | call to MyClass.init(contentsOfFile:) [str] : |
239239
| test.swift:543:7:543:7 | [post] self [str] : | test.swift:542:17:545:5 | self[return] [str] : |
240240
| test.swift:543:7:543:7 | [post] self [str] : | test.swift:544:17:544:17 | self [str] : |
241241
| test.swift:543:20:543:28 | call to source3() : | test.swift:536:10:536:13 | s : |
@@ -245,8 +245,8 @@ edges
245245
| test.swift:549:13:549:33 | call to MyClass.init(s:) [str] : | test.swift:549:13:549:35 | .str |
246246
| test.swift:549:24:549:32 | call to source3() : | test.swift:536:10:536:13 | s : |
247247
| test.swift:549:24:549:32 | call to source3() : | test.swift:549:13:549:33 | call to MyClass.init(s:) [str] : |
248-
| test.swift:550:13:550:41 | call to Self.init(contentsOfFile:) [str] : | test.swift:535:9:535:9 | self [str] : |
249-
| test.swift:550:13:550:41 | call to Self.init(contentsOfFile:) [str] : | test.swift:550:13:550:43 | .str |
248+
| test.swift:550:13:550:41 | call to MyClass.init(contentsOfFile:) [str] : | test.swift:535:9:535:9 | self [str] : |
249+
| test.swift:550:13:550:41 | call to MyClass.init(contentsOfFile:) [str] : | test.swift:550:13:550:43 | .str |
250250
| test.swift:567:8:567:11 | x : | test.swift:568:14:568:14 | x : |
251251
| test.swift:568:5:568:5 | [post] self [x] : | test.swift:567:3:569:3 | self[return] [x] : |
252252
| test.swift:568:14:568:14 | x : | test.swift:568:5:568:5 | [post] self [x] : |
@@ -541,7 +541,7 @@ nodes
541541
| test.swift:549:13:549:33 | call to MyClass.init(s:) [str] : | semmle.label | call to MyClass.init(s:) [str] : |
542542
| test.swift:549:13:549:35 | .str | semmle.label | .str |
543543
| test.swift:549:24:549:32 | call to source3() : | semmle.label | call to source3() : |
544-
| test.swift:550:13:550:41 | call to Self.init(contentsOfFile:) [str] : | semmle.label | call to Self.init(contentsOfFile:) [str] : |
544+
| test.swift:550:13:550:41 | call to MyClass.init(contentsOfFile:) [str] : | semmle.label | call to MyClass.init(contentsOfFile:) [str] : |
545545
| test.swift:550:13:550:43 | .str | semmle.label | .str |
546546
| test.swift:567:3:569:3 | self[return] [x] : | semmle.label | self[return] [x] : |
547547
| test.swift:567:8:567:11 | x : | semmle.label | x : |
@@ -609,7 +609,7 @@ subpaths
609609
| test.swift:543:20:543:28 | call to source3() : | test.swift:536:10:536:13 | s : | test.swift:537:7:537:7 | [post] self [str] : | test.swift:543:7:543:7 | [post] self [str] : |
610610
| test.swift:549:13:549:33 | call to MyClass.init(s:) [str] : | test.swift:535:9:535:9 | self [str] : | file://:0:0:0:0 | .str : | test.swift:549:13:549:35 | .str |
611611
| test.swift:549:24:549:32 | call to source3() : | test.swift:536:10:536:13 | s : | test.swift:536:5:538:5 | self[return] [str] : | test.swift:549:13:549:33 | call to MyClass.init(s:) [str] : |
612-
| test.swift:550:13:550:41 | call to Self.init(contentsOfFile:) [str] : | test.swift:535:9:535:9 | self [str] : | file://:0:0:0:0 | .str : | test.swift:550:13:550:43 | .str |
612+
| test.swift:550:13:550:41 | call to MyClass.init(contentsOfFile:) [str] : | test.swift:535:9:535:9 | self [str] : | file://:0:0:0:0 | .str : | test.swift:550:13:550:43 | .str |
613613
| test.swift:573:16:573:23 | call to source() : | test.swift:567:8:567:11 | x : | test.swift:567:3:569:3 | self[return] [x] : | test.swift:573:11:573:24 | call to S.init(x:) [x] : |
614614
| test.swift:575:13:575:13 | s [x] : | test.swift:574:11:574:14 | enter #keyPath(...) [x] : | test.swift:574:11:574:14 | exit #keyPath(...) : | test.swift:575:13:575:25 | \\...[...] |
615615
| test.swift:578:13:578:13 | s [x] : | test.swift:577:36:577:38 | enter #keyPath(...) [x] : | test.swift:577:36:577:38 | exit #keyPath(...) : | test.swift:578:13:578:32 | \\...[...] |

swift/ql/test/query-tests/Security/CWE-757/InsecureTLS.expected

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ edges
4949
| InsecureTLS.swift:181:53:181:76 | .TLSv10 : | InsecureTLS.swift:19:7:19:7 | value : |
5050
| InsecureTLS.swift:181:53:181:76 | .TLSv10 : | InsecureTLS.swift:181:3:181:9 | [post] getter for .config |
5151
| InsecureTLS.swift:181:53:181:76 | .TLSv10 : | InsecureTLS.swift:181:3:181:9 | [post] getter for .config [tlsMinimumSupportedProtocolVersion] : |
52+
| InsecureTLS.swift:185:20:185:36 | withMinVersion : | InsecureTLS.swift:187:42:187:42 | withMinVersion : |
53+
| InsecureTLS.swift:187:5:187:5 | [post] self [tlsMinimumSupportedProtocolVersion] : | InsecureTLS.swift:187:5:187:5 | [post] self |
54+
| InsecureTLS.swift:187:42:187:42 | withMinVersion : | InsecureTLS.swift:187:5:187:5 | [post] self [tlsMinimumSupportedProtocolVersion] : |
55+
| InsecureTLS.swift:193:51:193:74 | .TLSv10 : | InsecureTLS.swift:185:20:185:36 | withMinVersion : |
5256
| file://:0:0:0:0 | [post] self [tlsMaximumSupportedProtocolVersion] : | file://:0:0:0:0 | [post] self |
5357
| file://:0:0:0:0 | [post] self [tlsMaximumSupportedProtocolVersion] : | file://:0:0:0:0 | [post] self : |
5458
| file://:0:0:0:0 | [post] self [tlsMaximumSupportedProtocol] : | file://:0:0:0:0 | [post] self |
@@ -103,6 +107,11 @@ nodes
103107
| InsecureTLS.swift:181:3:181:9 | [post] getter for .config | semmle.label | [post] getter for .config |
104108
| InsecureTLS.swift:181:3:181:9 | [post] getter for .config [tlsMinimumSupportedProtocolVersion] : | semmle.label | [post] getter for .config [tlsMinimumSupportedProtocolVersion] : |
105109
| InsecureTLS.swift:181:53:181:76 | .TLSv10 : | semmle.label | .TLSv10 : |
110+
| InsecureTLS.swift:185:20:185:36 | withMinVersion : | semmle.label | withMinVersion : |
111+
| InsecureTLS.swift:187:5:187:5 | [post] self | semmle.label | [post] self |
112+
| InsecureTLS.swift:187:5:187:5 | [post] self [tlsMinimumSupportedProtocolVersion] : | semmle.label | [post] self [tlsMinimumSupportedProtocolVersion] : |
113+
| InsecureTLS.swift:187:42:187:42 | withMinVersion : | semmle.label | withMinVersion : |
114+
| InsecureTLS.swift:193:51:193:74 | .TLSv10 : | semmle.label | .TLSv10 : |
106115
| file://:0:0:0:0 | .TLSVersion : | semmle.label | .TLSVersion : |
107116
| file://:0:0:0:0 | [post] self | semmle.label | [post] self |
108117
| file://:0:0:0:0 | [post] self | semmle.label | [post] self |
@@ -154,6 +163,7 @@ subpaths
154163
| InsecureTLS.swift:122:3:122:3 | [post] config | InsecureTLS.swift:127:25:127:48 | .TLSv11 : | InsecureTLS.swift:122:3:122:3 | [post] config | This TLS configuration is insecure. |
155164
| InsecureTLS.swift:165:3:165:3 | [post] config | InsecureTLS.swift:163:20:163:43 | .TLSv10 : | InsecureTLS.swift:165:3:165:3 | [post] config | This TLS configuration is insecure. |
156165
| InsecureTLS.swift:181:3:181:9 | [post] getter for .config | InsecureTLS.swift:181:53:181:76 | .TLSv10 : | InsecureTLS.swift:181:3:181:9 | [post] getter for .config | This TLS configuration is insecure. |
166+
| InsecureTLS.swift:187:5:187:5 | [post] self | InsecureTLS.swift:193:51:193:74 | .TLSv10 : | InsecureTLS.swift:187:5:187:5 | [post] self | This TLS configuration is insecure. |
157167
| file://:0:0:0:0 | [post] self | InsecureTLS.swift:40:47:40:70 | .TLSv10 : | file://:0:0:0:0 | [post] self | This TLS configuration is insecure. |
158168
| file://:0:0:0:0 | [post] self | InsecureTLS.swift:45:47:45:70 | .TLSv11 : | file://:0:0:0:0 | [post] self | This TLS configuration is insecure. |
159169
| file://:0:0:0:0 | [post] self | InsecureTLS.swift:57:47:57:70 | .TLSv10 : | file://:0:0:0:0 | [post] self | This TLS configuration is insecure. |

0 commit comments

Comments
 (0)