mirror of
https://github.com/github/codeql.git
synced 2026-01-29 14:23:03 +01:00
Implement Field.hasQualifiedName.
This commit is contained in:
@@ -260,6 +260,18 @@ class Field extends Variable {
|
||||
Field() { fieldstructs(this, declaringType) }
|
||||
|
||||
StructType getDeclaringType() { result = declaringType }
|
||||
|
||||
/**
|
||||
* Holds if this field has name `f` and it belongs to a type `tp` declared in package `pkg`.
|
||||
*
|
||||
* Note that due to field embedding the same field may belong to multiple types.
|
||||
*/
|
||||
predicate hasQualifiedName(string pkg, string tp, string f) {
|
||||
exists(Type base |
|
||||
base.hasQualifiedName(pkg, tp) and
|
||||
this = base.getField(f)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** A built-in or declared function. */
|
||||
|
||||
@@ -31,12 +31,8 @@ module ZipSlip {
|
||||
/** A file name from a zip or tar entry, as a source for zip slip. */
|
||||
class FileNameSource extends Source, DataFlow::FieldReadNode {
|
||||
FileNameSource() {
|
||||
exists(Type t |
|
||||
t.hasQualifiedName("archive/zip", "File") or
|
||||
t.hasQualifiedName("archive/tar", "Header")
|
||||
|
|
||||
getField() = t.getField("Name")
|
||||
)
|
||||
getField().hasQualifiedName("archive/zip", "File", "Name") or
|
||||
getField().hasQualifiedName("archive/tar", "Header", "Name")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user