mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Refactor ImproperIntentVerificationQuery.qll
This commit is contained in:
@@ -14,14 +14,12 @@ private class OnReceiveMethod extends Method {
|
||||
}
|
||||
|
||||
/** A configuration to detect whether the `action` of an `Intent` is checked. */
|
||||
private class VerifiedIntentConfig extends DataFlow::Configuration {
|
||||
VerifiedIntentConfig() { this = "VerifiedIntentConfig" }
|
||||
|
||||
override predicate isSource(DataFlow::Node src) {
|
||||
private module VerifiedIntentConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node src) {
|
||||
src.asParameter() = any(OnReceiveMethod orm).getIntentParameter()
|
||||
}
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) {
|
||||
predicate isSink(DataFlow::Node sink) {
|
||||
exists(MethodAccess ma |
|
||||
ma.getMethod().hasQualifiedName("android.content", "Intent", "getAction") and
|
||||
sink.asExpr() = ma.getQualifier()
|
||||
@@ -29,10 +27,12 @@ private class VerifiedIntentConfig extends DataFlow::Configuration {
|
||||
}
|
||||
}
|
||||
|
||||
private module VerifiedIntentFlow = DataFlow::Make<VerifiedIntentConfig>;
|
||||
|
||||
/** An `onReceive` method that doesn't verify the action of the intent it receives. */
|
||||
private class UnverifiedOnReceiveMethod extends OnReceiveMethod {
|
||||
UnverifiedOnReceiveMethod() {
|
||||
not any(VerifiedIntentConfig c).hasFlow(DataFlow::parameterNode(this.getIntentParameter()), _)
|
||||
not VerifiedIntentFlow::hasFlow(DataFlow::parameterNode(this.getIntentParameter()), _)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user