Skip to content

Commit 02ddcab

Browse files
committed
Swift: Cleanup / corrections.
1 parent 5c6b8bd commit 02ddcab

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
private import codeql.swift.generated.decl.EnumElementDecl
2-
private import codeql.swift.elements.decl.Decl
2+
private import codeql.swift.elements.decl.EnumDecl
33

44
/**
55
* An enum element declaration, for example `enumElement` and `anotherEnumElement` in:
@@ -14,25 +14,24 @@ class EnumElementDecl extends Generated::EnumElementDecl {
1414
override string toString() { result = this.getName() }
1515

1616
/**
17-
* Holds if this function is called `funcName` and is a member of a
18-
* class, struct, extension, enum or protocol called `typeName`.
17+
* Holds if this enum element declaration is called `enumElementName` and is a member of an
18+
* enum called `enumName`.
1919
*/
2020
cached
21-
predicate hasQualifiedName(string typeName, string enumElementName) {
21+
predicate hasQualifiedName(string enumName, string enumElementName) {
2222
this.getName() = enumElementName and
23-
exists(Decl d |
24-
d.asNominalTypeDecl().getFullName() = typeName and
23+
exists(EnumDecl d |
24+
d.getFullName() = enumName and
2525
d.getAMember() = this
2626
)
2727
}
2828

2929
/**
30-
* Holds if this function is called `funcName` and is a member of a
31-
* class, struct, extension, enum or protocol called `typeName` in a module
32-
* called `moduleName`.
30+
* Holds if this enum element declaration is called `enumElementName` and is a member of an
31+
* enumcalled `enumName` in a module called `moduleName`.
3332
*/
34-
predicate hasQualifiedName(string moduleName, string typeName, string enumElementName) {
35-
this.hasQualifiedName(typeName, enumElementName) and
33+
predicate hasQualifiedName(string moduleName, string enumName, string enumElementName) {
34+
this.hasQualifiedName(enumName, enumElementName) and
3635
this.getModule().getFullName() = moduleName
3736
}
3837
}

swift/ql/lib/codeql/swift/security/PathInjectionExtensions.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ private class DefaultPathInjectionSink extends PathInjectionSink {
3838
*/
3939
private class GlobalVariablePathInjectionSink extends PathInjectionSink {
4040
GlobalVariablePathInjectionSink() {
41-
// value assigned to global variable `sqlite3_temp_directory`
41+
// value assigned to the sqlite3 global variable `sqlite3_temp_directory`
4242
// the sink should be the `DeclRefExpr` itself, but we don't currently have taint flow to globals.
4343
exists(AssignExpr ae |
4444
ae.getDest().(DeclRefExpr).getDecl().(VarDecl).getName() = "sqlite3_temp_directory" and
@@ -48,11 +48,11 @@ private class GlobalVariablePathInjectionSink extends PathInjectionSink {
4848
}
4949

5050
/**
51-
* A sink that is a write to a global variable.
51+
* A sink that is an argument to an enum element.
5252
*/
5353
private class EnumConstructorPathInjectionSink extends PathInjectionSink {
5454
EnumConstructorPathInjectionSink() {
55-
// first argument to `Connection.Location.uri(_:parameters:)`
55+
// first argument to SQLite.swift's `Connection.Location.uri(_:parameters:)`
5656
exists(ApplyExpr ae, EnumElementDecl decl |
5757
ae.getFunction().(MethodLookupExpr).getMember() = decl and
5858
decl.hasQualifiedName("Connection.Location", "uri") and

0 commit comments

Comments
 (0)