mirror of
https://github.com/github/codeql.git
synced 2026-04-26 17:25:19 +02:00
Swift: Cleanup / corrections.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
private import codeql.swift.generated.decl.EnumElementDecl
|
||||
private import codeql.swift.elements.decl.Decl
|
||||
private import codeql.swift.elements.decl.EnumDecl
|
||||
|
||||
/**
|
||||
* An enum element declaration, for example `enumElement` and `anotherEnumElement` in:
|
||||
@@ -14,25 +14,24 @@ class EnumElementDecl extends Generated::EnumElementDecl {
|
||||
override string toString() { result = this.getName() }
|
||||
|
||||
/**
|
||||
* Holds if this function is called `funcName` and is a member of a
|
||||
* class, struct, extension, enum or protocol called `typeName`.
|
||||
* Holds if this enum element declaration is called `enumElementName` and is a member of an
|
||||
* enum called `enumName`.
|
||||
*/
|
||||
cached
|
||||
predicate hasQualifiedName(string typeName, string enumElementName) {
|
||||
predicate hasQualifiedName(string enumName, string enumElementName) {
|
||||
this.getName() = enumElementName and
|
||||
exists(Decl d |
|
||||
d.asNominalTypeDecl().getFullName() = typeName and
|
||||
exists(EnumDecl d |
|
||||
d.getFullName() = enumName and
|
||||
d.getAMember() = this
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this function is called `funcName` and is a member of a
|
||||
* class, struct, extension, enum or protocol called `typeName` in a module
|
||||
* called `moduleName`.
|
||||
* Holds if this enum element declaration is called `enumElementName` and is a member of an
|
||||
* enumcalled `enumName` in a module called `moduleName`.
|
||||
*/
|
||||
predicate hasQualifiedName(string moduleName, string typeName, string enumElementName) {
|
||||
this.hasQualifiedName(typeName, enumElementName) and
|
||||
predicate hasQualifiedName(string moduleName, string enumName, string enumElementName) {
|
||||
this.hasQualifiedName(enumName, enumElementName) and
|
||||
this.getModule().getFullName() = moduleName
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ private class DefaultPathInjectionSink extends PathInjectionSink {
|
||||
*/
|
||||
private class GlobalVariablePathInjectionSink extends PathInjectionSink {
|
||||
GlobalVariablePathInjectionSink() {
|
||||
// value assigned to global variable `sqlite3_temp_directory`
|
||||
// value assigned to the sqlite3 global variable `sqlite3_temp_directory`
|
||||
// the sink should be the `DeclRefExpr` itself, but we don't currently have taint flow to globals.
|
||||
exists(AssignExpr ae |
|
||||
ae.getDest().(DeclRefExpr).getDecl().(VarDecl).getName() = "sqlite3_temp_directory" and
|
||||
@@ -48,11 +48,11 @@ private class GlobalVariablePathInjectionSink extends PathInjectionSink {
|
||||
}
|
||||
|
||||
/**
|
||||
* A sink that is a write to a global variable.
|
||||
* A sink that is an argument to an enum element.
|
||||
*/
|
||||
private class EnumConstructorPathInjectionSink extends PathInjectionSink {
|
||||
EnumConstructorPathInjectionSink() {
|
||||
// first argument to `Connection.Location.uri(_:parameters:)`
|
||||
// first argument to SQLite.swift's `Connection.Location.uri(_:parameters:)`
|
||||
exists(ApplyExpr ae, EnumElementDecl decl |
|
||||
ae.getFunction().(MethodLookupExpr).getMember() = decl and
|
||||
decl.hasQualifiedName("Connection.Location", "uri") and
|
||||
|
||||
Reference in New Issue
Block a user