Skip to content

Commit 9a5039d

Browse files
committed
Add some logging and additional error checking
1 parent 5d37f23 commit 9a5039d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

app/src/main/java/fuzion24/device/vulnerability/broadcastreceiver/ScanRunnerBroadcastReceiver.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.content.pm.ApplicationInfo;
77
import android.os.AsyncTask;
88
import android.os.Bundle;
9+
import android.util.Log;
910

1011
import org.json.JSONObject;
1112

@@ -23,27 +24,40 @@
2324
* Created by fuzion24 on 11/25/15.
2425
*/
2526
public class ScanRunnerBroadcastReceiver extends BroadcastReceiver {
26-
27+
private static final String TAG = "ScanRunnerReceiver";
2728
@Override
2829
public void onReceive(final Context context, Intent intent) {
2930

31+
Log.d(TAG, "Received broadcast for scanrunner");
3032
//Only allow this code to be ran on debug builds, since it accepts and writes to arbitrary file
3133
//paths, which would allow another app to arbitrarily write anywhere in this app's context.
3234
// http://android-developers.blogspot.com/2010/09/securing-android-lvl-applications.html
3335
boolean isDebuggable = ( 0 != ( context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE ) );
3436
if(!isDebuggable){
37+
Log.d(TAG, "Not running the tests because the app is not debuggable");
3538
return;
3639
}
3740

3841
Bundle intentExtras = intent.getExtras();
42+
if(intentExtras == null){
43+
Log.d(TAG, "There were no extras with the broadcast. Include RESULT_PATH");
44+
return;
45+
}
46+
3947
final String writeResultPath = intentExtras.getString("RESULT_PATH");
48+
if(writeResultPath == null || writeResultPath.equals("")){
49+
Log.d(TAG, "Result write path is null or empty");
50+
}
51+
52+
Log.d(TAG, "Results will be written to: " + writeResultPath);
4053

4154
new AsyncTask<Void,Void,Void>(){
4255
@Override
4356
protected Void doInBackground(Void... params) {
4457
List<VulnerabilityTest> tests = VulnerabilityOrganizer.getTests(context);
4558
List<VulnerabilityTestResult> results = new ArrayList<VulnerabilityTestResult>();
4659
for(VulnerabilityTest vt : tests){
60+
Log.d(TAG, "Running: " + vt.getCVEorID());
4761
boolean vulnerable = false;
4862
Exception x = null;
4963
try {
@@ -52,7 +66,6 @@ protected Void doInBackground(Void... params) {
5266
x = e;
5367
}
5468
results.add(new VulnerabilityTestResult(vt, vulnerable, x));
55-
5669
}
5770

5871
try {

0 commit comments

Comments
 (0)