Java: convert ImproperIntentVerification test to .qlref

It's a non-path query, so the InlineExpectationsTest postprocessor doesn't do anything.
This commit is contained in:
Nora Dimitrijević
2025-06-24 11:38:11 +02:00
parent aac4f63e9a
commit e0311e26c6
4 changed files with 8 additions and 21 deletions

View File

@@ -6,8 +6,8 @@ import android.content.BroadcastReceiver;
class BootReceiverXml extends BroadcastReceiver {
void doStuff(Intent intent) {}
@Override
public void onReceive(Context ctx, Intent intent) { // $hasResult
@Override
public void onReceive(Context ctx, Intent intent) { // $ Alert
doStuff(intent);
}
}
}

View File

@@ -0,0 +1 @@
| BootReceiverXml.java:10:17:10:25 | onReceive | This reciever doesn't verify intents it receives, and $@ to receive $@. | AndroidManifest.xml:3:9:7:20 | receiver | it is registered | AndroidManifest.xml:5:17:5:79 | action | the system action action |

View File

@@ -1,18 +0,0 @@
import java
import semmle.code.java.security.ImproperIntentVerificationQuery
import utils.test.InlineExpectationsTest
module HasFlowTest implements TestSig {
string getARelevantTag() { result = "hasResult" }
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "hasResult" and
exists(Method orm | unverifiedSystemReceiver(_, orm, _) |
orm.getLocation() = location and
element = orm.toString() and
value = ""
)
}
}
import MakeTest<HasFlowTest>

View File

@@ -0,0 +1,4 @@
query: Security/CWE/CWE-925/ImproperIntentVerification.ql
postprocess:
- utils/test/PrettyPrintModels.ql
- utils/test/InlineExpectationsTestQuery.ql