mirror of
https://github.com/github/codeql.git
synced 2026-04-26 01:05:15 +02:00
Swift: Use regexp for function name.
This commit is contained in:
@@ -6,6 +6,16 @@ private import codeql.swift.elements.decl.Method
|
||||
*/
|
||||
class Function extends Generated::Function, Callable {
|
||||
override string toString() { result = this.getName() }
|
||||
|
||||
/**
|
||||
* Gets the name of this function, without the argument list. For example
|
||||
* a function with name `myFunction(arg:)` has short name `myFunction`.
|
||||
*/
|
||||
string getShortName() {
|
||||
// match as many characters as possible that are not `(`.
|
||||
// (`*+` is possessive matching)
|
||||
result = this.getName().regexpCapture("([^(]*+).*", 1)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -102,7 +102,7 @@ private class SensitiveFunction extends Function {
|
||||
string name; // name of the function, not including the argument list.
|
||||
|
||||
SensitiveFunction() {
|
||||
name = this.getName().splitAt("(", 0) and
|
||||
name = this.getShortName() and
|
||||
name.regexpMatch(sensitiveType.getRegexp())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user