Skip to content

Commit 7185286

Browse files
Add case for androidx.biometric api
1 parent 2a00375 commit 7185286

File tree

4 files changed

+137
-0
lines changed

4 files changed

+137
-0
lines changed

java/ql/lib/semmle/code/java/security/AndroidLocalAuthQuery.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ private class AuthenticationCallbackClass extends Class {
99
"FingerprintManager$AuthenticationCallback")
1010
or
1111
this.hasQualifiedName("android.hardware.biometrics", "BiometricPrompt$AuthenticationCallback")
12+
or
13+
this.hasQualifiedName("androidx.biometric", "BiometricPrompt$AuthenticationCallback")
1214
}
1315
}
1416

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import androidx.biometric.BiometricPrompt;
2+
3+
class TestC {
4+
public static void useKey(BiometricPrompt.CryptoObject key) {}
5+
6+
7+
// GOOD: result is used
8+
class Test1 extends BiometricPrompt.AuthenticationCallback {
9+
@Override
10+
public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) {
11+
TestC.useKey(result.getCryptoObject());
12+
}
13+
}
14+
15+
// BAD: result is not used
16+
class Test2 extends BiometricPrompt.AuthenticationCallback {
17+
@Override
18+
public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) { // $insecure-auth
19+
20+
}
21+
}
22+
23+
// BAD: result is only used in a super call
24+
class Test3 extends BiometricPrompt.AuthenticationCallback {
25+
@Override
26+
public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) { // $insecure-auth
27+
super.onAuthenticationSucceeded(result);
28+
}
29+
}
30+
31+
// GOOD: result is used
32+
class Test4 extends BiometricPrompt.AuthenticationCallback {
33+
@Override
34+
public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) {
35+
super.onAuthenticationSucceeded(result);
36+
TestC.useKey(result.getCryptoObject());
37+
}
38+
}
39+
40+
// GOOD: result is used in a super call to a class other than the base class
41+
class Test5 extends Test1 {
42+
@Override
43+
public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) {
44+
super.onAuthenticationSucceeded(result);
45+
}
46+
}
47+
}

java/ql/test/stubs/google-android-9.0.0/android/security/identity/PresentationSession.java

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

java/ql/test/stubs/google-android-9.0.0/androidx/biometric/BiometricPrompt.java

Lines changed: 79 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)