Skip to content

Conversation

@KushalNParmar
Copy link

release v2.0.0

GlamArLogger.d("Glam_myApp", "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, the call to WebView.setWebContentsDebuggingEnabled(true) should be guarded so debugging is only enabled in debug builds. The safest and most canonical way is to check the ApplicationInfo.FLAG_DEBUGGABLE flag at runtime; this indicates whether the app was built as debuggable (as is typical during development) or not (as is typical for production releases). In Kotlin, you can check it as follows:

if (0 != (applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE)) {
    WebView.setWebContentsDebuggingEnabled(true)
}

This fix should be applied in app/src/main/java/io/pixelbin/glamar/sample/MyApp.kt, replacing the unconditional call at line 20. You will also need to add an import for android.content.pm.ApplicationInfo if it is not already present.


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.webkit.WebView
 import android.widget.FrameLayout.LayoutParams
+import android.content.pm.ApplicationInfo
 import io.pixelbin.glamar.GlamAr
 import io.pixelbin.glamar.GlamArLogger
 import io.pixelbin.glamar.model.Configuration
@@ -17,7 +18,9 @@
         GlamArLogger.d("Glam_myApp", "onCreate: ")
 
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
-            WebView.setWebContentsDebuggingEnabled(true)
+            if (0 != (applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE)) {
+                WebView.setWebContentsDebuggingEnabled(true)
+            }
         }
 
         val webView = WebView(
EOF
@@ -4,6 +4,7 @@
import android.os.Build
import android.webkit.WebView
import android.widget.FrameLayout.LayoutParams
import android.content.pm.ApplicationInfo
import io.pixelbin.glamar.GlamAr
import io.pixelbin.glamar.GlamArLogger
import io.pixelbin.glamar.model.Configuration
@@ -17,7 +18,9 @@
GlamArLogger.d("Glam_myApp", "onCreate: ")

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true)
if (0 != (applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE)) {
WebView.setWebContentsDebuggingEnabled(true)
}
}

val webView = WebView(
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.

4 participants