Skip to content

Commit af35b8f

Browse files
committed
unified: Document bug for qualified type access
1 parent 56d5444 commit af35b8f

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

‎unified/ql/lib/codeql/unified/internal/mad/LegacyMaD.qll‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ private class Selector extends TSelector {
156156
// - The name "init" is too common to match on anyway. It is more precise to match on the type name in this case.
157157
//
158158
// So to wire up "init" calls correctly, we just use the type name as the method name.
159+
//
160+
// TODO: does not work for compound access like `String.Index(...)` where the type is `String.Index` but the
161+
// call selector only uses `Index`.
159162
this = MkSelector(name, _, "init", argLabels, _)
160163
}
161164

‎unified/ql/test/library-tests/mad/test.swift‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,41 @@ func testProperties(
5656
configuration.tlsMaximumSupportedProtocolVersion = 0 // $ MISSING: isSink=tls-protocol-version
5757
configuration.tlsMinimumSupportedProtocolVersion = 0 // $ MISSING: isSink=tls-protocol-version
5858
}
59+
60+
class Realm {
61+
struct Configuration {}
62+
}
63+
64+
func testQualifiedConstructors(
65+
encodedOffset: Int,
66+
encryptionKey: String,
67+
fileURL: String,
68+
seedFilePath: String
69+
) {
70+
_ = String.Index(encodedOffset: encodedOffset) // $ MISSING: isSink=string-length
71+
72+
_ = Realm.Configuration(
73+
deleteRealmIfMigrationNeeded: false,
74+
encryptionKey: encryptionKey, // $ MISSING: isSink=encryption-key
75+
fileURL: fileURL, // $ MISSING: isSink=path-injection
76+
inMemoryIdentifier: nil,
77+
migrationBlock: nil,
78+
objectTypes: nil,
79+
readOnly: false,
80+
schemaVersion: 0,
81+
shouldCompactOnLaunch: nil,
82+
syncConfiguration: nil)
83+
84+
_ = Realm.Configuration(
85+
deleteRealmIfMigrationNeeded: false,
86+
encryptionKey: encryptionKey, // $ MISSING: isSink=encryption-key
87+
fileURL: fileURL, // $ MISSING: isSink=path-injection
88+
inMemoryIdentifier: nil,
89+
migrationBlock: nil,
90+
objectTypes: nil,
91+
readOnly: false,
92+
schemaVersion: 0,
93+
seedFilePath: seedFilePath, // $ MISSING: isSink=path-injection
94+
shouldCompactOnLaunch: nil,
95+
syncConfiguration: nil)
96+
}

0 commit comments

Comments
 (0)