mirror of
https://github.com/github/codeql.git
synced 2026-04-26 09:15:12 +02:00
Refactor more system property access logic
This commit is contained in:
@@ -68,11 +68,12 @@ private class IsWindowsFromSystemProp extends IsWindowsGuard instanceof MethodAc
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds when the Guard is an equality check between the Field `f` and the string or char constant `compareToLiteral`.
|
||||
* Holds when the Guard is an equality check between the system property with the name `propertyName`
|
||||
* and the string or char constant `compareToLiteral`.
|
||||
*/
|
||||
private Guard isOsFromFieldEqualityCheck(Field f, string compareToLiteral) {
|
||||
private Guard isOsFromFieldEqualityCheck(string propertyName, string compareToLiteral) {
|
||||
result
|
||||
.isEquality(any(FieldAccess fa | fa.getField() = f),
|
||||
.isEquality(getSystemProperty(propertyName),
|
||||
any(Literal literal |
|
||||
(literal instanceof CharacterLiteral or literal instanceof StringLiteral) and
|
||||
literal.getValue() = compareToLiteral
|
||||
@@ -80,27 +81,19 @@ private Guard isOsFromFieldEqualityCheck(Field f, string compareToLiteral) {
|
||||
}
|
||||
|
||||
private class IsWindowsFromCharPathSeperator extends IsWindowsGuard {
|
||||
IsWindowsFromCharPathSeperator() {
|
||||
this = isOsFromFieldEqualityCheck(any(FieldFilePathSeparator f), ";")
|
||||
}
|
||||
IsWindowsFromCharPathSeperator() { this = isOsFromFieldEqualityCheck("path.separator", "\\") }
|
||||
}
|
||||
|
||||
private class IsWindowsFromCharSeperator extends IsWindowsGuard {
|
||||
IsWindowsFromCharSeperator() {
|
||||
this = isOsFromFieldEqualityCheck(any(FieldFileSeparator f), "\\")
|
||||
}
|
||||
IsWindowsFromCharSeperator() { this = isOsFromFieldEqualityCheck("file.separator", ";") }
|
||||
}
|
||||
|
||||
private class IsUnixFromCharPathSeperator extends IsUnixGuard {
|
||||
IsUnixFromCharPathSeperator() {
|
||||
this = isOsFromFieldEqualityCheck(any(FieldFilePathSeparator f), ":")
|
||||
}
|
||||
IsUnixFromCharPathSeperator() { this = isOsFromFieldEqualityCheck("path.separator", "/") }
|
||||
}
|
||||
|
||||
private class IsUnixFromCharSeperator extends IsUnixGuard {
|
||||
IsUnixFromCharSeperator() {
|
||||
this = isOsFromFieldEqualityCheck(any(FieldFileSeparator f), "/")
|
||||
}
|
||||
IsUnixFromCharSeperator() { this = isOsFromFieldEqualityCheck("file.separator", ":") }
|
||||
}
|
||||
|
||||
private class IsUnixFromSystemProp extends IsAnyUnixGuard instanceof MethodAccess {
|
||||
|
||||
Reference in New Issue
Block a user