Compare commits

...

1 Commits

Author SHA1 Message Date
Max Schaefer
95c2788c83 Automodel: Do not consider results of getter methods as source candidates. 2024-03-28 15:45:19 +00:00
2 changed files with 32 additions and 0 deletions

View File

@@ -499,6 +499,22 @@ private class UnexploitableIsCharacteristic extends CharacteristicsImpl::NotASin
}
}
/**
* A negative characteristic that excludes the result of getter methods from being considered sources.
*
* Our heuristic for detecting getter methods is extremely simple: any method whose name starts with `get` is considered
* a getter.
*/
private class GetterResultCharacteristic extends CharacteristicsImpl::NotASourceCharacteristic {
GetterResultCharacteristic() { this = "result of getter method" }
override predicate appliesToEndpoint(Endpoint e) {
e.getCallable().getName().matches("get%") and
e.getMaDOutput() = "ReturnValue" and
not FrameworkCandidatesImpl::isSource(e, _, _)
}
}
/**
* A negative characteristic that indicates that parameters of an existence-checking boolean method should not be
* considered sinks.

View File

@@ -446,6 +446,22 @@ private class UnexploitableIsCharacteristic extends CharacteristicsImpl::Neither
}
}
/**
* A negative characteristic that excludes the result of getter methods from being considered sources.
*
* Our heuristic for detecting getter methods is extremely simple: any method whose name starts with `get` is considered
* a getter.
*/
private class GetterResultCharacteristic extends CharacteristicsImpl::NotASourceCharacteristic {
GetterResultCharacteristic() { this = "result of getter method" }
override predicate appliesToEndpoint(Endpoint e) {
e.getCallable().getName().matches("get%") and
e.getMaDOutput() = "ReturnValue" and
not FrameworkCandidatesImpl::isSource(e, _, _)
}
}
/**
* A negative characteristic that indicates that parameters of an existence-checking boolean method should not be
* considered sinks, and its return value should not be considered a source.