зеркало из https://github.com/github/codeql.git
Merge pull request #13356 from geoffw0/qualname
Swift: Add FieldDecl.getQualifiedName
This commit is contained in:
Коммит
aa8878ba86
|
@ -9,8 +9,32 @@ class VarDecl extends Generated::VarDecl {
|
|||
}
|
||||
|
||||
/**
|
||||
* A field declaration.
|
||||
* A field declaration. That is, a variable declaration that is a member of a
|
||||
* class, struct, enum or protocol.
|
||||
*/
|
||||
class FieldDecl extends VarDecl {
|
||||
FieldDecl() { this = any(Decl ctx).getAMember() }
|
||||
|
||||
/**
|
||||
* Holds if this field is called `fieldName` and is a member of a
|
||||
* class, struct, extension, enum or protocol called `typeName`.
|
||||
*/
|
||||
cached
|
||||
predicate hasQualifiedName(string typeName, string fieldName) {
|
||||
this.getName() = fieldName and
|
||||
exists(Decl d |
|
||||
d.asNominalTypeDecl().getFullName() = typeName and
|
||||
d.getAMember() = this
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this field is called `fieldName` and is a member of a
|
||||
* class, struct, extension, enum or protocol called `typeName` in a module
|
||||
* called `moduleName`.
|
||||
*/
|
||||
predicate hasQualifiedName(string moduleName, string typeName, string fieldName) {
|
||||
this.hasQualifiedName(typeName, fieldName) and
|
||||
this.getModule().getFullName() = moduleName
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,9 +47,6 @@ private class CollectionFieldsInheritTaint extends TaintInheritingContent,
|
|||
DataFlow::Content::FieldContent
|
||||
{
|
||||
CollectionFieldsInheritTaint() {
|
||||
exists(FieldDecl f | this.getField() = f |
|
||||
f.getEnclosingDecl().asNominalTypeDecl().getName() = ["Collection", "BidirectionalCollection"] and
|
||||
f.getName() = ["first", "last"]
|
||||
)
|
||||
this.getField().hasQualifiedName(["Collection", "BidirectionalCollection"], ["first", "last"])
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,20 +132,18 @@ private class NsStringFieldsInheritTaint extends TaintInheritingContent,
|
|||
DataFlow::Content::FieldContent
|
||||
{
|
||||
NsStringFieldsInheritTaint() {
|
||||
exists(FieldDecl f | this.getField() = f |
|
||||
f.getEnclosingDecl().asNominalTypeDecl().getName() = "NSString" and
|
||||
f.getName() =
|
||||
[
|
||||
"utf8String", "lowercased", "localizedLowedCase", "uppercased", "localizedUppercase",
|
||||
"capitalized", "localizedCapitalized", "decomposedStringWithCanonicalMapping",
|
||||
"decomposedStringWithCompatibilityMapping", "precomposedStringWithCanonicalMapping",
|
||||
"precomposedStringWithCompatibilityMapping", "doubleValue", "floatValue", "intValue",
|
||||
"integerValue", "longLongValue", "boolValue", "description", "pathComponents",
|
||||
"fileSystemRepresentation", "lastPathComponent", "pathExtension",
|
||||
"abbreviatingWithTildeInPath", "deletingLastPathComponent", "deletingPathExtension",
|
||||
"expandingTildeInPath", "resolvingSymlinksInPath", "standardizingPath",
|
||||
"removingPercentEncoding"
|
||||
]
|
||||
)
|
||||
this.getField()
|
||||
.hasQualifiedName("NSString",
|
||||
[
|
||||
"utf8String", "lowercased", "localizedLowedCase", "uppercased", "localizedUppercase",
|
||||
"capitalized", "localizedCapitalized", "decomposedStringWithCanonicalMapping",
|
||||
"decomposedStringWithCompatibilityMapping", "precomposedStringWithCanonicalMapping",
|
||||
"precomposedStringWithCompatibilityMapping", "doubleValue", "floatValue", "intValue",
|
||||
"integerValue", "longLongValue", "boolValue", "description", "pathComponents",
|
||||
"fileSystemRepresentation", "lastPathComponent", "pathExtension",
|
||||
"abbreviatingWithTildeInPath", "deletingLastPathComponent", "deletingPathExtension",
|
||||
"expandingTildeInPath", "resolvingSymlinksInPath", "standardizingPath",
|
||||
"removingPercentEncoding"
|
||||
])
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,10 +36,5 @@ private class SequenceSummaries extends SummaryModelCsv {
|
|||
private class SequenceFieldsInheritTaint extends TaintInheritingContent,
|
||||
DataFlow::Content::FieldContent
|
||||
{
|
||||
SequenceFieldsInheritTaint() {
|
||||
exists(FieldDecl f | this.getField() = f |
|
||||
f.getEnclosingDecl().asNominalTypeDecl().getName() = "Sequence" and
|
||||
f.getName() = "lazy"
|
||||
)
|
||||
}
|
||||
SequenceFieldsInheritTaint() { this.getField().hasQualifiedName("Sequence", "lazy") }
|
||||
}
|
||||
|
|
|
@ -124,16 +124,15 @@ private class StringFieldsInheritTaint extends TaintInheritingContent,
|
|||
DataFlow::Content::FieldContent
|
||||
{
|
||||
StringFieldsInheritTaint() {
|
||||
exists(FieldDecl f | this.getField() = f |
|
||||
f.getEnclosingDecl().asNominalTypeDecl().getName() = ["String", "StringProtocol"] and
|
||||
f.getName() =
|
||||
[
|
||||
"unicodeScalars", "utf8", "utf16", "lazy", "utf8CString", "description",
|
||||
"debugDescription", "dataValue", "identifierValue", "capitalized", "localizedCapitalized",
|
||||
"localizedLowercase", "localizedUppercase", "decomposedStringWithCanonicalMapping",
|
||||
"decomposedStringWithCompatibilityMapping", "precomposedStringWithCanonicalMapping",
|
||||
"precomposedStringWithCompatibilityMapping", "removingPercentEncoding"
|
||||
]
|
||||
)
|
||||
this.getField()
|
||||
.hasQualifiedName(["String", "StringProtocol"],
|
||||
[
|
||||
"unicodeScalars", "utf8", "utf16", "lazy", "utf8CString", "description",
|
||||
"debugDescription", "dataValue", "identifierValue", "capitalized",
|
||||
"localizedCapitalized", "localizedLowercase", "localizedUppercase",
|
||||
"decomposedStringWithCanonicalMapping", "decomposedStringWithCompatibilityMapping",
|
||||
"precomposedStringWithCanonicalMapping", "precomposedStringWithCompatibilityMapping",
|
||||
"removingPercentEncoding"
|
||||
])
|
||||
}
|
||||
}
|
||||
|
|
|
@ -208,10 +208,5 @@ private class WKUserScriptSummaries extends SummaryModelCsv {
|
|||
private class WKUserScriptInheritsTaint extends TaintInheritingContent,
|
||||
DataFlow::Content::FieldContent
|
||||
{
|
||||
WKUserScriptInheritsTaint() {
|
||||
exists(FieldDecl f | this.getField() = f |
|
||||
f.getEnclosingDecl().asNominalTypeDecl().getName() = "WKUserScript" and
|
||||
f.getName() = "source"
|
||||
)
|
||||
}
|
||||
WKUserScriptInheritsTaint() { this.getField().hasQualifiedName("WKUserScript", "source") }
|
||||
}
|
||||
|
|
|
@ -74,12 +74,7 @@ private class OsLogNonRedactedType extends Type {
|
|||
private class OsLogPrivacyRef extends MemberRefExpr {
|
||||
string optionName;
|
||||
|
||||
OsLogPrivacyRef() {
|
||||
exists(FieldDecl f | this.getMember() = f |
|
||||
f.getEnclosingDecl().asNominalTypeDecl().getName() = "OSLogPrivacy" and
|
||||
optionName = f.getName()
|
||||
)
|
||||
}
|
||||
OsLogPrivacyRef() { this.getMember().(FieldDecl).hasQualifiedName("OSLogPrivacy", optionName) }
|
||||
|
||||
/** Holds if this is a safe privacy option (private or sensitive). */
|
||||
predicate isSafe() { optionName = ["private", "sensitive"] }
|
||||
|
|
Загрузка…
Ссылка в новой задаче