Skip to content

Commit 2875d86

Browse files
committed
Swift: Cover additional edge case.
1 parent 4c47de5 commit 2875d86

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

swift/ql/lib/codeql/swift/dataflow/ExternalFlow.qll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,9 @@ private Element interpretElement0(
434434
subtypes = true and
435435
declWithMethod.getNominalTypeDecl() = namedTypeDecl.getADerivedTypeDecl*()
436436
or
437-
exists(ExtensionDecl e | e.getExtendedTypeDecl() = declWithMethod.getNominalTypeDecl() |
437+
exists(ExtensionDecl e |
438+
e.getExtendedTypeDecl().getADerivedTypeDecl*() = declWithMethod.getNominalTypeDecl()
439+
|
438440
subtypes = true and
439441
e.getAProtocol() = namedTypeDecl.getADerivedTypeDecl*()
440442
)
@@ -454,7 +456,9 @@ private Element interpretElement0(
454456
subtypes = true and
455457
declWithField.getNominalTypeDecl() = namedTypeDecl.getADerivedTypeDecl*()
456458
or
457-
exists(ExtensionDecl e | e.getExtendedTypeDecl() = declWithField.getNominalTypeDecl() |
459+
exists(ExtensionDecl e |
460+
e.getExtendedTypeDecl().getADerivedTypeDecl*() = declWithField.getNominalTypeDecl()
461+
|
458462
subtypes = true and
459463
e.getAProtocol() = namedTypeDecl.getADerivedTypeDecl*()
460464
)

swift/ql/test/library-tests/dataflow/flowsources/FlowSources.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
| generics.swift:132:9:132:15 | .source1 | external |
7575
| generics.swift:133:9:133:15 | .source2 | external |
7676
| generics.swift:162:9:162:22 | call to source2() | external |
77+
| generics.swift:163:9:163:22 | call to source3() | external |
7778
| nsdata.swift:18:17:18:40 | call to NSData.init(contentsOf:) | external |
7879
| nsdata.swift:19:17:19:53 | call to NSData.init(contentsOf:options:) | external |
7980
| string.swift:56:21:56:44 | call to String.init(contentsOf:) | external |

swift/ql/test/library-tests/dataflow/flowsources/generics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,5 +160,5 @@ class MyChildClass3: MyClass3 {
160160
func useProtocol3(impl: MyChildClass3) {
161161
_ = impl.source1() // not a source (`MyProtocol3.source1` is the declared source and `MyParentClass3` doesn't extend it)
162162
_ = impl.source2() // SOURCE
163-
_ = impl.source3() // SOURCE [NOT DETECTED]
163+
_ = impl.source3() // SOURCE
164164
}

0 commit comments

Comments
 (0)