Skip to content

Conversation

@KushalNParmar
Copy link

release 2.0.0

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

Log.d("TAG", "onCreate: ")

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true);

Check failure

Code scanning / CodeQL

Android Webview debugging enabled High

Webview debugging is enabled.

Copilot Autofix

AI 2 months ago

To fix the problem, we need to ensure that WebView debugging is only enabled for debug builds, not for release builds. The best way is by checking if the application is marked as debuggable before enabling debugging. In Android/Kotlin, this can be done by checking the application's ApplicationInfo.flags for the FLAG_DEBUGGABLE bit. Specifically, wrap the call to WebView.setWebContentsDebuggingEnabled(true); with an if statement that only evaluates to true if the application is debuggable. This change is to be made in MyApp.kt, within the onCreate() method. Ensure imports are sufficient to access ApplicationInfo.

Suggested changeset 1
app/src/main/java/io/pixelbin/glamar/sample/MyApp.kt

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/app/src/main/java/io/pixelbin/glamar/sample/MyApp.kt b/app/src/main/java/io/pixelbin/glamar/sample/MyApp.kt
--- a/app/src/main/java/io/pixelbin/glamar/sample/MyApp.kt
+++ b/app/src/main/java/io/pixelbin/glamar/sample/MyApp.kt
@@ -4,6 +4,7 @@
 import android.os.Build
 import android.util.Log
 import android.webkit.WebView
+import android.content.pm.ApplicationInfo
 import io.pixelbin.galmar.sample.BuildConfig
 import io.pixelbin.glamar.GlamAr
 import io.pixelbin.glamar.PreviewMode
@@ -14,7 +15,10 @@
         Log.d("TAG", "onCreate: ")
 
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
-            WebView.setWebContentsDebuggingEnabled(true);
+            // Enable WebView debugging only for debug builds
+            if (0 != (applicationInfo.flags and android.content.pm.ApplicationInfo.FLAG_DEBUGGABLE)) {
+                WebView.setWebContentsDebuggingEnabled(true);
+            }
         }
         // Initialise SDK
         GlamAr.initialize(
EOF
@@ -4,6 +4,7 @@
import android.os.Build
import android.util.Log
import android.webkit.WebView
import android.content.pm.ApplicationInfo
import io.pixelbin.galmar.sample.BuildConfig
import io.pixelbin.glamar.GlamAr
import io.pixelbin.glamar.PreviewMode
@@ -14,7 +15,10 @@
Log.d("TAG", "onCreate: ")

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true);
// Enable WebView debugging only for debug builds
if (0 != (applicationInfo.flags and android.content.pm.ApplicationInfo.FLAG_DEBUGGABLE)) {
WebView.setWebContentsDebuggingEnabled(true);
}
}
// Initialise SDK
GlamAr.initialize(
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants